summaryrefslogtreecommitdiffstats
path: root/content/posts/piwik-in-docker-for-pelican.rst
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/piwik-in-docker-for-pelican.rst')
-rw-r--r--content/posts/piwik-in-docker-for-pelican.rst95
1 files changed, 95 insertions, 0 deletions
diff --git a/content/posts/piwik-in-docker-for-pelican.rst b/content/posts/piwik-in-docker-for-pelican.rst
new file mode 100644
index 0000000..1bf5df0
--- /dev/null
+++ b/content/posts/piwik-in-docker-for-pelican.rst
@@ -0,0 +1,95 @@
+Piwik for this blog
+####################
+:date: 2014-02-18 08:00
+:tags: piwik, docker, pelican
+
+I was looking for a simple analytics tool for this blog. As everyone seems to
+be using **piwik** and everyone loves **docker** for rapid deployment. As i am
+always short on resources on all my machines i decided to deploy piwik on
+another of my VMs which is ``mediengewitter.krebsco.de`` instead of directly on
+``euer.krebsco.de`` Again it was a case of 'how-hard-can-it-be?'.
+Turns out everything is much harder than expected.
+As always this this is the digest of some hours work.
+
+Installing piwik in docker
+==========================
+After testing out all kinds of non-working Dockerfiles, this is what worked for
+me:
+
+.. code-block:: bash
+
+ git clone https://github.com/makefu/docker-piwik.git piwik
+ cd piwik
+ ./build
+
+ # if you want persistence, see:
+ mkdir -p /media/ext/piwik/{www,mysql}
+ cat README
+
+Running piwik
+=============
+Because docker handles it's own network, the docker image port 80 must be
+forwarded to the host (i use 10000). Also i want data persistence via exported filesystems.
+
+.. code-block:: bash
+
+ docker run -p=10000:80 -d
+ \ -v /media/ext/piwik/www:/var/www
+ \ -v /media/ext/piwik/mysql:/var/lib/mysql piwik
+ # or ./run
+
+Adding piwik to pelican
+=======================
+Integration of piwik tracking to pelican **should** be straight forward, just
+add the following to your ``pelicanconf.py``:
+
+.. code-block:: python
+
+ PIWIK_URL='mediengewitter.krebsco.de:10000'
+ # first piwik site is always id 1
+ PIWIK_SITE_ID=1
+
+Bit nothing seemed to be happening, turns out my theme of choice does not
+support piwik so i had to add this feature explicitly to the skin (by stealing
+the code from another theme). I created a pull request for my code:
+https://github.com/getpelican/pelican-themes/pull/195 .
+If it will never be merged, use my repository for themes:
+
+.. code-block:: bash
+
+ cd <pelican-dir>
+ git clone git@github.com:makefu/pelican-themes.git -b add-piwik-to-gum themes
+
+Add piwik to another skin
+=========================
+If you are using another skin without piwik integration, this is basically what you
+need to do:
+
+1. Add piwik.html to '``<skin>/templates``'
+
+.. code-block:: html
+
+ {% if PIWIK_URL and PIWIK_SITE_ID %}
+ <script type="text/javascript">
+ {% if PIWIK_SSL_URL %}
+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://{{ PIWIK_SSL_URL }}/" : "http://{{ PIWIK_URL }}/");
+ {% else %}
+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://{{ PIWIK_URL }}/" : "http://{{ PIWIK_URL }}/");
+ {% endif %}
+ document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
+ </script><script type="text/javascript">
+ try {
+ var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {{ PIWIK_SITE_ID }});
+ piwikTracker.trackPageView();
+ piwikTracker.enableLinkTracking();
+ } catch( err ) {}
+ </script><noscript><p><img src="http://{{ PIWIK_URL }}/piwik.php?idsite={{ PIWIK_SITE_ID }}" style="border:0" alt="" /></p></noscript>
+ {% endif %}
+
+2. Add this line somewhere near the end but before </body></html> to '``<skin>/templates/base.html``':
+
+.. code-block:: html
+
+ ...
+ {% include 'piwik.html' %}
+ ...