From 831a1532798bc8545570bb91167b126d8fa022a4 Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Thu, 4 Dec 2014 15:31:12 -0200 Subject: [PATCH] Added google analytics tracking option --- colab/home/context_processors.py | 7 ++++++- colab/settings.py | 1 + colab/templates/base.html | 2 ++ colab/templates/includes/google_analytics.html | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 colab/templates/includes/google_analytics.html diff --git a/colab/home/context_processors.py b/colab/home/context_processors.py index 67c3850..a569bee 100644 --- a/colab/home/context_processors.py +++ b/colab/home/context_processors.py @@ -6,6 +6,11 @@ def robots(request): return {'ROBOTS_NOINDEX': getattr(settings, 'ROBOTS_NOINDEX', False)} +def google_analytics(request): + key = 'GOOGLE_ANALYTICS_TRACKING_ID' + return {key: getattr(settings, key, False)} + + def ribbon(request): enabled = getattr(settings, 'RIBBON_ENABLED', True) if not enabled: @@ -15,7 +20,7 @@ def ribbon(request): text = _('Fork me!') return { - 'ribbon': { + 'ribbon': { 'text': getattr(settings, 'RIBBON_TEXT', text), 'url': getattr(settings, 'RIBBON_URL', url), } diff --git a/colab/settings.py b/colab/settings.py index ec51a0d..5038712 100644 --- a/colab/settings.py +++ b/colab/settings.py @@ -198,6 +198,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'colab.proxy.context_processors.proxied_apps', 'colab.home.context_processors.robots', 'colab.home.context_processors.ribbon', + 'colab.home.context_processors.google_analytics', 'colab.planet.context_processors.feedzilla', ) diff --git a/colab/templates/base.html b/colab/templates/base.html index 0742b56..589ad89 100644 --- a/colab/templates/base.html +++ b/colab/templates/base.html @@ -38,6 +38,8 @@ + {% include "includes/google_analytics.html" %} + {% block head_js %}{% endblock %} {% block head_css %}{% endblock %} diff --git a/colab/templates/includes/google_analytics.html b/colab/templates/includes/google_analytics.html new file mode 100644 index 0000000..cd04918 --- /dev/null +++ b/colab/templates/includes/google_analytics.html @@ -0,0 +1,17 @@ + +

HEHEHE

+{% if GOOGLE_ANALYTICS_TRACKING_ID %} +

HAHAHA

+ + +{% endif %} -- libgit2 0.21.2