Bugzilla – Attachment 71566 Details for
Bug 20181
Allow plugins to add CSS and Javascript to OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20181: Allow plugins to add css and javascript to OPAC
Bug-20181-Allow-plugins-to-add-css-and-javascript-.patch (text/plain), 4.78 KB, created by
Mark Tompsett
on 2018-02-13 19:16:13 UTC
(
hide
)
Description:
Bug 20181: Allow plugins to add css and javascript to OPAC
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2018-02-13 19:16:13 UTC
Size:
4.78 KB
patch
obsolete
>From da2e111414d0f5a86ea990e699d06dfcf65806e9 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Mon, 12 Feb 2018 09:09:20 -0500 >Subject: [PATCH] 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> >--- > Koha/Template/Plugin/KohaPlugins.pm | 58 ++++++++++++++++++++++ > .../bootstrap/en/includes/doc-head-close.inc | 2 + > .../bootstrap/en/includes/opac-bottom.inc | 2 + > 3 files changed, 62 insertions(+) > create mode 100644 Koha/Template/Plugin/KohaPlugins.pm > >diff --git a/Koha/Template/Plugin/KohaPlugins.pm b/Koha/Template/Plugin/KohaPlugins.pm >new file mode 100644 >index 0000000..a2b9e29 >--- /dev/null >+++ b/Koha/Template/Plugin/KohaPlugins.pm >@@ -0,0 +1,58 @@ >+package Koha::Template::Plugin::KohaPlugins; >+ >+# This file is part of Koha. >+# >+# Copyright ByWater Solutions 2018 >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use base qw( Template::Plugin ); >+ >+use Koha::Plugins; >+ >+sub get_plugins_opac_head { >+ return q{} >+ unless C4::Context->preference('UseKohaPlugins') >+ && C4::Context->config("enable_plugins"); >+ >+ my @plugins = Koha::Plugins->new()->GetPlugins( >+ { >+ method => 'opac_head', >+ } >+ ); >+ >+ my @data = map { $_->opac_head || q{} } @plugins; >+ >+ return join( "\n", @data ); >+} >+ >+sub get_plugins_opac_js { >+ return q{} >+ unless C4::Context->preference('UseKohaPlugins') >+ && C4::Context->config("enable_plugins"); >+ >+ my @plugins = Koha::Plugins->new()->GetPlugins( >+ { >+ method => 'opac_js', >+ } >+ ); >+ >+ my @data = map { $_->opac_js || q{} } @plugins; >+ >+ return join( "\n", @data ); >+} >+ >+1; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc >index 838606e..471a210 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc >@@ -1,3 +1,4 @@ >+[%- USE KohaPlugins -%] > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> > <meta name="generator" content="Koha [% Version %]" /> <!-- leave this for stats --> > <meta name="viewport" content="width=device-width, initial-scale=1" /> >@@ -53,3 +54,4 @@ > <script type="text/javascript" src="[% interface %]/[% theme %]/lib/modernizr.min_[% KOHA_VERSION %].js"></script> > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/lib/font-awesome/css/font-awesome.min_[% KOHA_VERSION %].css" /> > [% PROCESS 'html_helpers.inc' %] >+[% KohaPlugins.get_plugins_opac_head %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index fcc3ee8..31f105f 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -1,3 +1,4 @@ >+[%- USE KohaPlugins -%] > [% UNLESS ( is_popup ) %] > [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] > [% IF ( opaccredits ) %] >@@ -272,5 +273,6 @@ $(document).ready(function() { > </script> > [% END %] > [% END %] >+[% KohaPlugins.get_plugins_opac_js %] > </body> > </html> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20181
:
71481
|
71483
|
71563
|
71565
|
71566
|
71567
|
71568
|
71569
|
73264
|
73265
|
73266
|
73267
|
73417