From 6789207347fc2df186741644a6fe968d41ea9077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 20 May 2018 20:00:29 +0200 Subject: [PATCH] tpl/tplimpl/embedded: Wrap the relevant templates with the privacy policy disable check See #4616 --- tpl/tplimpl/embedded/templates.autogen.go | 50 ++++++++++++++----- tpl/tplimpl/embedded/templates/disqus.html | 5 +- .../embedded/templates/google_analytics.html | 5 +- .../templates/google_analytics_async.html | 5 +- .../templates/shortcodes/instagram.html | 5 +- .../templates/shortcodes/speakerdeck.html | 5 +- .../embedded/templates/shortcodes/tweet.html | 5 +- .../embedded/templates/shortcodes/vimeo.html | 5 +- .../templates/shortcodes/youtube.html | 5 +- 9 files changed, 69 insertions(+), 21 deletions(-) diff --git a/tpl/tplimpl/embedded/templates.autogen.go b/tpl/tplimpl/embedded/templates.autogen.go index d30352502..033d8defc 100644 --- a/tpl/tplimpl/embedded/templates.autogen.go +++ b/tpl/tplimpl/embedded/templates.autogen.go @@ -76,7 +76,9 @@ var EmbeddedTemplates = [][2]string{ {{ end }} `}, - {`disqus.html`, `{{ if .Site.DisqusShortname }}
+ {`disqus.html`, `{{- $pc := .Page.Site.PrivacyConfig.Disqus -}} +{{- if not $pc.Disable -}} +{{ if .Site.DisqusShortname }}
-comments powered by Disqus{{end}}`}, - {`google_analytics.html`, `{{ with .Site.GoogleAnalytics }} +comments powered by Disqus{{end}} +{{- end -}}`}, + {`google_analytics.html`, `{{- $pc := .Page.Site.PrivacyConfig.GoogleAnalytics -}} +{{- if not $pc.Disable -}} +{{ with .Site.GoogleAnalytics }} -{{ end }}`}, - {`google_analytics_async.html`, `{{ with .Site.GoogleAnalytics }} +{{ end }} +{{- end -}}`}, + {`google_analytics_async.html`, `{{- $pc := .Page.Site.PrivacyConfig.GoogleAnalytics -}} +{{- if not $pc.Disable -}} +{{ with .Site.GoogleAnalytics }} -{{ end }}`}, +{{ end }} +{{- end -}}`}, {`google_news.html`, `{{ if .IsPage }}{{ with .Params.news_keywords }} {{ end }}{{ end }}`}, @@ -238,19 +247,33 @@ ga('send', 'pageview'); `}, {`shortcodes/gist.html`, ``}, {`shortcodes/highlight.html`, `{{ if len .Params | eq 2 }}{{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .Inner "\n\r") (.Get 0) "" }}{{ end }}`}, - {`shortcodes/instagram.html`, `{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }}`}, + {`shortcodes/instagram.html`, `{{- $pc := .Page.Site.PrivacyConfig.Instagram -}} +{{- if not $pc.Disable -}} +{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }} +{{- end -}}`}, {`shortcodes/ref.html`, `{{ if len .Params | eq 2 }}{{ ref .Page (.Get 0) (.Get 1) }}{{ else }}{{ ref .Page (.Get 0) }}{{ end }}`}, {`shortcodes/relref.html`, `{{ if len .Params | eq 2 }}{{ relref .Page (.Get 0) (.Get 1) }}{{ else }}{{ relref .Page (.Get 0) }}{{ end }}`}, - {`shortcodes/speakerdeck.html`, ``}, - {`shortcodes/tweet.html`, `{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}`}, - {`shortcodes/vimeo.html`, `{{ if .IsNamedParams }}
+ {`shortcodes/speakerdeck.html`, `{{- $pc := .Page.Site.PrivacyConfig.SpeakerDeck -}} +{{- if not $pc.Disable -}} + +{{- end -}}`}, + {`shortcodes/tweet.html`, `{{- $pc := .Page.Site.PrivacyConfig.Tweet -}} +{{- if not $pc.Disable -}} +{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }} +{{- end -}}`}, + {`shortcodes/vimeo.html`, `{{- $pc := .Page.Site.PrivacyConfig.Vimeo -}} +{{- if not $pc.Disable -}} +{{ if .IsNamedParams }}
{{ else }}
-{{ end }}`}, - {`shortcodes/youtube.html`, `{{ if .IsNamedParams }} +{{ end }} +{{- end -}}`}, + {`shortcodes/youtube.html`, `{{- $pc := .Page.Site.PrivacyConfig.YouTube -}} +{{- if not $pc.Disable -}} +{{ if .IsNamedParams }}
@@ -258,7 +281,8 @@ ga('send', 'pageview');
-{{ end }}`}, +{{ end }} +{{- end -}}`}, {`twitter_cards.html`, `{{- with $.Params.images -}} diff --git a/tpl/tplimpl/embedded/templates/disqus.html b/tpl/tplimpl/embedded/templates/disqus.html index a42298e53..3f44369a7 100755 --- a/tpl/tplimpl/embedded/templates/disqus.html +++ b/tpl/tplimpl/embedded/templates/disqus.html @@ -1,3 +1,5 @@ +{{- $pc := .Page.Site.PrivacyConfig.Disqus -}} +{{- if not $pc.Disable -}} {{ if .Site.DisqusShortname }}
-comments powered by Disqus{{end}} \ No newline at end of file +comments powered by Disqus{{end}} +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/google_analytics.html b/tpl/tplimpl/embedded/templates/google_analytics.html index 8155cf6f2..2473ff5dd 100755 --- a/tpl/tplimpl/embedded/templates/google_analytics.html +++ b/tpl/tplimpl/embedded/templates/google_analytics.html @@ -1,3 +1,5 @@ +{{- $pc := .Page.Site.PrivacyConfig.GoogleAnalytics -}} +{{- if not $pc.Disable -}} {{ with .Site.GoogleAnalytics }} -{{ end }} \ No newline at end of file +{{ end }} +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/google_analytics_async.html b/tpl/tplimpl/embedded/templates/google_analytics_async.html index 0e983850a..3088949c6 100755 --- a/tpl/tplimpl/embedded/templates/google_analytics_async.html +++ b/tpl/tplimpl/embedded/templates/google_analytics_async.html @@ -1,3 +1,5 @@ +{{- $pc := .Page.Site.PrivacyConfig.GoogleAnalytics -}} +{{- if not $pc.Disable -}} {{ with .Site.GoogleAnalytics }} -{{ end }} \ No newline at end of file +{{ end }} +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/shortcodes/instagram.html b/tpl/tplimpl/embedded/templates/shortcodes/instagram.html index 9f012cf3a..471dcc77d 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/instagram.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/instagram.html @@ -1 +1,4 @@ -{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }} \ No newline at end of file +{{- $pc := .Page.Site.PrivacyConfig.Instagram -}} +{{- if not $pc.Disable -}} +{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }} +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/shortcodes/speakerdeck.html b/tpl/tplimpl/embedded/templates/shortcodes/speakerdeck.html index 9ef1f92f6..5045f3478 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/speakerdeck.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/speakerdeck.html @@ -1 +1,4 @@ - \ No newline at end of file +{{- $pc := .Page.Site.PrivacyConfig.SpeakerDeck -}} +{{- if not $pc.Disable -}} + +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/shortcodes/tweet.html b/tpl/tplimpl/embedded/templates/shortcodes/tweet.html index 008b0b776..ef2dd07a1 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/tweet.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/tweet.html @@ -1 +1,4 @@ -{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }} \ No newline at end of file +{{- $pc := .Page.Site.PrivacyConfig.Tweet -}} +{{- if not $pc.Disable -}} +{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }} +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/shortcodes/vimeo.html b/tpl/tplimpl/embedded/templates/shortcodes/vimeo.html index 513e5c2b4..bd021376d 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/vimeo.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/vimeo.html @@ -1,7 +1,10 @@ +{{- $pc := .Page.Site.PrivacyConfig.Vimeo -}} +{{- if not $pc.Disable -}} {{ if .IsNamedParams }}
{{ else }}
-{{ end }} \ No newline at end of file +{{ end }} +{{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html index f128889ae..2bdcb7441 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html @@ -1,3 +1,5 @@ +{{- $pc := .Page.Site.PrivacyConfig.YouTube -}} +{{- if not $pc.Disable -}} {{ if .IsNamedParams }}
-{{ end }} \ No newline at end of file +{{ end }} +{{- end -}} \ No newline at end of file