[base] add piwik js stuff

Tue, 15 Mar 2016 16:23:38 +0100

author
David Douard <david.douard@logilab.fr>
date
Tue, 15 Mar 2016 16:23:38 +0100
changeset 40
2a30ebfd851f
parent 38
71e96f955e7a
child 41
376692051823

[base] add piwik js stuff

pelicanconf.py file | annotate | diff | comparison | revisions
theme/templates/base.html file | annotate | diff | comparison | revisions
--- a/pelicanconf.py	Tue Mar 15 16:23:22 2016 +0100
+++ b/pelicanconf.py	Tue Mar 15 16:23:38 2016 +0100
@@ -1,13 +1,37 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*- #
 from __future__ import unicode_literals
+import socket
+_isprod = socket.gethostname() == 'sd-56079'
 
 AUTHOR = u'David Douard'
 SITENAME = u'Whatever'
 SITESUBTITLE = u"A blog, sort of"
 TWITTER_USERNAME = u'douardda'
 CONTACTS = (('twitter', 'https://twitter.com/twttrAcc'),)
-SITEURL = 'https://whatever.sdfa3.org'
+
+if _isprod:
+    SITEURL = 'https://whatever.sdfa3.org'
+    PIWIK = '''
+<script type="text/javascript">
+  var _paq = _paq || [];
+  _paq.push(["setDomains", ["*.whatever.sdfa3.org"]]);
+  _paq.push(['trackPageView']);
+  _paq.push(['enableLinkTracking']);
+  (function() {
+    var u="//piwik.sdfa3.org/";
+    _paq.push(['setTrackerUrl', u+'piwik.php']);
+    _paq.push(['setSiteId', 2]);
+    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+  })();
+</script>
+<noscript><p><img src="//piwik.sdfa3.org/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
+<!-- End Piwik Code -->
+'''
+else:
+    SITEURL = ''
+    PIWIK = ''
 
 PATH = 'content'
 
--- a/theme/templates/base.html	Tue Mar 15 16:23:22 2016 +0100
+++ b/theme/templates/base.html	Tue Mar 15 16:23:38 2016 +0100
@@ -34,6 +34,9 @@
         {% if TAG_FEED_RSS and tag %}
         <link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_RSS|format(tag.slug) }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Tags RSS Feed" />
         {% endif %}
+        {% if PIWIK %}
+        {{PIWIK}}
+        {% endif %} 
         {% endblock head %}        
 </head>
 <body>

mercurial