ref: 3bfe8f4be653f44674293685cb5750d90668b2f6
parent: 6aa2c38507aa1c2246222684717b4d69d26b03d7
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Thu May 24 07:24:38 EDT 2018
tpl: Alias tweet shortode to twitter See #4765
--- a/config/privacy/privacyConfig.go
+++ b/config/privacy/privacyConfig.go
@@ -31,7 +31,7 @@
GoogleAnalytics GoogleAnalytics
Instagram Instagram
SpeakerDeck SpeakerDeck
- Tweet Tweet
+ Twitter Twitter
Vimeo Vimeo
YouTube YouTube
}
@@ -64,8 +64,8 @@
Service `mapstructure:",squash"`
}
-// Tweet holds the privacy configuration settingsrelated to the Tweet shortcode.
-type Tweet struct {+// Twitter holds the privacy configuration settingsrelated to the Twitter shortcode.
+type Twitter struct {Service `mapstructure:",squash"`
}
--- a/config/privacy/privacyConfig_test.go
+++ b/config/privacy/privacyConfig_test.go
@@ -39,7 +39,7 @@
simple = true
[privacy.speakerDeck]
disable = true
-[privacy.tweet]
+[privacy.twitter]
disable = true
[privacy.vimeo]
disable = true
@@ -61,7 +61,7 @@
assert.True(pc.Instagram.Disable)
assert.True(pc.Instagram.Simple)
assert.True(pc.SpeakerDeck.Disable)
- assert.True(pc.Tweet.Disable)
+ assert.True(pc.Twitter.Disable)
assert.True(pc.Vimeo.Disable)
assert.True(pc.YouTube.PrivacyEnhanced)
--- a/tpl/tplimpl/embedded/templates.autogen.go
+++ b/tpl/tplimpl/embedded/templates.autogen.go
@@ -363,7 +363,7 @@
{{- 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.Config.Privacy.Tweet -}}+ {`shortcodes/twitter.html`, `{{- $pc := .Page.Site.Config.Privacy.Twitter -}} {{- if not $pc.Disable -}} {{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }} {{- end -}}`},--- a/tpl/tplimpl/embedded/templates/shortcodes/tweet.html
+++ /dev/null
@@ -1,4 +1,0 @@
-{{- $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
--- /dev/null
+++ b/tpl/tplimpl/embedded/templates/shortcodes/twitter.html
@@ -1,0 +1,4 @@
+{{- $pc := .Page.Site.Config.Privacy.Twitter -}}+{{- 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/template.go
+++ b/tpl/tplimpl/template.go
@@ -686,10 +686,21 @@
}
}
+var embeddedTemplatesAliases = map[string][]string{+ "shortcodes/twitter.html": []string{"shortcodes/tweet.html"},+}
+
func (t *templateHandler) loadEmbedded() { for _, kv := range embedded.EmbeddedTemplates {// 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)
+ }
+
+ }
}
}
--
⑨