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.
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.
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.
I'm not sure we should expose system preferences to the public front end.
I agree it should be a 'whitelist' for the OPAC related features if we do this - some of the preferences might contain critical information.