Commit f2ce0968 authored by fred's avatar fred
Browse files

add support for piwik tracker code (disabled by default)

parent 4457fcaf
......@@ -3,6 +3,7 @@ import urllib2
import uuid
from django import template
from django.conf import settings
from django.db.models.query import QuerySet
from django.utils import simplejson
from datetime import datetime, timedelta
......@@ -166,3 +167,8 @@ class FormatSearchResultNode(template.Node):
}
t = template.loader.get_template('%s/search_result.html' % dir_mapping.get(result.model_name))
return t.render(template.context.Context({'result': result}, autoescape=context.autoescape))
@register.inclusion_tag('includes/piwik.html')
def piwik():
return {'enabled': settings.ENABLE_PIWIK}
......@@ -164,6 +164,8 @@ FIBER_TEMPLATE_CHOICES = (
('tpl-default.html', 'Default template'),
)
ENABLE_PIWIK = False
try:
from local_settings import *
except ImportError, e:
......
......@@ -58,5 +58,7 @@
{% block pageend %}
{% endblock %}
{% piwik %}
</body>
</html>
{% if enabled %}
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://stats.radiopanik.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.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
{% endif %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment