django-honeypot==0.7.0
python-memcached
-django-piwik
python-fb
# Feedparser
--- /dev/null
+import hashlib
+from django.conf import settings
+
+
+def context_processor(request):
+ ab = {}
+ for abtest, nvalues in settings.AB_TESTS.items():
+ print(abtest, nvalues)
+ ab[abtest] = hashlib.md5(
+ (abtest + request.META['REMOTE_ADDR']).encode('utf-8')
+ ).digest()[0] % nvalues
+ print(ab)
+ return {'AB': ab}
'rest_framework',
'fnp_django_pagination',
'pipeline',
- 'piwik',
'sorl.thumbnail',
'honeypot',
'fnpdjango',
'django.template.context_processors.media',
'django.template.context_processors.request',
'wolnelektury.context_processors.extra_settings',
+ 'wolnelektury.abtests.context_processor',
'search.context_processors.search_form',
'machina.core.context_processors.metadata',
),
CLUB_PAYU_POS = '300746'
CLUB_PAYU_RECURRING_POS = '300746'
CLUB_APP_HOST = None
+
+AB_TESTS = {
+ 'PAYLOGO': 2,
+}
--- /dev/null
+<!-- Piwik -->
+<script type="text/javascript">
+ var pkBaseURL = "{{ url }}";
+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", {{ id }});
+{% for ab, abval in AB.items %}
+ piwikTracker.setCustomVariable({{ forloop.counter }}, "{{ ab }}", "{{ abval }}", "page");
+{% endfor %}
+piwikTracker.trackPageView();
+piwikTracker.enableLinkTracking();
+} catch( err ) {}
+</script><noscript><p><img src="{{ url }}piwik.php?idsite={{ id }}" style="border:0" alt="" /></p></noscript>
+<!-- End Piwik Tracking Code -->
--- /dev/null
+"""Piwik template tag."""
+
+from django import template
+from django.conf import settings
+from django.core.exceptions import ImproperlyConfigured
+
+
+register = template.Library()
+
+
+@register.inclusion_tag('piwik/tracking_code.html', takes_context=True)
+def tracking_code(context):
+ try:
+ id = settings.PIWIK_SITE_ID
+ except AttributeError:
+ raise ImproperlyConfigured('PIWIK_SITE_ID does not exist.')
+ try:
+ url = settings.PIWIK_URL
+ except AttributeError:
+ raise ImproperlyConfigured('PIWIK_URL does not exist.')
+ return {'id': id, 'url': url, 'AB': context.get('AB')}