1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 12:36:20 -04:00

more shortcode tweaks for valid RSS

This commit is contained in:
Jake Jarvis 2019-12-15 14:06:00 -05:00
parent 77f3233702
commit 951c5f2c3f
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
7 changed files with 49 additions and 7 deletions

View File

@ -1 +0,0 @@
codepen.html

View File

@ -0,0 +1 @@
<p><a href="https://codepen.io/{{ .Get "username" }}/pen/{{ .Get "id" }}" target="_blank" rel="noopener">Open this CodePen in a new window.</a></p>

View File

@ -1 +0,0 @@
gh-buttons.html

View File

@ -0,0 +1,4 @@
<p style="text-align: center;">
<a href="https://github.com/{{ .Get "username" }}/{{ .Get "repo" }}">Star {{ .Get "username" }}/{{ .Get "repo" }} on GitHub</a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/{{ .Get "username" }}/{{ .Get "repo" }}/issues">Issues for {{ .Get "username" }}/{{ .Get "repo" }} on GitHub</a>
</p>

View File

@ -1,7 +1,8 @@
{{- /* Automatic resizing for HiDPI/retina images */ -}}
{{- $original := .Page.Resources.GetMatch (.Get "src") -}}
{{- .Scratch.Set "image" $original -}}
<!-- TODO: automatically pull max-width of page -->
{{- $maxWidth := 910 -}}
{{- $setWidth := 0 -}}

View File

@ -1,9 +1,8 @@
<!-- Automatic resizing for HiDPI/retina images -->
{{- /* Automatic resizing for HiDPI/retina images */ -}}
{{- $original := .Page.Resources.GetMatch (.Get "src") -}}
{{- .Scratch.Set "image" $original -}}
<!-- TODO: automatically pull max-width of page -->
{{- $maxWidth := 910 -}}
{{- $setWidth := 0 -}}

View File

@ -1 +0,0 @@
image.html

View File

@ -0,0 +1,35 @@
{{- /* Automatic resizing for HiDPI/retina images */ -}}
{{- $original := .Page.Resources.GetMatch (.Get "src") -}}
{{- .Scratch.Set "image" $original -}}
{{- $maxWidth := 910 -}}
{{- $setWidth := 0 -}}
{{- if .Get "width" -}}
{{- $setWidth = (int (.Get "width")) -}}
{{- $retinaWidth := (mul $setWidth 2) -}}
{{- if gt $original.Width $retinaWidth -}}
{{- $finalWidth := (printf "%dx" $retinaWidth) -}}
{{- .Scratch.Set "image" ($original.Resize $finalWidth) -}}
{{- end -}}
{{- else -}}
{{- $setWidth = $maxWidth -}}
{{- if gt $original.Width 1820 -}}
{{- .Scratch.Set "image" ($original.Resize "1820x") -}}
{{- end -}}
{{- end -}}
{{- $image := .Scratch.Get "image" -}}
{{- $origRatio := (div (float $image.Height) $image.Width) -}}
{{- $displayWidth := $setWidth -}}
{{- $displayHeight := (math.Ceil (mul $origRatio $setWidth)) -}}
<p style="text-align: center;">
<img src="{{ $image.Permalink }}" width="{{ $displayWidth }}" height="{{ $displayHeight }}"
{{- with .Get "alt" }} alt="{{ . }}"{{ end }}
{{- with .Get "caption" }} title="{{ . }}"{{ end }}>
{{ with .Get "caption" }}<br>{{ . }}{{ end -}}
</p>

View File

@ -0,0 +1,5 @@
{{- /* Modified from /tpl/tplimpl/embedded/templates/shortcodes/twitter.html to fetch tweet without script (&omit_script=1) */ -}}
{{- $url := printf "https://api.twitter.com/1/statuses/oembed.json?id=%d&omit_script=true" (index .Params 0) -}}
{{- $json := getJSON $url -}}
{{- $json.html | safeHTML -}}

View File

@ -1 +0,0 @@
youtube.html

View File

@ -0,0 +1 @@
<p style="text-align: center;"><a href="https://www.youtube.com/watch?v={{ index .Params 0 }}">Watch this video on YouTube.</a></p>