[Bug 17498] New: Expose system preference values to JavaScript in the OPAC
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Bug ID: 17498 Summary: Expose system preference values to JavaScript in the OPAC Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: ASSIGNED Severity: enhancement Priority: P5 - low Component: OPAC Assignee: oleonard@myacpl.org Reporter: oleonard@myacpl.org QA Contact: testopia@bugs.koha-community.org We process a lot of JavaScript in the OPAC templates, usually because there are template variable which need to be processed. Some of these variable, like system preferences, are a global setting which is common to many pages in the OPAC. I propose that these settings be defined in embedded JavaScript so that the scripts themselves can be moved to a separate file. In my proposal, opac-bottom.inc will contain a section like this: <script type="text/javascript"> if (typeof KOHA == "undefined" || !KOHA) { var KOHA = {}; } KOHA.paths = { "interface_theme":"[% interface %]/[% theme %]" } KOHA.preferences = { "BakerTaylorEnabled" : [% IF ( Koha.Preference( 'BakerTaylorEnabled' ) == 1 ) %]1[% ELSE %]0[% END %], ...and then an separate JS file will use those variables to conditionally load resources: if( KOHA.preferences.Coce && KOHA.preferences.CoceProviders ){ KOHA.externalResources.push( KOHA.paths.interface_theme + "/js/coce.js" ); var NO_COCE_JACKET = _("No cover image available"); } if( KOHA.externalResources.length > 0 ){ Modernizr.load({ load: KOHA.externalResources }); } I'd appreciate comments anyone might have on this system. My goal, if this works well, is to then add a JavaScript concatenation/minification task for OPAC js assets. Moving as much JS as possible out of the templates will help us take advantage of that minification. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 --- Comment #1 from Owen Leonard <oleonard@myacpl.org> --- I feel I should clarify: This wouldn't expose any private system preference data like API keys. It would be used primarily to expose "on" or "off" settings for various features. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chris@bigballofwax.co.nz --- Comment #2 from Chris Cormack <chris@bigballofwax.co.nz> --- As long as it's an opt in thing, IE we have to define in opac-bottom.inc which preferences we want exposed, and only do ones that it is safe to do so. Then I think it is a great idea. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Frédéric Demians <frederic@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |frederic@tamil.fr -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- I'm not sure we should expose system preferences to the public front end. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de --- Comment #4 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- I agree it should be a 'whitelist' for the OPAC related features if we do this - some of the preferences might contain critical information. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17498 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|NEW |RESOLVED --- Comment #5 from Owen Leonard <oleonard@myacpl.org> --- *** This bug has been marked as a duplicate of bug 41562 *** -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org