Bug 20181 - Allow plugins to add CSS and Javascript to OPAC
Summary: Allow plugins to add CSS and Javascript to OPAC
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Kyle M Hall
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 20496 20766
  Show dependency treegraph
 
Reported: 2018-02-12 14:08 UTC by Kyle M Hall
Modified: 2018-05-14 17:26 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20181: Allow plugins to add css and javascript to OPAC (4.73 KB, patch)
2018-02-12 15:08 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20181 - Unit Tests (3.46 KB, patch)
2018-02-12 16:15 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20181: Followup to ensure test runs (1.99 KB, patch)
2018-02-13 18:53 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 20181: Add POD for new plugin (1.62 KB, patch)
2018-02-13 19:08 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20181: Allow plugins to add css and javascript to OPAC (4.78 KB, patch)
2018-02-13 19:16 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 20181 - Unit Tests (3.51 KB, patch)
2018-02-13 19:16 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 20181: Followup to ensure test runs (2.04 KB, patch)
2018-02-13 19:16 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 20181: Add POD for new plugin (1.67 KB, patch)
2018-02-13 19:16 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 20181: Allow plugins to add css and javascript to OPAC (4.84 KB, patch)
2018-03-25 20:02 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 20181: Unit tests (3.56 KB, patch)
2018-03-25 20:02 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 20181: (follow-up) Ensure test runs (2.10 KB, patch)
2018-03-25 20:02 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 20181: Add POD for new plugin (1.72 KB, patch)
2018-03-25 20:02 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 20181 [QA Followup]: Remove double check (1.52 KB, patch)
2018-03-29 11:11 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 M. 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 M. 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 M. 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 M. 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 M. 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 M. 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