From 7cd1bf8d36a8d7cd16aa78addb071c17578b9f97 Mon Sep 17 00:00:00 2001 From: chang-ning Date: Sat, 6 Oct 2018 09:10:35 +0800 Subject: [PATCH] support analytics --- app.py | 2 ++ docs/_templates/layout.html | 13 +++++++++++++ docs/conf.py | 1 + 3 files changed, 16 insertions(+) diff --git a/app.py b/app.py index bf788029..488ea463 100644 --- a/app.py +++ b/app.py @@ -27,6 +27,8 @@ def find_key(token): "script-src": [ "'self'", "*.cloudflare.com", + "*.googletagmanager.com", + "*.google-analytics.com", "'unsafe-inline'", "'unsafe-eval'", ], diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html index 70050e32..7cf23ad4 100644 --- a/docs/_templates/layout.html +++ b/docs/_templates/layout.html @@ -1,2 +1,15 @@ {% extends "!layout.html" %} +{%- block extrahead %} +{%- if tracking_id %} + + + +{% endif -%} +{% endblock %} {% set css_files = css_files + [ "_static/style.css" ] %} diff --git a/docs/conf.py b/docs/conf.py index e4d6df99..9d0881dc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -132,6 +132,7 @@ # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = "pysheeet" +html_context = {"tracking_id": os.environ.get("TRACKING_ID")} # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None