From 36c8a83018698dbdf70d7c8cd615f89e870aaa4b Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 10 Nov 2020 15:44:05 +0100 Subject: [PATCH] Add plausible analytics if env variable exists --- articles/context_processors.py | 4 ++++ articles/templates/articles/analytics.html | 3 +++ articles/templates/articles/base.html | 1 + articles/tests/test_articles.py | 17 +++++++++++++++++ blog/settings.py | 3 +++ 5 files changed, 28 insertions(+) create mode 100644 articles/templates/articles/analytics.html diff --git a/articles/context_processors.py b/articles/context_processors.py index d51fd98..65b429d 100644 --- a/articles/context_processors.py +++ b/articles/context_processors.py @@ -37,3 +37,7 @@ def git_version(request): version = "latest" url = settings.BLOG["repo"]["log"] return {"git_version": version, "git_version_url": url} + + +def plausible(request): + return {"plausible_domain": settings.PLAUSIBLE_DOMAIN} diff --git a/articles/templates/articles/analytics.html b/articles/templates/articles/analytics.html new file mode 100644 index 0000000..97863ae --- /dev/null +++ b/articles/templates/articles/analytics.html @@ -0,0 +1,3 @@ +{% if plausible_domain is not None %} + +{% endif %} diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index da67a0e..c60fa6c 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -11,6 +11,7 @@ {% include "articles/favicon.html" %} + {% include "articles/analytics.html" %}