This question about Configuration: Answered
How to insert a specific script tag onto every page emitted by Foswiki instance
--
LoriKayBrown - 26 Mar 2014
I need to have a way to insert a specific script tag onto every single page emitted by our Foswiki instance. All the webs, all the admin screens, all the forms, every. stinking. page.
It can reside in either the head or right before the closing </body> tag.
The script that we are required to insert is a specialized version of a Google Analytics script, so we cannot use the Google Analytics plug in, because it does not permit me to reference the specific script needed.
We don't want it to be optimized, or chewed on by Foswiki. We don't want to talk about security problems.
We just absolutely, non-negotiably have to insert this code:
<script id='_fed_an_js_tag' type='text/javascript' src='http://www.star.nesdis.noaa.gov/star/global/js/federated-analytics.js?agency=DOC&subagency=NOAA&pua=UA-48915369-2'></script>
onto EVERY page rendered by our Foswiki instance.
Is this possible? If so, how does one do it? I do not know foswiki well, and am not interested in this being a days long project.
--
LoriKayBrown - 26 Mar 2014
Take a look at
http://trac.foswiki.org/browser/trunk/core/tools/admin/PiwikPlugin.pm I had to add it into subversion as an example. It's a quick & dirty plugin someone wrote to add a script to every foswiki page.
It's not a real plugin, so some infrastructure is missing to enable it. It has to be manually enabled by editing
lib/LocalSite.cfg
for example:
$Foswiki::cfg{Plugins}{PiwikPlugin}{Enabled} = 1;
$Foswiki::cfg{Plugins}{PiwikPlugin}{Module} = 'Foswiki::Plugins::PiwikPlugin';
See
DevelopingPlugins for more information about plugins.
--
GeorgeClark - 27 Mar 2014
Thanks, George, I'll take a look at this more tomorrow.
So what does one do to install it, if one doesn't use the usual plugin methods?
I'm assuming I would replace lines 48-58 with my single line script reference?
--
LoriKayBrown - 28 Mar 2014
You install it by copying it into the lib/Foswiki/Plugins directory, and then adding the two lines I pasted in above into the lib/LocalSite.cfg. it would be best to get some help from someone who has worked with perl code before.
--
GeorgeClark - 28 Mar 2014
That is exactly what I am doing. Will post here if we are successful. I would strongly recommend that if this works, a permanent and formally installable version of the blank plugin be made generally available. If I couldn't solve this problem, I would have had to get rid of our Foswiki instance.
--
LoriKayBrown - 29 Mar 2014
Our adaptation of your piwik plugin worked, thanks so much for your assistance, George. It is likely to be handy for future insertions as well. Hooray!
--
LoriKayBrown - 01 Apr 2014