redesign 2023

This commit is contained in:
m3tam3re
2023-10-12 14:01:05 +02:00
commit 19bfc7311a
3053 changed files with 76380 additions and 0 deletions

View File

@ -0,0 +1,9 @@
{{- /* Checkbox unchecked */ -}}
{{- $old := `<input disabled="" type="checkbox">` -}}
{{- $new := dict "Class" "fa-regular fa-square fa-fw" | partial "plugin/icon.html" -}}
{{- $content := replace . $old $new -}}
{{- /* Checkbox checked */ -}}
{{- $old = `<input checked="" disabled="" type="checkbox">` -}}
{{- $new := dict "Class" "fa-regular fa-check-square fa-fw" | partial "plugin/icon.html" -}}
{{- return replace $content $old $new -}}

View File

@ -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 -}}

View File

@ -0,0 +1,4 @@
{{- /* Unify new lines symbol */ -}}
{{- /* See https://en.wikipedia.org/wiki/Newline */ -}}
{{- return replace . "\r\n" "\n" -}}

View File

@ -0,0 +1,5 @@
{{- /* Escape character */ -}}
{{- /* {?X} -> X */ -}}
{{- $REin := `\{\?(.)\}` -}}
{{- $REout := `$1` -}}
{{- return replaceRE $REin $REout . -}}

View File

@ -0,0 +1,6 @@
{{- /* Escape url special characters to query format, e.g: `#` -> `%23` */ -}}
{{- /* https://github.com/hugo-fixit/FixIt/issues/245 */ -}}
{{- $content := . -}}
{{- $content = replace $content "#" "%23" -}}
{{- return $content -}}

View File

@ -0,0 +1,14 @@
{{- /* Font Awesome */ -}}
{{- /* :(fa-regular fa-circle): -> <i class="fa-regular fa-circle" aria-hidden="true"></i> */ -}}
{{- $REin := ` (:\([\w- ]+?\):)` -}}
{{- $REout := `&nbsp;$1` -}}
{{- $content := replaceRE $REin $REout . -}}
{{- $REin = `(:\([\w- ]+?\):) ` -}}
{{- $REout = `$1&nbsp;` -}}
{{- $content = replaceRE $REin $REout . -}}
{{- $REin = `:\(([\w- ]+?)\):` -}}
{{- $REout = `<i class="$1" aria-hidden="true"></i>` -}}
{{- return replaceRE $REin $REout $content -}}

View File

@ -0,0 +1,5 @@
{{- /* Fraction */ -}}
{{- /* [A]/[B] -> <sup>A</sup>/<sub>B</sub> */ -}}
{{- $REin := `\[(.+?)\]/\[(.+?)\]` -}}
{{- $REout := `<sup>$1</sup>/<sub>$2</sub>` -}}
{{- return replaceRE $REin $REout . -}}

View File

@ -0,0 +1,14 @@
{{- /* ID */ -}}
{{- $id := "" -}}
{{- with .Id -}}
{{- /* If an ID is specified, then just use it.*/ -}}
{{- $id = printf "%v" . -}}
{{- else -}}
{{- $count := ($.Scratch.Get "this").count | default 1 -}}
{{- $id = printf "id-%d" $count -}}
{{- $count | add 1 | $.Scratch.SetInMap "this" "count" -}}
{{- end -}}
{{- with .Content -}}
{{- dict $id . | dict "data" | dict "config" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}}
{{- end -}}
{{- return $id -}}

View File

@ -0,0 +1,4 @@
{{- /* https://discourse.gohugo.io/t/how-decode-urls-in-hugo/7549/4 */ -}}
{{- $URL := partial "function/escapeurl.html" . -}}
{{- $URL = $URL | urlize | urls.Parse -}}
{{- return $URL.Path -}}

View File

@ -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 -}}

View File

@ -0,0 +1,5 @@
{{- /* Ruby */ -}}
{{- /* [EN]^(English) -> <strong><ruby>EN<rt>English</rt></ruby></strong> */ -}}
{{- $REin := `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout := `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- return replaceRE $REin $REout . -}}