diff options
Diffstat (limited to 'themes/default/layouts')
171 files changed, 3499 insertions, 2202 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock-mathml.html b/themes/default/layouts/_default/_markup/render-codeblock-mathml.html new file mode 100644 index 0000000..f6e5b61 --- /dev/null +++ b/themes/default/layouts/_default/_markup/render-codeblock-mathml.html @@ -0,0 +1,18 @@ +{{- $caption := default "Math Render" .Attributes.caption -}} +{{- $ordinal := add .Ordinal 1 -}} +{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) "-" $ordinal -}} +{{- $id := print "math:" $hash | safeURL -}} + +<math-ml> + <figure id="{{ $id }}"> + <figure> + {{- with $math := .Inner -}} + {{- $math | safeHTML -}} + {{- end -}} + </figure> + <figcaption> + <a href="#{{ $id }}">({{ $ordinal }})</a> + {{ $caption | markdownify }} + </figcaption> + </figure> +</math-ml> diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html index f5c0e13..ab9a786 100644 --- a/themes/default/layouts/_default/_markup/render-codeblock.html +++ b/themes/default/layouts/_default/_markup/render-codeblock.html @@ -1,19 +1,25 @@ -{{ $options := .Attributes.options | default "default=1" }} -{{ $caption := .Attributes.caption }} +{{- $caption := .Attributes.caption -}} +{{- $type := .Type | default "text" -}} +{{- $options := .Attributes.options | default "default=1" -}} +{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) .Ordinal -}} +{{- $id := print "code-block:" $hash | safeURL -}} +{{- $highlight := highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) -}} -<code-block {{ if in (lower $options) "linenos" }}data-lines{{ end }}> +<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}> <header> <language-label> - {{ .Type }} + <a href="#{{ $id }}">{{ $type }}</a> </language-label> - <button> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/copy.svg")) }} - <span>Copy</span> - </button> </header> - {{ highlight .Inner .Type (print $options ",lineAnchors=" "code-" (truncate 7 "" (md5 .Inner))) }} + <code-content contenteditable="true" spellcheck="false"> + {{- replace $highlight + `class="lnlinks"` + `contenteditable="false" class="lnlinks"` + | safeHTML + -}} + </code-content> </code-block> -{{ with $caption }} +{{- with $caption -}} <footer>{{ . | markdownify }}</footer> -{{ end }} +{{- end -}} diff --git a/themes/default/layouts/_default/_markup/render-heading.html b/themes/default/layouts/_default/_markup/render-heading.html index 37eddb2..86b8e35 100644 --- a/themes/default/layouts/_default/_markup/render-heading.html +++ b/themes/default/layouts/_default/_markup/render-heading.html @@ -1,6 +1,9 @@ -<h{{ .Level }} id="{{ .Anchor | safeURL }}"> - <a - title="{{ .Text | safeHTML }}" - href="#{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} +{{- $text := .Text -}} +{{- $hash := print (truncate 2 "" (sha256 .Page.RelPermalink)) (truncate 2 "" (sha256 $text)) -}} +{{- $id := print "heading:" $hash ":" .Anchor -}} + +<h{{ .Level }} id="{{ $id | safeURL }}"> + <a title="{{ $text | safeHTML }}" href="#{{ $id | safeURL }}"> + {{ $text | safeHTML }} </a> </h{{ .Level }}> diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index 0cf1d5a..04bf931 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -1,93 +1,110 @@ -{{- $source := $.Destination | safeURL -}} -{{- $public := print "public/" $source -}} -{{- $local := "" -}} -{{- $cache := "" -}} -{{- $exists := "" -}} -{{- $width := "" -}} -{{- $height := "" -}} -{{- $dimensions := "600x360" -}} -{{- $author := .Page.Section -}} -{{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} -{{- $immutable := print ($relURL | humanize | urlize) "-" ($source | sha256 | truncate 8 "") -}} -{{- $fileCache := print (partial "function-paths-media.html") "/" $author "/" $immutable -}} +{{- $cache := "" -}} +{{- $width := "" -}} +{{- $height := "" -}} +{{- $srcset := "" -}} +{{- $colors := "" -}} +{{- $type := "" -}} +{{- $source := $.Destination | safeURL -}} +{{- $public := print "public/" $source -}} +{{- $fetch := print (urls.Parse $source).Scheme "://" (urls.Parse $source).Host (urls.Parse $source).RequestURI -}} +{{- $figcaption := "Image/Picture" -}} +{{- $orientation := "landscape" -}} +{{- $dimensions := "600x360" -}} +{{- $author := .Page.Section -}} +{{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} +{{- $immutable := print ($relURL | humanize | urlize) "-" ($source | sha256 | truncate 8 "") -}} +{{- $storage := print $author "/media/" $immutable -}} +{{- $cached := fileExists (print "public/" $storage ".webp") -}} -{{- if not (or (fileExists (print "public/" $fileCache ".webp")) (fileExists (print "public/" $fileCache (path.Ext $source)))) -}} - {{- with $remote := resources.GetRemote $source -}} +{{- $moderns := slice ".webp" ".avif" -}} +{{- $fallbacks := slice ".png" ".jpg" ".gif" ".jpeg" ".svg" ".apng" ".jfif" ".pjpeg" ".pjp" -}} +{{- $mimes := slice "image/avif" "image/webp" "image/apng" "image/gif" "image/jpeg" "image/png" "image/svg+xml" -}} + +{{- if not $cached -}} + {{- with $remote := cond (default true $.Page.Site.Params.site.offline) false (resources.GetRemote $fetch) -}} {{- with .Err -}} {{- if fileExists $public -}} - {{- $local = resources.Get $public -}} - {{- with $local -}} - {{- $local = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}} + {{- with $local := resources.Get $public -}} + {{- $local = .Content | resources.FromString (print $storage (path.Base .)) -}} + {{- $local = .Fit (print $dimensions " webp") -}} + {{- $local = $local | resources.Copy (print $storage ".webp") -}} + {{- $srcset = $local.Permalink -}} + {{- $local = .Fit $dimensions -}} + {{- $local = $local | resources.Copy (print $storage (path.Ext $local)) -}} + {{- $width = $local.Width -}} + {{- $height = $local.Height -}} + {{- $colors = $local.Colors -}} + {{- $cache = $local.Permalink -}} {{- end -}} {{- $source = print ("" | absURL) $source -}} {{- else -}} - {{- $404image := resources.Get "data/media/404.png" -}} - {{- with $404image -}} - {{- $width = .Width -}} - {{- $height = .Height -}} + {{- with $404image := resources.Get "data/media/404.png" -}} + {{- $width = $404image.Width -}} + {{- $height = $404image.Height -}} + {{- $source = $404image.Permalink -}} {{- end -}} - {{- $source = $404image.RelPermalink -}} {{- end -}} {{- else -}} - {{- $cache = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}} + {{- with $cache = $remote.Content | resources.FromString (print $storage (path.Base $remote)) -}} + {{- $cache = .Fit (print $dimensions " webp") -}} + {{- $cache = $cache | resources.Copy (print $storage ".webp") -}} + {{- $srcset = $cache.Permalink -}} + {{- $cache = .Fit $dimensions -}} + {{- $cache = $cache | resources.Copy (print $storage (path.Ext $cache)) -}} + {{- $width = $cache.Width -}} + {{- $height = $cache.Height -}} + {{- $colors = $cache.Colors -}} + {{- $cache = $cache.Permalink -}} + {{- end -}} {{- end -}} {{- end -}} {{- else -}} - {{- $exists = resources.Get (print "public/" $fileCache (path.Ext $source)) -}} - {{- $exists = $exists.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base $exists)) -}} + {{- with $cache = resources.Get (print "public/" $storage ".webp") -}} + {{- $width = $cache.Width -}} + {{- $height = $cache.Height -}} + {{- $colors = $cache.Colors -}} + {{- $type = $cache.MediaType -}} + {{- $srcset = print ("" | absURL) "/" $storage ".webp" -}} + {{- end -}} + {{- range $extension := $fallbacks -}} + {{- with resources.Get (print "public/" $storage $extension) -}} + {{- $cache = print ("" | absURL) "/" $storage $extension -}} + {{- break -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- if lt $width $height -}} + {{- $orientation = "portrait" -}} +{{- end -}} + +{{- with $caption := $.Title -}} + {{- $figcaption = $caption | markdownify -}} {{ end }} {{- /* This comment removes trailing newlines and white spaces. */ -}} <figure> - <a href="{{ $source }}"> + <a data-orientation="{{ $orientation }}" href="{{ $source }}"> <picture> - {{- with $local }} - {{- $local = .Fit (print $dimensions " webp") }} - {{- $local = $local | resources.Copy (print (partial "function-paths-media.html") "/" $author "/" $immutable ".webp") }} - <source srcset="{{- $local.RelPermalink -}}" type="image/webp" /> - {{- $local = .Fit $dimensions }} - {{- $local = $local | resources.Copy (print (partial "function-paths-media.html") "/" $author "/" $immutable (path.Ext $local)) }} - {{- $width = $local.Width -}} - {{- $height = $local.Height -}} - {{- $writeToFile := $local.Permalink }} + {{- with $srcset }} + <source srcset="{{ $srcset }}" type="{{ or $type "image/webp" }}" /> {{- end }} - {{- with $cache }} - {{- $cache = .Fit (print $dimensions " webp") }} - {{- $cache = $cache | resources.Copy (print $author "/media/" $immutable ".webp") }} - <source srcset="{{- $cache.RelPermalink -}}" type="image/webp" /> - {{- $cache = .Fit $dimensions }} - {{- $cache = $cache | resources.Copy (print (partial "function-paths-media.html") "/" $author "/" $immutable (path.Ext $cache)) }} - {{- $width = $cache.Width -}} - {{- $height = $cache.Height -}} - {{- $cache = $cache.RelPermalink }} - {{- end -}} - {{- with $exists }} - {{- if fileExists (print "public/" $fileCache ".webp") -}} - <source srcset="/{{- print $fileCache ".webp" -}}" type="image/webp" /> - {{- end -}} - {{- if fileExists (print "public/" $author "/media/" $immutable ".webp") -}} - <source srcset="/{{- print $author "/media/" $immutable ".webp" -}}" type="image/webp" /> - {{- end -}} - {{- $width = .Width -}} - {{- $height = .Height -}} - {{- $cache = .RelPermalink }} - {{- end -}} - <img loading="lazy" + <img + loading="lazy" src="{{ or $cache $source }}" alt="{{ $.Text | htmlUnescape }}" title="{{ $.Text | htmlUnescape }}" width="{{ $width }}" height="{{ $height }}" + {{ printf `style="` | safeHTMLAttr -}} + {{- partial "image-gradient.css.html" $colors | safeHTMLAttr -}} + {{- printf `"` | safeHTMLAttr }} /> </picture> </a> <figcaption> - {{ with $.Title -}} - {{ . | markdownify }} - {{ else -}} - Image/Picture - {{ end -}} - <br> - Index: {{ with $cache }} {{ print "[Cache](" . ")" | markdownify }} · {{ end }} + {{ $figcaption }} + <br /> + Index: {{ with $cache }} {{ print "[Cache](" $cache ")" | markdownify }} · {{ end }} {{ print "[Source](" $source ")" | markdownify }} </figcaption> </figure> diff --git a/themes/default/layouts/_default/_markup/render-link.html b/themes/default/layouts/_default/_markup/render-link.html index 17a6f2c..ccfbc06 100644 --- a/themes/default/layouts/_default/_markup/render-link.html +++ b/themes/default/layouts/_default/_markup/render-link.html @@ -1,21 +1,31 @@ {{- $link := .Destination -}} -{{ $isRemote := strings.HasPrefix $link "http" }} -{{- if not $isRemote -}} -{{ $url := urls.Parse .Destination }} -{{- if $url.Path -}} -{{ $fragment := "" }} -{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}} -{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .Permalink $fragment }}{{ end }}{{ end -}} +{{- $url := urls.Parse $link -}} +{{- $site := urls.Parse .Page.Site.BaseURL -}} +{{- $local := or (eq $url.Host $site.Host) (strings.HasPrefix $link "/") -}} +{{- $remote := not $local -}} + +{{- if and $local $url.Path -}} + +{{- $fragment := "" -}} + + {{- with $url.Fragment -}} + {{- $fragment = printf "#%s" . -}} + {{- end -}} + + {{- with .Page.GetPage $url.Path -}} + {{- $link = printf "%s%s" .Permalink $fragment -}} + {{- end -}} + {{- end -}} + <a + {{- if $remote }} + rel="noopener no-referrer" + {{- else }} + data-internal="" + {{- end }} href="{{ $link | safeURL }}" {{ with or .Title ($link | safeURL) -}} title="{{ . }}" - {{ end }} - {{- if $isRemote -}} - target="_blank" - rel="noopener no-referrer" - {{ end }}> - {{- .Text | safeHTML -}} -</a> + {{ end }}>{{ .Text | safeHTML }}</a> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/_default/baseof.html b/themes/default/layouts/_default/baseof.html index 3ee2e03..c277115 100644 --- a/themes/default/layouts/_default/baseof.html +++ b/themes/default/layouts/_default/baseof.html @@ -1,11 +1,26 @@ +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if $modified -}} <!DOCTYPE html> -<html lang="en-us" itemscope itemtype="http://schema.org/BlogPosting"> +<html + lang="en-us" + data-kind="{{ .Page.Kind }}" + data-type="{{ .Page.Type }}" + itemscope="" + itemtype="http://schema.org/BlogPosting" + data-document="html" +> <head> <title> {{- block "title" . -}}{{- end -}} - {{- partial "site-title.html" . -}} + {{- partial "head-title.html" . -}} </title> - <meta name="description" content="{{- partial "site-description.html" . -}}"> + <meta name="description" content="{{- partial "head-description.html" . -}}" /> {{- partial "head.html" . -}} {{- block "styles" . -}}{{- end -}} </head> @@ -14,19 +29,27 @@ <a href="#main">Skip to main content</a> </skip-link> - <column-left> + <column-base position="left"> {{- partial "navigator-left.html" . -}} - </column-left> + </column-base> - <column-middle> + <column-base position="middle"> + {{- block "header" . -}}{{- end -}} <main id="main"> - {{- block "middle" . -}}{{- end -}} - {{- partial "footer.html" . -}} + {{- block "middle" . -}} + <footer>Silence is golden.</footer> + {{- end -}} </main> - </column-middle> + {{- block "footer" . -}} + {{- partial "footer.html" . -}} + {{- end -}} + </column-base> - <column-right> - {{- block "right" . -}}{{- end -}} - </column-right> + <column-base position="right"> + {{- block "right" . -}} + <footer>Silence is golden.</footer> + {{- end -}} + </column-base> </body> </html> +{{- end -}} diff --git a/themes/default/layouts/_default/baseof.json b/themes/default/layouts/_default/baseof.json new file mode 100644 index 0000000..e1203cc --- /dev/null +++ b/themes/default/layouts/_default/baseof.json @@ -0,0 +1,12 @@ +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if $modified -}} + {{- block "main" . -}} + "Silence is golden." + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/_default/baseof.txt b/themes/default/layouts/_default/baseof.txt new file mode 100644 index 0000000..c354667 --- /dev/null +++ b/themes/default/layouts/_default/baseof.txt @@ -0,0 +1,12 @@ +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if $modified -}} + {{- block "main" . -}} + Silence is golden. + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/_default/baseof.xml b/themes/default/layouts/_default/baseof.xml new file mode 100644 index 0000000..73f129f --- /dev/null +++ b/themes/default/layouts/_default/baseof.xml @@ -0,0 +1,13 @@ +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if $modified -}} +{{- block "main" . -}} +{{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>%s` "\n" | safeHTML -}} +<root>Silence is golden.</root> +{{- end -}} +{{- end -}} diff --git a/themes/default/layouts/_default/drafts.html b/themes/default/layouts/_default/drafts.html deleted file mode 100644 index 635f17b..0000000 --- a/themes/default/layouts/_default/drafts.html +++ /dev/null @@ -1,54 +0,0 @@ -{{ define "styles" }} -{{ $author := partial "author-user.html" . }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} - - tab-list a[href="{{ .Site.BaseURL }}/{{ $author }}/drafts/"] { - color: #111; - color: var(--foreground); - display: inherit; - font-weight: 700; - text-decoration-color: #014cc6; - text-decoration-color: var(--link); - text-decoration: underline; - } -</style> -{{ end }} - -{{ define "middle" }} - - {{ partial "navigator-middle.html" - (dict - "Title" "Drafts" - "Subtitle" (partial "count-drafts.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) - }} - - {{ partial "profile.html" . }} - - {{- $author := partial "author-user.html" . -}} - {{- $users := where .Site.RegularPages "Section" $author -}} - {{- $drafts := where .Site.RegularPages "Draft" true -}} - {{- $filteredPages := $users | intersect $drafts -}} - {{- $paginator := .Paginate $filteredPages }} - - {{ range $paginator.Pages }} - {{ .Render "summary" }} - {{ else }} - <footer> - <code>No drafts found!</code> - </footer> - {{ end }} - - {{ partial "pagination.html" . }} - -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right.html" . -}} -{{ end }} diff --git a/themes/default/layouts/_default/feeds.html b/themes/default/layouts/_default/feeds.html deleted file mode 100644 index 332c455..0000000 --- a/themes/default/layouts/_default/feeds.html +++ /dev/null @@ -1,50 +0,0 @@ -{{ define "styles" }} -{{ $author := partial "author-user.html" . }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} - - tab-list a[href="{{ .Site.BaseURL }}/{{ $author }}/feeds/"] { - color: #111; - color: var(--foreground); - display: inherit; - font-weight: 700; - text-decoration-color: #014cc6; - text-decoration-color: var(--link); - text-decoration: underline; - } -</style> -{{ end }} - -{{ define "middle" }} - - {{ partial "navigator-middle.html" - (dict - "Title" "Feeds" - "Subtitle" (partial "count-feeds.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) - }} - - {{ partial "profile.html" . }} - - {{ range .Paginator.Pages }} - {{ .Render "summary" }} - {{ else }} - <footer> - <code>No feeds found!</code> - </footer> - {{ end }} - - {{ partial "pagination.html" . }} - - {{ partial "generate-feeds" . }} - -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right.html" . -}} -{{ end }} diff --git a/themes/default/layouts/_default/home.archive-messages.html b/themes/default/layouts/_default/home.archive-messages.html deleted file mode 100644 index d97694f..0000000 --- a/themes/default/layouts/_default/home.archive-messages.html +++ /dev/null @@ -1,48 +0,0 @@ -{{ define "title" }}Message History — {{ end }} -{{ define "description" }}This page contains an archive of all messages — {{ end }} -{{ define "styles" }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/archives/messages/") | safeCSS }} -</style> -{{ end }} - -{{ define "middle" }} - -{{ partial "navigator-middle.html" - (dict - "Title" "History" - "Subtitle" (partial "count-total-messages.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) -}} - -<message-archive> - <item-list> - {{ $type := (partial "author-user.html" .) }} - {{ range (.Site.RegularPages.GroupByDate "2006") }} - {{ range (first 1 .Pages) }} - <h1>{{ .Date.Format "2006" }}</h1> - {{ end }} - <ul> - {{ range .Pages }} - <li> - <a title="{{ partial "title.html" . }}" href="{{ .RelPermalink }}#{{ partial "card-id.html" . }}"> - <span><code>{{ .Date.Format "02 Jan" }}</code></span> - <span>{{ partial "title.html" . }}</span> - <span>@{{ partial "author-user.html" . }}</span> - </a> - </li> - {{ end }} - </ul> - {{ end }} - </item-list> -</message-archive> -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right-default.html" . -}} -{{ end }} diff --git a/themes/default/layouts/_default/home.archive-tags.html b/themes/default/layouts/_default/home.archive-tags.html deleted file mode 100644 index 7fec925..0000000 --- a/themes/default/layouts/_default/home.archive-tags.html +++ /dev/null @@ -1,56 +0,0 @@ -{{ define "title" }}Tags Archive — {{ end }} -{{ define "description" }}This page contains an archive of all tags — {{ end }} -{{ define "styles" }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/archives/tags/") | safeCSS }} -</style> -{{ end }} - -{{ define "middle" }} - -{{ partial "navigator-middle.html" - (dict - "Title" "Records" - "Subtitle" (partial "count-tags.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) -}} - -{{- $page := 1 -}} -{{- $count := 0 -}} - -<item-list> - {{ range $taxonomy := .Site.Taxonomies }} - {{ range $tag, $article := $taxonomy }} - <h1><a href="{{ $.Site.BaseURL }}/tags/{{ $tag }}/">#{{ $tag }}</a></h1> - <ul> - {{ range $article.Pages -}} - {{- $count = add $count 1 -}} - <li> - <a - title="{{ partial "title.html" . }}" - href="{{ .Site.BaseURL }}/tags/{{ $tag }}/{{ if gt $page 1 }}page/{{ $page }}/{{ end }}#{{ partial "card-id.html" . }}"> - <span><code>{{ .Date.Format "02 Jan 2006" }}</code></span> - <span>{{ partial "title.html" . }}</span> - <span>@{{ partial "author-user.html" . }}</span> - </a> - </li> - {{ if eq (mod $count $.Paginator.PageSize) 0 }} - {{ $page = add $page 1 }} - {{- end -}} - {{- end -}} - {{- $page = 1 -}} - {{- $count = 0 -}} - </ul> - {{ end }} - {{ end }} -</item-list> -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right-default.html" . -}} -{{ end }} diff --git a/themes/default/layouts/_default/home.archives.html b/themes/default/layouts/_default/home.archives.html new file mode 100644 index 0000000..f443583 --- /dev/null +++ b/themes/default/layouts/_default/home.archives.html @@ -0,0 +1,67 @@ +{{- define "title" -}}Archives — {{ end -}} +{{- define "description" -}}An archive of all items — {{ end -}} +{{- define "styles" -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/archives/") | safeCSS }} +</style> +{{- end -}} + +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Context" . + "IconLabel" "Back" + "Id" "back" + "Title" "Archives" + "Icon" "arrow-left" + "Subtitle" (print (partial "count.html" .) " " "Total") + "Href" (or (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) "/") + ) + -}} +{{- end -}} + +{{- define "middle" -}} + <archive-list> + <time-line> + {{ range (.Paginator.Pages.GroupByDate "2006") }} + {{ range (first 1 .Pages) }} + <h1>{{ .Date | time.Format "2006" }}</h1> + {{ end }} + <ul> + {{ range .Pages }} + {{- $author := .Page.Section -}} + <li> + <a + title="{{ partial "meta-title.html" . }}" + href="{{ .Permalink }}#{{ partial "card-id.html" . }}" + > + <code> + <time + data-type="disabled" + datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" + title="{{ .Date | time.Format "Posted: Monday January 2 2006 at 15:04:05 MST" }}" + > + {{ .Date | time.Format "02 Jan" }} + </time> + </code> + <section> + <h2>{{ partial "meta-title.html" . }}</h2> + <p>@{{ or .Params.feed.domain $author }}</p> + </section> + </a> + </li> + {{ end }} + </ul> + {{ end }} + </time-line> + </archive-list> +{{- end -}} + +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/home.authors.html b/themes/default/layouts/_default/home.authors.html index db67566..0662285 100644 --- a/themes/default/layouts/_default/home.authors.html +++ b/themes/default/layouts/_default/home.authors.html @@ -1,38 +1,41 @@ -{{ define "title" }}Authors — {{ end }} -{{ define "description" }}This page contains a list of all authors — {{ end }} -{{ define "styles" }} +{{- define "title" -}}Authors — {{ end -}} +{{- define "description" -}}A list of all authors — {{ end -}} +{{- define "styles" -}} <style> - {{ partial "styles-navigator.html" (dict "Link" "/authors/") | safeCSS }} + {{ partial "navigator.css.html" (dict "Link" "/authors/") | safeCSS }} </style> -{{ end }} +{{- end -}} -{{ define "middle" }} - - {{ partial "navigator-middle.html" +{{- define "header" -}} + {{- partial "navigator-middle.html" (dict "Title" "Authors" - "Subtitle" (partial "count-authors.html" .) + "Subtitle" (print (partial "count-authors.html" .) " " "Total") "Icon" "arrow-left" "IconLabel" "Back" "Href" "/" "Id" "back" "Context" . ) - }} - - {{ $authors := slice }} + -}} +{{- end -}} - {{- range $index, $data := .Site.Data -}} - {{- $authors = $authors | append $data.user -}} - {{- end -}} +{{- define "middle" -}} + {{- partial "generate-authors" . -}} - {{- range $author := (shuffle (uniq $authors)) -}} - {{ $data := index $.Site.Data $author | default "default" }} - {{ partial "author-card.html" (dict "Data" $data) }} - {{ end }} + {{- $authors := partial "function-authors-slice.html" . -}} -{{ end }} + {{- range $author := $authors -}} + {{- $data := index $.Site.Data.authors $author -}} + {{- $date := (index (first 1 (where $.Site.Pages.ByDate.Reverse "Section" $author)) 0).Date -}} + {{- partial "author-card.html" (dict + "Data" $data + "Date" $date + ) + -}} + {{- end -}} +{{- end -}} -{{ define "right" }} - {{- partial "navigator-right-default.html" . -}} -{{ end }} +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/home.authors.section.html b/themes/default/layouts/_default/home.authors.section.html new file mode 100644 index 0000000..b0b1161 --- /dev/null +++ b/themes/default/layouts/_default/home.authors.section.html @@ -0,0 +1,20 @@ +{{- $authors := partial "function-authors-slice.html" . -}} + +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if $modified -}} + {{- range $author := first 3 $authors -}} + {{- $data := index $.Site.Data.authors $author -}} + {{- $date := (index (first 1 (where $.Site.Pages.ByDate.Reverse "Section" $author)) 0).Date -}} + {{- partial "author-card.html" (dict + "Data" $data + "Date" $date + ) + -}} + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/_default/home.browserconfig.xml b/themes/default/layouts/_default/home.browserconfig.xml deleted file mode 100644 index 67bc7a3..0000000 --- a/themes/default/layouts/_default/home.browserconfig.xml +++ /dev/null @@ -1,13 +0,0 @@ -{{- $icon := resources.Get .Site.Params.webmanifest.logo -}} - -{{- $mstile150 := $icon.Fit "150x150" -}} - -<?xml version="1.0" encoding="utf-8"?> -<browserconfig> - <msapplication> - <tile> - <square150x150logo src="{{ $mstile150.Permalink }}"/> - <TileColor>#da532c</TileColor> - </tile> - </msapplication> -</browserconfig> diff --git a/themes/default/layouts/_default/home.rss-style.xsl b/themes/default/layouts/_default/home.rss-style.xsl deleted file mode 100644 index b537d38..0000000 --- a/themes/default/layouts/_default/home.rss-style.xsl +++ /dev/null @@ -1,146 +0,0 @@ -{{- print "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }} -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="3.0"> - <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> - <xsl:template match="/"> - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - {{ print "<title><xsl:value-of select=\"/rss/channel/title\"/> Web Feed</title>" | safeHTML }} - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> - {{- $default := resources.Get "css/default.css" -}} - {{- if .Site.Params.site.production -}} - {{ $css := slice $default | resources.Concat "css/bundle.css" | resources.Minify | fingerprint }} - <link rel="stylesheet" type="text/css" href="{{ $css.Permalink }}"/> - {{- else }} - <link rel="stylesheet" type="text/css" href="{{ $default.Permalink }}"/> - {{- end }} - </head> - <body> - <column-left> - </column-left> - <column-middle> - <main> - <nav> - <icon-button> - <a id="back" href="/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/arrow-left.svg")) }} - <small>Back</small> - </a> - </icon-button> - - <section> - <h2><xsl:value-of select="/rss/channel/title"/> Feed</h2> - <small>Web Feed Preview</small> - </section> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-home" href="/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/home.svg")) }} - <small>Home</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-tag" href="/tags/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/tag.svg")) }} - <small>Tags</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-clock" href="/archives/messages/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/tabler/clock.svg")) }} - <small>History</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-book-2" href="/archives/tags/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/tabler/book-2.svg")) }} - <small>Records</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-users" href="/authors/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/users.svg")) }} - <small>Authors</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-rss" href="/rss.xml"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/rss.svg")) }} - <small>RSS</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-circle" href="/index.json"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/circle.svg")) }} - <small>JSON</small> - </a> - </icon-button> - </icon-navigator> - - <icon-navigator hidden=""> - <icon-button> - <a id="nav-middle-git-commit" href="/sources/"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/git-commit.svg")) }} - <small>Sources</small> - </a> - </icon-button> - </icon-navigator> - </nav> - <navigation-separator><hr hidden=""></hr></navigation-separator> - <xsl:for-each select="/rss/channel/item"> - <micro-card> - <micro-summary> - <micro-thumbnail> - <figure> - <a><xsl:attribute name="href"><xsl:value-of select="/rss/channel/link"/></xsl:attribute> - <picture> - <img - loading="lazy" - > - <xsl:attribute name="alt"><xsl:value-of select="/rss/channel/category"/></xsl:attribute> - <xsl:attribute name="title"><xsl:value-of select="/rss/channel/category"/></xsl:attribute> - <xsl:attribute name="src">{{ .Site.BaseURL }}/<xsl:value-of select="/rss/channel/category"/>/media/profile/picture.png</xsl:attribute> - </img> - </picture> - </a> - </figure> - </micro-thumbnail> - <micro-content> - <h2> - <a> - <xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute> - <xsl:value-of select="title" /> - </a> - </h2> - <small> Published: <xsl:value-of select="pubDate" /> </small> - </micro-content> - </micro-summary> - </micro-card> - </xsl:for-each> - </main> - </column-middle> - <column-right> - </column-right> - </body> - </html> - </xsl:template> -</xsl:stylesheet> diff --git a/themes/default/layouts/_default/home.settings.html b/themes/default/layouts/_default/home.settings.html new file mode 100644 index 0000000..84e8080 --- /dev/null +++ b/themes/default/layouts/_default/home.settings.html @@ -0,0 +1,32 @@ +{{- define "title" -}}Settings — {{ end -}} +{{- define "description" -}}A list of all interface settings — {{ end -}} +{{- define "styles" -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/settings/") | safeCSS }} +</style> +{{- end -}} + +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Context" . + "IconLabel" "Back" + "Id" "back" + "Title" "Settings" + "Icon" "arrow-left" + "Subtitle" "Interface" + "Href" (or (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) "/") + ) + -}} +{{- end -}} + +{{- define "middle" -}} +{{- end -}} + +{{- define "footer" -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/home.sources.html b/themes/default/layouts/_default/home.sources.html index 424180a..32f7822 100644 --- a/themes/default/layouts/_default/home.sources.html +++ b/themes/default/layouts/_default/home.sources.html @@ -1,41 +1,53 @@ -{{ define "title" }}Sources — {{ end }} -{{ define "description" }}This page contains a list of all source files — {{ end }} -{{ define "styles" }} +{{- define "title" -}}Sources — {{ end -}} +{{- define "description" -}}A list of all sources — {{ end -}} +{{- define "styles" -}} <style> - {{ partial "styles-navigator.html" (dict "Link" "/sources/") | safeCSS }} + {{ partial "navigator.css.html" (dict "Link" "/sources/") | safeCSS }} </style> -{{ end }} +{{- end -}} -{{ define "middle" }} +{{- define "header" -}} + {{- $_default := readDir (print "/themes/default/layouts/_default") -}} + {{- $_markup := readDir (print "/themes/default/layouts/_default/_markup") -}} + {{- $partials := readDir (print "/themes/default/layouts/partials") -}} + {{- $shortcodes := readDir (print "/themes/default/layouts/shortcodes") -}} - {{ $_default := readDir (print "/themes/default/layouts/_default") }} - {{ $_markup := readDir (print "/themes/default/layouts/_default/_markup") }} - {{ $partials := readDir (print "/themes/default/layouts/partials") }} - {{ $shortcodes := readDir (print "/themes/default/layouts/shortcodes") }} + {{- $fileCount := add + (add + (sub (len $_default) 1) + (len $_markup)) + (add + (len $partials) + (len $shortcodes)) + -}} - {{ $fileCount := add (len $shortcodes) (len $partials) }} - - {{ partial "navigator-middle.html" + {{- partial "navigator-middle.html" (dict "Title" "Sources" - "Subtitle" (print $fileCount " " "Files") + "Subtitle" (print $fileCount " " "Total") "Icon" "arrow-left" "IconLabel" "Back" "Href" "/" "Id" "back" "Context" . ) - }} + -}} +{{- end -}} + +{{- define "middle" -}} + {{- $_default := readDir (print "/themes/default/layouts/_default") -}} + {{- $_markup := readDir (print "/themes/default/layouts/_default/_markup") -}} + {{- $partials := readDir (print "/themes/default/layouts/partials") -}} + {{- $shortcodes := readDir (print "/themes/default/layouts/shortcodes") -}} <source-files> <item-list> - <h1>Defaults</h1> <ul> {{ range sort $_default ".ModTime" "desc" }} {{ if not .IsDir }} <li> - <a download title="{{ .Name }}" href="{{ $.Site.BaseURL }}/sources/files/_default/{{ .Name }}"> + <a download="" title="{{ .Name }}" href="{{ "sources/files/_default" | relURL }}/{{ .Name }}"> <span><code>{{- .ModTime | time.Format "2006-01-02 15:04 MST" }}</code></span> <span><code>{{ .Name }}</code></span> <span><code>{{ .Size -}}</code></span> @@ -50,7 +62,7 @@ {{ range sort $_markup ".ModTime" "desc" }} {{ if not .IsDir }} <li> - <a download title="{{ .Name }}" href="{{ $.Site.BaseURL }}/sources/files/_default/_markup/{{ .Name }}"> + <a download="" title="{{ .Name }}" href="{{ "sources/files/_default/_markup" | relURL }}/{{ .Name }}"> <span><code>{{- .ModTime | time.Format "2006-01-02 15:04 MST" }}</code></span> <span><code>{{ .Name }}</code></span> <span><code>{{ .Size -}}</code></span> @@ -65,7 +77,7 @@ {{ range sort $partials ".ModTime" "desc" }} {{ if not .IsDir }} <li> - <a download title="{{ .Name }}" href="{{ $.Site.BaseURL }}/sources/files/partials/{{ .Name }}"> + <a download="" title="{{ .Name }}" href="{{ "sources/files/partials" | relURL }}/{{ .Name }}"> <span><code>{{- .ModTime | time.Format "2006-01-02 15:04 MST" }}</code></span> <span><code>{{ .Name }}</code></span> <span><code>{{ .Size -}}</code></span> @@ -80,7 +92,7 @@ {{ range sort $shortcodes ".ModTime" "desc" }} {{ if not .IsDir }} <li> - <a download title="{{ .Name }}" href="{{ $.Site.BaseURL }}/sources/files/shortcodes/{{ .Name }}"> + <a download="" title="{{ .Name }}" href="{{ "sources/files/shortcodes" | relURL }}/{{ .Name }}"> <span><code>{{- .ModTime | time.Format "2006-01-02 15:04 MST" }}</code></span> <span><code>{{ .Name }}</code></span> <span><code>{{ .Size -}}</code></span> @@ -93,20 +105,18 @@ <footer> <p> - Canory Version: 0.8.13 - · Dictionary Access by Paul Lutus: <a href="https://arachnoid.com/javascript/dictionary_access.js">GPLv2+ License</a> - · Feather Icons by Cole Bemis: <a href="https://github.com/feathericons/feather/blob/8b5d6802fa8fd1eb3924b465ff718d2fa8d61efe/LICENSE">MIT License</a> - · Tabler Icons by PaweÅ‚ Kuna: <a href="https://github.com/tabler/tabler-icons/blob/60f39297d0f785f2e8635faca6857b2260b2d164/LICENSE">MIT License</a> - · Instant Page by Alexandre Dieulot: <a href="https://github.com/instantpage/instant.page/blob/729e97d5b3245552e41d8f92ed03d08f1d62ea46/LICENSE">MIT License</a> - · Fixed Search by Heracles Papatheodorou: <a href="https://gist.github.com/Arty2/8b0c43581013753438a3d35c15091a9f#file-license-md">License</a> - · Fuzzy Sort by Stephen Kamenar: <a href="https://github.com/farzher/fuzzysort/blob/e7f484a124f09bf3cb9a4db366a95457d962dbed/LICENSE">MIT License</a> + Canory Version: {{ "{{% version number %}}" | markdownify }} + · Dictionary Access by Paul Lutus: <a href="https://arachnoid.com/javascript/dictionary_access.js">GPLv2+ Licence</a> + · Feather Icons by Cole Bemis: <a href="https://github.com/feathericons/feather/blob/8b5d6802fa8fd1eb3924b465ff718d2fa8d61efe/Licence">MIT Licence</a> + · Tabler Icons by PaweÅ‚ Kuna: <a href="https://github.com/tabler/tabler-icons/blob/60f39297d0f785f2e8635faca6857b2260b2d164/Licence">MIT Licence</a> + · Instant Page by Alexandre Dieulot: <a href="https://github.com/instantpage/instant.page/blob/729e97d5b3245552e41d8f92ed03d08f1d62ea46/Licence">MIT Licence</a> + · Fixed Search by Heracles Papatheodorou: <a href="https://gist.github.com/Arty2/8b0c43581013753438a3d35c15091a9f#file-Licence-md">MIT Licence</a> + · Fuzzy Sort by Stephen Kamenar: <a href="https://github.com/farzher/fuzzysort/blob/e7f484a124f09bf3cb9a4db366a95457d962dbed/Licence">MIT Licence</a> </p> </footer> - </source-files> +{{- end -}} -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right-default.html" . -}} -{{ end }} +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/home.xslt.rss.xsl b/themes/default/layouts/_default/home.xslt.rss.xsl new file mode 100644 index 0000000..587d119 --- /dev/null +++ b/themes/default/layouts/_default/home.xslt.rss.xsl @@ -0,0 +1,104 @@ +{{- printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" + version="1.1" +> + <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" /> + <xsl:template match="/"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" data-xml="" data-document="xhtml"> + <head> + {{ printf `<title><xsl:value-of select="/rss/channel/title" /> Web Feed</title>` | safeHTML }} + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> + {{- partial "head-css.html" . -}} + {{- partial "head-js.html" . -}} + </head> + <body> + <column-base position="left"></column-base> + <column-base position="middle"> + <nav> + <icon-button> + <a id="back" target="_self"> + <xsl:choose> + <xsl:when test="/rss/channel/atom:link[@rel='previous']/@href"> + <xsl:attribute name="href"> + <xsl:value-of select="/rss/channel/atom:link[@rel='previous']/@href" /> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="href">/</xsl:attribute> + </xsl:otherwise> + </xsl:choose> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-left.svg")) }} + <small>Back</small> + </a> + </icon-button> + <section> + <h2><xsl:value-of select="/rss/channel/title" />'s Feed</h2> + <small>Web Feed Preview</small> + </section> + <xsl:if test="/rss/channel/atom:link[@rel='next']/@href"> + <icon-button> + <a> + <xsl:attribute name="href"> + <xsl:value-of select="/rss/channel/atom:link[@rel='next']/@href" /> + </xsl:attribute> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-right.svg")) }} + <small>Next</small> + </a> + </icon-button> + </xsl:if> + {{ if .Site.Menus.main }} + {{ range .Site.Menus.main }} + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-{{ path.Base .Identifier }}" href="{{ .URL | absURL }}"> + {{ with .Identifier }} + {{ $icon := print (partial "function-paths.html").static "/icons/" . ".svg" }} + {{ safeHTML (readFile $icon) }} + {{ end }} + <small>{{ delimit (first 1 (split .Name " ")) " " }}</small> + </a> + </icon-button> + </icon-navigator> + {{ end }} + {{ end }} + </nav> + <main> + <xsl:for-each select="/rss/channel/item"> + <micro-card> + <header> + <figure> + <a> + <xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute> + <span> + <object> + <xsl:attribute name="title"><xsl:value-of select="atom:author/atom:name" /></xsl:attribute> + <xsl:attribute name="data"><xsl:value-of select="atom:author/atom:uri" /></xsl:attribute> + <xsl:value-of select="substring(atom:author/atom:name, 1, 1)" /> + </object> + </span> + </a> + </figure> + </header> + <article> + <h2> + <a> + <xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute> + <xsl:value-of select="title" /> + </a> + </h2> + <small>Published: <xsl:value-of select="pubDate" /></small> + </article> + </micro-card> + </xsl:for-each> + </main> + </column-base> + <column-base position="right"></column-base> + </body> + </html> + </xsl:template> +</xsl:stylesheet> diff --git a/themes/default/layouts/_default/home.xslt.sitemap.xsl b/themes/default/layouts/_default/home.xslt.sitemap.xsl new file mode 100644 index 0000000..e0be723 --- /dev/null +++ b/themes/default/layouts/_default/home.xslt.sitemap.xsl @@ -0,0 +1,90 @@ +{{- printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" + version="1.1" +> + <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> + <xsl:template match="/"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" data-xml="sitemap" data-document="xhtml"> + <head> + <title>{{ $.Site.Title }} Site Map</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> + {{- partial "head-css.html" . -}} + {{- partial "head-js.html" . -}} + </head> + <body> + <column-base position="left"></column-base> + <column-base position="middle"> + <nav> + <icon-button> + <a id="back" target="_self" href="/"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-left.svg")) }} + <small>Back</small> + </a> + </icon-button> + <section> + <h2>{{ $.Site.Title }} Site Map</h2> + <small>Site Map Preview</small> + </section> + {{ if .Site.Menus.main }} + {{ range .Site.Menus.main }} + <icon-navigator hidden=""> + <icon-button> + <a + id="nav-middle-{{ path.Base .Identifier }}" + href="{{ .URL | absURL }}" + > + {{ with .Identifier }} + {{ $icon := print (partial "function-paths.html").static "/icons/" . ".svg" }} + {{ safeHTML (readFile $icon) }} + {{ end }} + <small>{{ delimit (first 1 (split .Name " ")) " " }}</small> + </a> + </icon-button> + </icon-navigator> + {{ end }} + {{ end }} + </nav> + <main> + <navigation-separator><hr hidden=""></hr></navigation-separator> + <section> + <table> + <thead> + <tr> + <th align="left"> + <code> + <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> + Uniform Resource Locators (URLs) + </code> + </th> + </tr> + </thead> + <tbody> + <xsl:for-each select="sitemap:urlset/sitemap:url"> + <tr> + <td> + <a> + <xsl:attribute name="href"> + <xsl:value-of select="sitemap:loc" /> + </xsl:attribute> +<xsl:attribute name="title">Last Modified: <xsl:value-of select="sitemap:lastmod" /> +Frequency: <xsl:value-of select="sitemap:changefreq" /> +Priority: <xsl:value-of select="sitemap:priority" /> + </xsl:attribute> + <xsl:value-of select="sitemap:loc" /> + </a> + </td> + </tr> + </xsl:for-each> + </tbody> + </table> + </section> + </main> + </column-base> + <column-base position="right"></column-base> + </body> + </html> + </xsl:template> +</xsl:stylesheet> diff --git a/themes/default/layouts/_default/index.html b/themes/default/layouts/_default/index.html new file mode 100644 index 0000000..f25cabf --- /dev/null +++ b/themes/default/layouts/_default/index.html @@ -0,0 +1,34 @@ +{{- define "styles" -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} +</style> +{{- end -}} + +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Context" . + "Title" "Home" + "Subtitle" (print (partial "count.html" .) " " "Total") + "IconLabel" (and (gt .Paginator.PageNumber 1) "Back") + "Id" (and (gt .Paginator.PageNumber 1) "back") + "Icon" (and (gt .Paginator.PageNumber 1) "arrow-left") + "Href" (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) + ) + -}} +{{- end -}} + +{{- define "middle" -}} + {{- range .Paginator.Pages -}} + {{- partial "render-embed.html" . -}} + {{- end -}} +{{- end -}} + +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/index.json b/themes/default/layouts/_default/index.json index 63f8445..9484e60 100644 --- a/themes/default/layouts/_default/index.json +++ b/themes/default/layouts/_default/index.json @@ -1,25 +1,30 @@ +{{- define "main" -}} + { "version": "https://jsonfeed.org/version/1.1", "title": "{{ .Site.Title }}", "home_page_url": "{{ .Site.BaseURL }}", "feed_url": "{{ .Site.BaseURL }}/index.json", + {{- with .Paginator.Next }} + "next_url": "{{ .URL | absURL }}", + {{- end }} "items": [ - {{- range $index, $data := .Site.RegularPages -}} - {{- if and (ne $data.Type "json") (not .ExpiryDate) (not .Params.unlisted) -}} + {{- $filteredPages := partial "function-filters-content.html" .Paginator.Pages -}} + {{- range $index, $data := $filteredPages -}} {{- if and $index (gt $index 0) -}},{{- end }} { - "id": "{{ md5 $data.Permalink }}", + "id": "{{ sha256 $data.Permalink }}", "url": "{{ $data.Permalink }}", - "title": "{{ $data.Summary | htmlUnescape }}", - "summary": "{{ $data.Summary | htmlUnescape }}", + "title": {{ $data.Summary | htmlUnescape | jsonify }}, + "summary": {{ $data.Summary | htmlUnescape | jsonify }}, "date_modified": "{{ $data.Date | time.Format "2006-01-02T15:04:05Z" }}", "date_published": "{{ $data.PublishDate | time.Format "2006-01-02T15:04:05Z" }}", "_metadata": { - "slug": "{{ $data.Slug }}", + "kind": "{{ $data.Kind }}", "type": "{{ $data.Type }}" }, "author": { - "name": "{{ partial "author-user.html" . }}" + "name": "{{ $data.Type }}" }, "tags": [ {{- range $tags, $tag := $data.Params.tags -}} @@ -32,9 +37,10 @@ {{- end -}} ], "content_text": {{ $data.Plain | jsonify }}, - "content_html": {{ $data.Content | jsonify }} + "content_html": {{ partial "function-content.html" $data | jsonify }} } - {{- end -}} - {{ end }} + {{- end }} ] } + +{{- end -}} diff --git a/themes/default/layouts/_default/index.webmanifest b/themes/default/layouts/_default/index.webmanifest deleted file mode 100644 index f7b3f66..0000000 --- a/themes/default/layouts/_default/index.webmanifest +++ /dev/null @@ -1,24 +0,0 @@ -{{- $icon := resources.Get .Site.Params.webmanifest.logo -}} - -{{- $androidChrome192 := $icon.Fit "192x192" -}} -{{- $androidChrome512 := $icon.Fit "512x512" -}} - -{ - "name": "{{ .Site.Params.webmanifest.name }}", - "short_name": "{{ .Site.Params.webmanifest.shortName }}", - "icons": [ - { - "src": "{{ $androidChrome192.Permalink }}", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "{{ $androidChrome512.Permalink }}", - "sizes": "512x512", - "type": "image/png" - } - ], - "theme_color": "{{ .Site.Params.webmanifest.themeColor }}", - "background_color": "{{ .Site.Params.webmanifest.backgroundColor }}", - "display": "{{ .Site.Params.webmanifest.display }}" -} diff --git a/themes/default/layouts/_default/likes.html b/themes/default/layouts/_default/likes.html deleted file mode 100644 index f37159c..0000000 --- a/themes/default/layouts/_default/likes.html +++ /dev/null @@ -1,54 +0,0 @@ -{{ define "styles" }} -{{ $author := partial "author-user.html" . }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} - - tab-list a[href="{{ .Site.BaseURL }}/{{ $author }}/likes/"] { - color: #111; - color: var(--foreground); - display: inherit; - font-weight: 700; - text-decoration-color: #014cc6; - text-decoration-color: var(--link); - text-decoration: underline; - } -</style> -{{ end }} - -{{ define "middle" }} - - {{ partial "navigator-middle.html" - (dict - "Title" "Likes" - "Subtitle" (partial "count-likes.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) - }} - - {{ partial "profile.html" . }} - - {{- $author := partial "author-user.html" . -}} - {{- $users := where .Site.RegularPages "Section" $author -}} - {{- $likes := where .Site.RegularPages ".Params.liked" true -}} - {{- $filteredPages := $users | intersect $likes -}} - {{- $paginator := .Paginate $filteredPages }} - - {{ range $paginator.Pages }} - {{ .Render "summary" }} - {{ else }} - <footer> - <code>No likes found!</code> - </footer> - {{ end }} - - {{ partial "pagination.html" . }} - -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right.html" . -}} -{{ end }} diff --git a/themes/default/layouts/_default/list.html b/themes/default/layouts/_default/list.html deleted file mode 100644 index 5cc563b..0000000 --- a/themes/default/layouts/_default/list.html +++ /dev/null @@ -1,36 +0,0 @@ -{{ define "styles" }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} -</style> -{{ end }} - -{{ define "middle" }} - - {{ partial "navigator-middle.html" - (dict - "Title" "Home" - "Subtitle" (partial "count-total-messages.html" .) - "Context" . - ) - }} - - {{ range .Paginator.Pages }} - {{ .Render "summary" }} - {{ end }} - - {{ partial "pagination.html" . }} - -{{ end }} - -{{ define "right" }} - {{- partial "author-list.html" . -}} - - {{ range first 1 (where .Site.Pages "Params.Author" .Site.Author.default.picturegallery) }} - {{- partial "gallery-images.html" . -}} - {{ end }} - - {{ range first 1 (where .Site.Pages "Params.Author" .Site.Author.default.webring) }} - {{- partial "web-ring.html" . -}} - {{ end }} - -{{ end }} diff --git a/themes/default/layouts/_default/media.html b/themes/default/layouts/_default/media.html deleted file mode 100644 index f4bb3a9..0000000 --- a/themes/default/layouts/_default/media.html +++ /dev/null @@ -1,68 +0,0 @@ -{{ define "styles" }} -{{ $author := partial "author-user.html" . }} -<style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} - - tab-list a[href="{{ .Site.BaseURL }}/{{ $author }}/media/"] { - color: #111; - color: var(--foreground); - display: inherit; - font-weight: 700; - text-decoration-color: #014cc6; - text-decoration-color: var(--link); - text-decoration: underline; - } -</style> -{{ end }} - -{{ define "middle" }} - - {{ partial "navigator-middle.html" - (dict - "Title" "Media" - "Subtitle" (partial "count-media.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) - }} - - {{ partial "profile.html" . }} - - {{- $author := partial "author-user.html" . -}} - - {{ $count := 0 }} - {{ $result := false }} - - {{ range .Site.Pages }} - {{ if or - (in .Content "<figure>") - (in .Content "<imgur-video>") - (in .Content "<youtube-video>") - (in .Content "<video-container>") - }} - {{ if eq .Type $author }} - {{ $result = true }} - {{ $count = add $count 1 }} - {{ if le $count 10 }} - {{ .Render "summary" }} - {{ end }} - {{ end }} - {{ end }} - {{ end }} - - {{ if not $result }} - <footer> - <code>No media found!</code> - </footer> - {{ end }} - - {{ partial "pagination.html" . }} - -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right.html" . -}} -{{ end }} diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml index a09f9bf..16aee5f 100644 --- a/themes/default/layouts/_default/rss.xml +++ b/themes/default/layouts/_default/rss.xml @@ -1,40 +1,112 @@ -{{- $pctx := . -}} -{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} -{{- $pages := $pctx.RegularPages -}} +{{- define "main" -}} + +{{- $absURL := "" | absURL -}} + {{- $limit := .Site.Config.Services.RSS.Limit -}} -{{- if ge $limit 1 -}} -{{- $pages = $pages | first $limit -}} + +{{- if lt $limit 1 -}} + {{- $limit = .Paginator.TotalNumberOfElements -}} +{{- end -}} + +{{- $lastBuildDate := now | time.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}} + +{{- if not .Date.IsZero -}} + {{- $lastBuildDate = .Date | time.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}} +{{- end -}} + +{{- $title := partial "head-title.html" . -}} +{{- $description := partial "head-title.html" . -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $image := print "/favicon.ico" -}} + +{{- if (eq .Page.Kind "section") -}} + {{- $title = $author.name -}} + {{- $description = $author.description | markdownify | html | htmlUnescape -}} + {{- $image = print "/" (partial "function-paths.html").media "/" .Section "/" .Section "-profile" (path.Ext $author.picture.profile) -}} +{{- end -}} + +{{- if (eq .Page.Type "tags") -}} + {{- $title = print "#" (lower .Title) " -- " .Site.Title | markdownify | htmlUnescape -}} + {{- $description = print .Site.Title " Tags: #" .Title -}} {{- end -}} -{{- print "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} -{{- print "<?xml-stylesheet href=\"/rss.xsl\" type=\"text/xsl\"?>" | safeHTML }} -<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> +{{- $atomSelf := "" -}} +{{- $atomPrevious := "" -}} +{{- $atomNext := "" -}} + +{{- with .OutputFormats.Get "RSS" -}} + {{- $atomSelf = printf `<atom:link rel="self" href=%q type=%q />` .Permalink .MediaType | safeHTML -}} + + {{- with $.Paginator.Prev -}} + {{- $atomPrevious = printf `<atom:link rel="previous" href=%q />` (.URL | absURL) | safeHTML -}} + {{- end -}} + + {{- with $.Paginator.Next -}} + {{- $atomNext = printf `<atom:link rel="next" href=%q />` (.URL | absURL) | safeHTML -}} + {{- end -}} +{{- end -}} + +{{- $filteredPages := partial "function-filters-content.html" .Paginator.Pages -}} + +{{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} +{{ printf `<?xml-stylesheet href="/rss.xsl" type="text/xsl"?>` | safeHTML }} + +<rss + version="2.0" + xmlns:atom="http://www.w3.org/2005/Atom" +> <channel> - <title>{{ partial "site-title" . }}</title> + <title>{{ or $title (title .Section) }}</title> <link>{{ .Permalink }}</link> - <description>Recent from {{ partial "site-title" . }}</description> + <description>{{ $description }}</description> <language>{{ .Site.LanguageCode }}</language> - <category>{{ partial "author-user" . }}</category> + <category>{{ or $author.user "default" }}</category> + <generator>Hugo {{ hugo.Version }}</generator> + <lastBuildDate>{{ $lastBuildDate }}</lastBuildDate> <image> - <title>{{ partial "site-title" . }}</title> - <url>{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}/profile/picture.png</url> + <title>{{ $title }}</title> + <url>{{ $absURL }}{{ $image }}</url> <link>{{ .Permalink }}</link> </image> - {{ if not .Date.IsZero -}} - <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} - {{ with .OutputFormats.Get "RSS" }} - {{- printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML -}} - {{ end }} - {{- range $pages -}} - {{ if and (not .Params.Unlisted) (not .ExpiryDate) }} + + {{ $atomSelf }} + {{ $atomPrevious }} + {{ $atomNext }} + + {{ range first $limit $filteredPages -}} + + {{- $author = partial "function-authors-data.html" . -}} + + {{- $image = print "/" (partial "function-paths.html").media + "/" $author.user "/" $author.user "-profile" (path.Ext $author.picture.profile) + -}} + + {{- $atomAuthorUri := print $absURL $image -}} + {{- $atomAuthorName := or .Params.Feed.name $author.name -}} + + {{- if .Params.Feed.favicon -}} + {{- $favicon := print "/" (partial "function-paths.html").media "/favicon." (.Params.Feed.source | anchorize) ".png" -}} + {{- $atomAuthorUri = print $absURL $favicon -}} + {{- end -}} + <item> - <title>{{ .Summary | htmlUnescape }}</title> - <link>{{ .Permalink }}</link> - <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> + <title>{{ (or .Summary .Title) | htmlUnescape }}</title> + <link>{{ or .Params.Feed.link .Permalink }}</link> + <pubDate>{{ .Date | time.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <guid>{{ .Permalink }}</guid> - <description>{{ .Content | html }}</description> + <description> + {{ partial "function-content.html" . | html -}} + {{- print "<br /><br />" | html -}} + {{- printf `<a href=%q>Permalink</a> ` .Permalink | html }} + {{ partial "tags.html" (dict "Format" "rss" "Context" .) | html }} + </description> + <atom:author> + <atom:name>{{ $atomAuthorName }}</atom:name> + <atom:uri>{{ $atomAuthorUri }}</atom:uri> + </atom:author> </item> - {{ end }} - {{ end }} + + {{ end -}} </channel> </rss> +{{- end -}} diff --git a/themes/default/layouts/_default/section.drafts.html b/themes/default/layouts/_default/section.drafts.html new file mode 100644 index 0000000..bb7485c --- /dev/null +++ b/themes/default/layouts/_default/section.drafts.html @@ -0,0 +1,58 @@ +{{- define "styles" -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $author = $author.user -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} + + tab-bar a[href^="{{ "" | absURL }}/{{ $author }}/drafts"] { + color: #111; + color: var(--foreground); + font-weight: 700; + text-decoration-color: #014cc6; + text-decoration-color: var(--link); + text-decoration: underline; + border-bottom: 2px solid var(--background); + } +</style> +{{- end -}} + +{{- define "header" -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $authors := where .Site.RegularPages "Section" $author.user -}} + {{- $drafts := where .Site.RegularPages "Draft" true -}} + {{- $filteredPages := $authors | intersect $drafts -}} + {{- $paginator := .Paginate $filteredPages -}} + + {{- partial "navigator-middle.html" + (dict + "Context" . + "IconLabel" "Back" + "Id" "back" + "Title" "Drafts" + "Icon" "arrow-left" + "Subtitle" (print (partial "count-drafts.html" .) " " "Total") + "Href" (or (and (gt $paginator.PageNumber 1) ($paginator.Paginator.Prev.URL | absURL)) "/") + ) + -}} + + {{- partial "profile.html" . -}} +{{- end -}} + +{{- define "middle" -}} + {{- range .Paginator.Pages -}} + {{- partial "render-embed.html" . -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} +{{- end -}} + +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.feeds.html b/themes/default/layouts/_default/section.feeds.html new file mode 100644 index 0000000..e239928 --- /dev/null +++ b/themes/default/layouts/_default/section.feeds.html @@ -0,0 +1,53 @@ +{{- define "styles" -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $author = $author.user -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} + + tab-bar a[href^="{{ "" | absURL }}/{{ $author }}/feeds"] { + color: #111; + color: var(--foreground); + font-weight: 700; + text-decoration-color: #014cc6; + text-decoration-color: var(--link); + text-decoration: underline; + border-bottom: 2px solid var(--background); + } +</style> +{{- end -}} + +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Context" . + "IconLabel" "Back" + "Id" "back" + "Title" "Feeds" + "Icon" "arrow-left" + "Subtitle" (print (partial "count-feeds.html" .) " " "Total") + "Href" (or (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) "/") + ) + -}} + + {{- partial "profile.html" . -}} +{{- end -}} + +{{- define "middle" -}} + {{- range .Paginator.Pages -}} + {{- partial "render-embed.html" . -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} + {{- $writeToFile := partial "function-generate-feeds" . -}} +{{- end -}} + +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.following.html b/themes/default/layouts/_default/section.following.html new file mode 100644 index 0000000..2bfcc2e --- /dev/null +++ b/themes/default/layouts/_default/section.following.html @@ -0,0 +1,75 @@ +{{- $parent := eq (len .Page.Ancestors) 1 -}} + +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if (and $parent $modified) -}} + {{- $sources := slice -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $feeds := partial "function-generate-feeds.html" . -}} + + {{- range $author.feeds.rss -}} + {{- $data := split . " " -}} + {{- $url := delimit (first 1 $data) "" -}} + {{- $sources = $sources | append (string $url) -}} + {{- end -}} + + {{- range $source := $sources -}} + {{- range $distinct := first 1 (where $feeds "FeedSourceLink" "eq" $source) -}} + + {{- $href := or $distinct.FeedHome (print "http://" $distinct.FeedSourceDomain) -}} + {{- $favicon := print "/" (partial "function-paths.html").media "/favicon." (.FeedSourceLink | anchorize) ".png" -}} + + <micro-author> + <micro-card> + <header> + <figure> + <a + title="{{ $distinct.FeedName }}" + href="{{ $href }}"> + <picture> + <img + width="64" + height="64" + alt="{{ $distinct.FeedName }}" + src="{{ $.Site.BaseURL }}{{ $favicon }}" + /> + </picture> + </a> + </figure> + </header> + <article> + <h2> + <b>{{ $distinct.FeedName }}</b> + </h2> + <h3> + <a + data-hover + title="{{ $distinct.FeedName }}" + href="{{ $href }}"> + @{{ $distinct.FeedSourceDomain }} + </a> + </h3> + <time + data-type="default" + title="{{ $distinct.FeedDateTitle }}" + datetime="{{ $distinct.FeedDateTime }}"> + {{ $distinct.FeedDate -}} + </time> + </article> + <a + title="Follow {{ $distinct.FeedName }}" + href="{{ $href }}"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) }} + <span>Feed</span> + </a> + </micro-card> + </micro-author> + + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.gallery.html b/themes/default/layouts/_default/section.gallery.html new file mode 100644 index 0000000..761a276 --- /dev/null +++ b/themes/default/layouts/_default/section.gallery.html @@ -0,0 +1,12 @@ +{{- $parent := eq (len .Page.Ancestors) 1 -}} + +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if (and $parent $modified) -}} + {{- partial "gallery-walk.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.html b/themes/default/layouts/_default/section.html index 2708e89..901ca1f 100644 --- a/themes/default/layouts/_default/section.html +++ b/themes/default/layouts/_default/section.html @@ -1,50 +1,56 @@ -{{ define "styles" }} +{{- define "styles" -}} <style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} - tab-list a[href="{{ .CurrentSection.Permalink }}"], - tab-list a[href="{{ strings.TrimRight "/" .CurrentSection.Permalink }}"] { + tab-bar a[href="{{ .CurrentSection.Permalink }}"], + tab-bar a[href^="{{ .CurrentSection.Permalink }}#"], + tab-bar a[href="{{ strings.TrimRight "/" .CurrentSection.Permalink }}"] { color: #111; color: var(--foreground); - display: inherit; font-weight: 700; text-decoration-color: #014cc6; text-decoration-color: var(--link); text-decoration: underline; + border-bottom: 2px solid var(--background); } </style> -{{ end }} +{{- end -}} -{{ define "middle" }} +{{- define "header" -}} + {{- $author := partial "function-authors-data.html" . -}} - {{- $messages := print (lang.FormatNumberCustom 0 .Paginator.TotalNumberOfElements) " " "Messages" -}} - - {{ partial "navigator-middle.html" + {{- partial "navigator-middle.html" (dict - "Title" (partial "author-name.html" .) - "Subtitle" $messages - "Icon" "arrow-left" + "Context" . "IconLabel" "Back" - "Href" "/" "Id" "back" - "Context" . + "Title" $author.name + "Icon" "arrow-left" + "Href" (or (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) "/") + "Subtitle" (print (lang.FormatNumberCustom 0 .Paginator.TotalNumberOfElements) " " "Total") ) - }} - - {{ partial "profile.html" . }} - - {{ range .Paginator.Pages }} - {{ .Render "summary" }} - {{ else }} - <footer> - <code>No messages found!</code> - </footer> - {{ end }} - - {{ partial "pagination.html" . }} - -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right.html" . -}} -{{ end }} + -}} + + {{- partial "author-section-picture.html" . -}} + + {{- partial "profile.html" . -}} +{{- end -}} + +{{- define "middle" -}} + {{- range .Paginator.Pages -}} + {{- partial "render-embed.html" . -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} +{{- end -}} + +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.marks.html b/themes/default/layouts/_default/section.marks.html new file mode 100644 index 0000000..def6c94 --- /dev/null +++ b/themes/default/layouts/_default/section.marks.html @@ -0,0 +1,58 @@ +{{- define "styles" -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $author = $author.user -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} + + tab-bar a[href^="{{ "" | absURL }}/{{ $author }}/marks"] { + color: #111; + color: var(--foreground); + font-weight: 700; + text-decoration-color: #014cc6; + text-decoration-color: var(--link); + text-decoration: underline; + border-bottom: 2px solid var(--background); + } +</style> +{{- end -}} + +{{- define "header" -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $authors := where .Site.RegularPages "Section" $author.user -}} + {{- $items := where .Site.RegularPages ".Params.marked" true -}} + {{- $filteredPages := $authors | intersect $items -}} + {{- $paginator := .Paginate $filteredPages -}} + + {{- partial "navigator-middle.html" + (dict + "Context" . + "IconLabel" "Back" + "Id" "back" + "Title" "Marks" + "Icon" "arrow-left" + "Subtitle" (print (partial "count-marks.html" .) " " "Total") + "Href" (or (and (gt $paginator.PageNumber 1) ($paginator.Prev.URL | absURL)) "/") + ) + -}} + + {{- partial "profile.html" . -}} +{{- end -}} + +{{- define "middle" -}} + {{- range .Paginator.Pages -}} + {{- partial "render-embed.html" . -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} +{{- end -}} + +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.media.html b/themes/default/layouts/_default/section.media.html new file mode 100644 index 0000000..ce570c7 --- /dev/null +++ b/themes/default/layouts/_default/section.media.html @@ -0,0 +1,65 @@ +{{- define "styles" -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $author = $author.user -}} +<style> + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} + + tab-bar a[href^="{{ "" | absURL }}/{{ $author }}/media"] { + color: #111; + color: var(--foreground); + font-weight: 700; + text-decoration-color: #014cc6; + text-decoration-color: var(--link); + text-decoration: underline; + border-bottom: 2px solid var(--background); + } +</style> +{{- end -}} + +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Title" "Media" + "Subtitle" (print (partial "count-media.html" .) " " "Total") + "Icon" "arrow-left" + "IconLabel" "Back" + "Href" "/" + "Id" "back" + "Context" . + ) + -}} + + {{- partial "profile.html" . -}} +{{- end -}} + +{{- define "middle" -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $notFeeds := where .Site.RegularPages "Params.feed" "eq" nil -}} + {{- $authors := where .Site.RegularPages "Section" $author.user -}} + {{- $filteredPages := $authors | intersect $notFeeds -}} + {{- $count := 0 -}} + + {{- range first 100 $filteredPages -}} + {{- if eq $count 10 -}} + {{- break -}} + {{- end -}} + {{- if or + (in .Content "</video>") + (in .Content "</picture>") + (in .Content "</youtube-video>") + -}} + {{- partial "render-embed.html" . -}} + {{- $count = add $count 1 -}} + {{- end -}} + {{- end -}} + + {{- if not $count -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/section.webring.html b/themes/default/layouts/_default/section.webring.html new file mode 100644 index 0000000..58181e1 --- /dev/null +++ b/themes/default/layouts/_default/section.webring.html @@ -0,0 +1,66 @@ +{{- $parent := eq (len .Page.Ancestors) 1 -}} + +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Disable" true + ) +-}} + +{{- if (and $parent $modified) -}} + {{- $items := slice -}} + {{- $sources := slice -}} + {{- $author := partial "function-authors-data.html" . -}} + {{- $feeds := partial "function-generate-feeds.html" . -}} + + {{- range $author.feeds.rss -}} + {{- $data := split . " " -}} + {{- $url := delimit (first 1 $data) "" -}} + {{- $sources = $sources | append (string $url) -}} + {{- end -}} + + {{- $inner := 1 -}} + + {{- if eq (len $sources) 1 -}} + {{- $inner = 3 -}} + {{- end -}} + + {{- range $source := (first 3 $sources) -}} + {{- range $distinct := first $inner (where $feeds "FeedSourceLink" "eq" $source) -}} + {{- $items = $items | append $distinct -}} + {{- end -}} + {{- end -}} + + {{- range (sort $items "FeedDateTime" "desc") -}} + <article> + <h2> + <a + data-hover + title="{{ .FeedLink }}" + href="{{ .FeedLink }}"> + {{ or .FeedTitle (truncate 50 "..." (or .FeedContentShort .FeedDescriptionShort)) }} + </a> + </h2> + <p> + {{ if gt (len .FeedDescriptionShort) (len .FeedContentShort) -}} + {{ or .FeedDescriptionShort .FeedTitle }} + {{- else -}} + {{ or .FeedContentShort .FeedTitle }} + {{- end }} + <br /> + <a + data-hover + title="{{ .FeedSourceDescription }}" + href="{{ or .FeedSourceHome .FeedSourceLink }}"> + {{ .FeedSourceTitle }} + </a> + </p> + <time + data-type="default" + title="{{ .FeedDateTitle }}" + datetime="{{ .FeedDateTime }}"> + {{ .FeedDate }} + </time> + </article> + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/_default/single.embed.html b/themes/default/layouts/_default/single.embed.html new file mode 100644 index 0000000..73a3add --- /dev/null +++ b/themes/default/layouts/_default/single.embed.html @@ -0,0 +1,26 @@ +{{- $pageContext := . -}} +{{- $format := "embed.html" -}} + +{{- $page := print "public/" (strings.TrimPrefix + $pageContext.Page.Site.BaseURL + $pageContext.Page.Permalink + ) $format +-}} + +{{- $modified := partial "function-page-modified.html" + (dict + "Context" $pageContext + "Format" $format + ) +-}} + +{{- with $embed := resources.Get $page -}} + {{- if (in $embed.Content "/data/media/404.png") -}} + {{- $modified = true -}} + {{- end -}} +{{- end -}} + +{{- if $modified -}} + {{- partial "head-embed.html" . -}} + {{- .Render "summary" -}} +{{- end -}} diff --git a/themes/default/layouts/_default/single.html b/themes/default/layouts/_default/single.html index a32ae01..f3123b3 100644 --- a/themes/default/layouts/_default/single.html +++ b/themes/default/layouts/_default/single.html @@ -1,28 +1,81 @@ -{{ define "styles" }} +{{- define "styles" -}} <style> - {{ partial "styles-navigator.html" (dict "Link" "/") | safeCSS }} + {{ partial "navigator.css.html" (dict "Link" "/") | safeCSS }} </style> -{{ end }} - -{{ define "middle" }} - -{{ partial "navigator-middle.html" - (dict - "Title" "Message" - "Subtitle" "Single" - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) -}} - -<micro-thread> - {{ .Render "summary" }} -</micro-thread> -{{ end }} - -{{ define "right" }} - {{- partial "navigator-right.html" . -}} -{{ end }} +{{- end -}} + +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Title" "Post" + "Subtitle" "Thread" + "Icon" "arrow-left" + "IconLabel" "Back" + "Href" "/" + "Id" "back" + "Context" . + ) + -}} +{{- end -}} + +{{- define "middle" -}} + <micro-thread> + {{- partial "render-embed.html" . -}} + + {{- $prevHref := "/" -}} + {{- $nextHref := "/" -}} + {{- $prevTitle := "hidden" -}} + {{- $nextTitle := "hidden" -}} + + {{- with .Next -}} + {{- $nextHref = $.Next.Permalink -}} + {{- $nextTitle = $.Next.Summary -}} + {{- end -}} + + {{- with .Prev -}} + {{- $prevHref = $.Prev.Permalink -}} + {{- $prevTitle = $.Prev.Summary -}} + {{- end -}} + + {{- with or .Next .Prev -}} + <nav data-type="pagination"> + <a rel="next" href="{{ $nextHref }}" title="{{ $nextTitle }}"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-left.svg")) }} + <header>Newer</header> + </a> + + <a rel="prev" href="{{ $prevHref }}" title="{{ $prevTitle }}"> + <header>Older</header> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-right.svg")) }} + </a> + </nav> + {{- end -}} + + {{- $filteredPages := partial "function-filters-content.html" (.Site.RegularPages.Related .) -}} + {{- $related := $filteredPages | first 3 -}} + + {{- with $related -}} + <related-content> + <footer> + <samp> + Related Tags + {{- with $.Params.tags -}} + {{- range $tag := first 1 $.Params.tags -}} + {{- $link := print ("tags/" | relURL) ($tag | urlize) "/" }} + {{ print "---" " " "[#" $tag "](" $link ")" | markdownify -}} + {{- end -}} + {{- end -}} + </samp> + </footer> + </related-content> + + {{- range $related -}} + {{- partial "render-embed.html" . -}} + {{- end -}} + {{- end -}} + </micro-thread> +{{- end -}} + +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/single.plain.txt b/themes/default/layouts/_default/single.plain.txt new file mode 100644 index 0000000..f46e495 --- /dev/null +++ b/themes/default/layouts/_default/single.plain.txt @@ -0,0 +1,3 @@ +{{- define "main" -}} + {{- partial "function-content.html" . | plainify | htmlUnescape -}} +{{- end -}} diff --git a/themes/default/layouts/_default/sitemap.xml b/themes/default/layouts/_default/sitemap.xml index 63f5119..f8ab315 100644 --- a/themes/default/layouts/_default/sitemap.xml +++ b/themes/default/layouts/_default/sitemap.xml @@ -1,22 +1,48 @@ -{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} -<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" - xmlns:xhtml="http://www.w3.org/1999/xhtml"> - {{ range .Data.Pages }} - <url> - <loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} - <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} - <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} - <priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }} - <xhtml:link - rel="alternate" - hreflang="{{ .Language.Lang }}" - href="{{ .Permalink }}" - />{{ end }} - <xhtml:link - rel="alternate" - hreflang="{{ .Language.Lang }}" - href="{{ .Permalink }}" - />{{ end }} - </url> +{{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} +{{ printf `<?xml-stylesheet href="/sitemap.xsl" type="text/xsl"?>` | safeHTML }} + +{{- $changefreq := "weekly" -}} +{{- $priority := 0.5 -}} +{{- $lastmod := now | time.Format "2006-01-02T15:04:05-07:00" }} + +<urlset + xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + xmlns:xhtml="http://www.w3.org/1999/xhtml" +> + {{- $filteredPages := partial "function-filters-content.html" .Data.Pages.ByDate.Reverse -}} + {{- range $filteredPages }} + + {{- with .Sitemap.ChangeFreq -}} + {{- $changefreq = . -}} + {{- end -}} + + {{- if ge .Sitemap.Priority 0.0 -}} + {{- $priority = .Sitemap.Priority -}} + {{- end -}} + + {{- if not .Lastmod.IsZero -}} + {{- $lastmod = safeHTML (.Lastmod | time.Format "2006-01-02T15:04:05-07:00") -}} + {{- end }} + + <url> + <loc>{{ .Permalink }}</loc> + <lastmod>{{ $lastmod }}</lastmod> + <changefreq>{{ $changefreq }}</changefreq> + <priority>{{ $priority }}</priority> + {{- if .IsTranslated -}} + {{ range .Translations }} + <xhtml:link + rel="alternate" + hreflang="{{ .Language.Lang }}" + href="{{ .Permalink }}" + /> + {{- end -}} + <xhtml:link + rel="alternate" + hreflang="{{ .Language.Lang }}" + href="{{ .Permalink }}" + /> + {{ end }} + </url> {{ end }} </urlset> diff --git a/themes/default/layouts/_default/summary.html b/themes/default/layouts/_default/summary.html index 4e47898..e820b24 100644 --- a/themes/default/layouts/_default/summary.html +++ b/themes/default/layouts/_default/summary.html @@ -1,35 +1,22 @@ -<micro-card {{ if .Weight }}pinned{{ end }} id="{{ partial "card-id.html" . }}"> - {{ if .ExpiryDate }}<micro-expires>{{ end }} - <micro-summary {{ if .Draft }}draft{{ end }} title="{{- partial "title.html" . -}}"> - <micro-thumbnail> - {{ partial "profile-picture.html" . }} - </micro-thumbnail> - <micro-content> - <micro-metadata> - {{ partial "card-meta.html" . }} - </micro-metadata> - {{ if .Params.unsafe }} - <micro-unsafe> - <details> - <summary> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/alert-circle.svg")) }} - <span>Danger: Unsafe Content. <b><u>Click here</u></b> to show/hide</span> - </summary> - </details> - <micro-unsafe-content> - {{ end }} - {{- - .Content | - replaceRE "<p>\n<figure>" "<figure>" | - replaceRE "</figure></p>" "</figure>" | - safeHTML - -}} - {{ if .Params.unsafe }} - </micro-unsafe-content> - </micro-unsafe> - {{ end }} - <micro-tags>{{ partial "tags.html" . }}</micro-tags> - </micro-content> - </micro-summary> - {{ if .ExpiryDate }}</micro-expires>{{ end }} +{{- $href := or .Params.Feed.link .Permalink -}} +{{- $content := partial "function-content.html" . | safeHTML -}} +{{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} + +<micro-card + id="{{ partial "card-id.html" . }}" + {{ if .Weight }}pinned{{ end }} + {{ if .Draft }}draft{{ end }} + {{ if .ExpiryDate }}data-expires{{ end }} +> + <a href="{{ $href }}"></a> + <header> + {{ partial "profile-picture.html" . }} + {{ partial "card-meta-header.html" . }} + </header> + <article aria-label="article"> + {{- $content -}} + <micro-tags> + {{- partial "tags.html" (dict "Format" "page" "Context" .) -}} + </micro-tags> + </article> </micro-card> diff --git a/themes/default/layouts/_default/taxonomy.html b/themes/default/layouts/_default/taxonomy.html index 97b9bd1..5c8e2ba 100644 --- a/themes/default/layouts/_default/taxonomy.html +++ b/themes/default/layouts/_default/taxonomy.html @@ -1,62 +1,71 @@ -{{ define "styles" }} +{{- define "styles" -}} <style> - {{ partial "styles-navigator.html" (dict "Link" "/tags/") | safeCSS }} + {{ partial "navigator.css.html" (dict "Link" "/tags/") | safeCSS }} </style> -{{ end }} +{{- end -}} -{{ define "middle" }} +{{- define "header" -}} + {{- partial "navigator-middle.html" + (dict + "Context" . + "IconLabel" "Back" + "Id" "back" + "Title" "Tags" + "Icon" "arrow-left" + "Subtitle" (print (partial "count-tags.html" .) " " "Total") + "Href" (or (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) "/") + ) + -}} +{{- end -}} - {{ $title := .Title }} +{{- define "middle" -}} + <tag-deck> + {{- range .Paginator.Pages -}} + {{- $count := lang.FormatNumberCustom 0 (len .Data.Pages) -}} + {{- $title := lower .Title -}} - {{ if eq .Title "Tags" }} - - {{ partial "navigator-middle.html" - (dict - "Title" "Tags" - "Subtitle" (partial "count-tags.html" .) - "Icon" "arrow-left" - "IconLabel" "Back" - "Href" "/" - "Id" "back" - "Context" . - ) - }} - - {{- $page := 1 -}} - {{- $count := 0 -}} - - {{ range .Paginator.Pages }} - {{ $title := lower .Title }} - <item-list> - <h1><a href="{{ .Site.BaseURL }}/tags/{{ $title }}">#{{ .Title }}</a></h1> - <ul> - {{ range .Pages }} - {{- $count = add $count 1 -}} - <li> - <a - title="{{ partial "title.html" . }}" - href="{{ .Site.BaseURL }}/tags/{{ $title }}/{{ if gt $page 1 }}page/{{ $page }}/{{ end }}#{{ partial "card-id.html" . }}"> - <span><code>{{ .Date.Format "02 Jan 2006" }}</code></span> - <span>{{ partial "title.html" . }}</span> - <span>@{{ partial "author-user.html" . }}</span> + {{- range first 1 .Pages -}} + {{- $author := partial "function-authors-data.html" . -}} + <tag-card> + <article> + <h2> + <code> + {{ $count }} in + <a data-hover href="{{ "" | absURL }}/tags/{{ $title }}/"> + #{{ $title }} + </a> + </code> + </h2> + <figure> + <a href="{{ print ("" | absURL) "/tags/" $title "/#" (partial "card-id.html" .) }}"> + <picture> + {{ partial "author-picture" . }} + </picture> </a> - </li> - {{ if eq (mod $count $.Paginator.PageSize) 0 }} - {{ $page = add $page 1 }} - {{- end -}} - {{- end -}} - {{- $page = 1 -}} - {{- $count = 0 -}} - </ul> - </item-list> - {{ end }} - - {{ partial "pagination.html" . }} - - {{ end }} + </figure> + <time + datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" + title="{{ .Date | time.Format "Posted: Monday, January 2, 2006 at 15:04:05 MST" }}" + > + {{ .Date | time.Format "02 Jan 2006" }} + </time> + <p> + <a data-hover href="{{ print ("" | absURL) "/tags/" $title "/#" (partial "card-id.html" .) }}"> + {{ partial "meta-title.html" . }} + </a> + </p> + </article> + </tag-card> + {{- end -}} + {{- end -}} + </tag-deck> +{{- end -}} -{{ end }} +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} -{{ define "right" }} - {{- partial "navigator-right-default.html" . -}} -{{ end }} +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/_default/term.html b/themes/default/layouts/_default/term.html index 8f31575..4f0d92a 100644 --- a/themes/default/layouts/_default/term.html +++ b/themes/default/layouts/_default/term.html @@ -1,33 +1,34 @@ -{{ define "styles" }} +{{- define "styles" -}} <style> - {{ partial "styles-navigator.html" (dict "Link" "/tags/") | safeCSS }} + {{ partial "navigator.css.html" (dict "Link" "/tags/") | safeCSS }} </style> -{{ end }} +{{- end -}} -{{ define "middle" }} - - {{- $terms := print (lang.FormatNumberCustom 0 (len .Data.Pages)) " " "Messages" -}} - - {{ partial "navigator-middle.html" +{{- define "header" -}} + {{- partial "navigator-middle.html" (dict - "Title" (print "#" .Title) - "Subtitle" $terms - "Icon" "arrow-left" + "Context" . "IconLabel" "Back" - "Href" "/" "Id" "back" - "Context" . + "Icon" "arrow-left" + "Title" (print "#" .Title) + "Subtitle" (print (lang.FormatNumberCustom 0 (len .Data.Pages)) " " "Total") + "Href" (or (and (gt .Paginator.PageNumber 1) (.Paginator.Prev.URL | absURL)) "/") ) - }} - - {{ range .Paginator.Pages }} - {{ .Render "summary" }} - {{ end }} + -}} +{{- end -}} - {{ partial "pagination.html" . }} +{{- define "middle" -}} + {{- range .Paginator.Pages -}} + {{- partial "render-embed.html" . -}} + {{- end -}} +{{- end -}} -{{ end }} +{{- define "footer" -}} + {{- partial "pagination.html" . -}} + {{- partial "footer.html" . -}} +{{- end -}} -{{ define "right" }} - {{- partial "navigator-right-default.html" . -}} -{{ end }} +{{- define "right" -}} + {{- partial "navigator-right.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/partials/archive-link.html b/themes/default/layouts/partials/archive-link.html deleted file mode 100644 index 8b08ba3..0000000 --- a/themes/default/layouts/partials/archive-link.html +++ /dev/null @@ -1,2 +0,0 @@ -/archives/{{ .Type }}/ -{{- /* Strip newline. */ -}} diff --git a/themes/default/layouts/partials/author-card.html b/themes/default/layouts/partials/author-card.html index 3e4bcca..561fef3 100644 --- a/themes/default/layouts/partials/author-card.html +++ b/themes/default/layouts/partials/author-card.html @@ -1,46 +1,81 @@ -{{- $path := print "public/" .Data.user "/media/profile/picture.png" -}} -{{- $image := resources.Get $path -}} -{{- $dimensions := "96x96" -}} -{{- $404image := resources.Get "data/media/404.png" -}} +{{- $metadata := print "public/" .Data.user "/author.json" -}} +{{- $date := .Date | time.Format "Mon Jan 2 2006" -}} + +{{- $host := (urls.Parse ("" | absURL)).Host -}} + +{{- if not $host -}} + {{- $host = "localhost" -}} +{{- end -}} + +{{- $alternate := .Data.name -}} +{{- $width := "" -}} +{{- $height := "" -}} +{{- $source := "" -}} +{{- $sourceset := "" -}} + +{{- $source = print "/" (partial "function-paths.html").media "/" .Data.user "/" .Data.user "-profile" (path.Ext .Data.picture.profile) -}} +{{- $sourceset = print "/" (partial "function-paths.html").media "/" .Data.user "/" .Data.user "-profile.webp" -}} + +{{- with $metadata := resources.Get $metadata -}} + {{- with $content := $metadata.Content -}} + {{- $metadata = $content | transform.Unmarshal -}} + {{- $width = $metadata.picture.profileWidth -}} + {{- $height = $metadata.picture.profileHeight -}} + {{- end -}} +{{- end -}} + +{{- if or + (not (path.Ext .Data.picture.profile)) + (not (fileExists (print "public/" (partial "function-paths.html").media "/" .Data.user))) +-}} + {{- $source = "/data/media/404.png" -}} + {{- $sourceset = "" -}} +{{- end -}} + +{{- if not .Date -}} + {{- $date = "Inactive" -}} +{{- end -}} <micro-author> <micro-card> - <micro-summary> - <micro-thumbnail> + <header> <figure> - <a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/#"> + <a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/"> <picture> - {{- with $image }} - {{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Data.user "/" (path.Base .)) }} - <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> - {{- end }} + {{- with $sourceset -}} + <source srcset="{{ print ("" | absURL) $sourceset }}" type="image/webp" /> + {{- end -}} <img - alt="{{ .Data.name }}" - {{- if fileExists $path }} - {{ with $image }} - {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Data.user "/" (path.Base .))).Fit $dimensions -}} - width="{{ $image.Width }}" - height="{{ $image.Height }}" - src="{{ $image.RelPermalink }}" - {{- end }} - {{ else }} - width="{{ $404image.Width }}" - height="{{ $404image.Height }}" - src="{{ $404image.RelPermalink }}" - {{- end -}} + width="{{ or $width "64" }}" + height="{{ or $height "64" }}" + src="{{ print ("" | absURL) $source }}" + alt="{{ $alternate }}" /> </picture> </a> </figure> - </micro-thumbnail> - <micro-header> - <h2><b>{{ .Data.name }}</b></h2> - <h3><a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/#">@{{ .Data.user }}</a></h3> - </micro-header> - <a title="Follow with RSS Reader" href="{{ "" | absURL }}/{{ .Data.user }}/rss.xml"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/rss.svg")) }} - <span>Follow</span> - </a> - </micro-summary> + </header> + <article> + <h2> + <b>{{ .Data.name }}</b> + </h2> + <h3> + <a data-hover="" title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/"> + {{ .Data.user }}@{{ $host }} + </a> + </h3> + <time + data-type="default" + title="{{ .Date | time.Format "Monday January 2 2006 at 15:04:05 MST" }}" + datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" + > + {{ $date }} + </time> + </article> + <p>{{ .Data.description | markdownify | plainify | htmlUnescape | truncate 60 "..." }}</p> + <a title="Follow with RSS Reader" href="{{ "" | absURL }}/{{ .Data.user }}/rss.xml"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) }} + <span>Feed</span> + </a> </micro-card> </micro-author> diff --git a/themes/default/layouts/partials/author-domain-host.html b/themes/default/layouts/partials/author-domain-host.html index 5396642..d182751 100644 --- a/themes/default/layouts/partials/author-domain-host.html +++ b/themes/default/layouts/partials/author-domain-host.html @@ -1,2 +1,3 @@ -{{ $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") }} +{{- $author := partial "function-authors-data.html" . -}} + {{- $author.domain.host | markdownify -}} diff --git a/themes/default/layouts/partials/author-header.html b/themes/default/layouts/partials/author-header.html index 9babf1d..5bcc0e6 100644 --- a/themes/default/layouts/partials/author-header.html +++ b/themes/default/layouts/partials/author-header.html @@ -1,30 +1,30 @@ -{{- $file := "/profile/header.jpg" -}} -{{- $path := print "public/" (partial "author-media-path.html" .) $file -}} -{{- $image := resources.Get $path -}} -{{- $404image := resources.Get "data/media/404.png" -}} -{{- $dimensions := "x600" -}} -{{- $author := partial "author-user.html" . }} +{{- $author := partial "function-authors-data.html" . -}} +{{- $header := $author.picture.header -}} +{{- $file := not (urls.Parse $header).Host -}} -{{- with $image -}} - {{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}} - <source srcset="{{- ($image.Resize (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> +{{- if $file -}} + {{- $header = print $author.user "/" $header -}} +{{- end -}} + +{{- $image := partial "function-caches-images.html" + (dict + "Context" . + "Source" $header + "Resize" "x600" + "Target" (print (partial "function-paths.html").media "/" $author.user "/") + "Copy" (print (partial "function-paths.html").media "/" $author.user "/" (path.Base $header)) + "AlternateCopy" (print (partial "function-paths.html").media "/" $author.user "/" (path.BaseName $header) ".webp") + ) +-}} + +{{- with $image.AltRelPermalink -}} + <source srcset="{{ . }}" type="image/webp" /> {{- end -}} <img - {{ if fileExists $path }} - {{- with $image -}} - {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .))).Resize $dimensions -}} width="{{ $image.Width }}" height="{{ $image.Height }}" src="{{ $image.RelPermalink }}" - {{- else -}} - src="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}{{ $file }}" - {{ end }} - {{- else -}} - width="{{ $404image.Width }}" - height="{{ $404image.Height }}" - src="{{ $404image.RelPermalink }}" - {{- end }} - alt="{{ partial "author-name.html" . }}" + alt="{{ $author.name }}" /> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/author-list.html b/themes/default/layouts/partials/author-list.html index bfeaa16..619b1b3 100644 --- a/themes/default/layouts/partials/author-list.html +++ b/themes/default/layouts/partials/author-list.html @@ -1,14 +1,18 @@ -{{ $authors := slice }} -{{ range $index, $data := .Site.Data -}} - {{- $authors = $authors | append $data.user -}} -{{- end -}} +{{- $authors := print "public/authors.html" -}} <author-list> - <h1>Authors</h1> - <section> - {{- range $author := first 3 (shuffle (uniq $authors)) -}} - {{ $data := index $.Site.Data $author | default "default" }} - {{ partial "author-card.html" (dict "Data" $data) }} - {{ end }} - </section> + <h1> + <a data-hover href="{{ "" | absURL }}/authors/"> + Authors + </a> + </h1> + <aside> + {{- with $authors = resources.Get $authors -}} + {{- $authors.Content | safeHTML -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} + </aside> </author-list> diff --git a/themes/default/layouts/partials/author-media-path.html b/themes/default/layouts/partials/author-media-path.html deleted file mode 100644 index 77090ea..0000000 --- a/themes/default/layouts/partials/author-media-path.html +++ /dev/null @@ -1,2 +0,0 @@ -{{ partial "author-user.html" . }}/media -{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/author-name.html b/themes/default/layouts/partials/author-name.html deleted file mode 100644 index a4424e4..0000000 --- a/themes/default/layouts/partials/author-name.html +++ /dev/null @@ -1,8 +0,0 @@ -{{- $author := .Data.Author -}} - -{{- with $author -}} -{{- else -}} - {{- $author = index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} -{{- end -}} - -{{- $author.name | markdownify -}} diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html index c269efc..01786e7 100644 --- a/themes/default/layouts/partials/author-picture.html +++ b/themes/default/layouts/partials/author-picture.html @@ -1,41 +1,49 @@ -{{- $file := "/profile/picture.png" -}} -{{- $path := print "public/" (partial "author-media-path.html" .) $file -}} -{{- $image := resources.Get $path -}} -{{- $404image := resources.Get "data/media/404.png" -}} -{{- $dimensions := "160x160" -}} -{{- $author := partial "author-user.html" . }} +{{- $author := partial "function-authors-data.html" . -}} +{{- $metadata := print "public/" $author.user "/author.json" -}} -{{- with .Params.feed -}} +{{- $alternate := $author.name -}} +{{- $width := "" -}} +{{- $height := "" -}} +{{- $source := "" -}} +{{- $sourceset := "" -}} + +{{- with .Params.feed.favicon -}} + {{- $alternate = $.Params.feed.name -}} + {{- $width = "64" -}} + {{- $height = "64" -}} + {{- $source = print "/" (partial "function-paths.html").media "/favicon." ($.Params.feed.source | anchorize) ".png" -}} + {{- if not (fileExists (print "public/" $source)) -}} + {{- $source = $.Params.feed.favicon -}} + {{- end -}} + {{- $sourceset = "" -}} {{- else -}} - {{- with $image -}} - {{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}} - <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> + {{- $source = print "/" (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile" (path.Ext $author.picture.profile) -}} + {{- $sourceset = print "/" (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile.webp" -}} + {{- with $metadata := resources.Get $metadata -}} + {{- with $content := $metadata.Content -}} + {{- $metadata = $content | transform.Unmarshal -}} + {{- $width = $metadata.picture.profileWidth -}} + {{- $height = $metadata.picture.profileHeight -}} {{- end -}} -{{ end }} + {{- else -}} + {{- $source = "/data/media/404.png" -}} + {{- $sourceset = "" -}} + {{- end -}} +{{- end -}} + +{{- if not (path.Ext $author.picture.profile) -}} + {{- $source = "/data/media/404.png" -}} + {{- $sourceset = "" -}} +{{- end -}} + +{{- with $sourceset -}} +<source srcset="{{ print ("" | absURL) $sourceset }}" type="image/webp" /> +{{- end -}} <img - loading="lazy" - {{- with .Params.feed }} - width="64" - height="64" - alt="{{ .name }}" - src="{{ .image }}" - {{ else }} - {{ if fileExists $path }} - {{- with $image -}} - {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .))).Fit $dimensions -}} - width="{{ $image.Width }}" - height="{{ $image.Height }}" - src="{{ $image.RelPermalink }}" - {{ else -}} - src="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}{{ $file }}" - {{ end }} - {{- else -}} - width="{{ $404image.Width }}" - height="{{ $404image.Height }}" - src="{{ $404image.RelPermalink }}" - {{- end }} - alt="{{ partial "author-name.html" . }}" - {{ end -}} + width="{{ $width }}" + height="{{ $height }}" + src="{{ print ("" | absURL) $source }}" + alt="{{ $alternate }}" /> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/author-section-picture.html b/themes/default/layouts/partials/author-section-picture.html new file mode 100644 index 0000000..de0806b --- /dev/null +++ b/themes/default/layouts/partials/author-section-picture.html @@ -0,0 +1,38 @@ +{{- $author := partial "function-authors-data.html" . -}} +{{- $profile := $author.picture.profile -}} +{{- $file := not (urls.Parse $profile).Host -}} + +{{- if $file -}} + {{- $profile = print $author.user "/" $profile -}} +{{- end -}} + +{{- $image := partial "function-caches-images.html" + (dict + "Context" . + "Source" $profile + "Fit" "160x160" + "Target" (print (partial "function-paths.html").media "/" $author.user "/") + "Copy" (print (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile" (path.Ext $profile)) + "AlternateCopy" (print (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile.webp") + ) +-}} + +{{- $width := $image.Width -}} +{{- $height := $image.Height -}} +{{- $source := $image.RelPermalink -}} +{{- $alternate := $author.name -}} +{{- $sourceset := $image.AltRelPermalink -}} + +{{- $metadata := (dict + "picture" (dict + "profileWidth" $width + "profileHeight" $height + "profileSource" $source + "profileAlternate" $alternate + "profileSourceSet" $sourceset + ) + ) +-}} + +{{- $authorMetadata := merge $author $metadata | jsonify | resources.FromString (print .Section "/author.json") -}} +{{- $writeToFile := $authorMetadata.Permalink -}} diff --git a/themes/default/layouts/partials/author-user.html b/themes/default/layouts/partials/author-user.html deleted file mode 100644 index 797610b..0000000 --- a/themes/default/layouts/partials/author-user.html +++ /dev/null @@ -1,8 +0,0 @@ -{{- $author := .Data.Author -}} - -{{- with $author -}} -{{- else -}} - {{- $author = index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} -{{- end -}} - -{{- $author.user | markdownify -}} diff --git a/themes/default/layouts/partials/card-id.html b/themes/default/layouts/partials/card-id.html index abaf5be..5f92697 100644 --- a/themes/default/layouts/partials/card-id.html +++ b/themes/default/layouts/partials/card-id.html @@ -1,7 +1,6 @@ -{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} -{{- $source := print $author.user "/messages/" .File.LogicalName -}} -{{- $source = replace (lower (humanize $source | truncate 50 "")) " " "-" -}} -{{ if .ExpiryDate }} - {{- $source = md5 $source -}} -{{ end }} +{{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} +{{- $source := urlize (humanize $relURL) -}} +{{- if .ExpiryDate -}} + {{- $source = truncate 8 "" (sha256 $source) -}} +{{- end -}} {{- $source -}} diff --git a/themes/default/layouts/partials/card-meta-header.html b/themes/default/layouts/partials/card-meta-header.html new file mode 100644 index 0000000..72b67b8 --- /dev/null +++ b/themes/default/layouts/partials/card-meta-header.html @@ -0,0 +1,25 @@ +<meta-data> + + {{- partial "meta-anchored.html" . -}} + + {{- partial "meta-name.html" . -}} + + {{- partial "meta-draft.html" . -}} + + {{- partial "meta-unlisted.html" . -}} + + {{- partial "meta-handle.html" . -}} + + {{- partial "meta-datetime.html" . -}} + + {{- partial "meta-view.html" . -}} + + {{- partial "meta-menu.html" . -}} + + {{- partial "meta-wordcount.html" . -}} + + {{- partial "meta-readtime.html" . -}} + + {{- partial "meta-expirydate.html" . -}} + +</meta-data> diff --git a/themes/default/layouts/partials/card-meta.html b/themes/default/layouts/partials/card-meta.html deleted file mode 100644 index 4359586..0000000 --- a/themes/default/layouts/partials/card-meta.html +++ /dev/null @@ -1,63 +0,0 @@ -<micro-thumbnail hidden> - {{ partial "profile-picture.html" . }} -</micro-thumbnail> - -<section> - {{ if or .Weight .Params.Liked .Params.feed }} - <anchored-entry> - {{- if .Params.feed -}} - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/rss.svg")) }} - <a data-hover - title="{{ partial "author-user.html" . }}@{{ (urls.Parse .Site.BaseURL).Host }}" - href="{{ .Site.BaseURL }}/{{ partial "author-user.html" . }}/feeds/#"> - via @{{ partial "author-user.html" . }} - </a> - {{- end -}} - - {{ if .Weight }} - <anchored-pinned> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/tabler/pinned.svg")) }} - </anchored-pinned> - <span>Pinned</span> - {{ end }} - - {{ if .Params.Liked }} - <anchored-liked> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/heart.svg")) }} - </anchored-liked> - <span>Liked</span> - {{ end }} - - </anchored-entry> - {{ end }} - - {{- partial "meta-name.html" . -}} - - · {{ partial "meta-handle.html" . }} - - {{ if .Draft }} - · {{ partial "meta-draft" . -}} - {{ end }} - - · {{- partial "meta-read-time.html" . -}} - - · {{- partial "meta-word-count.html" . -}} - - {{ if .Params.Unlisted }} - · <unlisted-entry title="This message is off the record"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/eye-off.svg")) }} - <span>unlisted</span></unlisted-entry> - {{ end }} - - · {{- partial "meta-date-time.html" . -}} - - {{- if .ExpiryDate -}} - · {{- partial "meta-expiry-date.html" . -}} - {{- end -}} - - · <cite><a title="#{{ partial "card-id.html" . }}" href="#{{ partial "card-id.html" . }}">#id</a></cite> - - {{ if not .ExpiryDate }} - · {{ partial "meta-source.html" . -}} - {{- end -}} -</section> diff --git a/themes/default/layouts/partials/context-menu.html b/themes/default/layouts/partials/context-menu.html deleted file mode 100644 index 40e0001..0000000 --- a/themes/default/layouts/partials/context-menu.html +++ /dev/null @@ -1,4 +0,0 @@ -<input type="checkbox" id="context-menu-{{ .Name }}" /> -<label for="context-menu-{{ .Name }}">{{ .Label }}</label> - -<context-menu>{{ .Content }}</context-menu> diff --git a/themes/default/layouts/partials/context-profile.html b/themes/default/layouts/partials/context-profile.html index c64e4a2..5150128 100644 --- a/themes/default/layouts/partials/context-profile.html +++ b/themes/default/layouts/partials/context-profile.html @@ -1,35 +1,34 @@ -{{ $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") }} +{{- $author := partial "function-authors-data.html" . -}} +{{- $description := or .Params.feed.description ($author.description | markdownify) -}} +{{- $name := or .Params.feed.name $author.name -}} +{{- $host := or (urls.Parse .Site.BaseURL).Host "localhost" -}} +{{- $author := .Section -}} +{{- $href := print ("" | absURL) "/" $author "/" -}} +{{- $title := print $author "@" $host -}} + +{{- with .Params.feed -}} + {{- $host = $.Params.feed.domain -}} + {{- $href = or $.Params.feed.home (print "http://" $.Params.feed.domain) -}} + {{- $title = $.Params.feed.domain -}} +{{- end -}} <context-profile> <context-menu> <div> <aside> <figure> - {{- with .Params.feed.name -}} - <a title="{{ . }}" href="http://{{ $.Params.feed.domain }}"> - {{- else -}} - <a title="{{ $author.name }}" href="{{ .Site.BaseURL }}/{{ $author.user }}/#"> - {{- end -}} + <a title="{{ $name }}" href="{{ $href }}"> <picture> - {{ partial "author-picture" . }} + {{ partial "author-picture" . }} </picture> </a> </figure> </aside> <aside> - {{- with .Params.feed.name -}} - <h2>{{ . }}</h2> - <p>@{{ $.Params.feed.domain }}</p> - {{- else -}} - <h2>{{ $author.name }}</h2> - <p>@{{ $author.user }}</p> - {{- end -}} + <h2>{{ $name }}</h2> + <p>@{{ $host }}</p> </aside> </div> - {{- with .Params.feed.description -}} - <p>{{ . }}</p> - {{- else -}} - <p>{{- $author.description | markdownify -}}</p> - {{- end -}} + <p>{{ $description }}</p> </context-menu> </context-profile> diff --git a/themes/default/layouts/partials/count-authors.html b/themes/default/layouts/partials/count-authors.html index 00655a0..8f2d7ef 100644 --- a/themes/default/layouts/partials/count-authors.html +++ b/themes/default/layouts/partials/count-authors.html @@ -1,7 +1,2 @@ -{{- $authors := slice -}} - -{{- range $index, $data := .Site.Data -}} - {{- $authors = $authors | append $data.name -}} -{{- end -}} - -{{- print (lang.FormatNumberCustom 0 (len (uniq $authors))) " " "Authors" -}} +{{- $authors := partial "function-authors-slice.html" . -}} +{{- print (lang.FormatNumberCustom 0 (len $authors)) -}} diff --git a/themes/default/layouts/partials/count-drafts.html b/themes/default/layouts/partials/count-drafts.html index 78b57a5..fae0b90 100644 --- a/themes/default/layouts/partials/count-drafts.html +++ b/themes/default/layouts/partials/count-drafts.html @@ -1,10 +1,7 @@ -{{ $author := partial "author-user.html" . }} -{{ $count := 0 }} +{{- $author := .Section -}} -{{ range .Site.Pages }} - {{ if and (eq .Type $author) .Draft }} - {{ $count = add $count 1 }} - {{ end }} -{{ end }} +{{- $authors := where .Site.RegularPages "Section" $author -}} +{{- $drafts := where .Site.RegularPages "Draft" true -}} +{{- $filteredPages := $authors | intersect $drafts -}} -{{ print (lang.FormatNumberCustom 0 $count) " " "Drafts" }} +{{- print (lang.FormatNumberCustom 0 (len $filteredPages)) -}} diff --git a/themes/default/layouts/partials/count-feeds.html b/themes/default/layouts/partials/count-feeds.html index cf54180..68495da 100644 --- a/themes/default/layouts/partials/count-feeds.html +++ b/themes/default/layouts/partials/count-feeds.html @@ -1,12 +1,7 @@ -{{ $author := partial "author-user.html" . }} -{{ $count := 0 }} +{{- $author := .Section -}} -{{ range .Site.Pages }} - {{ if .Params.feed }} - {{ if eq .Type $author }} - {{ $count = add $count 1 }} - {{ end }} - {{ end }} -{{ end }} +{{- $feeds := where .Site.Pages "Params.feed" "ne" nil -}} +{{- $authors := where .Site.Pages "Section" $author -}} +{{- $filteredPages := $authors | intersect $feeds -}} -{{ print (lang.FormatNumberCustom 0 $count) " " "Messages" }} +{{- print (lang.FormatNumberCustom 0 (len $filteredPages)) -}} diff --git a/themes/default/layouts/partials/count-likes.html b/themes/default/layouts/partials/count-likes.html deleted file mode 100644 index a808576..0000000 --- a/themes/default/layouts/partials/count-likes.html +++ /dev/null @@ -1,10 +0,0 @@ -{{ $author := partial "author-user.html" . }} -{{ $count := 0 }} - -{{ range .Site.Pages }} - {{ if and (eq .Type $author) .Params.Liked }} - {{ $count = add $count 1 }} - {{ end }} -{{ end }} - -{{ print (lang.FormatNumberCustom 0 $count) " " "Messages" }} diff --git a/themes/default/layouts/partials/count-marks.html b/themes/default/layouts/partials/count-marks.html new file mode 100644 index 0000000..deb532d --- /dev/null +++ b/themes/default/layouts/partials/count-marks.html @@ -0,0 +1,6 @@ +{{- $author := .Section -}} +{{- $items := where .Site.RegularPages ".Params.marked" true -}} +{{- $authors := where .Site.RegularPages "Section" $author -}} +{{- $filteredPages := $authors | intersect $items -}} + +{{- print (lang.FormatNumberCustom 0 (len $filteredPages)) -}} diff --git a/themes/default/layouts/partials/count-media.html b/themes/default/layouts/partials/count-media.html index 1d5e49b..1d68e0a 100644 --- a/themes/default/layouts/partials/count-media.html +++ b/themes/default/layouts/partials/count-media.html @@ -1,17 +1,20 @@ -{{ $author := partial "author-user.html" . }} -{{ $count := 0 }} +{{- $author := .Section -}} +{{- $notFeeds := where .Site.RegularPages "Params.feed" "eq" nil -}} +{{- $authors := where .Site.RegularPages "Section" $author -}} +{{- $filteredPages := $authors | intersect $notFeeds -}} +{{- $count := 0 -}} -{{ range .Site.Pages }} - {{ if or - (in .Content "<figure>") - (in .Content "<imgur-video>") - (in .Content "<youtube-video>") - (in .Content "<video-container>") - }} - {{ if eq .Type $author }} - {{ $count = add $count 1 }} - {{ end }} - {{ end }} -{{ end }} +{{- range first 100 $filteredPages -}} + {{- if eq $count 10 -}} + {{- break -}} + {{- end -}} + {{- if or + (in .Content "</video>") + (in .Content "</picture>") + (in .Content "</youtube-video>") + -}} + {{- $count = add $count 1 -}} + {{- end -}} +{{- end -}} -{{ print (lang.FormatNumberCustom 0 $count) " " "Messages" }} +{{- print (lang.FormatNumberCustom 0 $count) -}} diff --git a/themes/default/layouts/partials/count-tags.html b/themes/default/layouts/partials/count-tags.html index 0ef6802..6d436c6 100644 --- a/themes/default/layouts/partials/count-tags.html +++ b/themes/default/layouts/partials/count-tags.html @@ -1 +1 @@ -{{- print (lang.FormatNumberCustom 0 (len .Site.Taxonomies.tags)) " " "Tags" -}} +{{- print (lang.FormatNumberCustom 0 (len .Site.Taxonomies.tags)) -}} diff --git a/themes/default/layouts/partials/count-total-messages.html b/themes/default/layouts/partials/count-total-messages.html deleted file mode 100644 index 10540a7..0000000 --- a/themes/default/layouts/partials/count-total-messages.html +++ /dev/null @@ -1,2 +0,0 @@ -{{ $messages := len .Site.RegularPages }} -{{ print (lang.FormatNumberCustom 0 $messages) " " "Messages" }} diff --git a/themes/default/layouts/partials/count.html b/themes/default/layouts/partials/count.html new file mode 100644 index 0000000..72b5d03 --- /dev/null +++ b/themes/default/layouts/partials/count.html @@ -0,0 +1 @@ +{{- print (lang.FormatNumberCustom 0 (len .Site.RegularPages)) -}} diff --git a/themes/default/layouts/partials/following-list.html b/themes/default/layouts/partials/following-list.html new file mode 100644 index 0000000..510d3d2 --- /dev/null +++ b/themes/default/layouts/partials/following-list.html @@ -0,0 +1,31 @@ +{{- $count := 0 -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $feeds := print "public/" .Section "/following.html" -}} + +{{- with $items := $author.feeds.rss -}} + {{- $count = len $items -}} +{{- end -}} + +{{- $expand := cond (gt $count 3) "more" "less" -}} + +<following-list> + <details + id="web-feeds" + data-expand="{{- $expand -}}" + > + <summary> + <h1>Web Feeds ({{ $count }})</h1> + </summary> + </details> + <aside> + {{- if and $author.feeds.rss (fileExists $feeds) -}} + {{- with $feeds = resources.Get $feeds -}} + {{- $feeds.Content | safeHTML -}} + {{- end -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} + </aside> +</following-list> diff --git a/themes/default/layouts/partials/footer.html b/themes/default/layouts/partials/footer.html index 6cac939..54d6ab1 100644 --- a/themes/default/layouts/partials/footer.html +++ b/themes/default/layouts/partials/footer.html @@ -1,12 +1,14 @@ -{{ $author := index .Site.Data ((or .Params.author .Site.Author.default.footer) | default "default") }} +{{- $kind := in (slice "home" "taxonomy" "term") .Page.Kind -}} +{{- $author := index .Site.Data.authors .Section -}} <footer> - {{- with .Site.Author.footer -}} - {{ if $.IsHome -}} - {{ . | markdownify }} - {{- else -}} - {{ $author.blogtitle }} + {{- if $kind -}} + {{- with $footer := (and $kind .Site.Author.default.footer) -}} + {{ $footer | markdownify }} · + Copyright © {{ now | time.Format "2006"}} · {{- end -}} + {{- else -}} + {{ or $author.footer $author.title | markdownify }} · {{- end }} - | Copyright © {{ now.Format "2006"}} + <a href="/sitemap.xml" >Site Map</a> </footer> diff --git a/themes/default/layouts/partials/function-authors-data.html b/themes/default/layouts/partials/function-authors-data.html new file mode 100644 index 0000000..dbc2c67 --- /dev/null +++ b/themes/default/layouts/partials/function-authors-data.html @@ -0,0 +1,9 @@ +{{- $input := . -}} + +{{- $pageContext := $input -}} + +{{- $author := $pageContext.Section -}} + +{{- $output := index $pageContext.Site.Data.authors $author -}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-authors-slice.html b/themes/default/layouts/partials/function-authors-slice.html new file mode 100644 index 0000000..fc25554 --- /dev/null +++ b/themes/default/layouts/partials/function-authors-slice.html @@ -0,0 +1,9 @@ +{{- $authors := slice -}} + +{{- range $user := .Site.Author.list -}} + {{- with $author := index $.Site.Data.authors $user -}} + {{- $authors = $authors | append $author.user -}} + {{- end -}} +{{- end -}} + +{{- return (uniq $authors) -}} diff --git a/themes/default/layouts/partials/function-caches-images.html b/themes/default/layouts/partials/function-caches-images.html new file mode 100644 index 0000000..c99103b --- /dev/null +++ b/themes/default/layouts/partials/function-caches-images.html @@ -0,0 +1,109 @@ +{{- $pageContext := .Context -}} +{{- $data := dict -}} +{{- $source := or .Source "nil" -}} +{{- $fit := .Fit -}} +{{- $resize := .Resize -}} +{{- $target := or .Target "/" -}} +{{- $copy := .Copy -}} +{{- $directory := path.Dir $copy -}} +{{- $basename := path.BaseName $copy -}} +{{- $type := strings.TrimPrefix "." (path.Ext $copy) -}} +{{- $alternateCopy := or .AlternateCopy (print $directory "/" $basename ".webp") -}} +{{- $alternateType := strings.TrimPrefix "." (path.Ext $alternateCopy) -}} +{{- $isFile := ne (path.Base $copy) "." -}} +{{- $cached := and $isFile (fileExists (print "public/" $copy)) (fileExists (print "public/" $alternateCopy)) -}} +{{- $local := print "public/" $source -}} +{{- $localized := fileExists $local -}} + +{{- with $404image := resources.Get "data/media/404.png" -}} + {{- $404image = .Content | resources.FromString (print $target (path.Base .)) -}} + {{- + $data = (dict + "Width" $404image.Width + "Height" $404image.Height + "Permalink" $404image.Permalink + "RelPermalink" $404image.RelPermalink + ) + -}} +{{- end -}} + +{{- if $cached -}} + {{- with $image := resources.Get (print "public/" $copy) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} + {{- + $data = (dict + "Width" $image.Width + "Height" $image.Height + "Permalink" $image.Permalink + "RelPermalink" $image.RelPermalink + ) + -}} + {{- $image = resources.Get (print "public/" $alternateCopy) -}} + {{- $image = .Content | resources.FromString (print $target (path.Base $image)) -}} + {{- + $data = merge $data (dict + "AltPermalink" $image.Permalink + "AltRelPermalink" $image.RelPermalink + ) + -}} + {{- end -}} +{{- else -}} + {{- with $image := cond (default true $pageContext.Site.Params.site.offline) false (resources.GetRemote $source) -}} + {{- with .Err -}} + {{- if $localized -}} + {{- $directory := path.Dir $local -}} + {{- $basename := path.BaseName $local -}} + {{- $type := strings.TrimPrefix "." (path.Ext $local) -}} + {{- with $image := resources.Get $local -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} + {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $type) -}} {{- end -}} + {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $type) -}} {{- end -}} + {{- $image = $image | resources.Copy $copy -}} + {{- + $data = (dict + "Width" $image.Width + "Height" $image.Height + "Permalink" $image.Permalink + "RelPermalink" $image.RelPermalink + ) + -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} + {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $alternateType) -}} {{- end -}} + {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $alternateType) -}} {{- end -}} + {{- $image = $image | resources.Copy $alternateCopy -}} + {{- + $data = merge $data (dict + "AltPermalink" $image.Permalink + "AltRelPermalink" $image.RelPermalink + ) + -}} + {{- end -}} + {{- end -}} + {{- else -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} + {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $type) -}} {{- end -}} + {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $type) -}} {{- end -}} + {{- $image = $image | resources.Copy $copy -}} + {{- + $data = (dict + "Width" $image.Width + "Height" $image.Height + "Permalink" $image.Permalink + "RelPermalink" $image.RelPermalink + ) + -}} + {{- $image = .Content | resources.FromString (print $target (path.Base .)) -}} + {{- with $fit -}} {{- $image = $image.Fit (print $fit " " $alternateType) -}} {{- end -}} + {{- with $resize -}} {{- $image = $image.Resize (print $resize " " $alternateType) -}} {{- end -}} + {{- $image = $image | resources.Copy $alternateCopy -}} + {{- + $data = merge $data (dict + "AltPermalink" $image.Permalink + "AltRelPermalink" $image.RelPermalink + ) + -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- return $data -}} diff --git a/themes/default/layouts/partials/function-content.html b/themes/default/layouts/partials/function-content.html new file mode 100644 index 0000000..19c15ea --- /dev/null +++ b/themes/default/layouts/partials/function-content.html @@ -0,0 +1,23 @@ +{{- $pageContext := . -}} +{{- $content := $pageContext.Content -}} +{{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} + +{{- $brokenBlockquotes := findRE `(?sU)</blockquote>\n<p>(–|—).*</p>` .Content -}} + +{{- range $brokenBlockquote := $brokenBlockquotes -}} + {{- $fixedBlockquote := $brokenBlockquote | + replaceRE "</blockquote>\n<p>" "<footer><cite>" | + replaceRE "</p>" "</cite></footer></blockquote>" | + -}} + {{- $content = replace $content $brokenBlockquote $fixedBlockquote -}} +{{- end -}} + +{{- if not $content -}} + {{- $content = "This message contains no content." -}} +{{- end -}} + +{{- if $expired -}} + {{- $content = "This message has expired." -}} +{{- end -}} + +{{- return $content -}} diff --git a/themes/default/layouts/partials/function-favicon-domain.html b/themes/default/layouts/partials/function-favicon-domain.html new file mode 100644 index 0000000..3814304 --- /dev/null +++ b/themes/default/layouts/partials/function-favicon-domain.html @@ -0,0 +1,11 @@ +{{- $input := . -}} + +{{- $output := + (print + "https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&size=64&url=" + "http://" + $input + ) +-}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-fetch-favicons.html b/themes/default/layouts/partials/function-fetch-favicons.html new file mode 100644 index 0000000..facde2f --- /dev/null +++ b/themes/default/layouts/partials/function-fetch-favicons.html @@ -0,0 +1,15 @@ +{{- $source := .Source -}} +{{- $infix := .Infix -}} +{{- $pageContext := .Context -}} + +{{- $output := partial "function-caches-images.html" + (dict + "Context" $pageContext + "Source" $source + "Fit" "160x160" + "Target" (print (partial "function-paths.html").media "/") + "Copy" (print (partial "function-paths.html").media "/favicon." $infix ".png") + ) +-}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-filters-content.html b/themes/default/layouts/partials/function-filters-content.html new file mode 100644 index 0000000..8ebad51 --- /dev/null +++ b/themes/default/layouts/partials/function-filters-content.html @@ -0,0 +1,10 @@ +{{- $input := . -}} + +{{- $notExpired := where $input "Params.expirydate" "eq" nil -}} +{{- $notUnlisted := where $input "Params.unlisted" "eq" nil -}} + +{{- $filteredPages := $notExpired | intersect $notUnlisted -}} + +{{- $output := $filteredPages -}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-generate-feeds.html b/themes/default/layouts/partials/function-generate-feeds.html new file mode 100644 index 0000000..57789b5 --- /dev/null +++ b/themes/default/layouts/partials/function-generate-feeds.html @@ -0,0 +1,245 @@ +{{- $author := partial "function-authors-data.html" . -}} + +{{- $feeds := slice -}} + +{{- if $author.feeds.rss -}} + {{- range $key, $value := (seq 3) -}} + {{- range $author.feeds.rss -}} + + {{- $data := split . " " -}} + {{- $url := delimit (first 1 $data) "" -}} + {{- $retitle := trim (delimit (after 1 $data) " ") " " -}} + + {{- with $fetch := cond (default true $.Site.Params.site.offline) false (resources.GetRemote $url) -}} + + {{- with $error := .Err -}} + {{- warnf "Feed fetch %s" $error -}} + {{- else -}} + + {{- with $fetch | transform.Unmarshal -}} + + {{- $content := "" -}} + {{- $date := now | time.Format "2006-01-02T15:04:05Z" -}} + {{- $description := "" -}} + {{- $enclosure := "" -}} + {{- $imageLink := "" -}} + {{- $link := "https://example.com/link/" -}} + {{- $sourceDescription := "" -}} + {{- $sourceHome := "" -}} + {{- $sourceLink := $url -}} + {{- $sourceTitle := "No source title found" -}} + {{- $title := "No Title Found" -}} + + {{- with .channel -}} + + {{- $sourceTitle = .title -}} + {{- $sourceDescription = .description -}} + + {{- if reflect.IsSlice .link -}} + {{- if reflect.IsMap (index .link 0) -}} + {{- $sourceHome = index (last 1 .link) 0 -}} + {{- else -}} + {{- $sourceHome = index .link 0 -}} + {{- end -}} + {{- end -}} + + {{- with .image -}} + {{- $imageLink = .url -}} + {{- end -}} + + {{- with .item -}} + {{- if reflect.IsMap . -}} + {{- $title = index . "title" -}} + {{- $link = index . "link" -}} + {{- $date = index . "pubDate" -}} + {{- else -}} + {{- range first $value . -}} + {{- $description = .description -}} + {{- $content = .description -}} + {{- $title = .title -}} + {{- $link = .link -}} + {{- $date = .pubDate -}} + {{- with .enclosure -}} + {{- $enclosure = index . "-url" -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- if not $date -}} + {{- $date = .lastBuildDate -}} + {{- end -}} + + {{- else -}} + + {{- with .author -}} + {{- if reflect.IsMap . -}} + {{- $sourceHome = .uri -}} + {{- end -}} + {{- end -}} + + {{- with .subtitle -}} + {{- if reflect.IsMap . -}} + {{- $sourceDescription = index . "#text" -}} + {{- else -}} + {{- $sourceDescription = . -}} + {{- end -}} + {{- end -}} + + {{- with .title -}} + {{- if reflect.IsMap . -}} + {{- $sourceTitle = index . "#text" -}} + {{- else -}} + {{- $sourceTitle = . -}} + {{- end -}} + {{- end -}} + + {{- with .entry -}} + {{- range first $value . -}} + {{- $date = .updated -}} + + {{- with .link -}} + {{- if reflect.IsMap . -}} + {{- $link = index . "-href" -}} + {{- else -}} + {{- if reflect.IsMap (index . 0) -}} + {{- $link = index (index . 0) "-href" -}} + {{- else -}} + {{- $link = . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- with .title -}} + {{- if reflect.IsMap . -}} + {{- $title = index . "#text" -}} + {{- else -}} + {{- $title = . -}} + {{- end -}} + {{- end -}} + + {{- with .content -}} + {{- $content = index . "#text" -}} + {{- end -}} + + {{- with .summary -}} + {{- $description = index . "#text" -}} + {{- end -}} + + {{- with .group -}} + {{- $description = .description -}} + {{- $content = index .content "#text" -}} + {{- $enclosure = index .thumbnail "-url" -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- end -}} + + {{- $sourceDomain := ($sourceLink | plainify | htmlUnescape | urls.Parse).Host -}} + + {{- /* Replace invalid time zones. */ -}} + {{- $date = replaceRE "G[0-9]+T" "UTC" $date -}} + + {{- /* If missing seconds split and try again. */ -}} + {{- if lt (len (split $date ":")) 3 -}} + {{- $date = delimit (first 3 (after 1 (split $date " "))) " " -}} + {{- end -}} + + {{- /* Try to complete enclosure relative links. */ -}} + {{- if and (not ($enclosure | urls.Parse).Host) (not ($link | urls.Parse).Host) -}} + {{- $enclosure = print "http://" $sourceDomain $link -}} + {{- end -}} + + {{- /* Try to complete link relative links. */ -}} + {{- if not ($link | urls.Parse).Host -}} + {{- $link = print "http://" $sourceDomain $link -}} + {{- end -}} + + {{- + $feeds = $feeds | append (dict + "FeedContent" ($content | plainify | htmlUnescape) + "FeedContentShort" (delimit (first 2 (split ($content | plainify | htmlUnescape) "\n")) " " | truncate 250 "...") + "FeedDate" ($date | plainify | htmlUnescape | time.Format "Mon Jan 2 2006") + "FeedDateTime" ($date | plainify | htmlUnescape | time.Format "2006-01-02T15:04:05Z") + "FeedDateTitle" ($date | plainify | htmlUnescape | time.Format "Monday January 2 2006 at 15:04:05 MST") + "FeedDescription" ($description | plainify | htmlUnescape) + "FeedDescriptionShort" (delimit (first 2 (split ($description | plainify | htmlUnescape) "\n")) " " | truncate 250 "...") + "FeedEnclosure" ($enclosure | plainify | htmlUnescape) + "FeedImageLink" ($imageLink | plainify | htmlUnescape) + "FeedLink" ($link | plainify | htmlUnescape) + "FeedName" (or $retitle (delimit (first 2 (split ($sourceTitle | plainify | htmlUnescape) " ")) " ")) + "FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape) + "FeedSourceDomain" ($sourceDomain | plainify | htmlUnescape) + "FeedSourceLink" ($sourceLink | plainify | htmlUnescape) + "FeedSourceHome" ($sourceHome | plainify | htmlUnescape) + "FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape) + "FeedTitle" ($title | plainify | htmlUnescape) + ) + -}} + + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- range $feeds -}} + + {{- $name := .FeedName -}} + {{- $domain := .FeedSourceDomain -}} + + {{- $favicon := partial "function-favicon-domain.html" $domain -}} + + {{- with .FeedImageLink -}} + {{- $favicon = . -}} + {{- end -}} + + {{- $imageSource := partial "function-fetch-favicons.html" + (dict + "Context" $.Page + "Source" $favicon + "Infix" (.FeedSourceLink | anchorize) + ) + -}} + + {{- $template := resources.Get "templates/markdown-feed.yaml" -}} + {{- $alias := truncate 255 "" (delimit (first 8 (split (.FeedTitle | urlize) "-")) "-" | humanize | urlize) -}} + {{- $hash := .FeedLink | sha256 | truncate 8 "" -}} + {{- $file := print $alias "-" $hash -}} + {{- $file = partial "function-strip-filechars.html" $file -}} + {{- $path := print "/data/generates/content/" $author.user "/feeds/" $file ".md" -}} + + {{- $content := .FeedContentShort -}} + + {{- if (gt (len .FeedTitle) (len $content)) -}} + {{- $content = .FeedTitle -}} + {{- end -}} + + {{- if (gt (len .FeedDescriptionShort) (len .FeedTitle)) -}} + {{- $content = .FeedDescriptionShort -}} + {{- end -}} + + {{- $markdown := resources.ExecuteAsTemplate + $path + (dict + "author" $author.user + "content" (or $content "No content found.") + "date" .FeedDateTime + "description" (or .FeedSourceDescription .FeedSourceTitle "No source description found.") + "domain" .FeedSourceDomain + "enclosure" .FeedEnclosure + "favicon" (strings.TrimPrefix ("" | absURL) $imageSource.Permalink) + "home" .FeedSourceHome + "link" .FeedLink + "name" .FeedName + "source" .FeedSourceLink + "tags" "[feeds]" + ) + $template + -}} + {{- $writeToFile := $markdown.Permalink -}} + {{- end -}} +{{- end -}} + +{{- return $feeds -}} diff --git a/themes/default/layouts/partials/function-page-modified.html b/themes/default/layouts/partials/function-page-modified.html new file mode 100644 index 0000000..43bea9f --- /dev/null +++ b/themes/default/layouts/partials/function-page-modified.html @@ -0,0 +1,39 @@ +{{- $input := .Context -}} +{{- $disable := or .Disable false -}} +{{- $pageContext := $input -}} +{{- $format := or .Format "index.html" -}} + +{{- $page := print "public/" (strings.TrimPrefix + $pageContext.Page.Site.BaseURL + $pageContext.Page.Permalink + ) $format +-}} + +{{- $pageModTime := "" -}} +{{- $markdownModTime := "" -}} +{{- $markdownContent := print "content/" $pageContext.File -}} +{{- $markdownPublic := print "public/data/generates/content/" $pageContext.File -}} + +{{- if fileExists $markdownContent -}} + {{- $markdownModTime = (os.Stat $markdownContent).ModTime -}} +{{- end -}} + +{{- if fileExists $markdownPublic -}} + {{- $markdownModTime = (os.Stat $markdownPublic).ModTime -}} +{{- end -}} + +{{- if fileExists $page -}} + {{- $pageModTime = (os.Stat $page).ModTime -}} +{{- end -}} + +{{- $page = gt $markdownModTime $pageModTime -}} + +{{- $modified := or $page (in (slice + "home" + "section" + "taxonomy" + "term" + ) $pageContext.Page.Kind) +-}} + +{{- return (or $disable $modified) -}} diff --git a/themes/default/layouts/partials/function-paths-markdown.html b/themes/default/layouts/partials/function-paths-markdown.html deleted file mode 100644 index ab92b8d..0000000 --- a/themes/default/layouts/partials/function-paths-markdown.html +++ /dev/null @@ -1 +0,0 @@ -{{ return "data/generates/content" }} diff --git a/themes/default/layouts/partials/function-paths-media.html b/themes/default/layouts/partials/function-paths-media.html deleted file mode 100644 index ce50a92..0000000 --- a/themes/default/layouts/partials/function-paths-media.html +++ /dev/null @@ -1 +0,0 @@ -{{ return "data/media" }} diff --git a/themes/default/layouts/partials/function-paths-static.html b/themes/default/layouts/partials/function-paths-static.html deleted file mode 100644 index b34dbeb..0000000 --- a/themes/default/layouts/partials/function-paths-static.html +++ /dev/null @@ -1 +0,0 @@ -{{ return "static" }} diff --git a/themes/default/layouts/partials/function-paths.html b/themes/default/layouts/partials/function-paths.html new file mode 100644 index 0000000..5f5a516 --- /dev/null +++ b/themes/default/layouts/partials/function-paths.html @@ -0,0 +1,7 @@ +{{- + return (dict + "markdown" "data/generates/content" + "media" "data/media" + "static" "static" + ) +-}} diff --git a/themes/default/layouts/partials/function-strip-filechars.html b/themes/default/layouts/partials/function-strip-filechars.html new file mode 100644 index 0000000..b68daa0 --- /dev/null +++ b/themes/default/layouts/partials/function-strip-filechars.html @@ -0,0 +1,28 @@ +{{- $input := . -}} +{{- $output := $input -}} + +{{- $output = replace $output `{` "" -}} +{{- $output = replace $output `}` "" -}} +{{- $output = replace $output `|` "" -}} +{{- $output = replace $output `\` "" -}} +{{- $output = replace $output `^` "" -}} +{{- $output = replace $output `[` "" -}} +{{- $output = replace $output `]` "" -}} +{{- $output = replace $output "`" "" -}} +{{- $output = replace $output `;` "" -}} +{{- $output = replace $output `/` "" -}} +{{- $output = replace $output `?` "" -}} +{{- $output = replace $output `:` "" -}} +{{- $output = replace $output `@` "" -}} +{{- $output = replace $output `&` "" -}} +{{- $output = replace $output `=` "" -}} +{{- $output = replace $output `+` "" -}} +{{- $output = replace $output `$` "" -}} +{{- $output = replace $output `,` "" -}} +{{- $output = replace $output `<` "" -}} +{{- $output = replace $output `>` "" -}} +{{- $output = replace $output `#` "" -}} +{{- $output = replace $output `%` "" -}} +{{- $output = replace $output `\` "" -}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/gallery-images.html b/themes/default/layouts/partials/gallery-images.html deleted file mode 100644 index f9be257..0000000 --- a/themes/default/layouts/partials/gallery-images.html +++ /dev/null @@ -1,9 +0,0 @@ -{{ $folder := print "public/" (partial "author-user.html" .) "/media/" }} - -<gallery-images> - <h1>Picture Gallery</h1> - <aside> - <gallery-overlay></gallery-overlay> - {{ partial "gallery-walk.html" $folder }} - </aside> -</gallery-images> diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html index 6dd9fbd..ca95d3f 100644 --- a/themes/default/layouts/partials/gallery-walk.html +++ b/themes/default/layouts/partials/gallery-walk.html @@ -1,96 +1,50 @@ -{{- $folder := . -}} -{{- $files := slice -}} -{{- $dimensions := "320x320" -}} -{{- $author := strings.TrimPrefix "public/" (strings.TrimSuffix "/media/" $folder) -}} - -{{- if fileExists $folder -}} - - {{- range readDir $folder -}} - - {{- $name := index (split .Name ".") 0 -}} - {{- $extension := path.Ext .Name -}} - - {{- if or - (eq $extension ".apng") - (eq $extension ".avif") - (eq $extension ".gif") - (eq $extension ".jfif") - (eq $extension ".jpeg") - (eq $extension ".jpg") - (eq $extension ".pjp") - (eq $extension ".pjpeg") - (eq $extension ".png") - (eq $extension ".svg") - (eq $extension ".webp") - (eq $extension ".webp") +{{- $data := slice -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $filteredPages := partial "function-filters-content.html" .Site.RegularPages -}} + +{{- range (where $filteredPages "Section" $author.user) -}} + {{- if in .Content "<picture>" -}} + {{- $data = $data | append (dict + "alt" (delimit (findRE `(?sU)alt=".*"` .Content 1) "") + "height" (delimit (findRE `(?sU)height=".*"` .Content 1) "") + "src" (delimit (findRE `(?sU)src=".*"` .Content 1) "") + "srcset" (delimit (findRE `(?sU)srcset=".*"` .Content 1) "") + "style" (delimit (findRE `(?sU)style=".*"` .Content 1) "") + "title" (delimit (findRE `(?sU)title=".*"` .Content 1) "") + "type" (delimit (findRE `(?sU)type=".*"` .Content 1) "") + "width" (delimit (findRE `(?sU)width=".*"` .Content 1) "") + "relatedHref" .Permalink + ) -}} - {{- - $files = $files | append (dict - "Name" .Name - "Path" (path.Join $folder .Name) - ) - -}} - {{- end -}} {{- end -}} - - {{- if fileExists (path.Join $folder "profile") -}} - {{- range readDir (path.Join $folder "profile") -}} - - {{- $name := index (split .Name ".") 0 -}} - {{- $extension := path.Ext .Name -}} - - {{- if or - (eq $extension ".apng") - (eq $extension ".avif") - (eq $extension ".gif") - (eq $extension ".jfif") - (eq $extension ".jpeg") - (eq $extension ".jpg") - (eq $extension ".pjp") - (eq $extension ".pjpeg") - (eq $extension ".png") - (eq $extension ".svg") - (eq $extension ".webp") - (eq $extension ".webp") - -}} - {{- - $files = $files | append (dict - "Name" .Name - "Path" (path.Join $folder "profile" .Name) - ) - -}} - {{- end -}} - {{- end -}} + {{- if eq (len $data) 6 -}} + {{- break -}} {{- end -}} - - {{- if $files }} - - {{- range first 6 $files }} - {{- if not .IsDir }} - {{- with $image := resources.Get .Path -}} - {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/gallery-walker_" (path.Base .))).Fit (print $dimensions " webp") }} - <picture> - <source srcset="{{- $image.RelPermalink -}}" type="image/webp" /> - {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/gallery-walker_" (path.Base .))).Fit (print $dimensions " png") }} - <img - alt="{{- .Name }}" - title="{{- .Name }}" - width="{{ $image.Width }}" - height="{{ $image.Height }}" - src="{{ $image.RelPermalink }}" - /> - </picture> +{{- end -}} + +{{- if $data -}} + {{- range $image := $data }} + <a href="{{ $image.relatedHref }}"> + <picture> + {{- with $image.srcset -}} + <source + {{ $image.srcset | safeHTMLAttr }} + {{ $image.type | safeHTMLAttr }} + /> + {{- end -}} + <img + loading="lazy" + {{ $image.alt | safeHTMLAttr }} + {{ $image.title | safeHTMLAttr }} + {{ with ne (index (last 1 (split $image.width "=")) 0) `""` }} + {{ $image.width | safeHTMLAttr }} + {{ $image.height | safeHTMLAttr }} {{ end }} - {{- end -}} - {{- end -}} - - {{- else -}} - <footer> - <code>No media found!</code> - </footer> - {{- end -}} -{{- else -}} - <footer> - <code>No media found!</code> - </footer> -{{- end }} + {{ $image.src | safeHTMLAttr }} + {{ $image.style | safeHTMLAttr }} + /> + </picture> + </a> + {{ end }} + <gallery-overlay></gallery-overlay> +{{- end -}} diff --git a/themes/default/layouts/partials/gallery.html b/themes/default/layouts/partials/gallery.html new file mode 100644 index 0000000..135aa14 --- /dev/null +++ b/themes/default/layouts/partials/gallery.html @@ -0,0 +1,14 @@ +{{- $gallery := print "public/" .Section "/gallery.html" -}} + +<gallery-images> + <h1>Gallery</h1> + <aside> + {{- if fileExists $gallery -}} + {{- (resources.Get $gallery).Content | safeHTML -}} + {{- else -}} + <footer> + <code>No items found!</code> + </footer> + {{- end -}} + </aside> +</gallery-images> diff --git a/themes/default/layouts/partials/generate-authors.html b/themes/default/layouts/partials/generate-authors.html index 8e2081f..d1fc0c2 100644 --- a/themes/default/layouts/partials/generate-authors.html +++ b/themes/default/layouts/partials/generate-authors.html @@ -1,70 +1,70 @@ -{{- range .Site.Author.list -}} +{{- range $author := .Site.Author.list -}} - {{- if not (fileExists (print "data/" . ".yaml")) -}} + {{- if not (fileExists (print "data/authors/" $author ".yaml")) -}} {{- $configuration := resources.Get "templates/author.yaml" -}} {{- $configuration := resources.ExecuteAsTemplate - (print "/data/generates/authors/" . ".yaml") + (print "/data/generates/authors/" $author ".yaml") (dict - "Name" (title .) - "User" . + "Name" (title $author) + "User" $author ) $configuration -}} - {{- $writeToFile := $configuration.RelPermalink -}} + {{- $writeToFile := $configuration.Permalink -}} {{- end -}} {{- $markdown := resources.Get "templates/markdown-frontmatter.yaml" -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/" "_index.md") + (print "/data/generates/content/" $author "/" "_index.md") (dict - "author" . + "author" $author "layout" "section" ) $markdown -}} - {{- $writeToFile := $template.RelPermalink -}} + {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/feeds/" "_index.md") + (print "/data/generates/content/" $author "/feeds/" "_index.md") (dict - "author" . - "layout" "feeds" + "author" $author + "layout" "section.feeds" ) $markdown -}} - {{- $writeToFile := $template.RelPermalink -}} + {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/media/" "_index.md") + (print "/data/generates/content/" $author "/media/" "_index.md") (dict - "author" . - "layout" "media" + "author" $author + "layout" "section.media" ) $markdown -}} - {{- $writeToFile := $template.RelPermalink -}} + {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/likes/" "_index.md") + (print "/data/generates/content/" $author "/marks/" "_index.md") (dict - "author" . - "layout" "likes" + "author" $author + "layout" "section.marks" ) $markdown -}} - {{- $writeToFile := $template.RelPermalink -}} + {{- $writeToFile := $template.Permalink -}} {{- $template := resources.ExecuteAsTemplate - (print "/data/generates/content/" . "/drafts/" "_index.md") + (print "/data/generates/content/" $author "/drafts/" "_index.md") (dict - "author" . - "layout" "drafts" + "author" $author + "layout" "section.drafts" ) $markdown -}} - {{- $writeToFile := $template.RelPermalink -}} + {{- $writeToFile := $template.Permalink -}} {{- end -}} diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html deleted file mode 100644 index d94e39a..0000000 --- a/themes/default/layouts/partials/generate-feeds.html +++ /dev/null @@ -1,278 +0,0 @@ -{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} - -{{- $feeds := slice -}} - -{{- if $author.webring.rss -}} - {{- range $key, $value := (seq 3) -}} - {{- range $author.webring.rss -}} - - {{- with resources.GetRemote . -}} - {{- with .Err -}} - {{- warnf "Feed fetch %s" . -}} - {{- end -}} - {{- end -}} - - {{- with resources.GetRemote . | transform.Unmarshal -}} - - {{- $title := "No Title Found" -}} - {{- $link := "https://example.com/link" -}} - {{- $description := "No description found." -}} - {{- $content := "No content found." -}} - {{- $sourceTitle := "No source title found" -}} - {{- $sourceLink := "https://example.com/" -}} - {{- $sourceDescription := "No source description found." -}} - {{- $date := now.Format "2006-01-02T15:04:05Z" -}} - {{- $enclosure := "" -}} - - {{- with .channel -}} - - {{- $sourceTitle = .title -}} - {{- $sourceDescription = .description -}} - - {{- if reflect.IsSlice .link -}} - {{- if reflect.IsMap (index .link 0) -}} - {{- $sourceLink = index (index .link 0) "-href" -}} - {{- else -}} - {{- $sourceLink = index .link 0 -}} - {{- end -}} - {{- else -}} - {{- $sourceLink = .link -}} - {{- end -}} - - {{- with .item -}} - {{- if reflect.IsMap . -}} - {{- $title = index . "title" -}} - {{- $link = index . "link" -}} - {{- $date = index . "pubDate" -}} - {{- else -}} - {{- range first $value . -}} - {{- $description = .description -}} - {{- $content = .description -}} - {{- $title = .title -}} - {{- $link = .link -}} - {{- $date = .pubDate -}} - {{- with .enclosure -}} - {{- $enclosure = index . "-url" -}} - {{- end -}} - {{- end -}} - {{- end -}} - {{- end -}} - - {{- if not $date -}} - {{- $date = .lastBuildDate -}} - {{- end -}} - - {{- else -}} - - {{- with .link -}} - {{- $sourceLink = index (index . 0) "-href" -}} - {{- end -}} - - {{- with .subtitle -}} - {{- if reflect.IsMap . -}} - {{- $sourceDescription = index . "#text" -}} - {{- else -}} - {{- $sourceDescription = . -}} - {{- end -}} - {{- end -}} - - {{- with .title -}} - {{- if reflect.IsMap . -}} - {{- $sourceTitle = index . "#text" -}} - {{- else -}} - {{- $sourceTitle = . -}} - {{- end -}} - {{- end -}} - - {{- with .entry -}} - {{- range first $value . -}} - {{- $date = .updated -}} - - {{- with .link -}} - {{- if reflect.IsMap . -}} - {{- $link = index . "-href" -}} - {{- else -}} - {{- if reflect.IsMap (index . 0) -}} - {{- $link = index (index . 0) "-href" -}} - {{- else -}} - {{- $link = . -}} - {{- end -}} - {{- end -}} - {{- end -}} - - {{- with .title -}} - {{- if reflect.IsMap . -}} - {{- $title = index . "#text" -}} - {{- else -}} - {{- $title = . -}} - {{- end -}} - {{- end -}} - - {{- with .content -}} - {{- $content = index . "#text" -}} - {{- end -}} - - {{- with .summary -}} - {{- $description = index . "#text" -}} - {{- end -}} - - {{- with .group -}} - {{- $description = .description -}} - {{- $content = index .content "#text" -}} - {{- $enclosure = index .thumbnail "-url" -}} - {{- end -}} - {{- end -}} - {{- end -}} - - {{- end -}} - - {{- /* Common time zone typos. */ -}} - {{- $date = strings.Replace $date "G6T" "GST" -}} - - {{- /* If missing seconds split and try again. */ -}} - {{- if lt (len (split $date ":")) 3 -}} - {{- $date = delimit (first 3 (after 1 (split $date " "))) " " -}} - {{- end -}} - - {{ - $feeds = $feeds | append (dict - "FeedContent" ($content | plainify | htmlUnescape) - "FeedContentShort" (delimit (first 2 (split ($content | plainify | htmlUnescape) "\n")) " " | truncate 250) - "FeedDate" ($date | plainify | htmlUnescape | time.Format "January 2, 2006") - "FeedDateTime" ($date | plainify | htmlUnescape | time.Format "2006-01-02T15:04:05Z") - "FeedDateTitle" ($date | plainify | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST") - "FeedDescription" ($description | plainify | htmlUnescape) - "FeedDescriptionShort" (delimit (first 2 (split ($description | plainify | htmlUnescape) "\n")) " " | truncate 250) - "FeedEnclosure" ($enclosure | plainify | htmlUnescape) - "FeedLink" ($link | plainify | htmlUnescape) - "FeedName" (delimit ((delimit (first 2 (split ($sourceTitle | plainify | htmlUnescape) " ")) " ") | findRE "^([^.|?|!|\n|\"|]+)") " " | replaceRE "[^a-zA-Z ]" "") - "FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape) - "FeedSourceDomain" (($sourceLink | plainify | htmlUnescape | urls.Parse).Host) - "FeedSourceLink" ($sourceLink | plainify | htmlUnescape) - "FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape) - "FeedTitle" ($title | plainify | htmlUnescape) - ) - -}} - - {{- end -}} - {{- end -}} - {{- end -}} - - {{- range $feeds -}} - - {{- $imageCanonicalURL := - (print - "https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=" - "http://" - .FeedSourceDomain - "&size=64" - ) - -}} - - {{- $404image := resources.Get "data/media/404.png" -}} - {{- $imageSource := $404image.RelPermalink -}} - {{- $imageTitle := "No image found" -}} - - {{- with $image := resources.GetRemote $imageCanonicalURL -}} - {{- with .Err -}} - {{- warnf "%s" . -}} - {{- else -}} - {{- $imageContent := $image.Content | resources.FromString (print (partial "function-paths-media.html") "/" ($image | urlize)) -}} - {{- $imageSource = $imageContent.RelPermalink -}} - {{- $imageTitle = $imageCanonicalURL -}} - {{- end -}} - {{- end -}} - - {{- $template := resources.Get "templates/markdown-feed.yaml" -}} - {{- $name := print (delimit (first 8 (split (.FeedTitle | urlize) "-")) "-" | humanize | urlize) "-" (.FeedLink | sha256 | truncate 8 "") | humanize | urlize -}} - {{- $path := print "/data/generates/content/" $author.user "/feeds/" $name ".md" -}} - - {{- $description := .FeedDescriptionShort -}} - {{- if gt (len .FeedTitle) (len .FeedDescriptionShort) -}} - {{- $description = .FeedTitle -}} - {{- end -}} - - {{- $content := .FeedContentShort -}} - {{- if or (eq $content "No content found.") (gt (len .FeedTitle) (len $content)) -}} - {{- $content = .FeedTitle -}} - {{- end -}} - - {{- $link := .FeedLink -}} - {{- $enclosure := .FeedEnclosure -}} - {{- if or - (in .FeedLink ".apng") - (in .FeedLink ".avif") - (in .FeedLink ".gif") - (in .FeedLink ".jfif") - (in .FeedLink ".jpeg") - (in .FeedLink ".jpg") - (in .FeedLink ".pjp") - (in .FeedLink ".pjpeg") - (in .FeedLink ".png") - (in .FeedLink ".svg") - (in .FeedLink ".webp") - -}} - {{- if (.Feedlink | urls.Parse).Host -}} - {{- else -}} - {{- $enclosure = print "http://" .FeedSourceDomain .FeedLink -}} - {{- $link = $enclosure -}} - {{- end -}} - {{- end -}} - - {{- $markdown := resources.ExecuteAsTemplate - $path - (dict - "author" $author.user - "content" $content - "date" .FeedDateTime - "description" .FeedSourceTitle - "domain" .FeedSourceDomain - "enclosure" $enclosure - "image" $imageSource - "link" $link - "name" .FeedName - "raw" (strings.TrimLeft "/" $path) - "self" (print $author.user "/feeds/" $name "/") - "tags" "[rss]" - ) - $template - -}} - {{- $writeToFile := $markdown.RelPermalink -}} - {{ end }} - - <web-ring> - <h1>Web Ring</h1> - <aside> - {{ range first 3 (uniq (sort $feeds "FeedDateTime" "desc")) }} - <web-ring-item> - <header> - <a - title="{{ .FeedLink }}" - href="{{ .FeedLink }}"> - {{ .FeedTitle }} - </a> - </header> - - <p> - <time - title="{{ .FeedDateTitle }}" - datetime="{{ .FeedDateTime }}"> - {{ .FeedDate }} - </time> - {{ if gt (len .FeedDescriptionShort) (len .FeedContentShort) -}} - {{ "--" | markdownify }} {{ .FeedDescriptionShort }} - {{- else -}} - {{ "--" | markdownify }} {{ .FeedContentShort }} - {{- end }} - </p> - - <a - title="{{ .FeedSourceDescription }}" - href="{{ .FeedSourceLink }}"> - {{ .FeedSourceTitle }} - </a> - </web-ring-item> - {{ end }} - </aside> - </web-ring> -{{- end -}} diff --git a/themes/default/layouts/partials/head-canonical.html b/themes/default/layouts/partials/head-canonical.html new file mode 100644 index 0000000..051e450 --- /dev/null +++ b/themes/default/layouts/partials/head-canonical.html @@ -0,0 +1,15 @@ +{{- $canonical := .Permalink -}} + +{{- with .Site.Params.site.canonical -}} + {{- $canonical = print $.Site.Params.site.canonical $.RelPermalink -}} +{{- end -}} + +{{- with .Params.feed -}} + {{- $canonical = $.Params.feed.link -}} +{{- end -}} + +{{- with .Params.canonical -}} + {{- $canonical = $.Params.canonical -}} +{{- end -}} + +<link rel="canonical" href="{{ $canonical }}" /> diff --git a/themes/default/layouts/partials/head-csp.html b/themes/default/layouts/partials/head-csp.html index 9519e14..d34043e 100644 --- a/themes/default/layouts/partials/head-csp.html +++ b/themes/default/layouts/partials/head-csp.html @@ -1,42 +1,19 @@ -{{ $upgrade := "" }} -{{ if .Site.Params.csp.upgrade }} - {{ $upgrade = "upgrade-insecure-requests;" }} -{{- end -}} - -<meta name="referrer" content="{{ .Site.Params.csp.referrer }}"> +<meta name="referrer" content="{{ .Site.Params.site.referrer }}" /> -{{ printf ` -<meta - http-equiv="Content-Security-Policy" - content=" - %s - block-all-mixed-content; - default-src 'self'; - child-src %s; - connect-src %s; - font-src %s; - form-action %s; - frame-src %s; - img-src %s; - media-src %s; - object-src %s; - prefetch-src %s; - script-src %s; - script-src-elem %s; - style-src %s; - ">` - ($upgrade) - (delimit .Site.Params.csp.childsrc " ") - (delimit .Site.Params.csp.connectsrc " ") - (delimit .Site.Params.csp.fontsrc " ") - (delimit .Site.Params.csp.formaction " ") - (delimit .Site.Params.csp.framesrc " ") - (delimit .Site.Params.csp.imgsrc " ") - (delimit .Site.Params.csp.mediasrc " ") - (delimit .Site.Params.csp.objectsrc " ") - (delimit .Site.Params.csp.prefetchsrc " ") - (delimit .Site.Params.csp.scriptsrc " ") - (delimit .Site.Params.csp.scriptsrcelem " ") - (delimit .Site.Params.csp.stylesrc " ") - | safeHTML }} +{{ with .Site.Params.csp -}} +<meta http-equiv="Content-Security-Policy" +{{- printf ` content="` | safeHTMLAttr }} +{{ range $policy, $list := . -}} +{{- if reflect.IsSlice $list -}} +{{- print $policy | safeHTMLAttr }} +{{- range $list -}} +{{ print " " . | safeHTMLAttr }} +{{- end }}; +{{ else }} +{{- print $policy ";" | safeHTMLAttr }} +{{ end }} +{{- end -}} +{{- printf `"` | safeHTMLAttr -}} +/> +{{ end -}} diff --git a/themes/default/layouts/partials/head-css.html b/themes/default/layouts/partials/head-css.html new file mode 100644 index 0000000..6e9eb56 --- /dev/null +++ b/themes/default/layouts/partials/head-css.html @@ -0,0 +1,26 @@ +{{- $default := resources.Get "css/default.css" -}} +{{- $syntax := resources.Get "css/default-syntax.css" -}} +{{- $simple := resources.Get "css/default-simple.css" -}} +{{- $fast := resources.Get "css/default-fast.css" -}} +{{- $math := resources.Get "css/default-mathml.css" -}} + +{{- $css := + slice + $default + $syntax + | resources.Concat "css/bundle.css" + | resources.Minify + | fingerprint +-}} + +{{ if .Site.Params.site.production }} +<link rel="stylesheet" href="{{ $css.Permalink }}" title="Default" /> +{{ else }} +<link rel="stylesheet" href="{{ $default.Permalink }}" title="Default" /> +<link rel="stylesheet" href="{{ $syntax.Permalink }}" /> +{{ end }} + +<link rel="stylesheet" href="{{ $math.Permalink }}" /> + +<link rel="alternate stylesheet" href="{{ $simple.Permalink }}" /> +<link rel="alternate stylesheet" href="{{ $fast.Permalink }}" /> diff --git a/themes/default/layouts/partials/site-description.html b/themes/default/layouts/partials/head-description.html index 8d021de..89e4691 100644 --- a/themes/default/layouts/partials/site-description.html +++ b/themes/default/layouts/partials/head-description.html @@ -4,5 +4,5 @@ {{ .Summary }} {{- else -}} {{- block "description" . -}}{{- end -}} - {{- partial "site-title.html" . -}} + {{- partial "head-title.html" . -}} {{- end -}} diff --git a/themes/default/layouts/partials/head-discovery.html b/themes/default/layouts/partials/head-discovery.html new file mode 100644 index 0000000..8c7272f --- /dev/null +++ b/themes/default/layouts/partials/head-discovery.html @@ -0,0 +1,62 @@ +{{- $author := partial "function-authors-data.html" . -}} + +{{- with (eq .Page.Kind "home") -}} +<link + rel="alternate" + type="application/rss+xml" + title="{{ $.Site.Title }} Feed" + href="{{ "" | absURL }}/rss.xml" +/> + + {{- range $author := $.Site.Sections }} + <link + rel="alternate" + type="application/rss+xml" + title="{{ $author.Page.Type }}'s Feed" + href="{{ print $author.Permalink "rss.xml" | absURL }}" + /> + {{ end }} +{{- end -}} + +{{- with (eq .Page.Kind "section") -}} +<link + rel="alternate" + type="application/rss+xml" + title="{{ $author.name }}'s Feed" + href="{{ print ("" | absURL) "/" $.Section }}/rss.xml" +/> + +{{- with $author.feeds.rss }} + {{ range $author.feeds.rss }} + {{ $data := split . " " }} + {{- $url := delimit (first 1 $data) "" -}} + {{- $retitle := trim (delimit (after 1 $data) " ") " " -}} + {{- $retitle := and $retitle (print $retitle "'s Feed") -}} + + <link + rel="alternate" + type="application/rss+xml" + title="{{ or $retitle $url }}" + href="{{ $url }}" + /> + {{ end }} +{{ end }} +{{- end -}} + +{{- with (eq .Page.Kind "taxonomy") -}} +<link + rel="alternate" + type="application/rss+xml" + title="{{ $.Title }} Feed" + href="{{ $.Permalink }}rss.xml" +/> +{{- end -}} + +{{- with (eq .Page.Kind "term") -}} +<link + rel="alternate" + type="application/rss+xml" + title="#{{ lower $.Title }} Tag Feed" + href="{{ $.Permalink }}rss.xml" +/> +{{- end }} diff --git a/themes/default/layouts/partials/head-embed.html b/themes/default/layouts/partials/head-embed.html new file mode 100644 index 0000000..e9c44d7 --- /dev/null +++ b/themes/default/layouts/partials/head-embed.html @@ -0,0 +1,4 @@ +<head> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + {{- partial "head-css.html" . -}} +</head> diff --git a/themes/default/layouts/partials/head-js.html b/themes/default/layouts/partials/head-js.html new file mode 100644 index 0000000..a491eee --- /dev/null +++ b/themes/default/layouts/partials/head-js.html @@ -0,0 +1,8 @@ +{{- $index := resources.Get "js/index.js" -}} +{{- $js := $index | resources.Minify | fingerprint -}} + +{{ if .Site.Params.site.production }} +<script src="{{ $js.Permalink }}"></script> +{{ else }} +<script src="{{ $index.Permalink }}"></script> +{{ end }} diff --git a/themes/default/layouts/partials/head-manifest.html b/themes/default/layouts/partials/head-manifest.html index 6c154ed..6d01c32 100644 --- a/themes/default/layouts/partials/head-manifest.html +++ b/themes/default/layouts/partials/head-manifest.html @@ -1,15 +1,59 @@ -{{- $icon := resources.Get .Site.Params.webmanifest.logo -}} +{{- $author := .Section -}} +{{- $home := or ("" | absURL) "/" -}} +{{- $kind := in (slice "home" "taxonomy" "term") .Page.Kind -}} +{{- $logo := .Site.Params.webmanifest.logo -}} +{{- $profile := print "public/data/media/" $author "/" $author "-profile" -}} -{{- $icon32 := $icon.Fit "32x32" -}} -{{- $icon16 := $icon.Fit "16x16" -}} -{{- $appleTouchIcon := $icon.Fit "180x180" -}} +{{- if not $kind -}} + {{- $home = print ("" | absURL) "/" $author "/" -}} + {{- if fileExists (print $profile ".gif") -}} {{- $logo = (print $profile ".gif") -}} {{- end -}} + {{- if fileExists (print $profile ".webp") -}} {{- $logo = (print $profile ".webp") -}} {{- end -}} + {{- if fileExists (print $profile ".png") -}} {{- $logo = (print $profile ".png") -}} {{- end -}} +{{- end -}} -{{- $ico := $icon32.Content | resources.FromString "/favicon.ico" -}} +{{- with $logo = resources.Get $logo -}} -<link rel="icon" type="image/x-icon" href="data:image/ico;base64,{{ $icon32.Content | base64Encode }}"> -<link rel="icon" type="image/png" sizes="16x16" href="data:image/png;base64,{{ $icon16.Content | base64Encode }}"> -<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,{{ $icon32.Content | base64Encode }}"> -<link rel="apple-touch-icon" sizes="180x180" href="data:image/png;base64,{{ $appleTouchIcon.Content | base64Encode }}"> -<link rel="manifest" href="{{ .Site.BaseURL }}/site.webmanifest"> -<meta name="msapplication-TileColor" content="#da532c"> -<meta name="theme-color" content="#ffffff"> +{{- $16 := $logo.Fit "16x16" -}} +{{- $32 := $logo.Fit "32x32" -}} + +{{- $180 := $logo.Resize "180x180" -}} +{{- $192 := $logo.Resize "192x192" -}} +{{- $512 := $logo.Resize "512x512" -}} + +{{- if (eq $.Page.Kind "home") -}} + {{- $writeToFile := ($32.Content | resources.FromString "/favicon.ico").Permalink -}} +{{- end -}} + +<link rel="icon" type="image/x-icon" sizes="32x32" href="data:image/ico;base64,{{ $32.Content | base64Encode }}" /> +<link rel="icon" type="{{ $16.MediaType }}" sizes="16x16" href="data:{{ $16.MediaType }};base64,{{ $16.Content | base64Encode }}" /> +<link rel="icon" type="{{ $32.MediaType }}" sizes="32x32" href="data:{{ $32.MediaType }};base64,{{ $32.Content | base64Encode }}" /> +<link rel="apple-touch-icon" type="{{ $180.MediaType }}" sizes="180x180" href="data:{{ $180.MediaType }};base64,{{ $180.Content | base64Encode }}" /> + +<link rel="home" href="{{ $home }}" /> + +{{ "" -}} <!-- Newline --> + +{{- with $manifest := $.Site.Params.webmanifest -}} +<link rel="manifest" href='data:application/manifest+json;base64,{{ merge $manifest (dict + "start_url" $home + "icons" (slice + (dict + "sizes" "192x192" + "src" (print "data:" $192.MediaType ";base64," ($192.Content | base64Encode)) + "type" (print $192.MediaType)) + (dict + "sizes" "512x512" + "src" (print "data:" $512.MediaType ";base64," ($512.Content | base64Encode)) + "type" (print $512.MediaType)))) + | jsonify + | base64Encode +}}'> + +<meta name="msapplication-TileColor" content="#da532c" /> +<meta name="msapplication-config" content="none" /> +<meta name="msapplication-square70x70logo" content="none" /> +<meta name="msapplication-square150x150logo" content="data:{{ $180.MediaType }};base64,{{ $180.Content | base64Encode }}" /> +<meta name="msapplication-square310x310logo" content="none" /> +<meta name="msapplication-wide310x150logo" content="none" /> +{{- end -}} +{{- end -}} diff --git a/themes/default/layouts/partials/head-search.html b/themes/default/layouts/partials/head-search.html index 1bfed6c..89113ab 100644 --- a/themes/default/layouts/partials/head-search.html +++ b/themes/default/layouts/partials/head-search.html @@ -1,11 +1,5 @@ -{{- with .Site.Params.search.verification.google -}} -<meta name="google-site-verification" content="{{ . }}" /> -{{ end }} - -{{- with .Site.Params.search.verification.bing -}} -<meta name="msvalidate.01" content="{{ . }}" /> -{{ end }} - -{{- with .Site.Params.search.verification.yandex -}} -<meta name="yandex-verification" content="{{ . }}" /> +{{- with .Site.Params.search.verification -}} +{{- range $name, $content := . }} +<meta name="{{ $name }}" content="{{ $content }}" /> +{{- end }} {{ end }} diff --git a/themes/default/layouts/partials/head-title.html b/themes/default/layouts/partials/head-title.html new file mode 100644 index 0000000..fff4530 --- /dev/null +++ b/themes/default/layouts/partials/head-title.html @@ -0,0 +1,20 @@ +{{- $author := index .Site.Data.authors .Section -}} + +{{- if not (eq .Title $.Site.Title) -}} + {{- with $title := or .Title .Summary -}} + {{ $title }} — + {{ end }} +{{- end -}} + +{{- with $title := $.Site.Title -}} + {{- if (in (slice + "home" + "taxonomy" + "term" + ) $.Page.Kind) + -}} + {{ $title }} + {{- else -}} + {{ $author.title }} + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/partials/head.html b/themes/default/layouts/partials/head.html index 509b177..1668d57 100644 --- a/themes/default/layouts/partials/head.html +++ b/themes/default/layouts/partials/head.html @@ -1,67 +1,62 @@ -{{- partial "generate-authors" . -}} -{{- $data := - (dict - "Author" (index .Site.Data ((or .Params.author .Site.Author.default.home) | default "default")) - ) --}} +{{- $noindex := "" -}} +{{- $image := "" -}} +{{- $author := .Section -}} +{{- $kind := in (slice "home" "taxonomy" "term") .Page.Kind -}} -<!-- HTML Meta Tags --> -<meta charset="utf-8"> -<meta name="author" content="{{ partial "author-name.html" (dict "Data" $data) -}}"> -{{ if or .Params.Unlisted .Params.ExpiryDate -}} -<meta name="robots" content="noindex,nofollow"> -{{- else -}} -<meta name="robots" content="index,follow"> -{{- end }} -<meta name="viewport" content="width=device-width, initial-scale=1"> -<meta name="keywords" content="{{- partial "site-title.html" . -}}"> -{{ hugo.Generator }} -{{ with .Site.Params.site.refresh -}} -<meta http-equiv="refresh" content="{{ . }}"> +{{- if not $kind -}} + {{- $image = print ("" | absURL) "/data/media/" $author "/" $author "-profile.png" -}} +{{- end -}} + +{{- with or .Params.Feed .Params.Unlisted .Params.ExpiryDate -}} + {{- $noindex = "noindex,nofollow" -}} {{- end }} +<!-- HTML Meta Tags --> +<meta charset="utf-8" /> +<meta name="author" content="{{ or $author $.Site.Title -}}" /> +<meta name="robots" content="{{ or $noindex .Site.Params.site.robots "index,follow" }}" /> +<meta name="viewport" content="width=device-width, initial-scale=1" /> +<meta name="keywords" content="{{- partial "head-title.html" . -}}" /> +<meta name="generator" content="Hugo {{ hugo.Version }}" /> + <!-- Search Engine Tags --> -<meta itemprop="name" content="{{ partial "site-title.html" . -}}"> -<meta itemprop="description" content="{{ if .Params.summary }}{{ .Params.summary }}{{ else }}{{ .Summary }}{{ end }}"> -<meta itemprop="image" content="{{ .Site.BaseURL }}/{{ partial "author-user.html" (dict "Data" $data) -}}/media/profile/picture.png"> +<meta itemprop="name" content="{{ partial "head-title.html" . -}}" /> +<meta itemprop="description" content="{{- partial "head-description.html" . -}}" /> +<meta itemprop="image" content="{{ $image }}" /> <!-- Open Graph Meta Tags --> -<meta property="og:title" content="{{ partial "site-title.html" . -}}"> -<meta property="og:description" content="{{- partial "site-description.html" . -}}"> -<meta property="og:url" content="{{ .Permalink }}"> -<meta property="og:image" content="{{ .Site.BaseURL }}/{{ partial "author-user.html" (dict "Data" $data) -}}/media/profile/picture.png"> -<meta property="og:type" content="website"> -<meta property="article:published_time" content="{{ .Params.PublishDate }}"> -<meta property="article:modified_time " content="{{ .Params.LastMod }}"> +<meta property="og:title" content="{{ partial "head-title.html" . -}}" /> +<meta property="og:description" content="{{- partial "head-description.html" . -}}" /> +<meta property="og:url" content="{{ .Permalink }}" /> +<meta property="og:image" content="{{ $image }}" /> +<meta property="og:type" content="website" /> +<meta property="article:published_time" content="{{ (or .Params.PublishDate now.UTC) | time.Format "2006-01-02T15:04:05Z" }}" /> +<meta property="article:modified_time " content="{{ (or .Params.LastMod now.UTC) | time.Format "2006-01-02T15:04:05Z" }}" /> <!-- Twitter Meta Tags --> -<meta name="twitter:card" content="summary_large_image"> -<meta name="twitter:title" content="{{ partial "site-title.html" . -}}"> -<meta name="twitter:description" content="{{- partial "site-description.html" . -}}"> -<meta name="twitter:image" content="{{ .Site.BaseURL }}/{{ partial "author-user.html" (dict "Data" $data) -}}/media/profile/picture.png"> +<meta name="twitter:card" content="summary_large_image" /> +<meta name="twitter:title" content="{{ partial "head-title.html" . -}}" /> +<meta name="twitter:description" content="{{- partial "head-description.html" . -}}" /> +<meta name="twitter:image" content="{{ $image }}" /> + +<!-- Extra Meta Tags --> +<meta name='base-url' content="{{ "" | absURL }}" /> +<meta name='last-modified' content="{{ now.UTC.Format "Mon, 02 Jan 2006 15:04:05 GMT" }}" /> <!-- Search Verification --> {{- partial "head-search.html" . -}} -<!-- Link Tags --> -<link rel="home" href="{{ .Site.BaseURL }}/{{ partial "author-user.html" (dict "Data" $data) }}"> +<!-- Feed Discovery --> +{{- partial "head-discovery.html" . -}} -<!-- Style Sheets & Scripts --> -{{- $index := resources.Get "js/index.js" -}} -{{- $default := resources.Get "css/default.css" -}} -{{- $syntax := resources.Get "css/syntax-highlight-default.css" -}} +<!-- Canonicalization --> +{{- partial "head-canonical.html" . -}} -{{- $js := $index | resources.Minify | fingerprint -}} -{{- $css := slice $default $syntax | resources.Concat "css/bundle.css" | resources.Minify | fingerprint -}} +<!-- Styles --> +{{- partial "head-css.html" . -}} -{{ if .Site.Params.site.production }} -<link rel="stylesheet" href="{{ $css.Permalink }}"> -<script src="{{ $js.Permalink }}"></script> -{{ else }} -<link rel="stylesheet" href="{{ $default.Permalink }}"> -<link rel="stylesheet" href="{{ $syntax.Permalink }}"> -<script src="{{ $index.Permalink }}"></script> -{{ end }} +<!-- Scripts --> +{{- partial "head-js.html" . -}} <!-- Progressive Enhancement --> {{- partial "head-manifest.html" . -}} diff --git a/themes/default/layouts/partials/image-gradient.css.html b/themes/default/layouts/partials/image-gradient.css.html new file mode 100644 index 0000000..794ea8b --- /dev/null +++ b/themes/default/layouts/partials/image-gradient.css.html @@ -0,0 +1,18 @@ +{{- $colors := . -}} + +{{- with $colors -}} + background: + {{- range $key, $color := $colors -}} + {{- $last := sub (len $colors) 1 -}} + {{- $separator := "," -}} + {{- $color = $color -}} + {{- $position := "top" -}} + {{- if eq $last $key -}} + {{- $separator = ";" -}} + {{- end -}} + {{- if gt $key 0 -}} + {{- $position = "bottom" -}} + {{- end -}} + radial-gradient(ellipse at {{ $position }}, {{ $color }}, transparent){{ $separator }} + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/partials/menu-datetime.html b/themes/default/layouts/partials/menu-datetime.html new file mode 100644 index 0000000..20ef50e --- /dev/null +++ b/themes/default/layouts/partials/menu-datetime.html @@ -0,0 +1,22 @@ +{{- $href := print .Permalink -}} + +<meta-datetime> + <a href="{{ $href }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/calendar.svg")) -}} + <time + data-type="localDate" + datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" + > + {{ .Date | time.Format "Jan 2 2006" -}} + </time> + </a> + <a href="{{ $href }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/clock.svg")) -}} + <time + data-type="localTime" + datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" + > + {{ .Date | time.Format "15:04 MST" -}} + </time> + </a> +</meta-datetime> diff --git a/themes/default/layouts/partials/menu-embed.html b/themes/default/layouts/partials/menu-embed.html new file mode 100644 index 0000000..1b03d27 --- /dev/null +++ b/themes/default/layouts/partials/menu-embed.html @@ -0,0 +1,8 @@ +{{- $href := print .Permalink -}} + +<meta-embed> + <a href="{{ print $href "embed.html" }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/code.svg")) -}} + <span>Embed</span> + </a> +</meta-embed> diff --git a/themes/default/layouts/partials/menu-markdown.html b/themes/default/layouts/partials/menu-markdown.html new file mode 100644 index 0000000..6e54238 --- /dev/null +++ b/themes/default/layouts/partials/menu-markdown.html @@ -0,0 +1,13 @@ +{{- if not .ExpiryDate -}} + {{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} + {{- $source := print (path.Dir $relURL) ".md" -}} + {{- $href := print .Site.BaseURL "/" (partial "function-paths.html").markdown $source -}} + {{- $title := .File.LogicalName -}} + + <meta-source> + <a href="{{ $href }}" title="{{ $title }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/square-letter-m.svg")) -}} + <span>Markdown</span> + </a> + </meta-source> +{{- end -}} diff --git a/themes/default/layouts/partials/menu-permalink.html b/themes/default/layouts/partials/menu-permalink.html new file mode 100644 index 0000000..6f19559 --- /dev/null +++ b/themes/default/layouts/partials/menu-permalink.html @@ -0,0 +1,11 @@ +{{- $href := print .Permalink "#" (partial "card-id.html" .) -}} + +<meta-permalink> + <a title="#{{ partial "card-id.html" . }}" href="{{ $href }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/link.svg")) -}} + <span>Permalink</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-permalink> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/menu-plain.html b/themes/default/layouts/partials/menu-plain.html new file mode 100644 index 0000000..3dee808 --- /dev/null +++ b/themes/default/layouts/partials/menu-plain.html @@ -0,0 +1,9 @@ +{{- $href := print .Permalink -}} +{{- $plain := print $href "index.txt" -}} + +<meta-plain> + <a href="{{ $plain }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/notes.svg")) -}} + <span>Plaintext</span> + </a> +</meta-plain> diff --git a/themes/default/layouts/partials/meta-anchored.html b/themes/default/layouts/partials/meta-anchored.html new file mode 100644 index 0000000..872f98e --- /dev/null +++ b/themes/default/layouts/partials/meta-anchored.html @@ -0,0 +1,24 @@ +{{- if or .Weight .Params.Liked .Params.feed -}} + <meta-anchored> + {{- $author := .Section -}} + {{- partial "meta-via.html" . -}} + + {{- if .Weight -}} + <a data-anchored="pinned"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/pinned.svg")) }} + <span>Pinned</span> + </a> + {{- end -}} + + {{- if .Params.Marked -}} + <a + href="{{ "" | absURL }}/{{ $author }}/marks/#marks" + data-anchored="marked" + data-hover="" + > + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/bookmark.svg")) }} + <span>Marked</span> + </a> + {{- end -}} + </meta-anchored> +{{- end -}} diff --git a/themes/default/layouts/partials/meta-date-time.html b/themes/default/layouts/partials/meta-date-time.html deleted file mode 100644 index 127785b..0000000 --- a/themes/default/layouts/partials/meta-date-time.html +++ /dev/null @@ -1,18 +0,0 @@ -{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} - -{{- with .Params.feed.self -}} -<a href="{{ $.Site.BaseURL }}/{{ . }}"> -{{ else }} -<a href="{{ .Site.BaseURL }}/{{ $author.user }}/messages/{{ path.Base .Permalink }}#{{ partial "card-id.html" . }}"> -{{ end }} - <time - datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}" - title="{{ .Date | time.Format "Posted: Monday, January 2, 2006 at 15:04:05 MST" }} -{{ if .Lastmod.After .Date }}{{ .Lastmod | time.Format "Edited: Monday, January 2, 2006 at 15:04:05 MST" }}{{ end }}"> - {{ (.Date.Local | time.Format "3:04 PM Jan 2 2006") -}} - {{ if .Lastmod.After .Date }} - (edited) - {{ end }} - </time> -{{- /* This comment removes trailing newlines and white spaces. */ -}} -</a> diff --git a/themes/default/layouts/partials/meta-datetime.html b/themes/default/layouts/partials/meta-datetime.html new file mode 100644 index 0000000..e0329bb --- /dev/null +++ b/themes/default/layouts/partials/meta-datetime.html @@ -0,0 +1,14 @@ +<meta-datetime +title="{{ .Date | time.Format "Posted: Monday January 2 2006 at 15:04:05 MST" }} +{{ if .Lastmod.After .Date }}{{ .Lastmod | time.Format "Edited: Monday January 2 2006 at 15:04:05 MST" }}{{ end }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/calendar.svg")) -}} + <time datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}"> + {{ (.Date | time.Format "Mon Jan 2 2006") -}} + </time> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + {{ if .Lastmod.After .Date }} + <span>(edited)</span> + {{- end -}} +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-datetime> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-draft.html b/themes/default/layouts/partials/meta-draft.html index 87933a5..d441b9a 100644 --- a/themes/default/layouts/partials/meta-draft.html +++ b/themes/default/layouts/partials/meta-draft.html @@ -1 +1,15 @@ -<draft-label><a href="{{ .Site.BaseURL }}/{{ .Type }}/drafts/"><em>Draft</em></a></draft-label> +{{- if .Draft -}} + <meta-draft> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <em> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <a href="{{ .Site.BaseURL }}/{{ .Type }}/drafts/#drafts"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/edit.svg")) -}} + <span>Draft</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </em> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </meta-draft> +{{- end -}} diff --git a/themes/default/layouts/partials/meta-expiry-date.html b/themes/default/layouts/partials/meta-expiry-date.html deleted file mode 100644 index 275e04e..0000000 --- a/themes/default/layouts/partials/meta-expiry-date.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ $diff := now.Sub .ExpiryDate }} -{{ $duration := lang.FormatNumberCustom 0 (math.Round (mul (div $diff.Hours 24) -1)) }} - -<expiry-date> - <time - datetime= "{{ .ExpiryDate | time.Format "2006-01-02T15:04:05Z" }}" - title="Self destructs within {{ $duration }} days ({{ .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" }})"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/trash-2.svg")) }} - {{ .ExpiryDate | time.Format "Jan 2 2006" }} - </time> -</expiry-date> diff --git a/themes/default/layouts/partials/meta-expirydate.html b/themes/default/layouts/partials/meta-expirydate.html new file mode 100644 index 0000000..1feefd1 --- /dev/null +++ b/themes/default/layouts/partials/meta-expirydate.html @@ -0,0 +1,20 @@ +{{- if .ExpiryDate -}} + {{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} + {{- $diff := now.Sub .ExpiryDate -}} + {{- $duration := lang.FormatNumberCustom 0 (math.Round (mul (div $diff.Hours 24) -1)) -}} + {{- $date := .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" -}} + {{- $title := print "Self destructs within" " " $duration " " "days" " " "(" $date ")" -}} + {{- if $expired -}} + {{- $title = print "Self destructed" " " $date -}} + {{- end -}} + + <meta-expiry + title="{{ $title }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/trash-2.svg")) -}} + <time datetime= "{{- .ExpiryDate | time.Format "2006-01-02T15:04:05Z" -}}"> + {{- .ExpiryDate | time.Format "Jan 2 2006" -}} +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </time> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </meta-expiry> +{{- end -}} diff --git a/themes/default/layouts/partials/meta-handle.html b/themes/default/layouts/partials/meta-handle.html index ee7f975..ee0cc50 100644 --- a/themes/default/layouts/partials/meta-handle.html +++ b/themes/default/layouts/partials/meta-handle.html @@ -1,13 +1,25 @@ -{{- with .Params.feed.domain -}} -<a - title="{{ . }}" - href="http://{{ . }}"> - @{{ . -}} -</a> -{{- else -}} -<a - title="{{ partial "author-user.html" . }}@{{ (urls.Parse .Site.BaseURL).Host }}" - href="{{ .Site.BaseURL }}/{{ partial "author-user.html" . }}/#"> - @{{ (urls.Parse .Site.BaseURL).Host -}} -</a> +{{- $author := .Section -}} + +{{- $host := or (urls.Parse ("" | absURL)).Host "localhost" -}} +{{- $href := print ("" | absURL) "/" $author "/" -}} + +{{- $title := print $author "@" $host -}} + +{{- with .Params.feed -}} + {{- $host = $.Params.feed.domain -}} + {{- $href = or $.Params.feed.home (print "http://" $.Params.feed.domain) -}} + {{- $title = $.Params.feed.domain -}} {{- end -}} + +<meta-handle> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <a + title="{{ $title }}" + href="{{ $href }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/at-sign.svg")) -}} + <span>{{- $host -}}</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-handle> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-menu.html b/themes/default/layouts/partials/meta-menu.html new file mode 100644 index 0000000..f5e127d --- /dev/null +++ b/themes/default/layouts/partials/meta-menu.html @@ -0,0 +1,23 @@ +{{- $id := partial "card-id.html" . -}} + +<menu> + <li> + <label for="context-metadata-{{ $id }}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-down-circle.svg")) -}} + <span>menu</span> + </label> + </li> + <li> + <input hidden="" type="checkbox" id="context-metadata-{{ $id }}" /> + <context-menu position="anchor"> + + {{- partial "menu-markdown.html" . -}} + {{- partial "menu-plain.html" . -}} + {{- partial "menu-embed.html" . -}} + {{- partial "menu-permalink.html" . -}} + {{- partial "menu-datetime.html" . -}} + + </context-menu> + </li> +</menu> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-name.html b/themes/default/layouts/partials/meta-name.html index eb5990f..7c2ca61 100644 --- a/themes/default/layouts/partials/meta-name.html +++ b/themes/default/layouts/partials/meta-name.html @@ -1,9 +1,17 @@ -<h2> - <b> - {{- with .Params.feed.name -}} - {{ . }} - {{- else -}} - {{ partial "author-name.html" . }} - {{- end -}} - </b> -</h2> +{{- $author := partial "function-authors-data.html" . -}} + +{{- $href := print ("" | absURL) "/" $author.user "/" -}} +{{- $name := $author.name -}} +{{- $title := $name -}} + +{{- with .Params.feed -}} + {{- $href = or $.Params.feed.home (print "http://" $.Params.feed.domain) -}} + {{- $name = $.Params.feed.name -}} + {{- $title = $name -}} +{{- end -}} + +<meta-name title="{{ $title }}"> + <b><a href="{{ $href }}">{{ $name }}</a></b> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-name> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-read-time.html b/themes/default/layouts/partials/meta-read-time.html deleted file mode 100644 index b3b1839..0000000 --- a/themes/default/layouts/partials/meta-read-time.html +++ /dev/null @@ -1,10 +0,0 @@ -{{- $seconds := mul (div .WordCount 180.0) 60.0 -}} -{{- $seconds = printf "%.0f" $seconds -}} - -{{- if eq $seconds "0" -}} - {{- $seconds = "1" -}} -{{- end -}} - -<read-time title="Takes {{ $seconds }} second{{- if not (eq $seconds "1") -}}s{{- end }} to read"> - {{ $seconds }} sec -</read-time> diff --git a/themes/default/layouts/partials/meta-readtime.html b/themes/default/layouts/partials/meta-readtime.html new file mode 100644 index 0000000..43b5303 --- /dev/null +++ b/themes/default/layouts/partials/meta-readtime.html @@ -0,0 +1,12 @@ +{{- $seconds := mul (div .WordCount 180.0) 60.0 -}} +{{- $seconds = printf "%.0f" $seconds -}} +{{- if eq $seconds "0" -}} + {{- $seconds = "1" -}} +{{- end -}} + +<meta-readtime title="{{ $seconds }} second{{- if not (eq $seconds "1") -}}s{{- end }} to read"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/eye.svg")) }} + <span>{{ $seconds }}s read</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-readtime> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-source.html b/themes/default/layouts/partials/meta-source.html deleted file mode 100644 index a172726..0000000 --- a/themes/default/layouts/partials/meta-source.html +++ /dev/null @@ -1,14 +0,0 @@ -{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} -{{- $source := print $author.user "/messages/" .File.LogicalName -}} - -<cite> -{{- with .Params.feed.raw -}} -<a title="{{ $.Site.BaseURL }}/{{ . }}" href="{{ $.Site.BaseURL }}/{{ . }}"> -{{- else -}} -<a - href="{{ .Site.BaseURL }}/{{ partial "function-paths-markdown.html" }}/{{ $source }}" - title="{{ .Site.BaseURL }}/{{ partial "function-paths-markdown.html" }}/{{ $source }}"> -{{- end -}} - raw -</a> -</cite> diff --git a/themes/default/layouts/partials/title.html b/themes/default/layouts/partials/meta-title.html index 988167f..988167f 100644 --- a/themes/default/layouts/partials/title.html +++ b/themes/default/layouts/partials/meta-title.html diff --git a/themes/default/layouts/partials/meta-unlisted.html b/themes/default/layouts/partials/meta-unlisted.html new file mode 100644 index 0000000..df67e4e --- /dev/null +++ b/themes/default/layouts/partials/meta-unlisted.html @@ -0,0 +1,7 @@ +{{- if .Params.Unlisted -}} + <meta-unlisted title="This message is off the record"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/eye-off.svg")) -}} + <span>unlisted</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </meta-unlisted> +{{- end -}} diff --git a/themes/default/layouts/partials/meta-via.html b/themes/default/layouts/partials/meta-via.html new file mode 100644 index 0000000..c34ca73 --- /dev/null +++ b/themes/default/layouts/partials/meta-via.html @@ -0,0 +1,13 @@ +{{- $author := .Section -}} + +{{- if .Params.feed -}} + <a + data-hover="" + data-anchored="via" + href="{{ "" | absURL }}/{{ $author }}/feeds/#feeds" + title="{{ $author }}@{{ or (urls.Parse ("" | absURL)).Host "localhost" }}" + > + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) -}} + via @{{ $author }} + </a> +{{- end -}} diff --git a/themes/default/layouts/partials/meta-view.html b/themes/default/layouts/partials/meta-view.html new file mode 100644 index 0000000..33aee6b --- /dev/null +++ b/themes/default/layouts/partials/meta-view.html @@ -0,0 +1,12 @@ +{{- $href := or .Params.Feed.link .Permalink -}} + +<meta-view> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <a href="{{ $href }}" title="{{- partial "meta-title.html" . -}}"> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/external-link.svg")) -}} + <span>view</span> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-view> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/meta-word-count.html b/themes/default/layouts/partials/meta-word-count.html deleted file mode 100644 index d4a4065..0000000 --- a/themes/default/layouts/partials/meta-word-count.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") }} -{{ $limit := $author.wordlimit }} -{{ $wordLimit := gt .WordCount $limit }} -{{ $overLimit := sub .WordCount $limit }} - -<word-limit title="{{- if $wordLimit -}}{{ $overLimit }} words over the limit{{ else }} {{ .WordCount }} words {{ end }}"> - <word-count> - {{- if $wordLimit -}} - <em>{{ .WordCount }}</em> - {{- else -}} - {{ .WordCount }} - {{- end -}} - </word-count>/{{ $limit }} words -</word-limit> diff --git a/themes/default/layouts/partials/meta-wordcount.html b/themes/default/layouts/partials/meta-wordcount.html new file mode 100644 index 0000000..b6ec95e --- /dev/null +++ b/themes/default/layouts/partials/meta-wordcount.html @@ -0,0 +1,33 @@ +{{- $author := partial "function-authors-data.html" . -}} +{{- $limit := $author.wordlimit -}} +{{- $wordLimit := gt .WordCount $limit -}} +{{- $overLimit := sub .WordCount $limit -}} +{{- $bitCount := lang.FormatNumberCustom 0 (len .Content) -}} + +<meta-wordcount +title=" +{{- if $wordLimit -}} + {{ $overLimit }} words over the limit + {{- else -}} + {{ .WordCount }} words +{{- end }} +{{ $bitCount }} bits +{{- /* This comment removes trailing newlines and white spaces. */ -}} +"> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + <word-limit> + {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/notes.svg")) -}} + <word-count> + {{- if $wordLimit -}} + <em>{{ .WordCount }}</em> + {{- else -}} + <sup>{{ .WordCount }}</sup> + {{- end -}} + /<sub>{{ $limit }}</sub> words +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </word-count> +{{- /* This comment removes trailing newlines and white spaces. */ -}} + </word-limit> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +</meta-wordcount> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/partials/navigator-left.html b/themes/default/layouts/partials/navigator-left.html index 41aaa2e..1a3bd1d 100644 --- a/themes/default/layouts/partials/navigator-left.html +++ b/themes/default/layouts/partials/navigator-left.html @@ -6,7 +6,7 @@ <a id="nav-left-{{ path.Base .Identifier }}" href="{{ .URL | absURL }}"> <span>{{ .Name }}</span> {{ with .Identifier }} - {{ $icon := print (partial "function-paths-static.html") "/icons/" . ".svg" }} + {{ $icon := print (partial "function-paths.html").static "/icons/" . ".svg" }} {{ safeHTML (readFile $icon) }} {{ end }} </a> diff --git a/themes/default/layouts/partials/navigator-middle-walk.html b/themes/default/layouts/partials/navigator-middle-walk.html deleted file mode 100644 index a0832a8..0000000 --- a/themes/default/layouts/partials/navigator-middle-walk.html +++ /dev/null @@ -1,15 +0,0 @@ -{{ if .Context.Site.Menus.main }} - {{ range .Context.Site.Menus.main }} - <icon-navigator hidden> - <icon-button> - <a id="nav-middle-{{ path.Base .Identifier }}" href="{{ .URL | absURL }}"> - {{ with .Identifier }} - {{ $icon := print (partial "function-paths-static.html") "/icons/" . ".svg" }} - {{ safeHTML (readFile $icon) }} - {{ end }} - <small>{{ delimit (first 1 (split .Name " ")) " " }}</small> - </a> - </icon-button> - </icon-navigator> - {{ end }} -{{ end }} diff --git a/themes/default/layouts/partials/navigator-middle.html b/themes/default/layouts/partials/navigator-middle.html index 418b237..7259b43 100644 --- a/themes/default/layouts/partials/navigator-middle.html +++ b/themes/default/layouts/partials/navigator-middle.html @@ -1,22 +1,29 @@ -{{ $id := .Id }} -{{ $href := .Href }} +{{- $href := or .Href "#" -}} +{{- $id := or .Id "top" -}} +{{- $label := title $id -}} +{{- $icon := readFile (print (partial "function-paths.html").static "/icons/feather/arrow-up.svg") -}} +{{- $refresh := readFile (print (partial "function-paths.html").static "/icons/feather/refresh-cw.svg") -}} + +{{- with .Icon -}} + {{- $icon = readFile (print (partial "function-paths.html").static "/icons/feather/" . ".svg") -}} +{{- end -}} + +{{- with .IconLabel -}} + {{- $label = . -}} +{{- end -}} <nav> <icon-button> <a - id="{{ or $id "top" }}" - href="{{ or $href "#" }}" + data-update="" + id="{{ $id }}" + href="{{ $href }}" + target="_self" > - {{ with .Icon }} - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/" . ".svg")) }} - {{ else }} - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/arrow-up.svg")) }} - {{ end }} - {{ with .IconLabel }} - <small>{{ . }}</small> - {{ else }} - <small>Top</small> - {{ end }} + {{ safeHTML $icon }} + {{ safeHTML $refresh }} + <small>{{ $label }}</small> + <small>Update</small> </a> </icon-button> @@ -29,29 +36,40 @@ {{ end }} </section> - {{ partial "navigator-middle-walk.html" . }} + {{ if .Context.Site.Menus.main }} + {{ range .Context.Site.Menus.main }} + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-{{ path.Base .Identifier }}" href="{{ .URL | absURL }}"> + {{ with .Identifier }} + {{ $icon := print (partial "function-paths.html").static "/icons/" . ".svg" }} + {{ safeHTML (readFile $icon) }} + {{ end }} + <small>{{ delimit (first 1 (split .Name " ")) " " }}</small> + </a> + </icon-button> + </icon-navigator> + {{ end }} + {{ end }} - <search-entry id="search-frame"> - <form - id="search-form" - action="https://lite.duckduckgo.com/lite/"> - <input required - id="search-input" - name="q" - value="" - type="search" - autocomplete="off" - spellcheck="false" + <search-box> + <form role="search" action="https://lite.duckduckgo.com/lite/"> + <input aria-autocomplete="list" aria-label="search input" + autocomplete="off" + id="search" + name="q" + required="" + spellcheck="false" + type="search" + value="" /> - <button id="search-submit"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/search.svg")) }} + <button type="submit"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/search.svg")) }} <small>Search</small> </button> - <ul hidden id="search-results"></ul> + <ul hidden=""></ul> </form> - </search-entry> - </nav> - -<navigation-separator><hr hidden></navigation-separator> + </search-box> +</nav> diff --git a/themes/default/layouts/partials/navigator-right-default.html b/themes/default/layouts/partials/navigator-right-default.html deleted file mode 100644 index 44b4bbd..0000000 --- a/themes/default/layouts/partials/navigator-right-default.html +++ /dev/null @@ -1,4 +0,0 @@ -{{- partial "author-list.html" . -}} -{{- range first 1 (where .Site.Pages "Params.Author" .Site.Author.default.webring) -}} - {{- partial "web-ring.html" . -}} -{{- end -}} diff --git a/themes/default/layouts/partials/navigator-right.html b/themes/default/layouts/partials/navigator-right.html index abe0d28..c2e6f4c 100644 --- a/themes/default/layouts/partials/navigator-right.html +++ b/themes/default/layouts/partials/navigator-right.html @@ -1,3 +1,7 @@ -{{- partial "author-list.html" . -}} -{{- partial "gallery-images.html" . -}} -{{- partial "web-ring.html" . -}} +{{- partial "author-list.html" . -}} + +{{- if (in (slice "page" "section") .Page.Kind) -}} + {{- partial "gallery.html" . -}} + {{- partial "following-list.html" . -}} + {{- partial "webring.html" . -}} +{{- end -}} diff --git a/themes/default/layouts/partials/navigator.css.html b/themes/default/layouts/partials/navigator.css.html new file mode 100644 index 0000000..7485408 --- /dev/null +++ b/themes/default/layouts/partials/navigator.css.html @@ -0,0 +1,19 @@ +icon-navigator a[href="{{ "" | absURL }}{{ .Link }}"], +column-base[position="left"] nav a[href="{{ "" | absURL }}{{ .Link }}"] { + font-weight: 700; +} + +column-base[position="left"] nav a[href="{{ "" | absURL }}{{ .Link }}"] { + background-color: #f0f6ff; + background-color: var(--hover-background-alternate); +} + +icon-navigator a[href="{{ "" | absURL }}{{ .Link }}"] svg { + fill: #cce0ff; + fill: var(--icon-hover-background); +} + +icon-navigator a[href="{{ "" | absURL }}{{ .Link }}"]:focus svg { + fill: #cce0ff; + fill: var(--icon-focus-background); +} diff --git a/themes/default/layouts/partials/pagination.html b/themes/default/layouts/partials/pagination.html index d9360c4..e64bfcf 100644 --- a/themes/default/layouts/partials/pagination.html +++ b/themes/default/layouts/partials/pagination.html @@ -1,75 +1,50 @@ {{- with .Paginator -}} - <paginator-navigation{{ if eq .TotalPages 1 }} hidden {{ end }}> - {{ if and .HasPrev .First }} - <a - href="{{ .First.URL }}" - aria-label="First" - title="First" - role="button"> - First - </a> - {{ else }} - <button - data-invisible - title="Disabled" - aria-label="First"> - First - </button> - {{- end -}} + {{- $firstTitle := "hidden" -}} + {{- $prevTitle := "hidden" -}} + {{- $nextTitle := "hidden" -}} + {{- $lastTitle := "hidden" -}} + {{- $firstHref := "/" -}} + {{- $prevHref := "/" -}} + {{- $nextHref := "/" -}} + {{- $lastHref := "/" -}} - {{ with .Prev }} - <a - href="{{ .URL }}" - aria-label="Back" - title="Back" - role="button"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/arrow-left.svg")) }} - Back - </a> - {{ else }} - <button - data-invisible - title="Disabled" - aria-label="Back"> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/arrow-left.svg")) }} - Back - </button> - {{- end -}} + {{- if and .HasPrev .First -}} + {{- $firstHref = .First.URL | absURL -}} + {{- $firstTitle = "Newest" -}} + {{- end -}} - {{ if .Next }} - <a - href="{{ .Next.URL }}" - aria-label="Next" - title="Next" - role="button"> - Next - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/arrow-right.svg")) }} - </a> - {{ else }} - <button - data-invisible - title="Disabled" - aria-label="Next"> - Next - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/arrow-right.svg")) }} - </button> - {{- end -}} + {{- with .Prev -}} + {{- $prevHref = .URL | absURL -}} + {{- $prevTitle = "Newer" -}} + {{- end -}} - {{ if and .HasNext .Last }} - <a - href="{{ .Last.URL }}" - aria-label="Last" - title="Next" - role="button"> - Last - </a> - {{ else }} - <button - data-invisible - title="Disabled" - aria-label="Last"> - Last - </button> - {{- end -}} - </paginator-navigation> -{{ end }} + {{- if .Next -}} + {{- $nextHref = .Next.URL | absURL -}} + {{- $nextTitle = "Older" -}} + {{- end -}} + + {{- if and .HasNext .Last -}} + {{- $lastHref = .Last.URL | absURL -}} + {{- $lastTitle = "Oldest" -}} + {{- end -}} + + <nav{{ if le .TotalPages 1 }} hidden="" {{ end }} data-type="pagination"> + <a rel="first" href="{{ $firstHref }}" title="{{ $firstTitle }}" > + <span>{{ $firstTitle }}</span> + </a> + + <a rel="prev" href="{{ $prevHref }}" title="{{ $prevTitle }}"> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-left.svg")) }} + <span>{{ $prevTitle }}</span> + </a> + + <a rel="next" href="{{ $nextHref }}" title="{{ $nextTitle }}"> + <span>{{ $nextTitle }}</span> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/arrow-right.svg")) }} + </a> + + <a rel="last" href="{{ $lastHref }}" title="{{ $lastTitle }}" data-count="{{ .TotalPages }}"> + <span>{{ $lastTitle }}</span> + </a> + </nav> +{{- end -}} diff --git a/themes/default/layouts/partials/profile-tabs.html b/themes/default/layouts/partials/profile-tabs.html index 4f2c3fb..1ca632b 100644 --- a/themes/default/layouts/partials/profile-tabs.html +++ b/themes/default/layouts/partials/profile-tabs.html @@ -1,13 +1,44 @@ -{{ $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") }} - -<tab-list> - <aside> - <a href="{{ .Site.BaseURL }}/{{ $author.user }}">Messages</a> - <a href="{{ .Site.BaseURL }}/{{ $author.user }}/feeds/">Feeds</a> - <a href="{{ .Site.BaseURL }}/{{ $author.user }}/media/">Media</a> - <a href="{{ .Site.BaseURL }}/{{ $author.user }}/likes/">Likes</a> - {{- if .Site.BuildDrafts }} - <a href="{{ .Site.BaseURL }}/{{ $author.user }}/drafts/">Drafts</a> +{{- $author := partial "function-authors-data.html" . -}} +{{- $path := print ("" | absURL) "/" $author.user -}} + +<tab-bar> + <nav> + <a + data-label="{{ $label := "Posts" }}{{ $label }}" + href="{{ $path }}/#{{ lower $label }}"> + {{ $label }} + <span data-scroll="" id="{{ lower $label }}"></span> + </a> + + <a + data-label="{{ $label := "Feeds" }}{{ $label }}" + href="{{ $path }}/{{ lower $label }}/#{{ lower $label }}"> + {{ $label }} + <span data-scroll="" id="{{ lower $label }}"></span> + </a> + + <a + data-label="{{ $label := "Media" }}{{ $label }}" + href="{{ $path }}/{{ lower $label }}/#{{ lower $label }}"> + {{ $label }} + <span data-scroll="" id="{{ lower $label }}"></span> + </a> + + <a + data-label="{{ $label := "Marks" }}{{ $label }}" + href="{{ $path }}/{{ lower $label }}/#{{ lower $label }}"> + {{ $label }} + <span data-scroll="" id="{{ lower $label }}"></span> + </a> + + {{- if $.Site.BuildDrafts }} + <a + data-draft="" + data-label="{{ $label := "Drafts" }}{{ $label }}" + href="{{ $path }}/{{ lower $label }}/#{{ lower $label }}"> + {{ $label }} + <span data-scroll="" id="{{ lower $label }}"></span> + </a> {{- end }} - </aside> -</tab-list> + </nav> +</tab-bar> diff --git a/themes/default/layouts/partials/profile.html b/themes/default/layouts/partials/profile.html index 1f01b23..e0c339b 100644 --- a/themes/default/layouts/partials/profile.html +++ b/themes/default/layouts/partials/profile.html @@ -1,52 +1,42 @@ -{{- $author := index .Site.Data ((or .Params.author .Site.Author.default.user) | default "default") -}} +{{- $author := partial "function-authors-data.html" . -}} -<micro-header> +<profile-box> + <picture data-type="banner"> + {{ partial "author-header.html" . }} + </picture> - <micro-header-image> - <picture> - {{ partial "author-header.html" . }} - </picture> - </micro-header-image> - - <micro-header-picture> - <picture> - {{ partial "author-picture.html" . }} - </picture> - </micro-header-picture> + <picture data-type="profile"> + {{ partial "author-picture.html" . }} + </picture> <section> - <micro-header-title> + <aside> <h2>{{ $author.name }}</h2> <h3>@{{ $author.user }}</h3> - </micro-header-title> - <micro-header-description> - <p> - {{ $author.description | markdownify }} - </p> - </micro-header-description> + </aside> + <p>{{ $author.description | markdownify }}</p> </section> <footer> <p> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/map-pin.svg")) }} + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/map-pin.svg")) }} <span>{{- $author.place | markdownify -}}</span> </p> <p> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/globe.svg")) }} + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/globe.svg")) }} <a href="{{ $author.domain.url }}"> {{- $author.domain.host | markdownify -}} </a> </p> <p> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/clock.svg")) }} + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/feather/clock.svg")) }} <span>{{- $author.epoch | markdownify -}}</span> </p> <p> - {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/user.svg")) }} - <span><b>{{ with $author.webring.rss }}{{ len . }}{{ else }} 0 {{ end }}</b> Following</span> + {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) }} + <span><b>{{ with $author.feeds.rss }}{{ len . }}{{ else }} 0 {{ end }}</b> Feeds</span> </p> </footer> +</profile-box> -</micro-header> - -{{ partial "profile-tabs.html" . }} +{{- partial "profile-tabs.html" . -}} diff --git a/themes/default/layouts/partials/render-embed.html b/themes/default/layouts/partials/render-embed.html new file mode 100644 index 0000000..77b6b8f --- /dev/null +++ b/themes/default/layouts/partials/render-embed.html @@ -0,0 +1,31 @@ +{{- $pageContext := . -}} +{{- $format := "embed.html" -}} + +{{- $page := print "public/" (strings.TrimPrefix + $pageContext.Page.Site.BaseURL + $pageContext.Page.Permalink + ) $format +-}} + +{{- $modified := partial "function-page-modified.html" + (dict + "Context" $pageContext + "Format" $format + ) +-}} + +{{- with $embed := resources.Get $page -}} + {{- if (in $embed.Content "/data/media/404.png") -}} + {{- $modified = true -}} + {{- end -}} +{{- end -}} + +{{- if $modified -}} + {{- $pageContext.Render "summary" -}} +{{- else -}} + {{- with $embed := resources.Get $page -}} + {{- range $chunks := after 1 (split ($embed.Content) "</head>") -}} + {{- $chunks | safeHTML -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/themes/default/layouts/partials/site-title.html b/themes/default/layouts/partials/site-title.html deleted file mode 100644 index afa17fa..0000000 --- a/themes/default/layouts/partials/site-title.html +++ /dev/null @@ -1,15 +0,0 @@ -{{ $author := index .Site.Data ((or .Params.author .Site.Author.default.title) | default "default") }} - -{{- if not (eq .Title $.Site.Title) -}} - {{- with or .Title .Summary -}} - {{ . }} — - {{ end }} -{{- end -}} - -{{- with $.Site.Title -}} - {{ if $.IsHome -}} - {{ . }} - {{- else -}} - {{ $author.blogtitle }} - {{- end -}} -{{- end -}} diff --git a/themes/default/layouts/partials/styles-navigator.html b/themes/default/layouts/partials/styles-navigator.html deleted file mode 100644 index 80ebcd6..0000000 --- a/themes/default/layouts/partials/styles-navigator.html +++ /dev/null @@ -1,14 +0,0 @@ -icon-navigator a[href="{{ "" | absURL }}{{ .Link }}"], -column-left nav a[href="{{ "" | absURL }}{{ .Link }}"] { - font-weight: 700; -} - -column-left nav a[href="{{ "" | absURL }}{{ .Link }}"] { - background-color: #f0f6ff; - background-color: var(--hover-background-alternate); -} - -icon-navigator a[href="{{ "" | absURL }}{{ .Link }}"] svg { - fill: #e5f0ff; - fill: var(--active-background-alternate); -} diff --git a/themes/default/layouts/partials/tags.html b/themes/default/layouts/partials/tags.html index d601b27..29202d0 100644 --- a/themes/default/layouts/partials/tags.html +++ b/themes/default/layouts/partials/tags.html @@ -1,5 +1,19 @@ -{{- with .Params.tags }} - {{- range $tags, $tag := sort . }} - <a href="{{ "tags/" | relURL }}{{ $tag | urlize }}/">#{{ $tag }}</a> - {{ end }} -{{ end }} +{{- $format := .Format -}} +{{- $pageContext := .Context -}} +{{- $path := "tags/" -}} +{{- $url := $path | relURL -}} + +{{- with $pageContext.Params.tags -}} + {{- range $tags, $tag := sort $pageContext.Params.tags -}} + {{- if (eq $format "rss") -}} + {{- $url = $path | absURL -}} + {{- end -}} + + {{- $link := print $url ((lower $tag) | urlize) "/" -}} + {{- print "[#" (lower $tag) "](" $link ")" | markdownify -}} + + {{- if (eq $format "rss") -}} {{- end }} + {{ end -}} +{{- else -}} + <a href="{{ "tags/" | absURL }}">#untagged</a> +{{- end -}} diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index 79df910..9e28e3d 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -1,48 +1,74 @@ {{- $cache := "" -}} +{{- $source := "" -}} +{{- $timestamp := "" -}} {{- $caption := .Caption -}} +{{- $remote := .Remote -}} {{- $public := print "public/" .Source -}} -{{- $timestamp := print "#t=" .Start "," .End -}} {{- $immutable := print (.RelURL | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}} {{- $extension := path.Ext .Source -}} -{{- $fileCache := print $.Author "/media/" $immutable $extension -}} +{{- $storage := print $.Author "/media/" $immutable $extension -}} +{{- $cached := fileExists (path.Join "public/" $storage) -}} -{{- if not (fileExists (path.Join "public/" $fileCache)) -}} - {{- with $remote := resources.GetRemote .Source -}} +{{- if .Start -}} + {{- $timestamp = print "#t=" .Start -}} +{{- end -}} + +{{- if .End -}} + {{- $timestamp = print "#t=," .End -}} +{{- end -}} + +{{- if and .Start .End -}} + {{- $timestamp = print "#t=" .Start "," .End -}} +{{- end -}} + +{{- if not $cached -}} + {{- with $remote := cond (default true $.Context.Site.Params.site.offline) false (resources.GetRemote .Source) -}} {{- with .Err -}} - {{- if fileExists $public -}} - {{- else -}} + {{- warnf "Video fetch %s" . -}} + {{- if not (fileExists $public) -}} {{- $caption = "No local video data found for source" -}} {{- end -}} {{- else -}} + {{- $cache = $remote | resources.Copy $storage -}} + {{- $cache = $cache.Permalink -}} {{- end -}} - {{- $cache = . | resources.Copy $fileCache -}} - {{- $cache = $cache.RelPermalink -}} {{- else -}} - {{- $caption = "No remote video data found for source" -}} + {{- $caption = "Unable to load remote source data" -}} {{- end -}} {{- else -}} - {{- $cache = resources.Get (path.Join "public/" $fileCache) -}} - {{- $cache = $cache.Content | resources.FromString $fileCache -}} - {{- $cache = $cache.RelPermalink -}} + {{- with $cache = resources.Get (path.Join "public/" $storage) -}} + {{- $cache = print ("" | absURL) (strings.TrimLeft "public" $cache) -}} + {{- end -}} +{{- end -}} + +{{- $source = $cache -}} + +{{- if .Remote -}} + {{- $source = .Source -}} {{- end -}} <video-container> <video title="{{ .Title }}" preload="{{ .Preload }}" + data-orientation="{{ .Orientation }}" {{ with .Poster }} poster="{{ . }}" {{ end -}} {{ with .Width }} width="{{ . }}" {{ end -}} {{ with .Height }} height="{{ . }}" {{ end -}} - {{ .Options | safeHTMLAttr }}> - <source src="{{ or .Source .Cache }}{{ $timestamp }}"> - <p> - Sorry, your browser does not support embedded videos. Here is a - <a href="{{ .Source }}">link to the video</a> instead. - </p> + {{- range $value := (split .Options " ") }} + {{- printf `%s=""` $value | safeHTMLAttr }} + {{ end -}} + > + <source src="{{ $source }}{{ $timestamp }}" /> + {{ print "Video: " $caption "." | markdownify }} + <p> + Sorry, your browser does not support embedded videos. Here is a + <a href="{{ .Source }}">link to the video</a> instead. + </p> </video> <footer> {{ $caption | markdownify }} - <br> + <br /> Index: {{ with $cache }} {{ print "[Cache](" . ")" | markdownify }} · {{ end }} {{ print "[Source](" .Source ")" | markdownify }} </footer> diff --git a/themes/default/layouts/partials/web-ring.html b/themes/default/layouts/partials/web-ring.html deleted file mode 100644 index c3d73b4..0000000 --- a/themes/default/layouts/partials/web-ring.html +++ /dev/null @@ -1 +0,0 @@ -{{ partial "generate-feeds" . }} diff --git a/themes/default/layouts/partials/webring.html b/themes/default/layouts/partials/webring.html new file mode 100644 index 0000000..009e2fc --- /dev/null +++ b/themes/default/layouts/partials/webring.html @@ -0,0 +1,15 @@ +{{- $author := partial "function-authors-data.html" . -}} +{{- $webring := print "public/" .Section "/webring.html" -}} + +<web-ring> + <h1>Web Ring</h1> + {{ if and $author.feeds.rss (fileExists $webring) }} + <aside> + {{- (resources.Get $webring).Content | safeHTML -}} + </aside> + {{ else }} + <footer> + <code>No items found!</code> + </footer> + {{ end }} +</web-ring> diff --git a/themes/default/layouts/shortcodes/abbr.html b/themes/default/layouts/shortcodes/abbr.html index 0edff43..61a2e32 100644 --- a/themes/default/layouts/shortcodes/abbr.html +++ b/themes/default/layouts/shortcodes/abbr.html @@ -1,7 +1,8 @@ {{- $abbr := default "TL;DR:" (.Get "abbr" | default (.Get 0)) -}} {{- $title := default "Too long, didn't read" (.Get "title" | default (.Get 1)) -}} +{{- $hash := print (truncate 4 "" (sha256 .Page.RelPermalink)) (truncate 4 "" (sha256 $abbr)) .Ordinal -}} -{{- $id := delimit (shuffle (seq 0 20)) "" -}} -<input hidden type="checkbox" id="abbr-{{ $id }}" /> -<abbr title="{{ $title }}"><label for="abbr-{{ $id }}">{{ $abbr | markdownify }}</label></abbr> +<input hidden="" type="checkbox" id="abbr-{{ $hash }}" /> +{{- /* This comment removes trailing newlines and white spaces. */ -}} +<abbr title="{{ $title }}"><label for="abbr-{{ $hash }}">{{ $abbr | markdownify }}</label></abbr> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/animate.html b/themes/default/layouts/shortcodes/animate.html new file mode 100644 index 0000000..b245596 --- /dev/null +++ b/themes/default/layouts/shortcodes/animate.html @@ -0,0 +1,11 @@ +{{- $type := default "default" (.Get "type" | default (.Get 0)) -}} +{{- $text := default "animate" (.Get "text" | default (.Get 1)) -}} + +{{- $letters := split $text "" -}} + +<text-animation {{ $type }}=""> +{{- range $value, $letter := $letters -}} + <span style="--frame:{{ $value }}">{{ $letter }}</span> +{{- end -}} +</text-animation> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/animate.rss.xml b/themes/default/layouts/shortcodes/animate.rss.xml new file mode 100644 index 0000000..c1f04b8 --- /dev/null +++ b/themes/default/layouts/shortcodes/animate.rss.xml @@ -0,0 +1,5 @@ +{{- $type := default "default" (.Get "type" | default (.Get 0)) -}} +{{- $text := default "animate" (.Get "text" | default (.Get 1)) -}} + +<a title="{{ $type }} animation" href="{{ .Page.Permalink }}">{{ $text }}</a> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/attach.html b/themes/default/layouts/shortcodes/attach.html new file mode 100644 index 0000000..55b5744 --- /dev/null +++ b/themes/default/layouts/shortcodes/attach.html @@ -0,0 +1,58 @@ +{{- $url := default "/canory/media/2city12p.pdf" (.Get "url" | default (.Get 0)) -}} +{{- $title := default "Attachment" (.Get "title" | default (.Get 1)) -}} +{{- $caption := default $title (.Get "caption" | default (.Get 2)) -}} +{{- $remote := default "" (.Get "remote" | default (.Get 3)) -}} + +{{- $data := "" -}} +{{- $cache := "" -}} +{{- $author := .Page.Section -}} +{{- $extension := path.Ext $url -}} +{{- $immutable := print $url | anchorize -}} +{{- $localFile := path.Join "public/" $url -}} +{{- $type := "application/octet-stream" -}} +{{- $storage := print $author "/media/" $immutable $extension -}} +{{- $cached := fileExists (path.Join "public/" $storage) -}} + +{{- if not $cached -}} + {{- with $remote := cond (default true $.Page.Site.Params.site.offline) false (resources.GetRemote $url) -}} + {{- with .Err -}} + {{- if not (fileExists $localFile) -}} + {{- $caption = "No local attachment data found for source" -}} + {{- warnf "Attachment local fetch error: %s" $url -}} + {{- end -}} + {{- else -}} + {{- $type = $remote.MediaType -}} + {{- $cache = $remote | resources.Copy $storage -}} + {{- $cache = $cache.Permalink -}} + {{- end -}} + {{- else -}} + {{- $caption = "Unable to load remote source data" -}} + {{- warnf "Attachment remote fetch error: %s" $url -}} + {{- end -}} +{{- else -}} + {{- with $cache = resources.Get (path.Join "public/" $storage) -}} + {{- $type = .MediaType -}} + {{- $cache = print ("" | absURL) (strings.TrimLeft "public" $cache) -}} + {{- end -}} +{{- end -}} + +{{- $data := or $cache $url -}} + +{{- if $remote -}} + {{- $data = $url -}} +{{- end -}} + +<document-attachment title="{{ $title }}"> + <object type="{{ $type }}" data="{{ $data }}"> + <p> + Your browser does not support the <code>{{ $type }}</code> plugin. Here's a + <a rel="canonical" href="{{ $data }}">link to the file</a> instead. + </p> + </object> + <footer> + {{ $caption | markdownify }} + <br /> + Index: {{ with $cache }} {{ print "[Cache](" $cache ")" | markdownify }} · {{ end }} + {{ print "[Source](" $url ")" | markdownify }} + </footer> +</document-attachment> diff --git a/themes/default/layouts/shortcodes/disclose.html b/themes/default/layouts/shortcodes/disclose.html new file mode 100644 index 0000000..231561b --- /dev/null +++ b/themes/default/layouts/shortcodes/disclose.html @@ -0,0 +1,13 @@ +{{- $text := default "Content Warning: " (.Get "text" | default (.Get 0)) -}} +{{- $hash := print (truncate 4 "" (sha256 .Page.RelPermalink)) (truncate 4 "" (sha256 $text)) .Ordinal -}} + +{{- if gt (len .Inner) 1 -}} + {{- $text = .Inner -}} +{{- end -}} + +<details id="disclosure-{{ $hash }}" data-disclosure=""> + <summary> + {{- (or $.Page.Params.title $text) | markdownify }} + </summary> +</details> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/footer.html b/themes/default/layouts/shortcodes/footer.html deleted file mode 100644 index 579913d..0000000 --- a/themes/default/layouts/shortcodes/footer.html +++ /dev/null @@ -1,7 +0,0 @@ -{{- $text := default "Block Quote" (.Get "text" | default (.Get 0)) -}} - -{{- if gt (len .Inner) 1 -}} - {{ $text = .Inner }} -{{- end -}} - -<span>{{ $text | markdownify }}</span> diff --git a/themes/default/layouts/shortcodes/gist.html b/themes/default/layouts/shortcodes/gist.html deleted file mode 100644 index c475672..0000000 --- a/themes/default/layouts/shortcodes/gist.html +++ /dev/null @@ -1,9 +0,0 @@ -{{- $user := default "gdb" (.Get "user" | default (.Get 0)) -}} -{{- $gist := default "b6365e79be6052e7531e7ba6ea8caf23" (.Get "gist" | default (.Get 1)) -}} -{{- $file := default "" (.Get "file" | default (.Get 2)) -}} - -<github-gist> - <script - src="https://gist.github.com/{{ $user }}/{{ $gist }}.js?file={{ $file }}"> - </script> -</github-gist> diff --git a/themes/default/layouts/shortcodes/imgur-video.html b/themes/default/layouts/shortcodes/imgur-video.html deleted file mode 100644 index a6d637a..0000000 --- a/themes/default/layouts/shortcodes/imgur-video.html +++ /dev/null @@ -1,17 +0,0 @@ -{{- $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)) -}} - -{{- $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") - ) --}} diff --git a/themes/default/layouts/shortcodes/imgur.html b/themes/default/layouts/shortcodes/imgur.html deleted file mode 100644 index f51bcef..0000000 --- a/themes/default/layouts/shortcodes/imgur.html +++ /dev/null @@ -1,13 +0,0 @@ -{{- $id := default "mkVcxUi" (.Get "id" | default (.Get 0)) -}} - -<imgur-image> - <blockquote - class="imgur-embed-pub" - lang="en" - data-id="a/{{ $id }}" - data-context="false" - > - <a href="//imgur.com/a/{{ $id }}"></a> - </blockquote> - <script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script> -</imgur-image> diff --git a/themes/default/layouts/shortcodes/kbd.html b/themes/default/layouts/shortcodes/kbd.html index b24fd9d..63af975 100644 --- a/themes/default/layouts/shortcodes/kbd.html +++ b/themes/default/layouts/shortcodes/kbd.html @@ -1,3 +1,4 @@ {{- $key := default "Ctrl" (.Get "key" | default (.Get 0)) -}} <kbd title="{{ $key }}">{{ $key | markdownify }}</kbd> +{{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/link.html b/themes/default/layouts/shortcodes/link.html new file mode 100644 index 0000000..49cd1c4 --- /dev/null +++ b/themes/default/layouts/shortcodes/link.html @@ -0,0 +1,36 @@ +{{- $source := default "https://example.com/" (.Get "source" | default (.Get 0)) -}} + +{{- $host := $source -}} + +{{- with (urls.Parse $source).Host -}} + {{- $host = . -}} +{{- end -}} + +{{- $favicon := partial "function-favicon-domain.html" $host -}} + +{{- $image := partial "function-fetch-favicons.html" + (dict + "Context" .Page + "Source" $favicon + "Infix" ($host | anchorize) + ) +-}} + +<link-card> + <a href="{{ $source }}"> + <img + loading="lazy" + alt="{{ $host }}" + title="{{ $host }}" + height="{{ $image.Height }}" + width="{{ $image.Width }}" + src="{{ $image.Permalink }}" + /> + </a> + <article> + <h2>{{ $host }}</h2> + <a href="{{ $source }}"> + {{ $source }} + </a> + </article> +</link-card> diff --git a/themes/default/layouts/shortcodes/mark.html b/themes/default/layouts/shortcodes/mark.html index 02af225..1b9ef3d 100644 --- a/themes/default/layouts/shortcodes/mark.html +++ b/themes/default/layouts/shortcodes/mark.html @@ -1,5 +1,15 @@ -{{- $text := default "highligted text" (.Get "text" | default (.Get 0)) -}} -{{- $title := default $text (.Get "title" | default (.Get 1)) -}} +{{- $text := default "mark" (.Get "text" | default (.Get 0)) -}} +{{- $title := default "highlighted text" (.Get "title" | default (.Get 1)) -}} +{{- $id := default "" (.Get "id" | default (.Get 2)) -}} -<mark title="{{ $title }}">{{ $text }}</mark> +{{- if gt (len .Inner) 1 -}} + {{- $text = trim .Inner "\n" -}} +{{- end -}} + +{{- if $id -}} + {{- $id = print "mark:" (truncate 30 "" $text | anchorize | replaceRE `\d` "") -}} + {{- $id = printf `id=%q` $id -}} +{{- end -}} + +<mark {{ $id | safeHTMLAttr }} title="{{- $title -}}"><span>{{- $text | markdownify -}}</span></mark> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/markdown.html b/themes/default/layouts/shortcodes/markdown.html index 3bc8726..f73aa90 100644 --- a/themes/default/layouts/shortcodes/markdown.html +++ b/themes/default/layouts/shortcodes/markdown.html @@ -1,4 +1,4 @@ -{{- $link := default (print "/" (partial "function-paths-markdown.html") "/" .Page.File ) (.Get "link" | default (.Get 0)) -}} +{{- $link := default (print "/" (partial "function-paths.html").markdown "/" .Page.File ) (.Get "link" | default (.Get 0)) -}} {{- $text := default (path.Base .Page.File) (.Get "text" | default (.Get 1)) -}} {{- $title := default "" (.Get "title" | default (.Get 2)) -}} {{- $embed := default false (.Get "embed" | default (.Get 3)) -}} diff --git a/themes/default/layouts/shortcodes/odysee.html b/themes/default/layouts/shortcodes/odysee.html index 0f2899e..cca7e9c 100644 --- a/themes/default/layouts/shortcodes/odysee.html +++ b/themes/default/layouts/shortcodes/odysee.html @@ -8,7 +8,8 @@ id="odysee-iframe" src="{{ $url }}" title="{{ $title }}" - allowfullscreen> + allowfullscreen="" + > </iframe> <footer>{{ $caption | markdownify }}</footer> </odysee-video> diff --git a/themes/default/layouts/shortcodes/pdf.html b/themes/default/layouts/shortcodes/pdf.html deleted file mode 100644 index 824169b..0000000 --- a/themes/default/layouts/shortcodes/pdf.html +++ /dev/null @@ -1,11 +0,0 @@ -{{- $url := default "https://www.gutenberg.org/files/98/old/2city12p.pdf" (.Get "url" | default (.Get 0)) -}} -{{- $title := default "PDF Document" (.Get "title" | default (.Get 1)) -}} -{{- $caption := default (print $title " ([Download](" $url "))") (.Get "caption" | default (.Get 2)) -}} - -<pdf-container title="{{ $title }}"> - <iframe loading="lazy" - sandbox="allow-scripts allow-presentation allow-same-origin" - src="https://docs.google.com/gview?url={{ $url }}&embedded=true"> - </iframe> - <footer>{{ $caption | markdownify }}</footer> -</pdf-container> diff --git a/themes/default/layouts/shortcodes/quote.html b/themes/default/layouts/shortcodes/quote.html index b933286..e0048d9 100644 --- a/themes/default/layouts/shortcodes/quote.html +++ b/themes/default/layouts/shortcodes/quote.html @@ -3,11 +3,9 @@ <q cite="$cite" title="{{ $text | markdownify }}"> {{- if $cite -}} - <a rel="noopener" href="{{ $cite }}" target="_blank"> - {{- end -}} - {{ $text | markdownify }} - {{- if $cite -}} - </a> + {{- print "[" $text "](" $cite ")" | markdownify -}} + {{- else -}} + {{- $text | markdownify -}} {{- end -}} </q> {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/react.html b/themes/default/layouts/shortcodes/react.html new file mode 100644 index 0000000..ea96101 --- /dev/null +++ b/themes/default/layouts/shortcodes/react.html @@ -0,0 +1,30 @@ +{{- $text := default "react" (.Get "text" | default (.Get 0)) -}} +{{- $source := default "" (.Get "source" | default (.Get 1)) -}} +{{- $title := default $text (.Get "title" | default (.Get 2)) -}} +{{- $alternate := default $title (.Get "alternate" | default (.Get 3)) -}} + +{{- $author := .Page.Section -}} + +{{- $image := partial "function-caches-images.html" + (dict + "Context" .Page + "Source" $source + "Fit" "100x100" + "Target" (print (partial "function-paths.html").media "/" $author "/") + "Copy" (print (partial "function-paths.html").media "/" $author "/react-" (path.Base $source)) + "AlternateCopy" (print (partial "function-paths.html").media "/" $author "/react-" (path.BaseName $source) ".webp") + ) +-}} + +<tool-tip data-type="reaction" title="{{ $title }}"> + {{ $text | markdownify }} + <a href="{{ $image.Permalink }}"> + <img + width="{{ $image.Width }}" + height="{{ $image.Height }}" + title="{{ $title }}" + alt="{{ $alternate }}" + src="{{ $image.Permalink }}" + /> + </a> +</tool-tip> diff --git a/themes/default/layouts/shortcodes/react.rss.xml b/themes/default/layouts/shortcodes/react.rss.xml new file mode 100644 index 0000000..0e03675 --- /dev/null +++ b/themes/default/layouts/shortcodes/react.rss.xml @@ -0,0 +1,19 @@ +{{- $text := default "react" (.Get "text" | default (.Get 0)) -}} +{{- $source := default "" (.Get "source" | default (.Get 1)) -}} +{{- $title := default $text (.Get "title" | default (.Get 2)) -}} +{{- $alternate := default $title (.Get "alternate" | default (.Get 3)) -}} + +{{- $author := .Page.Section -}} + +{{- $image := partial "function-caches-images.html" + (dict + "Context" .Page + "Source" $source + "Fit" "100x100" + "Target" (print (partial "function-paths.html").media "/" $author "/") + "Copy" (print (partial "function-paths.html").media "/" $author "/react-" (path.Base $source)) + "AlternateCopy" (print (partial "function-paths.html").media "/" $author "/react-" (path.BaseName $source) ".webp") + ) +-}} + +{{ $text | markdownify }} (<a title="{{ $title }}" href="{{ $image.Permalink }}">reaction</a>) diff --git a/themes/default/layouts/shortcodes/reddit.html b/themes/default/layouts/shortcodes/reddit.html deleted file mode 100644 index 10ef0b9..0000000 --- a/themes/default/layouts/shortcodes/reddit.html +++ /dev/null @@ -1,29 +0,0 @@ -{{- $path := default "linux/comments/aeufh6/vlc_has_now_reached_3_billions_downloads_and/edsvibz" (.Get "path" | default (.Get 0)) -}} -{{- $depth := default "2" (.Get "depth" | default (.Get 1)) -}} -{{- $context := default "1" (.Get "context" | default (.Get 2)) -}} -{{- $theme := default "light" (.Get "theme" | default (.Get 3)) -}} -{{- $showtitle := default "true" (.Get "showtitle" | default (.Get 4)) -}} -{{- $showedits := default "false" (.Get "showedits" | default (.Get 5)) -}} -{{- $showmedia := default "false" (.Get "showmedia" | default (.Get 6)) -}} -{{- $showmore := default "false" (.Get "showmore" | default (.Get 7)) -}} - -<reddit-comment> - <iframe loading="lazy" - id="reddit-embed" - src="https://www.redditmedia.com/r/{{ trim $path "/" }}/ -?depth={{ $depth }} -&embed=true -&showmore={{ $showmore }} -&showtitle={{ $showtitle }} -&context={{ $context }} -&showmedia={{ $showmedia }} -&theme={{ $theme }} -&showedits={{ $showedits }} -&created={{ now.Format "2006-01-02T15:04:05Z" }}" - sandbox="allow-scripts allow-same-origin allow-popups" - style="border: none;" - height="452" - width="640" - scrolling="no" - ></iframe> -</reddit-comment> diff --git a/themes/default/layouts/shortcodes/self.html b/themes/default/layouts/shortcodes/self.html index 2f0d7eb..6036e07 100644 --- a/themes/default/layouts/shortcodes/self.html +++ b/themes/default/layouts/shortcodes/self.html @@ -10,6 +10,7 @@ <self-embed> <iframe height="165" + scrolling="no" sandbox="{{ $sandbox }}" src="{{ .Site.BaseURL }}{{ $url }}" title="{{ $title }}" diff --git a/themes/default/layouts/shortcodes/spoiler.html b/themes/default/layouts/shortcodes/spoiler.html index 9267876..9c5e59a 100644 --- a/themes/default/layouts/shortcodes/spoiler.html +++ b/themes/default/layouts/shortcodes/spoiler.html @@ -1,9 +1,13 @@ {{- $text := default "This is a spoiler." (.Get "text" | default (.Get 0)) -}} {{- $title := default "Click to show/hide text." (.Get "title" | default (.Get 1)) -}} +{{- $hash := print (truncate 4 "" (sha256 .Page.RelPermalink)) (truncate 4 "" (sha256 $text)) .Ordinal -}} -{{ if gt (len .Inner) 1 }} - {{ $text = .Inner }} -{{ end }} +{{- if gt (len .Inner) 1 -}} + {{- $text = .Inner -}} +{{- end -}} -<input hidden type="checkbox" id="spoiler-text-{{ md5 $text }}" /> -<s title="{{ $title }}"><label for="spoiler-text-{{ md5 $text }}">{{ $text | markdownify }}</label></s> +<input hidden="" type="checkbox" id="spoiler-text-{{ $hash }}" /> + +<s title="{{ $title }}"> + <label for="spoiler-text-{{ $hash }}">{{ $text | markdownify }}</label> +</s> diff --git a/themes/default/layouts/shortcodes/spoiler.rss.xml b/themes/default/layouts/shortcodes/spoiler.rss.xml index 73dde8a..adbce7b 100644 --- a/themes/default/layouts/shortcodes/spoiler.rss.xml +++ b/themes/default/layouts/shortcodes/spoiler.rss.xml @@ -5,4 +5,6 @@ {{ $text = .Inner }} {{ end }} -<s title="{{ $title }}"><label for="spoiler-text-{{ md5 $text }}">{{ $text | markdownify }}</label></s> +<s title="{{ $title }}"> + <label>{{ $text | markdownify }}</label> +</s> diff --git a/themes/default/layouts/shortcodes/tweet.html b/themes/default/layouts/shortcodes/tweet.html deleted file mode 100644 index faf1f00..0000000 --- a/themes/default/layouts/shortcodes/tweet.html +++ /dev/null @@ -1,18 +0,0 @@ -{{- $user := default "jack" (.Get "user" | default (.Get 0)) -}} -{{- $status := default "20" (.Get "status" | default (.Get 1)) -}} -{{- $caption := default "Twitter Tweet" (.Get "caption" | default (.Get 2)) -}} - -<twitter-tweet> - <blockquote class="twitter-tweet"> - <a href="https://twitter.com/{{ $user }}/status/{{ $status }}"> - https://twitter.com/{{ $user }}/status/{{ $status }} - </a> - </blockquote> - <script - async - src="https://platform.twitter.com/widgets.js" - charset="utf-8"> - </script> -</twitter-tweet> - -<footer>{{ $caption }}</footer> diff --git a/themes/default/layouts/shortcodes/version.html b/themes/default/layouts/shortcodes/version.html new file mode 100644 index 0000000..2e3eda8 --- /dev/null +++ b/themes/default/layouts/shortcodes/version.html @@ -0,0 +1,20 @@ +{{- $version := "0.11.12" -}} +{{- $generator := "0.110.0" -}} + +{{- $number := default false (.Get "number" | default (.Get 0)) -}} +{{- $clone := default false (.Get "clone" | default (.Get 1)) -}} +{{- $hugo := default false (.Get "hugo" | default (.Get 2)) -}} + +{{- if $number -}} + {{ $version }} +{{- end -}} + +{{- if $hugo -}} + {{ $generator }} +{{- end -}} + +{{- if $clone -}} +```shell +git clone --branch {{ $version }} https://www.thedroneely.com/git/thedroneely/canory +``` +{{- end -}} diff --git a/themes/default/layouts/shortcodes/asciicast.html b/themes/default/layouts/shortcodes/video-ascii.html index 10da091..10da091 100644 --- a/themes/default/layouts/shortcodes/asciicast.html +++ b/themes/default/layouts/shortcodes/video-ascii.html diff --git a/themes/default/layouts/shortcodes/video-imgur.html b/themes/default/layouts/shortcodes/video-imgur.html new file mode 100644 index 0000000..2edb9a4 --- /dev/null +++ b/themes/default/layouts/shortcodes/video-imgur.html @@ -0,0 +1,14 @@ +{{- $id := default "rQIb4Vw" (.Get "id" | default (.Get 0)) -}} +{{- $title := default "Imgur Gif" (.Get "title" | default (.Get 1)) -}} +{{- $caption := default $title (.Get "caption" | default (.Get 2)) -}} + +{{- $options := default "controls autoplay loop muted playsinline" + (.Get "options" | default (.Get 3)) +-}} + +{{- $source := print "https://i.imgur.com/" $id ".mp4" -}} + +{{- printf `{{< video source="%s" title="%s" caption="%s" options="%s" >}}` + $source $title $caption $options + | .Page.RenderString +-}} diff --git a/themes/default/layouts/shortcodes/video.html b/themes/default/layouts/shortcodes/video.html index bb49f8c..289559c 100644 --- a/themes/default/layouts/shortcodes/video.html +++ b/themes/default/layouts/shortcodes/video.html @@ -1,32 +1,36 @@ {{- - $source := default + $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 "`HTML5` Video" (.Get "caption" | default (.Get 6)) -}} -{{- $title := default "HTML5 Video" (.Get "title" | default (.Get 7)) -}} -{{- $start := default "" (.Get "start" | default (.Get 8)) -}} -{{- $end := default "" (.Get "end" | default (.Get 9)) -}} +{{- $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)) -}} {{- partial "video-container.html" (dict - "Author" .Page.Section - "Caption" $caption - "End" $end - "Height" $height - "Options" $options - "Poster" $poster - "Preload" $preload - "RelURL" (strings.TrimPrefix .Site.BaseURL .Page.Permalink) - "Source" $source - "Source" $source - "Start" $start - "Title" $title - "Width" $width + "Author" .Page.Section + "Caption" $caption + "Context" .Page + "End" $end + "Height" $height + "Options" $options + "Orientation" $orientation + "Poster" $poster + "Preload" $preload + "RelURL" (strings.TrimPrefix .Site.BaseURL .Page.Permalink) + "Remote" $remote + "Source" $source + "Start" $start + "Title" $title + "Width" $width ) -}} diff --git a/themes/default/layouts/shortcodes/video.rss.xml b/themes/default/layouts/shortcodes/video.rss.xml new file mode 100644 index 0000000..be262e7 --- /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)) -}} + +<p> + <b> + <a + title="{{ $title }}" + href="{{ $source }}" + > + Video: {{ $caption -}} + </a> + </b> + <br> + <span>Title: {{ $title }}</span> +</p> diff --git a/themes/default/layouts/shortcodes/vimeo.html b/themes/default/layouts/shortcodes/vimeo.html deleted file mode 100644 index 009ebb0..0000000 --- a/themes/default/layouts/shortcodes/vimeo.html +++ /dev/null @@ -1,12 +0,0 @@ -{{- $id := default "1084537" (.Get "id" | default (.Get 0)) -}} -{{- $title := default "Vimeo Video" (.Get "title" | default (.Get 1)) -}} - -<vimeo-video> - <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"> - <iframe loading="lazy" - src="https://player.vimeo.com/video/{{ $id }}?dnt=1" - style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" - title="{{ $title }}" webkitallowfullscreen mozallowfullscreen allowfullscreen> - </iframe> - </div> -</vimeo-video> diff --git a/themes/default/layouts/shortcodes/wikipedia.html b/themes/default/layouts/shortcodes/wikipedia.html index 65fa399..dd33a55 100644 --- a/themes/default/layouts/shortcodes/wikipedia.html +++ b/themes/default/layouts/shortcodes/wikipedia.html @@ -7,7 +7,9 @@ -}} <wikipedia-container title="{{ $title }}"> - <iframe loading="lazy" + <iframe + loading="lazy" + scrolling="no" height="300" src="https://en.m.wikipedia.org/wiki/{{ $id }}" title="{{ $title }}" diff --git a/themes/default/layouts/shortcodes/youtube.html b/themes/default/layouts/shortcodes/youtube.html index 99612ed..9ec1cfb 100644 --- a/themes/default/layouts/shortcodes/youtube.html +++ b/themes/default/layouts/shortcodes/youtube.html @@ -1,10 +1,12 @@ -{{- $url := "www.youtube-nocookie.com" -}} {{- $id := default "aqz-KE-bpKQ" (.Get "id" | default (.Get 0)) -}} {{- $title := default "YouTube Video" (.Get "title" | default (.Get 1)) -}} {{- $start := default "" (.Get "start" | default (.Get 2)) -}} {{- $end := default "" (.Get "end" | default (.Get 3)) -}} {{- $muted := default "" (.Get "muted" | default (.Get 4)) -}} +{{- $url := "www.youtube-nocookie.com" -}} +{{- $controls := "?controls=1" -}} + {{- if (and $start $end) -}} {{ $start = print "&start=" $start }} {{ $end = print "&end=" $end }} @@ -15,11 +17,14 @@ {{- end -}} <youtube-video> - <iframe loading="lazy" + <iframe + allowfullscreen="" height="300" + loading="lazy" + title="{{ $title }}" sandbox="allow-scripts allow-same-origin" - src="https://{{ $url }}/embed/{{ $id }}{{ "?controls=1" }}{{ $start }}{{ $end }}{{ $muted }}" - allowfullscreen title="{{ $title }}"> + src="https://{{ $url }}/embed/{{ $id }}{{ $controls }}{{ $start }}{{ $end }}{{ $muted }}" + > </iframe> <footer> {{ $title | markdownify }} |