aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-06-14 15:05:07 -0400
committertdro <tdro@noreply.example.com>2022-06-14 15:05:07 -0400
commit3fec7028a7d5e0590ac490abacf13a77dfe5e04d (patch)
tree1b2abd0a380bb099c70c5699d8695e4574803b5a
parent815f469994b995966319ca98ce6934ea3e3c28a0 (diff)
downloadcanory-3fec7028a7d5e0590ac490abacf13a77dfe5e04d.tar.gz
canory-3fec7028a7d5e0590ac490abacf13a77dfe5e04d.tar.bz2
canory-3fec7028a7d5e0590ac490abacf13a77dfe5e04d.zip
themes/default/layouts/partials/feeds-generate: Support more RSS feeds
Handle groups and a few common mapped situations. Link via header directly to author's feeds.
-rw-r--r--themes/default/layouts/partials/card-meta.html2
-rw-r--r--themes/default/layouts/partials/feeds-generate.html60
2 files changed, 47 insertions, 15 deletions
diff --git a/themes/default/layouts/partials/card-meta.html b/themes/default/layouts/partials/card-meta.html
index 19796db..5d3fe20 100644
--- a/themes/default/layouts/partials/card-meta.html
+++ b/themes/default/layouts/partials/card-meta.html
@@ -9,7 +9,7 @@
{{ safeHTML (readFile "static/icons/feather/rss.svg") }}
<a data-hover
title="{{ partial "author-user.html" . }}@{{ (urls.Parse .Site.BaseURL).Host }}"
- href="{{ .Site.BaseURL }}/{{ partial "author-user.html" . }}">
+ href="{{ .Site.BaseURL }}/{{ partial "author-user.html" . }}/feeds/#">
via @{{ partial "author-user.html" . }}
</a>
{{- end -}}
diff --git a/themes/default/layouts/partials/feeds-generate.html b/themes/default/layouts/partials/feeds-generate.html
index fbe2775..0db11d2 100644
--- a/themes/default/layouts/partials/feeds-generate.html
+++ b/themes/default/layouts/partials/feeds-generate.html
@@ -60,28 +60,57 @@
{{- else -}}
- {{- $sourceTitle = .title -}}
{{- $sourceDescription = .subtitle -}}
{{- with .link -}}
{{- $sourceLink = index (index . 0) "-href" -}}
{{- end -}}
+ {{- with .title -}}
+ {{- if reflect.IsMap . -}}
+ {{- $sourceTitle = index . "#text" -}}
+ {{- else -}}
+ {{- $sourceTitle = . -}}
+ {{- end -}}
+ {{- end -}}
+
{{- with .entry -}}
{{- range first $value . -}}
- {{- $link = .id -}}
{{- $date = .updated -}}
- {{- $title = index .title "#text" -}}
+
+ {{- 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" -}}
- {{- $description = index . "#text" -}}
+ {{- $content = index . "#text" -}}
{{- end -}}
{{- with .summary -}}
- {{- $content = index . "#text" -}}
{{- $description = index . "#text" -}}
{{- end -}}
+
+ {{- with .group -}}
+ {{- $description = .description -}}
+ {{- $content = index .content "#text" -}}
+ {{- $enclosure = index .thumbnail "-url" -}}
+ {{- end -}}
{{- end -}}
{{- end -}}
@@ -92,18 +121,18 @@
{{- /* If missing seconds split and try again. */ -}}
{{- if lt (len (split $date ":")) 3 -}}
- {{- $date = delimit (first 3 (after 1 (split $date " "))) " " -}}
+ {{- $date = delimit (first 3 (after 1 (split $date " "))) " " -}}
{{- end -}}
{{
$feeds = $feeds | append (dict
"FeedContent" ($content | plainify | htmlUnescape)
- "FeedContentShort" (delimit (first 1 (split ($content | plainify | htmlUnescape) "\n")) " " | truncate 250)
+ "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 1 (split ($description | plainify | htmlUnescape) "\n")) " " | truncate 250)
+ "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 ]" "")
@@ -129,6 +158,7 @@
"&size=64"
)
-}}
+
{{- $imageSource := "/images/404.png" -}}
{{- $imageTitle := "No image found" -}}
@@ -151,9 +181,9 @@
{{- $name := urlize (replace (.FeedTitle | truncate 50 "") "/" "-") -}}
{{- $path := print "/data/generates/content/" $author.user "/feeds/" $name ".md" -}}
- {{- $description := .FeedSourceTitle -}}
- {{- if gt (len .FeedSourceDescription) (len .FeedSourceTitle) -}}
- {{- $description = .FeedSourceDescription -}}
+ {{- $description := .FeedDescriptionShort -}}
+ {{- if gt (len .FeedTitle) (len .FeedDescriptionShort) -}}
+ {{- $description = .FeedTitle -}}
{{- end -}}
{{- $content := .FeedContentShort -}}
@@ -223,8 +253,10 @@
datetime="{{ .FeedDateTime }}">
{{ .FeedDate }}
</time>
- {{- with .FeedDescriptionShort -}}
- {{ "--" | markdownify }} {{ . }}
+ {{ if gt (len .FeedDescriptionShort) (len .FeedContentShort) -}}
+ {{ "--" | markdownify }} {{ .FeedDescriptionShort }}
+ {{- else -}}
+ {{ "--" | markdownify }} {{ .FeedContentShort }}
{{- end }}
</p>