Add Privacy Pack

- To enable, set `privacy_pack = true` in `config.toml`
- Show a cookie consent message to visitors
- Anonymize IP in Google Analytics (if enabled)

See #507
This commit is contained in:
George Cushen committed 2018-04-21 12:07:57 +01:00
1 parent f23526e55d
commit c22d653c43
4 files changed
+40

No files matched your search

+5
View File
@@ -151,6 +151,11 @@ defaultContentLanguageInSubdir = false
# Enable native social sharing buttons?
sharing = true
# Privacy pack
# Show a cookie consent message to visitors
# Anonymize IP in Google Analytics (if enabled)
privacy_pack = false
# Link custom CSS and JS assets
# (relative to /static/css and /static/js respectively)
custom_css = []
+11
View File
@@ -147,3 +147,14 @@
- id: 404_recommendations
translation: Perhaps you were looking for one of these?
# Cookie consent
- id: cookie_message
translation: This website uses cookies to ensure you get the best experience on our website.
- id: cookie_dismiss
translation: Got it!
- id: cookie_learn
translation: Learn more
+22
View File
@@ -0,0 +1,22 @@
{{ if .Site.Params.privacy_pack }}
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#000"
},
"button": {
"background": "#f1d600"
}
},
"content": {
"message": {{ i18n "cookie_message" | default "This website uses cookies to ensure you get the best experience on our website." }},
"dismiss": {{ i18n "cookie_dismiss" | default "Got it!" }},
"link": {{ i18n "cookie_learn" | default "Learn more" }}
}
})});
</script>
{{ end }}
+2
View File
@@ -81,6 +81,7 @@
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ .Site.GoogleAnalytics }}', 'auto');
{{ if .Site.Params.privacy_pack }}ga('set', 'anonymizeIp', true);{{ end }}
ga('require', 'eventTracker');
ga('require', 'outboundLinkTracker');
ga('require', 'urlChangeTracker');
@@ -124,6 +125,7 @@
{{ if not .Date.IsZero }}<meta property="og:updated_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
{{ end }}
{{ partial "cookie_consent" . }}
{{ partial "head_custom" . }}
<title>{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ .Site.Title }}</title>