Browse Source

Configurable analytics javascript

sferot 10 years ago
parent
commit
f5735ed3f6
3 changed files with 14 additions and 0 deletions
  1. 4 0
      pboard/development.ini.base
  2. 9 0
      pboard/pboard/lib/helpers.py
  3. 1 0
      pboard/pboard/templates/master.mak

+ 4 - 0
pboard/development.ini.base View File

@@ -96,6 +96,10 @@ templating.mako.compiled_templates_dir = %(here)s/data/templates
96 96
 #javascript files (if your library supports that)
97 97
 toscawidgets.framework.resource_variant=debug
98 98
 
99
+# if you have an analytics tracker, like google analytics or piwik,
100
+# put the path of the js file to include here (relative to .ini directory)
101
+js_tracker_path = analytics.js
102
+
99 103
 [loggers]
100 104
 keys = root, pboard, sqlalchemy, auth
101 105
 

+ 9 - 0
pboard/pboard/lib/helpers.py View File

@@ -6,6 +6,7 @@
6 6
 from markupsafe import Markup
7 7
 from datetime import datetime
8 8
 from tg.i18n import ugettext as _, lazy_ugettext as l_
9
+import tg
9 10
 
10 11
 def current_year():
11 12
   now = datetime.now()
@@ -84,3 +85,11 @@ class ICON(object):
84 85
   Shared = '<i class="fa fa-group"></i>'
85 86
   Private = '<i class="fa fa-key"></i>'
86 87
 
88
+def tracker_js():
89
+    js_file_path = tg.config.get('js_tracker_path', None)
90
+    if js_file_path is not None:
91
+        with open (js_file_path, "r") as js_file:
92
+            data=js_file.read()
93
+        return data
94
+    else:
95
+        return ""

+ 1 - 0
pboard/pboard/templates/master.mak View File

@@ -29,6 +29,7 @@
29 29
   <script src="${tg.url('/javascript/external/google-code-prettify/prettify.js')}"></script>
30 30
   <script src="${tg.url('/javascript/external/bootstrap-wysiwyg.js')}"></script>
31 31
   <script src="/javascript/external/bootstrap-datetimepicker.min.js"></script>
32
+  ${h.tracker_js()|n}
32 33
 
33 34
 </body>
34 35