Fix matomo and CATEGORY_FEED_ATOM config option

Thu, 10 Nov 2022 18:52:14 +0100

author
David Douard <david.douard@logilab.fr>
date
Thu, 10 Nov 2022 18:52:14 +0100
changeset 144
202ad178f68f
parent 143
9e963e155d4c
child 146
11e6db4102f1

Fix matomo and CATEGORY_FEED_ATOM config option

publishconf.py file | annotate | diff | comparison | revisions
theme/templates/base.html file | annotate | diff | comparison | revisions
--- a/publishconf.py	Thu Nov 10 17:26:20 2022 +0100
+++ b/publishconf.py	Thu Nov 10 18:52:14 2022 +0100
@@ -14,10 +14,12 @@
 RELATIVE_URLS = False
 
 FEED_ALL_ATOM = 'feeds/all.atom.xml'
-CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
+CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
 
 DELETE_OUTPUT_DIRECTORY = True
 
+MATOMO_JS = True
+
 # Following items are often useful when publishing
 
 #DISQUS_SITENAME = ""
--- a/theme/templates/base.html	Thu Nov 10 17:26:20 2022 +0100
+++ b/theme/templates/base.html	Thu Nov 10 18:52:14 2022 +0100
@@ -35,8 +35,20 @@
   {% if TAG_FEED_RSS and tag %}
   <link href="{{ FEED_DOMAIN }}/{% if TAG_FEED_RSS_URL %}{{ TAG_FEED_RSS_URL|format(tag.slug) }}{% else %}{{ TAG_FEED_RSS|format(tag.slug) }}{% endif %}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Tags RSS Feed" />
   {% endif %}
-  {% if PIWIK %}
-  {{PIWIK}}
+  {% if MATOMO_JS %}
+<script>
+  var _paq = window._paq = window._paq || [];
+  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
+  _paq.push(['trackPageView']);
+  _paq.push(['enableLinkTracking']);
+  (function() {
+    var u="//matomo.sdfa3.org/";
+    _paq.push(['setTrackerUrl', u+'matomo.php']);
+    _paq.push(['setSiteId', '2']);
+    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
+  })();
+</script>
   {% endif %}
   {% if article %}
     {% if article.stylesheets %}
@@ -134,10 +146,9 @@
         </div>
         {% include 'trademark.html' %}
     </div>
-  {% if PIWIK %}
-  <noscript>
-  <img src="https://piwik.sdfa3.org/matomo.php?idsite=2&amp;rec=1" style="border:0" alt="" />
-  </noscript>
+
+  {% if MATOMO_IMG %}
+  <img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.sdfa3.org/matomo.php?idsite=2&amp;rec=1" style="border:0" alt="" />
   {% endif %}
     
 </body>

mercurial