diff options
| author | tdro <tdro@noreply.example.com> | 2025-03-08 00:00:00 +0000 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2025-03-08 00:00:00 +0000 |
| commit | 223c8ef7e2d8b795f6132a360dc570c74e872b1e (patch) | |
| tree | 83fe101d1efa4a54f9b8a1a8bffbc5d8789b7fc6 | |
| parent | a9a2e531e9c5dca0a87c520a8311e173daac3599 (diff) | |
| download | canory-223c8ef7e2d8b795f6132a360dc570c74e872b1e.tar.gz canory-223c8ef7e2d8b795f6132a360dc570c74e872b1e.tar.bz2 canory-223c8ef7e2d8b795f6132a360dc570c74e872b1e.zip | |
themes/default/layouts/partials/author-card: Unify
| -rw-r--r-- | themes/default/layouts/_default/section.webfeeds.html | 78 | ||||
| -rw-r--r-- | themes/default/layouts/partials/author-card.html | 112 | ||||
| -rw-r--r-- | themes/default/layouts/partials/author-data.html | 26 |
3 files changed, 94 insertions, 122 deletions
diff --git a/themes/default/layouts/_default/section.webfeeds.html b/themes/default/layouts/_default/section.webfeeds.html index e8bf821..6a23a1e 100644 --- a/themes/default/layouts/_default/section.webfeeds.html +++ b/themes/default/layouts/_default/section.webfeeds.html @@ -9,8 +9,9 @@ {{- if (and $parent $modified) -}} {{- $sources := slice -}} - {{- $author := partial "function-authors-data.html" . -}} - {{- $feeds := partial "function-generate-feeds.html" . -}} + + {{- $author := partial "function-authors-data.html" . -}} + {{- $feeds := partial "function-generate-feeds.html" . -}} {{- range $author.feeds.rss -}} {{- $data := split . " " -}} @@ -24,63 +25,22 @@ {{- $href := or $distinct.FeedHome (print "http://" $distinct.FeedSourceDomain) -}} {{- $favicon := print (partial "function-paths.html").media "/favicon." (.FeedSourceLink | anchorize) ".png" -}} - <micro-author> - <micro-card> - <header> - <figure> - <a - title="{{ $distinct.FeedName }}" - href="{{ $href }}"> - {{- if fileExists (print "public/" $favicon) -}} - <picture> - <img - width="64" - height="64" - alt="{{ $distinct.FeedName }}" - src="{{ $favicon | relURL }}" - /> - </picture> - {{- else -}} - <svg xmlns="http://www.w3.org/2000/svg"> - <text - x="50%" - y="50%" - text-anchor="middle" - dominant-baseline="central" - >{{ delimit (first 1 (split $distinct.FeedName "")) "" | strings.Title }}</text> - </svg> - {{- end -}} - </a> - </figure> - </header> - <article> - <h2> - <b>{{ $distinct.FeedName }}</b> - </h2> - <h3> - <a - data-hover - title="{{ $distinct.FeedName }}" - href="{{ $href }}"> - @{{ $distinct.FeedSourceDomain }} - </a> - </h3> - <time - data-type="default" - title="{{ $distinct.FeedDateTitle }}" - datetime="{{ $distinct.FeedDateTime }}"> - {{ $distinct.FeedDate -}} - </time> - </article> - <a - title="Follow {{ $distinct.FeedName }}" - href="{{ $distinct.FeedSourceLink }}"> - {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) }} - <span>Feed</span> - </a> - </micro-card> - </micro-author> - + {{- partial "author-card.html" (dict + "Href" ($href) + "HrefTitle" ($href) + "Source" ($favicon | relURL) + "Author" ($distinct.FeedName) + "Alternate" ($distinct.FeedName) + "Name" ($distinct.FeedName) + "Title" ($distinct.FeedName) + "Date" ($distinct.FeedDateTime) + "DateTime" ($distinct.FeedDateTime) + "DateTitle" ($distinct.FeedDateTitle) + "Host" ($distinct.FeedSourceDomain) + "FeedTitle" (print "Read" " " $distinct.FeedName) + "Expired" (not (fileExists (print "public/" $favicon))) + ) + -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/themes/default/layouts/partials/author-card.html b/themes/default/layouts/partials/author-card.html index 6f15ff3..354696c 100644 --- a/themes/default/layouts/partials/author-card.html +++ b/themes/default/layouts/partials/author-card.html @@ -1,78 +1,68 @@ -{{- $host := (urls.Parse ("" | absURL)).Host -}} -{{- $date := .Date | time.Format "Mon Jan 2 2006" -}} -{{- $metadata := print "public/" .Data.user "/author.json" -}} +{{- $alternate := or .Alternate "" -}} +{{- $author := or .Author "" -}} +{{- $date := or .Date "" -}} +{{- $datetime := or .DateTime "" -}} +{{- $datetitle := or .DateTitle "" -}} +{{- $description := or .Description "" -}} +{{- $expired := or .Expired "" -}} +{{- $feedtitle := or .FeedTitle "" -}} +{{- $host := or .Host "" -}} +{{- $href := or .Href "" -}} +{{- $hreftitle := or .HrefTitle "" -}} +{{- $name := or .Name "" -}} +{{- $source := or .Source "" -}} +{{- $sourceset := or .SourceSet "" -}} +{{- $title := or .Title "" -}} +{{- $height := or .Height "64" -}} +{{- $width := or .Width "64" -}} {{- if not $host -}} - {{- $host = "localhost" -}} + {{- $host = (urls.Parse ("" | absURL)).Host -}} + {{- if not $host -}} {{- $host = "localhost" -}} {{- end -}} {{- 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 -}} +{{- $date = .Date | time.Format "Mon Jan 2 2006" -}} +{{- if not .Date -}} {{- $date = "Inactive" -}} {{- end -}} <micro-author> <micro-card> <header> <figure> - <a title="{{ .Data.name }}" href="{{ .Data.user | relURL }}/"> - <picture> - {{- with $sourceset -}} - <source srcset="{{ strings.TrimPrefix "/" $sourceset | relURL }}" type="image/webp" /> - {{- end -}} - <img - width="{{ or $width "64" }}" - height="{{ or $height "64" }}" - src="{{ strings.TrimPrefix "/" $source | relURL }}" - alt="{{ $alternate }}" - /> - </picture> + <a title="{{ $title }}" href="{{ $href }}/"> + {{- if not $expired -}} + <picture> + {{- with $sourceset -}} + <source srcset="{{ $sourceset }}" type="image/webp" /> + {{- end -}} + <img + width="{{ $width }}" + height="{{ $height }}" + src="{{ $source }}" + alt="{{ $alternate }}" + /> + </picture> + {{- else -}} + <svg xmlns="http://www.w3.org/2000/svg"> + <text + x="50%" + y="50%" + text-anchor="middle" + dominant-baseline="central" + >{{ delimit (first 1 (split $author "")) "" | strings.Title }}</text> + </svg> + {{- end -}} </a> </figure> </header> <article> - <h2> - <b>{{ .Data.name }}</b> - </h2> - <h3> - <a data-hover="" title="{{ .Data.name }}" href="{{ .Data.user | relURL }}/"> - @{{ $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> + <h2><b>{{ $name }}</b></h2> + <h3><a data-hover="" title="{{ $hreftitle }}" href="{{ $href }}/">@{{ $host }}</a></h3> + <time data-type="default" title="{{ $datetitle }}" datetime="{{ $datetime }}">{{ $date }}</time> </article> - <p>{{ .Data.description | markdownify | plainify | htmlUnescape | truncate 60 "..." }}</p> - <a title="Follow with RSS Reader" href="{{ .Data.user | relURL }}/rss.xml"> + {{ with $description }} + <p>{{ $description }}</p> + {{- end -}} + <a title="{{ $feedtitle }}" href="{{ $href }}/rss.xml"> {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) }} <span>Feed</span> </a> diff --git a/themes/default/layouts/partials/author-data.html b/themes/default/layouts/partials/author-data.html index 985cbfd..f26451e 100644 --- a/themes/default/layouts/partials/author-data.html +++ b/themes/default/layouts/partials/author-data.html @@ -16,9 +16,31 @@ {{- $data := index $pageContext.Site.Data.authors $author -}} {{- $date := or (index (first 1 ($recent)) 0).Date 0 -}} + {{- $width := "" -}} + {{- $height := "" -}} + + {{- with $metadata := resources.Get (print "public/" $data.user "/author.json") -}} + {{- with $content := $metadata.Content -}} + {{- $metadata = $content | transform.Unmarshal -}} + {{- $width = $metadata.picture.profileWidth -}} + {{- $height = $metadata.picture.profileHeight -}} + {{- end -}} + {{- end -}} + {{- partial "author-card.html" (dict - "Data" $data - "Date" $date + "Date" ($date) + "Title" ($data.name) + "Name" ($data.name) + "Author" ($data.user) + "Href" ($data.user | relURL) + "HrefTitle" ($data.user | relURL) + "FeedTitle" ("Read with Feed Reader") + "DateTime" ($date | time.Format "2006-01-02T15:04:05Z") + "DateTitle" ($date | time.Format "Monday January 2 2006 at 15:04:05 MST") + "Description" ($data.description | markdownify | plainify | htmlUnescape | truncate 60 "...") + "Expired" (or (not (path.Ext $data.picture.profile)) (not (fileExists (print "public/" (partial "function-paths.html").media "/" $data.user)))) + "SourceSet" (print (partial "function-paths.html").media "/" $data.user "/" $data.user "-profile.webp" | relURL) + "Source" (print (partial "function-paths.html").media "/" $data.user "/" $data.user "-profile" (path.Ext $data.picture.profile) | relURL) ) -}} {{- end -}} |
