From f02259a87f5be78ac3611a2341bed83306e94223 Mon Sep 17 00:00:00 2001 From: tdro Date: Thu, 22 Dec 2022 02:19:54 -0500 Subject: themes/default/layouts/shortcodes/video: Add RSS version Unify other helpers --- .../default/layouts/partials/function-content.html | 3 +-- .../default/layouts/partials/video-container.html | 7 +++--- themes/default/layouts/shortcodes/imgur-video.html | 15 +++++------ themes/default/layouts/shortcodes/video.html | 2 +- themes/default/layouts/shortcodes/video.rss.xml | 29 ++++++++++++++++++++++ 5 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 themes/default/layouts/shortcodes/video.rss.xml (limited to 'themes') diff --git a/themes/default/layouts/partials/function-content.html b/themes/default/layouts/partials/function-content.html index 9ad5a1a..59776aa 100644 --- a/themes/default/layouts/partials/function-content.html +++ b/themes/default/layouts/partials/function-content.html @@ -1,7 +1,6 @@ {{- $context := . -}} {{- $content := $context.Content -}} {{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} -{{- $empty := eq (len $content) 0 -}} {{- $content = $content | @@ -20,7 +19,7 @@ {{- $content = replace $content $brokenBlockquote $fixedBlockquote -}} {{- end -}} -{{- if $empty -}} +{{- if not $content -}} {{- $content = "This message contains no content." -}} {{- end -}} diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index caf89d3..bae0cbb 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -36,9 +36,10 @@ {{- $caption = "No remote video data found for source" -}} {{- end -}} {{- else -}} - {{- $cache = resources.Get (path.Join "public/" $fileCache) -}} - {{- $cache = $cache.Content | resources.FromString $fileCache -}} - {{- $cache = $cache.Permalink -}} + {{- with $cache = resources.Get (path.Join "public/" $fileCache) -}} + {{- $cache = $cache.Content | resources.FromString $fileCache -}} + {{- $cache = $cache.Permalink -}} + {{- end -}} {{- end -}} {{- $source = $cache -}} diff --git a/themes/default/layouts/shortcodes/imgur-video.html b/themes/default/layouts/shortcodes/imgur-video.html index a6d637a..9bc130f 100644 --- a/themes/default/layouts/shortcodes/imgur-video.html +++ b/themes/default/layouts/shortcodes/imgur-video.html @@ -1,17 +1,14 @@ {{- $id := default "rQIb4Vw" (.Get "id" | default (.Get 0)) -}} {{- $title := default "Imgur Gif" (.Get "title" | default (.Get 1)) -}} -{{- $caption := default "Imgur Gif" (.Get "caption" | default (.Get 2)) -}} +{{- $caption := default $title (.Get "caption" | default (.Get 2)) -}} {{- $options := default "controls autoplay loop muted playsinline" (.Get "options" | default (.Get 3)) -}} -{{- partial "video-container.html" - (dict - "Author" .Page.Section - "Caption" $caption - "Options" $options - "RelURL" (strings.TrimPrefix .Site.BaseURL .Page.Permalink) - "Source" (print "https://i.imgur.com/" $id ".mp4") - ) +{{- $source := print "https://i.imgur.com/" $id ".mp4" -}} + +{{- printf `{{< video source="%s" title="%s" caption="%s" options="%s" >}}` + $source $title $caption $options + | markdownify -}} diff --git a/themes/default/layouts/shortcodes/video.html b/themes/default/layouts/shortcodes/video.html index 64de78f..18065f8 100644 --- a/themes/default/layouts/shortcodes/video.html +++ b/themes/default/layouts/shortcodes/video.html @@ -1,5 +1,5 @@ {{- - $source := default + $source := default "https://raw.githubusercontent.com/benhosmer/HTML5-Test-Videos/9a6c2db46472454c634963cbeb0900fd37901fac/big_buck_bunny.mp4" (.Get "source" | default (.Get 0)) -}} diff --git a/themes/default/layouts/shortcodes/video.rss.xml b/themes/default/layouts/shortcodes/video.rss.xml new file mode 100644 index 0000000..cff5974 --- /dev/null +++ b/themes/default/layouts/shortcodes/video.rss.xml @@ -0,0 +1,29 @@ +{{- + $source := default + "https://raw.githubusercontent.com/benhosmer/HTML5-Test-Videos/9a6c2db46472454c634963cbeb0900fd37901fac/big_buck_bunny.mp4" + (.Get "source" | default (.Get 0)) +-}} +{{- $poster := default "" (.Get "poster" | default (.Get 1)) -}} +{{- $width := default "" (.Get "width" | default (.Get 2)) -}} +{{- $height := default "" (.Get "height" | default (.Get 3)) -}} +{{- $preload := default "metadata" (.Get "preload" | default (.Get 4)) -}} +{{- $options := default "controls" (.Get "options" | default (.Get 5)) -}} +{{- $caption := default "Untitled Video" (.Get "caption" | default (.Get 6)) -}} +{{- $title := default $caption (.Get "title" | default (.Get 7)) -}} +{{- $start := default "" (.Get "start" | default (.Get 8)) -}} +{{- $end := default "" (.Get "end" | default (.Get 9)) -}} +{{- $orientation := default "landscape" (.Get "orientation" | default (.Get 10)) -}} +{{- $remote := default "" (.Get "remote" | default (.Get 11)) -}} + +

+ + + {{- $caption -}} + + +
+ {{ $caption }} +

-- cgit v1.2.3