aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-07-01 22:00:16 -0400
committertdro <tdro@noreply.example.com>2022-07-01 22:00:16 -0400
commit44f95bee10b43e810e570fcafbc3cda54cfe71b5 (patch)
treedc7ca4d70711c74a81ec9af55e6e213e41b4f2e4
parentda474d74e545b077bd9c1f3249eba1efc57e3515 (diff)
downloadcanory-44f95bee10b43e810e570fcafbc3cda54cfe71b5.tar.gz
canory-44f95bee10b43e810e570fcafbc3cda54cfe71b5.tar.bz2
canory-44f95bee10b43e810e570fcafbc3cda54cfe71b5.zip
themes/default/layouts/partials/generate-feeds: Expand check for invalid time zones
Fill in relative links and remove duplicated code. Hopefully we won't need to get serious and validate dates anytime soon.
-rw-r--r--content/default/messages/quickstart.md2
-rw-r--r--themes/default/layouts/_default/home.sources.html2
-rw-r--r--themes/default/layouts/partials/generate-feeds.html46
3 files changed, 20 insertions, 30 deletions
diff --git a/content/default/messages/quickstart.md b/content/default/messages/quickstart.md
index 2661cf1..bd8f0d3 100644
--- a/content/default/messages/quickstart.md
+++ b/content/default/messages/quickstart.md
@@ -11,7 +11,7 @@ explaining how to get started.
GIT CLONE. EXECUTE HUGO TWICE. HUGO VERSION >= 0.94.2.
```shell
-git clone --branch 0.8.13 https://www.thedroneely.com/git/thedroneely/canory
+git clone --branch 0.9.37 https://www.thedroneely.com/git/thedroneely/canory
cd canory
hugo && hugo
```
diff --git a/themes/default/layouts/_default/home.sources.html b/themes/default/layouts/_default/home.sources.html
index 424180a..d2a05e7 100644
--- a/themes/default/layouts/_default/home.sources.html
+++ b/themes/default/layouts/_default/home.sources.html
@@ -93,7 +93,7 @@
<footer>
<p>
- Canory Version: 0.8.13
+ Canory Version: 0.9.37
&middot; Dictionary Access by Paul Lutus: <a href="https://arachnoid.com/javascript/dictionary_access.js">GPLv2+ License</a>
&middot; Feather Icons by Cole Bemis: <a href="https://github.com/feathericons/feather/blob/8b5d6802fa8fd1eb3924b465ff718d2fa8d61efe/LICENSE">MIT License</a>
&middot; Tabler Icons by Paweł Kuna: <a href="https://github.com/tabler/tabler-icons/blob/60f39297d0f785f2e8635faca6857b2260b2d164/LICENSE">MIT License</a>
diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html
index d94e39a..02164f9 100644
--- a/themes/default/layouts/partials/generate-feeds.html
+++ b/themes/default/layouts/partials/generate-feeds.html
@@ -126,15 +126,27 @@
{{- end -}}
- {{- /* Common time zone typos. */ -}}
- {{- $date = strings.Replace $date "G6T" "GST" -}}
+ {{- $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 not ($enclosure | 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)
@@ -147,7 +159,7 @@
"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)
+ "FeedSourceDomain" ($sourceDomain)
"FeedSourceLink" ($sourceLink | plainify | htmlUnescape)
"FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape)
"FeedTitle" ($title | plainify | htmlUnescape)
@@ -197,28 +209,6 @@
{{- $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
@@ -227,9 +217,9 @@
"date" .FeedDateTime
"description" .FeedSourceTitle
"domain" .FeedSourceDomain
- "enclosure" $enclosure
+ "enclosure" .FeedEnclosure
"image" $imageSource
- "link" $link
+ "link" .FeedLink
"name" .FeedName
"raw" (strings.TrimLeft "/" $path)
"self" (print $author.user "/feeds/" $name "/")