From 9ad46a20357a7e28b405feef5c8f7d4501186da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 23 May 2018 12:26:10 +0200 Subject: Add instagram_simple shortcode Fixes #4748 --- tpl/tplimpl/embedded/templates.autogen.go | 59 +++++++++++++++++++++- .../templates/shortcodes/__h_simple_assets.html | 3 +- .../embedded/templates/shortcodes/instagram.html | 8 ++- .../templates/shortcodes/instagram_simple.html | 48 ++++++++++++++++++ 4 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 tpl/tplimpl/embedded/templates/shortcodes/instagram_simple.html (limited to 'tpl') diff --git a/tpl/tplimpl/embedded/templates.autogen.go b/tpl/tplimpl/embedded/templates.autogen.go index 9498d8f87..3339c3888 100644 --- a/tpl/tplimpl/embedded/templates.autogen.go +++ b/tpl/tplimpl/embedded/templates.autogen.go @@ -241,7 +241,8 @@ if (!doNotTrack) { {{ end }}`}, - {`shortcodes/__h_simple_assets.html`, `{{ define "__h_simple_css" }}{{/* This is also used in other "simple" variants. These template definitions are global. */}} + {`shortcodes/__h_simple_assets.html`, `{{ define "__h_simple_css" }}{{/* These template definitions are global. */}} +{{/* TODO(bep) rename this to Youtube something. We need to add these per service. */}} {{ if not (.Page.Scratch.Get "__h_simple_css") }} {{/* Only include once */}} {{ .Page.Scratch.Set "__h_simple_css" true }} @@ -298,8 +299,62 @@ 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 {`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.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 }} +{{- if $pc.Simple -}} +{{ template "_internal/shortcodes/instagram_simple.html" . }} +{{- else -}} +{{ $id := .Get 0 }} +{{ $hideCaption := cond (eq (.Get 1) "hidecaption") "1" "0" }} +{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" $id "/&hidecaption=" $hideCaption }}{{ .html | safeHTML }}{{ end }} +{{- end -}} {{- end -}}`}, + {`shortcodes/instagram_simple.html`, `{{- $pc := .Page.Site.Config.Privacy.Instagram -}} +{{- $sc := .Page.Site.Config.Services.Instagram -}} +{{- if not $pc.Disable -}} +{{- $id := .Get 0 -}} +{{- $item := getJSON "https://api.instagram.com/oembed/?url=https://www.instagram.com/p/" $id "/&maxwidth=640&omitscript=true" -}} +{{- $class1 := "__h_instagram" -}} +{{- $class2 := "s_instagram_simple" -}} +{{- $hideCaption := (eq (.Get 1) "hidecaption") -}} +{{ with $item }} +{{- $mediaURL := printf "https://instagram.com/p/%s/" $id | safeURL -}} +{{- if not $sc.DisableInlineCSS -}} +{{ template "__h_simple_instagram_css" $ }} +{{- end -}} +
+ + Instagram Image +
+ {{ if not $hideCaption }}

{{ $item.author_name }} {{ $item.title}}

{{ end }} + Vew More on Instagram +
+
+{{ end }} +{{- end -}} + +{{ define "__h_simple_instagram_css" }} +{{ if not (.Page.Scratch.Get "__h_simple_instagram_css") }} +{{/* Only include once */}} +{{ .Page.Scratch.Set "__h_simple_instagram_css" true }} + +{{ 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.Config.Privacy.SpeakerDeck -}} diff --git a/tpl/tplimpl/embedded/templates/shortcodes/__h_simple_assets.html b/tpl/tplimpl/embedded/templates/shortcodes/__h_simple_assets.html index 837378329..dddefd9ae 100644 --- a/tpl/tplimpl/embedded/templates/shortcodes/__h_simple_assets.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/__h_simple_assets.html @@ -1,4 +1,5 @@ -{{ define "__h_simple_css" }}{{/* This is also used in other "simple" variants. These template definitions are global. */}} +{{ define "__h_simple_css" }}{{/* These template definitions are global. */}} +{{/* TODO(bep) rename this to Youtube something. We need to add these per service. */}} {{ if not (.Page.Scratch.Get "__h_simple_css") }} {{/* Only include once */}} {{ .Page.Scratch.Set "__h_simple_css" true }} diff --git a/tpl/tplimpl/embedded/templates/shortcodes/instagram.html b/tpl/tplimpl/embedded/templates/shortcodes/instagram.html index ba6c5e601..67ff2e72c 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/instagram.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/instagram.html @@ -1,4 +1,10 @@ {{- $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 }} +{{- if $pc.Simple -}} +{{ template "_internal/shortcodes/instagram_simple.html" . }} +{{- else -}} +{{ $id := .Get 0 }} +{{ $hideCaption := cond (eq (.Get 1) "hidecaption") "1" "0" }} +{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" $id "/&hidecaption=" $hideCaption }}{{ .html | safeHTML }}{{ end }} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/shortcodes/instagram_simple.html b/tpl/tplimpl/embedded/templates/shortcodes/instagram_simple.html new file mode 100644 index 000000000..4a2cd8880 --- /dev/null +++ b/tpl/tplimpl/embedded/templates/shortcodes/instagram_simple.html @@ -0,0 +1,48 @@ +{{- $pc := .Page.Site.Config.Privacy.Instagram -}} +{{- $sc := .Page.Site.Config.Services.Instagram -}} +{{- if not $pc.Disable -}} +{{- $id := .Get 0 -}} +{{- $item := getJSON "https://api.instagram.com/oembed/?url=https://www.instagram.com/p/" $id "/&maxwidth=640&omitscript=true" -}} +{{- $class1 := "__h_instagram" -}} +{{- $class2 := "s_instagram_simple" -}} +{{- $hideCaption := (eq (.Get 1) "hidecaption") -}} +{{ with $item }} +{{- $mediaURL := printf "https://instagram.com/p/%s/" $id | safeURL -}} +{{- if not $sc.DisableInlineCSS -}} +{{ template "__h_simple_instagram_css" $ }} +{{- end -}} +
+ + Instagram Image +
+ {{ if not $hideCaption }}

{{ $item.author_name }} {{ $item.title}}

{{ end }} + Vew More on Instagram +
+
+{{ end }} +{{- end -}} + +{{ define "__h_simple_instagram_css" }} +{{ if not (.Page.Scratch.Get "__h_simple_instagram_css") }} +{{/* Only include once */}} +{{ .Page.Scratch.Set "__h_simple_instagram_css" true }} + +{{ end }} +{{ end }} \ No newline at end of file -- cgit v1.2.3