mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-07 03:59:22 +00:00
parent
568b4335c2
commit
353148c2bc
10 changed files with 23 additions and 19 deletions
|
@ -22,11 +22,19 @@ import (
|
|||
"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 {
|
||||
Fs afero.Fs
|
||||
|
|
|
@ -384,6 +384,6 @@ privacyEnhanced = true
|
|||
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)
|
||||
|
||||
}
|
||||
|
|
|
@ -388,11 +388,7 @@ type SiteInfo struct {
|
|||
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 @@ func (s *Site) initializeSiteInfo() error {
|
|||
Data: &s.Data,
|
||||
owner: s.owner,
|
||||
s: s,
|
||||
PrivacyConfig: privacyConfig,
|
||||
Config: SiteConfig{Privacy: privacyConfig},
|
||||
}
|
||||
|
||||
rssOutputFormat, found := s.outputFormats[KindHome].GetByName(output.RSSFormat.Name)
|
||||
|
|
|
@ -76,7 +76,7 @@ var EmbeddedTemplates = [][2]string{
|
|||
{{ 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 @@ M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.5
|
|||
<!-- 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 @@ M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.5
|
|||
</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 -}}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 -}}
|
|
@ -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 -}}
|
|
@ -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 -}}
|
|
@ -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>
|
||||
|
|
|
@ -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 -}}
|
||||
|
|
Loading…
Add table
Reference in a new issue