Bug 20181

Summary: Allow plugins to add CSS and Javascript to OPAC
Product: Koha Reporter: Kyle M Hall <kyle>
Component: OPACAssignee: Kyle M Hall <kyle>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, katrin.fischer, mtompset, nick
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 20496, 20766, 20764, 21352    
Attachments: Bug 20181: Allow plugins to add css and javascript to OPAC
Bug 20181 - Unit Tests
Bug 20181: Followup to ensure test runs
Bug 20181: Add POD for new plugin
Bug 20181: Allow plugins to add css and javascript to OPAC
Bug 20181 - Unit Tests
Bug 20181: Followup to ensure test runs
Bug 20181: Add POD for new plugin
Bug 20181: Allow plugins to add css and javascript to OPAC
Bug 20181: Unit tests
Bug 20181: (follow-up) Ensure test runs
Bug 20181: Add POD for new plugin
Bug 20181 [QA Followup]: Remove double check

Description Kyle M Hall 2018-02-12 14:08:14 UTC
A number of Koha plugins have been written that enhance Koha's public catalog. These plugins often make due to adding css and javascript to the various opac system preferences. It would be nice if the plugin system had hooks so plugin developers could add code the the head block and the area where we include javascript in the opac template.
Comment 1 Kyle M Hall 2018-02-12 15:08:18 UTC
Created attachment 71481 [details] [review]
Bug 20181: Allow plugins to add css and javascript to OPAC

A number of Koha plugins have been written that enhance Koha's public catalog. These plugins often make due to adding css and javascript to the various opac system preferences. It would be nice if the plugin system had hooks so plugin developers could add code the the head block and the area where we include javascript in the opac template.

Test Plan:
1) Apply this patch
2) Download and install the Kitchen Sink plugin ( v2.1.12 or later )
   https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.12/koha-plugin-kitchen-sink-v2.1.12.kpz
3) Install the plugin
4) Restart all the things if you can ( restart_all if you are using kohadevbox )
   This will ensure the plugin takes effect right away, it should be
   necessary but it won't hurt anything!
5) Load the opac, notice you get an alert message and the background
   for your opac is now orange ( assuming you've not customized the
   opac in any way )
Comment 2 Kyle M Hall 2018-02-12 16:15:58 UTC
Created attachment 71483 [details] [review]
Bug 20181 - Unit Tests
Comment 3 Mark Tompsett 2018-02-13 18:53:50 UTC
Created attachment 71563 [details] [review]
Bug 20181: Followup to ensure test runs

If EnablePlugins was 0, this test before this patch fails.
After this patch, it passes.

TEST PLAN
---------
1) Apply all but this patch
2) Run the following commands
    kshell
    prove t/Koha_Template_Plugin_KohaPlugins.t
   -- two tests fail, if you have the conf or syspref set to 0.
3) Apply this patch
4) Repeat step 2.
   -- all tests pass, including the positive and negative case checks.
5) run koha qa test tools
Comment 4 Kyle M Hall 2018-02-13 18:55:05 UTC
(In reply to M. Tompsett from comment #3)
> Created attachment 71563 [details] [review] [review]
> Bug 20181: Followup to ensure test runs
> 
> If EnablePlugins was 0, this test before this patch fails.
> After this patch, it passes.
> 
> TEST PLAN
> ---------
> 1) Apply all but this patch
> 2) Run the following commands
>     kshell
>     prove t/Koha_Template_Plugin_KohaPlugins.t
>    -- two tests fail, if you have the conf or syspref set to 0.
> 3) Apply this patch
> 4) Repeat step 2.
>    -- all tests pass, including the positive and negative case checks.
> 5) run koha qa test tools

Doh, thanks Mark!
Comment 5 Kyle M Hall 2018-02-13 19:08:38 UTC
Created attachment 71565 [details] [review]
Bug 20181: Add POD for new plugin
Comment 6 Mark Tompsett 2018-02-13 19:16:13 UTC
Created attachment 71566 [details] [review]
Bug 20181: Allow plugins to add css and javascript to OPAC

A number of Koha plugins have been written that enhance Koha's public catalog. These plugins often make due to adding css and javascript to the various opac system preferences. It would be nice if the plugin system had hooks so plugin developers could add code the the head block and the area where we include javascript in the opac template.

Test Plan:
1) Apply this patch
2) Download and install the Kitchen Sink plugin ( v2.1.12 or later )
   https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.12/koha-plugin-kitchen-sink-v2.1.12.kpz
3) Install the plugin
4) Restart all the things if you can ( restart_all if you are using kohadevbox )
   This will ensure the plugin takes effect right away, it should be
   necessary but it won't hurt anything!
5) Load the opac, notice you get an alert message and the background
   for your opac is now orange ( assuming you've not customized the
   opac in any way )

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 7 Mark Tompsett 2018-02-13 19:16:16 UTC
Created attachment 71567 [details] [review]
Bug 20181 - Unit Tests

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 8 Mark Tompsett 2018-02-13 19:16:18 UTC
Created attachment 71568 [details] [review]
Bug 20181: Followup to ensure test runs

If EnablePlugins was 0, this test before this patch fails.
After this patch, it passes.

TEST PLAN
---------
1) Apply all but this patch
2) Run the following commands
    kshell
    prove t/Koha_Template_Plugin_KohaPlugins.t
   -- two tests fail, if you have the conf or syspref set to 0.
3) Apply this patch
4) Repeat step 2.
   -- all tests pass, including the positive and negative case checks.
5) run koha qa test tools

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 9 Mark Tompsett 2018-02-13 19:16:22 UTC
Created attachment 71569 [details] [review]
Bug 20181: Add POD for new plugin

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 10 Katrin Fischer 2018-03-25 20:02:23 UTC
Created attachment 73264 [details] [review]
Bug 20181: Allow plugins to add css and javascript to OPAC

A number of Koha plugins have been written that enhance Koha's public catalog. These plugins often make due to adding css and javascript to the various opac system preferences. It would be nice if the plugin system had hooks so plugin developers could add code the the head block and the area where we include javascript in the opac template.

Test Plan:
1) Apply this patch
2) Download and install the Kitchen Sink plugin ( v2.1.12 or later )
   https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.12/koha-plugin-kitchen-sink-v2.1.12.kpz
3) Install the plugin
4) Restart all the things if you can ( restart_all if you are using kohadevbox )
   This will ensure the plugin takes effect right away, it should be
   necessary but it won't hurt anything!
5) Load the opac, notice you get an alert message and the background
   for your opac is now orange ( assuming you've not customized the
   opac in any way )

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Katrin Fischer 2018-03-25 20:02:28 UTC
Created attachment 73265 [details] [review]
Bug 20181: Unit tests

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2018-03-25 20:02:32 UTC
Created attachment 73266 [details] [review]
Bug 20181: (follow-up) Ensure test runs

If EnablePlugins was 0, this test before this patch fails.
After this patch, it passes.

TEST PLAN
---------
1) Apply all but this patch
2) Run the following commands
    kshell
    prove t/Koha_Template_Plugin_KohaPlugins.t
   -- two tests fail, if you have the conf or syspref set to 0.
3) Apply this patch
4) Repeat step 2.
   -- all tests pass, including the positive and negative case checks.
5) run koha qa test tools

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Katrin Fischer 2018-03-25 20:02:36 UTC
Created attachment 73267 [details] [review]
Bug 20181: Add POD for new plugin

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 14 Jonathan Druart 2018-03-28 19:36:52 UTC
It sounds weird to me to test UseKohaPlugins and enable_plugins in the Koha::Template::Plugin::KohaPlugins
I would have expected more something like
  my $p = Koha::Plugins->new;
  return unless $p;
  my @plugins = $p->GetPlugins;

as Koha::Plugins->new already test UseKohaPlugins.

Not blocker.
Comment 15 Kyle M Hall 2018-03-29 11:11:53 UTC
Created attachment 73417 [details] [review]
Bug 20181 [QA Followup]: Remove double check
Comment 16 Kyle M Hall 2018-03-29 11:13:09 UTC
(In reply to Jonathan Druart from comment #14)
> It sounds weird to me to test UseKohaPlugins and enable_plugins in the
> Koha::Template::Plugin::KohaPlugins
> I would have expected more something like
>   my $p = Koha::Plugins->new;
>   return unless $p;
>   my @plugins = $p->GetPlugins;
> 
> as Koha::Plugins->new already test UseKohaPlugins.
> 
> Not blocker.

I wonder if we could move the syspref check into new() as well.
Comment 17 Mark Tompsett 2018-03-29 13:28:49 UTC
(In reply to Kyle M Hall from comment #16)
> I wonder if we could move the syspref check into new() as well.

If there was a way to determine why a new() failed, then I'd say go for it.
Because there may exist cases where we wish to know why a new() failed.
Did it fail because the system administrator side of it wasn't configured?
Did it fail because the koha administrator turned off plugins system preference?
Did it fail for some other reason?
Comment 18 Kyle M Hall 2018-03-29 14:54:31 UTC
(In reply to M. Tompsett from comment #17)
> (In reply to Kyle M Hall from comment #16)
> > I wonder if we could move the syspref check into new() as well.
> 
> If there was a way to determine why a new() failed, then I'd say go for it.
> Because there may exist cases where we wish to know why a new() failed.
> Did it fail because the system administrator side of it wasn't configured?
> Did it fail because the koha administrator turned off plugins system
> preference?
> Did it fail for some other reason?

Good thoughts. I'd say it's out of scope for this bug. I'll file a new bug report where we can deal with it.
Comment 19 Jonathan Druart 2018-04-06 17:53:35 UTC
Pushed to master for 18.05, thanks to everybody involved!
Comment 20 Nick Clemens 2018-05-14 17:26:27 UTC
Enhancement, not backported for 17.11.x
Comment 21 Fridolin Somers 2018-10-19 08:55:14 UTC
I've decided to backport to 17.11.x, this is very useful and not risky.

Pushed to 17.11.x for 17.11.11