diff options
Diffstat (limited to 'themes/default/layouts/partials')
96 files changed, 1750 insertions, 1102 deletions
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> |