aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-12-26 17:01:38 -0500
committertdro <tdro@noreply.example.com>2022-12-26 17:01:38 -0500
commit75327dddfefbb3259d6cbc6e7b02f481777f4e5b (patch)
tree9ff8cbd78bef08d42ad5aeeb306de82bf0425eea
parentbaaac565e9b4c082a73efb2044b224e2d906d6af (diff)
downloadcanory-75327dddfefbb3259d6cbc6e7b02f481777f4e5b.tar.gz
canory-75327dddfefbb3259d6cbc6e7b02f481777f4e5b.tar.bz2
canory-75327dddfefbb3259d6cbc6e7b02f481777f4e5b.zip
themes/default/layouts/partials/function-generate-feeds: Remove outside duplicate call
Nest warning inside
-rw-r--r--themes/default/layouts/partials/function-generate-feeds.html276
1 files changed, 139 insertions, 137 deletions
diff --git a/themes/default/layouts/partials/function-generate-feeds.html b/themes/default/layouts/partials/function-generate-feeds.html
index d97d647..4427f44 100644
--- a/themes/default/layouts/partials/function-generate-feeds.html
+++ b/themes/default/layouts/partials/function-generate-feeds.html
@@ -10,174 +10,176 @@
{{- $url := delimit (first 1 $data) "" -}}
{{- $retitle := trim (delimit (after 1 $data) " ") " " -}}
- {{- with resources.GetRemote $url -}}
- {{- with .Err -}}
- {{- warnf "Feed fetch %s" . -}}
- {{- end -}}
- {{- end -}}
-
- {{- with resources.GetRemote $url | transform.Unmarshal -}}
-
- {{- $content := "" -}}
- {{- $date := now.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" -}}
+ {{- with $fetch := resources.GetRemote $url -}}
+
+ {{- with $error := .Err -}}
+ {{- warnf "Feed fetch %s" $error -}}
+ {{- else -}}
+
+ {{- with $fetch | transform.Unmarshal -}}
+
+ {{- $content := "" -}}
+ {{- $date := now.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 -}}
- {{- end -}}
- {{- end -}}
-
- {{- if not $date -}}
- {{- $date = .lastBuildDate -}}
- {{- end -}}
- {{- else -}}
+ {{- with .image -}}
+ {{- $imageLink = .url -}}
+ {{- end -}}
- {{- with .author -}}
- {{- if reflect.IsMap . -}}
- {{- $sourceHome = .uri -}}
- {{- end -}}
- {{- 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 -}}
- {{- with .subtitle -}}
- {{- if reflect.IsMap . -}}
- {{- $sourceDescription = index . "#text" -}}
- {{- else -}}
- {{- $sourceDescription = . -}}
- {{- end -}}
- {{- end -}}
+ {{- if not $date -}}
+ {{- $date = .lastBuildDate -}}
+ {{- end -}}
- {{- with .title -}}
- {{- if reflect.IsMap . -}}
- {{- $sourceTitle = index . "#text" -}}
{{- else -}}
- {{- $sourceTitle = . -}}
- {{- end -}}
- {{- end -}}
- {{- with .entry -}}
- {{- range first $value . -}}
- {{- $date = .updated -}}
+ {{- with .author -}}
+ {{- if reflect.IsMap . -}}
+ {{- $sourceHome = .uri -}}
+ {{- end -}}
+ {{- end -}}
- {{- with .link -}}
+ {{- with .subtitle -}}
{{- if reflect.IsMap . -}}
- {{- $link = index . "-href" -}}
+ {{- $sourceDescription = index . "#text" -}}
{{- else -}}
- {{- if reflect.IsMap (index . 0) -}}
- {{- $link = index (index . 0) "-href" -}}
- {{- else -}}
- {{- $link = . -}}
- {{- end -}}
+ {{- $sourceDescription = . -}}
{{- end -}}
{{- end -}}
{{- with .title -}}
{{- if reflect.IsMap . -}}
- {{- $title = index . "#text" -}}
+ {{- $sourceTitle = index . "#text" -}}
{{- else -}}
- {{- $title = . -}}
+ {{- $sourceTitle = . -}}
{{- end -}}
{{- end -}}
- {{- with .content -}}
- {{- $content = index . "#text" -}}
- {{- 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 .summary -}}
- {{- $description = index . "#text" -}}
- {{- 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" -}}
+ {{- with .group -}}
+ {{- $description = .description -}}
+ {{- $content = index .content "#text" -}}
+ {{- $enclosure = index .thumbnail "-url" -}}
+ {{- end -}}
+ {{- end -}}
{{- end -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
+ {{- end -}}
- {{- $sourceDomain := ($sourceLink | plainify | html | htmlUnescape | urls.Parse).Host -}}
+ {{- $sourceDomain := ($sourceLink | plainify | html | htmlUnescape | urls.Parse).Host -}}
- {{- /* Replace invalid time zones. */ -}}
- {{- $date = replaceRE "G[0-9]+T" "UTC" $date -}}
+ {{- /* 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 -}}
+ {{- /* 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 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 -}}
+ {{- /* 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 | html | htmlUnescape)
- "FeedContentShort" (delimit (first 2 (split ($content | plainify | html | htmlUnescape) "\n")) " " | truncate 250)
- "FeedDate" ($date | plainify | html | htmlUnescape | time.Format "January 2, 2006")
- "FeedDateTime" ($date | plainify | html | htmlUnescape | time.Format "2006-01-02T15:04:05Z")
- "FeedDateTitle" ($date | plainify | html | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST")
- "FeedDescription" ($description | plainify | html | htmlUnescape)
- "FeedDescriptionShort" (delimit (first 2 (split ($description | plainify | html | htmlUnescape) "\n")) " " | truncate 250)
- "FeedEnclosure" ($enclosure | plainify | html | htmlUnescape)
- "FeedImageLink" ($imageLink | plainify | html | htmlUnescape)
- "FeedLink" ($link | plainify | html | htmlUnescape)
- "FeedName" (or $retitle (delimit (first 2 (split ($sourceTitle | plainify | html | htmlUnescape) " ")) " "))
- "FeedSourceDescription" ($sourceDescription | plainify | html | htmlUnescape)
- "FeedSourceDomain" ($sourceDomain | plainify | html | htmlUnescape)
- "FeedSourceLink" ($sourceLink | plainify | html | htmlUnescape)
- "FeedSourceHome" ($sourceHome | plainify | html | htmlUnescape)
- "FeedSourceTitle" ($sourceTitle | plainify | html | htmlUnescape)
- "FeedTitle" ($title | plainify | html | htmlUnescape)
- )
- -}}
+ {{-
+ $feeds = $feeds | append (dict
+ "FeedContent" ($content | plainify | html | htmlUnescape)
+ "FeedContentShort" (delimit (first 2 (split ($content | plainify | html | htmlUnescape) "\n")) " " | truncate 250)
+ "FeedDate" ($date | plainify | html | htmlUnescape | time.Format "January 2, 2006")
+ "FeedDateTime" ($date | plainify | html | htmlUnescape | time.Format "2006-01-02T15:04:05Z")
+ "FeedDateTitle" ($date | plainify | html | htmlUnescape | time.Format "Monday, January 2 2006 at 15:04:05 MST")
+ "FeedDescription" ($description | plainify | html | htmlUnescape)
+ "FeedDescriptionShort" (delimit (first 2 (split ($description | plainify | html | htmlUnescape) "\n")) " " | truncate 250)
+ "FeedEnclosure" ($enclosure | plainify | html | htmlUnescape)
+ "FeedImageLink" ($imageLink | plainify | html | htmlUnescape)
+ "FeedLink" ($link | plainify | html | htmlUnescape)
+ "FeedName" (or $retitle (delimit (first 2 (split ($sourceTitle | plainify | html | htmlUnescape) " ")) " "))
+ "FeedSourceDescription" ($sourceDescription | plainify | html | htmlUnescape)
+ "FeedSourceDomain" ($sourceDomain | plainify | html | htmlUnescape)
+ "FeedSourceLink" ($sourceLink | plainify | html | htmlUnescape)
+ "FeedSourceHome" ($sourceHome | plainify | html | htmlUnescape)
+ "FeedSourceTitle" ($sourceTitle | plainify | html | htmlUnescape)
+ "FeedTitle" ($title | plainify | html | htmlUnescape)
+ )
+ -}}
+ {{- end -}}
+ {{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}