mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
6aa2c38507
commit
3bfe8f4be6
5 changed files with 19 additions and 8 deletions
|
@ -31,7 +31,7 @@ type Config struct {
|
||||||
GoogleAnalytics GoogleAnalytics
|
GoogleAnalytics GoogleAnalytics
|
||||||
Instagram Instagram
|
Instagram Instagram
|
||||||
SpeakerDeck SpeakerDeck
|
SpeakerDeck SpeakerDeck
|
||||||
Tweet Tweet
|
Twitter Twitter
|
||||||
Vimeo Vimeo
|
Vimeo Vimeo
|
||||||
YouTube YouTube
|
YouTube YouTube
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,8 @@ type SpeakerDeck struct {
|
||||||
Service `mapstructure:",squash"`
|
Service `mapstructure:",squash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tweet holds the privacy configuration settingsrelated to the Tweet shortcode.
|
// Twitter holds the privacy configuration settingsrelated to the Twitter shortcode.
|
||||||
type Tweet struct {
|
type Twitter struct {
|
||||||
Service `mapstructure:",squash"`
|
Service `mapstructure:",squash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ disable = true
|
||||||
simple = true
|
simple = true
|
||||||
[privacy.speakerDeck]
|
[privacy.speakerDeck]
|
||||||
disable = true
|
disable = true
|
||||||
[privacy.tweet]
|
[privacy.twitter]
|
||||||
disable = true
|
disable = true
|
||||||
[privacy.vimeo]
|
[privacy.vimeo]
|
||||||
disable = true
|
disable = true
|
||||||
|
@ -61,7 +61,7 @@ simple = true
|
||||||
assert.True(pc.Instagram.Disable)
|
assert.True(pc.Instagram.Disable)
|
||||||
assert.True(pc.Instagram.Simple)
|
assert.True(pc.Instagram.Simple)
|
||||||
assert.True(pc.SpeakerDeck.Disable)
|
assert.True(pc.SpeakerDeck.Disable)
|
||||||
assert.True(pc.Tweet.Disable)
|
assert.True(pc.Twitter.Disable)
|
||||||
assert.True(pc.Vimeo.Disable)
|
assert.True(pc.Vimeo.Disable)
|
||||||
|
|
||||||
assert.True(pc.YouTube.PrivacyEnhanced)
|
assert.True(pc.YouTube.PrivacyEnhanced)
|
||||||
|
|
|
@ -363,7 +363,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
|
||||||
{{- if not $pc.Disable -}}
|
{{- 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>
|
<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>
|
||||||
{{- end -}}`},
|
{{- end -}}`},
|
||||||
{`shortcodes/tweet.html`, `{{- $pc := .Page.Site.Config.Privacy.Tweet -}}
|
{`shortcodes/twitter.html`, `{{- $pc := .Page.Site.Config.Privacy.Twitter -}}
|
||||||
{{- if not $pc.Disable -}}
|
{{- if not $pc.Disable -}}
|
||||||
{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}
|
{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}
|
||||||
{{- end -}}`},
|
{{- end -}}`},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{{- $pc := .Page.Site.Config.Privacy.Tweet -}}
|
{{- $pc := .Page.Site.Config.Privacy.Twitter -}}
|
||||||
{{- if not $pc.Disable -}}
|
{{- if not $pc.Disable -}}
|
||||||
{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}
|
{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}
|
||||||
{{- end -}}
|
{{- end -}}
|
|
@ -686,10 +686,21 @@ func (t *templateHandler) addTemplateFile(name, baseTemplatePath, path string) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var embeddedTemplatesAliases = map[string][]string{
|
||||||
|
"shortcodes/twitter.html": []string{"shortcodes/tweet.html"},
|
||||||
|
}
|
||||||
|
|
||||||
func (t *templateHandler) loadEmbedded() {
|
func (t *templateHandler) loadEmbedded() {
|
||||||
for _, kv := range embedded.EmbeddedTemplates {
|
for _, kv := range embedded.EmbeddedTemplates {
|
||||||
// TODO(bep) error handling
|
// TODO(bep) error handling
|
||||||
t.addInternalTemplate(kv[0], kv[1])
|
name, templ := kv[0], kv[1]
|
||||||
|
t.addInternalTemplate(name, templ)
|
||||||
|
if aliases, found := embeddedTemplatesAliases[name]; found {
|
||||||
|
for _, alias := range aliases {
|
||||||
|
t.addInternalTemplate(alias, templ)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue