diff options
author | tdro <tdro@noreply.example.com> | 2022-06-06 00:14:09 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-06-06 00:14:09 -0400 |
commit | 3ea52e9b4365b7a49f13ad72b152f227de0f4baf (patch) | |
tree | e24d8432f2a3703bfa485a149d83b65439545b75 | |
parent | 84198d30f618c37a4c2b623ec5a0d76dfdcb595a (diff) | |
download | canory-3ea52e9b4365b7a49f13ad72b152f227de0f4baf.tar.gz canory-3ea52e9b4365b7a49f13ad72b152f227de0f4baf.tar.bz2 canory-3ea52e9b4365b7a49f13ad72b152f227de0f4baf.zip |
themes/default/layouts/partials/feeds-generate: White space cleanup
-rw-r--r-- | themes/default/layouts/partials/feeds-generate.html | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/themes/default/layouts/partials/feeds-generate.html b/themes/default/layouts/partials/feeds-generate.html index cd93449..fbe2775 100644 --- a/themes/default/layouts/partials/feeds-generate.html +++ b/themes/default/layouts/partials/feeds-generate.html @@ -1,18 +1,18 @@ {{- $author := index .Site.Data.authors ((or .Params.author .Site.Author.default.user) | default "default") -}} -{{ $feeds := slice }} +{{- $feeds := slice -}} {{- if $author.webring.rss -}} - {{ range $key, $value := (seq 3) }} - {{ range $author.webring.rss -}} + {{- range $key, $value := (seq 3) -}} + {{- range $author.webring.rss -}} - {{ with resources.GetRemote . }} + {{- with resources.GetRemote . -}} {{- with .Err -}} {{- warnf "Feed fetch %s" . -}} {{- end -}} - {{ end }} + {{- end -}} - {{ with resources.GetRemote . | transform.Unmarshal -}} + {{- with resources.GetRemote . | transform.Unmarshal -}} {{- $title := "No Title Found" -}} {{- $link := "https://example.com/link" -}} @@ -24,76 +24,76 @@ {{- $date := now.Format "2006-01-02T15:04:05Z" -}} {{- $enclosure := "" -}} - {{ with .channel -}} + {{- 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 -}} + + {{- else -}} + + {{- $sourceTitle = .title -}} + {{- $sourceDescription = .subtitle -}} + + {{- with .link -}} + {{- $sourceLink = index (index . 0) "-href" -}} + {{- end -}} + + {{- with .entry -}} + {{- range first $value . -}} + {{- $link = .id -}} + {{- $date = .updated -}} + {{- $title = index .title "#text" -}} + + {{- with .content -}} + {{- $content = index . "#text" -}} + {{- $description = index . "#text" -}} + {{- end -}} + + {{- with .summary -}} + {{- $content = index . "#text" -}} + {{- $description = index . "#text" -}} + {{- end -}} + {{- end -}} + {{- end -}} - {{ $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 }} - - {{ else -}} - - {{ $sourceTitle = .title -}} - {{ $sourceDescription = .subtitle -}} - - {{ with .link }} - {{ $sourceLink = index (index . 0) "-href" -}} - {{ end }} - - {{ with .entry }} - {{ range first $value . -}} - {{ $link = .id -}} - {{ $date = .updated -}} - {{ $title = index .title "#text" -}} - - {{ with .content -}} - {{ $content = index . "#text" -}} - {{ $description = index . "#text" -}} - {{ end -}} - - {{ with .summary -}} - {{ $content = index . "#text" -}} - {{ $description = index . "#text" -}} - {{ end -}} - {{ end -}} - {{ end }} - - {{ end -}} + {{- end -}} {{- /* Common time zone typos. */ -}} - {{ $date = strings.Replace $date "G6T" "GST" }} + {{- $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 }} + {{- if lt (len (split $date ":")) 3 -}} + {{- $date = delimit (first 3 (after 1 (split $date " "))) " " -}} + {{- end -}} {{ $feeds = $feeds | append (dict @@ -113,13 +113,13 @@ "FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape) "FeedTitle" ($title | plainify | htmlUnescape) ) - }} + -}} - {{ end }} - {{ end }} - {{ end }} + {{- end -}} + {{- end -}} + {{- end -}} - {{ range $feeds }} + {{- range $feeds -}} {{- $imageCanonicalURL := (print @@ -134,35 +134,35 @@ {{- with $image := resources.GetRemote $imageCanonicalURL -}} {{- with .Err -}} - {{ warnf "%s" . }} + {{- warnf "%s" . -}} {{- $fallbackImage := imageConfig (print "static/images/404.png") -}} {{- with $fallbackImage -}} {{- $fallbackWidth := .Width -}} {{- $fallbackHeight := .Height -}} - {{ end }} + {{- end -}} {{- else -}} {{- $imageContent := $image.Content | resources.FromString (print "/data/static/images/" ($image | urlize)) -}} {{- $imageSource = $imageContent.RelPermalink -}} {{- $imageTitle = $imageCanonicalURL -}} - {{ end }} - {{ end }} + {{- end -}} + {{- end -}} - {{ $template := resources.Get "templates/markdown-feed.yaml" }} - {{ $name := urlize (replace (.FeedTitle | truncate 50 "") "/" "-") }} - {{ $path := print "/data/generates/content/" $author.user "/feeds/" $name ".md" }} + {{- $template := resources.Get "templates/markdown-feed.yaml" -}} + {{- $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 }} - {{ end }} + {{- $description := .FeedSourceTitle -}} + {{- if gt (len .FeedSourceDescription) (len .FeedSourceTitle) -}} + {{- $description = .FeedSourceDescription -}} + {{- end -}} - {{ $content := .FeedContentShort }} - {{ if gt (len .FeedTitle) (len .FeedContentShort) }} - {{ $content = .FeedTitle }} - {{ end }} + {{- $content := .FeedContentShort -}} + {{- if gt (len .FeedTitle) (len .FeedContentShort) -}} + {{- $content = .FeedTitle -}} + {{- end -}} - {{ $link := .FeedLink }} - {{ $enclosure := .FeedEnclosure }} + {{- $link := .FeedLink -}} + {{- $enclosure := .FeedEnclosure -}} {{- if or (in .FeedLink "apng") (in .FeedLink "avif") @@ -175,15 +175,15 @@ (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 + -}} + {{- if (.Feedlink | urls.Parse).Host -}} + {{- else -}} + {{- $enclosure = print "http://" .FeedSourceDomain .FeedLink -}} + {{- $link = $enclosure -}} + {{- end -}} + {{- end -}} + + {{- $markdown := resources.ExecuteAsTemplate $path (dict "author" $author.user @@ -200,8 +200,8 @@ "tags" "[rss]" ) $template - }} - {{ $writeToFile := $markdown.RelPermalink }} + -}} + {{- $writeToFile := $markdown.RelPermalink -}} {{ end }} <web-ring> @@ -237,4 +237,4 @@ {{ end }} </aside> </web-ring> -{{ end }} +{{- end -}} |