From 51fb029ca27d67d7cd67352cdede45e5b25868f7 Mon Sep 17 00:00:00 2001 From: Christoph Cullmann Date: Sun, 14 Aug 2022 19:01:21 +0200 Subject: switch back to LoveIt, other theme is deprectated --- .../LoveIt/layouts/partials/function/checkbox.html | 9 +++++++++ .../LoveIt/layouts/partials/function/content.html | 23 ++++++++++++++++++++++ .../LoveIt/layouts/partials/function/escape.html | 5 +++++ .../layouts/partials/function/fontawesome.html | 14 +++++++++++++ .../LoveIt/layouts/partials/function/fraction.html | 5 +++++ themes/LoveIt/layouts/partials/function/id.html | 8 ++++++++ themes/LoveIt/layouts/partials/function/path.html | 3 +++ .../LoveIt/layouts/partials/function/resource.html | 16 +++++++++++++++ themes/LoveIt/layouts/partials/function/ruby.html | 5 +++++ 9 files changed, 88 insertions(+) create mode 100644 themes/LoveIt/layouts/partials/function/checkbox.html create mode 100644 themes/LoveIt/layouts/partials/function/content.html create mode 100644 themes/LoveIt/layouts/partials/function/escape.html create mode 100644 themes/LoveIt/layouts/partials/function/fontawesome.html create mode 100644 themes/LoveIt/layouts/partials/function/fraction.html create mode 100644 themes/LoveIt/layouts/partials/function/id.html create mode 100644 themes/LoveIt/layouts/partials/function/path.html create mode 100644 themes/LoveIt/layouts/partials/function/resource.html create mode 100644 themes/LoveIt/layouts/partials/function/ruby.html (limited to 'themes/LoveIt/layouts/partials/function') diff --git a/themes/LoveIt/layouts/partials/function/checkbox.html b/themes/LoveIt/layouts/partials/function/checkbox.html new file mode 100644 index 0000000..c94f9a6 --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/checkbox.html @@ -0,0 +1,9 @@ +{{- /* Checkbox unchecked */ -}} +{{- $old := `` -}} +{{- $new := `` -}} +{{- $content := replace . $old $new -}} + +{{- /* Checkbox checked */ -}} +{{- $old = `` -}} +{{- $new = `` -}} +{{- return replace $content $old $new -}} diff --git a/themes/LoveIt/layouts/partials/function/content.html b/themes/LoveIt/layouts/partials/function/content.html new file mode 100644 index 0000000..250a5b7 --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/content.html @@ -0,0 +1,23 @@ +{{- $content := .Content -}} + +{{- if $content -}} + + {{- if .Ruby -}} + {{- $content = partial "function/ruby.html" $content -}} + {{- end -}} + + {{- if .Fraction -}} + {{- $content = partial "function/fraction.html" $content -}} + {{- end -}} + + {{- if .Fontawesome -}} + {{- $content = partial "function/fontawesome.html" $content -}} + {{- end -}} + + {{- $content = partial "function/checkbox.html" $content -}} + + {{- $content = partial "function/escape.html" $content -}} + +{{- end -}} + +{{- return $content -}} diff --git a/themes/LoveIt/layouts/partials/function/escape.html b/themes/LoveIt/layouts/partials/function/escape.html new file mode 100644 index 0000000..1ff794f --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/escape.html @@ -0,0 +1,5 @@ +{{- /* Escape character */ -}} +{{- /* {?X} -> X */ -}} +{{- $REin := `\{\?(.)\}` -}} +{{- $REout := `$1` -}} +{{- return replaceRE $REin $REout . -}} diff --git a/themes/LoveIt/layouts/partials/function/fontawesome.html b/themes/LoveIt/layouts/partials/function/fontawesome.html new file mode 100644 index 0000000..2e14326 --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/fontawesome.html @@ -0,0 +1,14 @@ +{{- /* Font Awesome */ -}} +{{- /* :(far fa-circle): -> */ -}} + +{{- $REin := ` (:\([\w- ]+?\):)` -}} +{{- $REout := ` $1` -}} +{{- $content := replaceRE $REin $REout . -}} + +{{- $REin = `(:\([\w- ]+?\):) ` -}} +{{- $REout = `$1 ` -}} +{{- $content = replaceRE $REin $REout . -}} + +{{- $REin = `:\(([\w- ]+?)\):` -}} +{{- $REout = `` -}} +{{- return replaceRE $REin $REout $content -}} diff --git a/themes/LoveIt/layouts/partials/function/fraction.html b/themes/LoveIt/layouts/partials/function/fraction.html new file mode 100644 index 0000000..9aa85d0 --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/fraction.html @@ -0,0 +1,5 @@ +{{- /* Fraction */ -}} +{{- /* [A]/[B] -> A/B */ -}} +{{- $REin := `\[(.+?)\]/\[(.+?)\]` -}} +{{- $REout := `$1/$2` -}} +{{- return replaceRE $REin $REout . -}} diff --git a/themes/LoveIt/layouts/partials/function/id.html b/themes/LoveIt/layouts/partials/function/id.html new file mode 100644 index 0000000..e84ef9c --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/id.html @@ -0,0 +1,8 @@ +{{- /* ID */ -}} +{{- $count := (.Scratch.Get "this").count | default 1 -}} +{{- $id := printf "id-%d" $count -}} +{{- $count | add 1 | .Scratch.SetInMap "this" "count" -}} +{{- with .Content -}} + {{- dict $id . | dict "data" | dict "config" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}} +{{- end -}} +{{- return $id -}} diff --git a/themes/LoveIt/layouts/partials/function/path.html b/themes/LoveIt/layouts/partials/function/path.html new file mode 100644 index 0000000..ece426f --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/path.html @@ -0,0 +1,3 @@ +{{- /* https://discourse.gohugo.io/t/how-decode-urls-in-hugo/7549/4 */ -}} +{{- $URL := . | urlize | urls.Parse -}} +{{- return $URL.Path -}} diff --git a/themes/LoveIt/layouts/partials/function/resource.html b/themes/LoveIt/layouts/partials/function/resource.html new file mode 100644 index 0000000..2febef3 --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/resource.html @@ -0,0 +1,16 @@ +{{- $resource := 0 -}} +{{- $url := urls.Parse .Path -}} +{{- if not $url.Host | and $url.Path | and (strings.HasSuffix $url.Path "/" | not) -}} + {{- if .Resources -}} + {{- with .Resources.GetMatch $url.Path -}} + {{- $resource = . -}} + {{- end -}} + {{- end -}} + {{- if not $resource -}} + {{- with resources.Get $url.Path -}} + {{- $resource = . -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- return $resource -}} diff --git a/themes/LoveIt/layouts/partials/function/ruby.html b/themes/LoveIt/layouts/partials/function/ruby.html new file mode 100644 index 0000000..49aa35b --- /dev/null +++ b/themes/LoveIt/layouts/partials/function/ruby.html @@ -0,0 +1,5 @@ +{{- /* Ruby */ -}} +{{- /* [EN]^(English) -> ENEnglish */ -}} +{{- $REin := `\[(.+?)\]\^\((.+?)\)` -}} +{{- $REout := `$1$2` -}} +{{- return replaceRE $REin $REout . -}} -- cgit v1.2.3