Thu, 10 Nov 2022 19:15:24 +0100
Better fix for matomo integration
pelicanconf.py | file | annotate | diff | comparison | revisions | |
publishconf.py | file | annotate | diff | comparison | revisions | |
theme/templates/base.html | file | annotate | diff | comparison | revisions |
--- a/pelicanconf.py Thu Nov 10 18:52:14 2022 +0100 +++ b/pelicanconf.py Thu Nov 10 19:15:24 2022 +0100 @@ -3,7 +3,7 @@ from __future__ import unicode_literals import socket -isprod = socket.gethostname() == 'sd-56079' +isprod = socket.gethostname() == 'sdfa3' AUTHOR = u'David Douard' SITENAME = u'Whatever' @@ -15,26 +15,30 @@ if isprod: SITEURL = 'https://whatever.sdfa3.org' - PIWIK = ''' + MATOMO_JS = ''' <!-- Matomo --> -<script type="text/javascript"> - var _paq = window._paq || []; +<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="https://piwik.sdfa3.org/"; + 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.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> ''' + MATOMO_IMG = ''' + <img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.sdfa3.org/matomo.php?idsite=2&rec=1" style="border:0" alt="" /> + ''' else: SITEURL = '' - PIWIK = '' + MATOMO_JS = '' + MATOMO_IMG = '' PATH = 'content'
--- a/publishconf.py Thu Nov 10 18:52:14 2022 +0100 +++ b/publishconf.py Thu Nov 10 19:15:24 2022 +0100 @@ -18,9 +18,3 @@ DELETE_OUTPUT_DIRECTORY = True -MATOMO_JS = True - -# Following items are often useful when publishing - -#DISQUS_SITENAME = "" -#GOOGLE_ANALYTICS = ""
--- a/theme/templates/base.html Thu Nov 10 18:52:14 2022 +0100 +++ b/theme/templates/base.html Thu Nov 10 19:15:24 2022 +0100 @@ -35,20 +35,8 @@ {% 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 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> + {% if MATOMO_JS%} + {{MATOMO_JS}} {% endif %} {% if article %} {% if article.stylesheets %} @@ -146,9 +134,8 @@ </div> {% include 'trademark.html' %} </div> - {% if MATOMO_IMG %} - <img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.sdfa3.org/matomo.php?idsite=2&rec=1" style="border:0" alt="" /> + {{MATOMO_IMG}} {% endif %} </body>