ref: 353148c2bc2cdb9f2eb8ee967ba756ce09323801
parent: 568b4335c20effb46168bd639317a3420f563463
author: Bjørn Erik Pedersen <[email protected]>
date: Tue May 22 10:00:36 EDT 2018
Move the privacy config into a parent See #4751
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -22,10 +22,18 @@
"strings"
"github.com/gohugoio/hugo/config"
+ "github.com/gohugoio/hugo/config/privacy"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/afero"
"github.com/spf13/viper"
)
+
+// SiteConfig represents the config in .Site.Config.
+type SiteConfig struct {
+ // This contains all privacy related settings that can be used to
+ // make the YouTube template etc. GDPR compliant.
+ Privacy privacy.Config
+}
// ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).
type ConfigSourceDescriptor struct {
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -384,6 +384,6 @@
b.WithConfigFile("toml", tomlConfig)
b.Build(BuildCfg{SkipRender: true})
- assert.True(b.H.Sites[0].Info.PrivacyConfig.YouTube.PrivacyEnhanced)
+ assert.True(b.H.Sites[0].Info.Config.Privacy.YouTube.PrivacyEnhanced)
}
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -388,11 +388,7 @@
preserveTaxonomyNames bool
Data *map[string]interface{}
- // This contains all privacy related settings that can be used to
- // make the YouTube template etc.GDPR compliant.
- // It is mostly in use by Hugo's built-in, but is also available
- // for end users with {{ .Site.PrivacyConfig.YouTube.NoCookie }} etc.
- PrivacyConfig privacy.Config
+ Config SiteConfig
owner *HugoSites
s *Site
@@ -1151,7 +1147,7 @@
Data: &s.Data,
owner: s.owner,
s: s,
- PrivacyConfig: privacyConfig,
+ Config: SiteConfig{Privacy: privacyConfig},
}
rssOutputFormat, found := s.outputFormats[KindHome].GetByName(output.RSSFormat.Name)
--- a/tpl/tplimpl/embedded/templates.autogen.go
+++ b/tpl/tplimpl/embedded/templates.autogen.go
@@ -76,7 +76,7 @@
{{ end }}
</sitemapindex>
`},
- {`disqus.html`, `{{- $pc := .Page.Site.PrivacyConfig.Disqus -}}
+ {`disqus.html`, `{{- $pc := .Page.Site.Config.Privacy.Disqus -}}
{{- if not $pc.Disable -}}
{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div>
<script>
@@ -296,21 +296,21 @@
<!-- image -->`},
{`shortcodes/gist.html`, `<script src="//gist.github.com/{{ index .Params 0 }}/{{ index .Params 1 }}.js{{if len .Params | eq 3 }}?file={{ index .Params 2 }}{{end}}"></script>`},
{`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`, `{{- $pc := .Page.Site.PrivacyConfig.Instagram -}}
+ {`shortcodes/instagram.html`, `{{- $pc := .Page.Site.Config.Privacy.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`, `{{- $pc := .Page.Site.PrivacyConfig.SpeakerDeck -}}
+ {`shortcodes/speakerdeck.html`, `{{- $pc := .Page.Site.Config.Privacy.SpeakerDeck -}}
{{- if not $pc.Disable -}}
<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>
{{- end -}}`},
- {`shortcodes/tweet.html`, `{{- $pc := .Page.Site.PrivacyConfig.Tweet -}}
+ {`shortcodes/tweet.html`, `{{- $pc := .Page.Site.Config.Privacy.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 -}}
+ {`shortcodes/vimeo.html`, `{{- $pc := .Page.Site.Config.Privacy.Vimeo -}}
{{- if not $pc.Disable -}}
{{ if .IsNamedParams }}<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
<iframe src="//player.vimeo.com/video/{{ .Get "id" }}" {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
@@ -320,7 +320,7 @@
</div>
{{ end }}
{{- end -}}`},
- {`shortcodes/youtube.html`, `{{- $pc := .Page.Site.PrivacyConfig.YouTube -}}
+ {`shortcodes/youtube.html`, `{{- $pc := .Page.Site.Config.Privacy.YouTube -}}
{{- if not $pc.Disable -}}
{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}}
{{- if $pc.Simple -}}
--- a/tpl/tplimpl/embedded/templates/disqus.html
+++ b/tpl/tplimpl/embedded/templates/disqus.html
@@ -1,4 +1,4 @@
-{{- $pc := .Page.Site.PrivacyConfig.Disqus -}}
+{{- $pc := .Page.Site.Config.Privacy.Disqus -}}
{{- if not $pc.Disable -}}
{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div>
<script>
--- a/tpl/tplimpl/embedded/templates/shortcodes/instagram.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/instagram.html
@@ -1,4 +1,4 @@
-{{- $pc := .Page.Site.PrivacyConfig.Instagram -}}
+{{- $pc := .Page.Site.Config.Privacy.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
--- a/tpl/tplimpl/embedded/templates/shortcodes/speakerdeck.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/speakerdeck.html
@@ -1,4 +1,4 @@
-{{- $pc := .Page.Site.PrivacyConfig.SpeakerDeck -}}
+{{- $pc := .Page.Site.Config.Privacy.SpeakerDeck -}}
{{- if not $pc.Disable -}}
<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>
{{- end -}}
\ No newline at end of file
--- a/tpl/tplimpl/embedded/templates/shortcodes/tweet.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/tweet.html
@@ -1,4 +1,4 @@
-{{- $pc := .Page.Site.PrivacyConfig.Tweet -}}
+{{- $pc := .Page.Site.Config.Privacy.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
--- a/tpl/tplimpl/embedded/templates/shortcodes/vimeo.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/vimeo.html
@@ -1,4 +1,4 @@
-{{- $pc := .Page.Site.PrivacyConfig.Vimeo -}}
+{{- $pc := .Page.Site.Config.Privacy.Vimeo -}}
{{- if not $pc.Disable -}}
{{ if .IsNamedParams }}<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
<iframe src="//player.vimeo.com/video/{{ .Get "id" }}" {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
--- a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html
@@ -1,4 +1,4 @@
-{{- $pc := .Page.Site.PrivacyConfig.YouTube -}}
+{{- $pc := .Page.Site.Config.Privacy.YouTube -}}
{{- if not $pc.Disable -}}
{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}}
{{- if $pc.Simple -}}