aboutsummaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-08-10 01:06:01 -0400
committertdro <tdro@noreply.example.com>2022-08-10 01:06:01 -0400
commita2753213c7a392e3f5d937c67580c356f29d71ba (patch)
tree9d42c2e1261e2698f0e628017dc856e58a77df7c /themes
parent8fff15f984b7d0b9a93c2ac4ef7b8a38230e7454 (diff)
downloadcanory-a2753213c7a392e3f5d937c67580c356f29d71ba.tar.gz
canory-a2753213c7a392e3f5d937c67580c356f29d71ba.tar.bz2
canory-a2753213c7a392e3f5d937c67580c356f29d71ba.zip
themes/default/layouts/partials/generate-feeds: Try to resolve home links
Carefully..
Diffstat (limited to 'themes')
-rw-r--r--themes/default/layouts/partials/following-list.html14
-rw-r--r--themes/default/layouts/partials/function-strip-urlchars.html31
-rw-r--r--themes/default/layouts/partials/generate-feeds.html16
-rw-r--r--themes/default/layouts/partials/meta-handle.html2
4 files changed, 52 insertions, 11 deletions
diff --git a/themes/default/layouts/partials/following-list.html b/themes/default/layouts/partials/following-list.html
index ac86897..4f364d3 100644
--- a/themes/default/layouts/partials/following-list.html
+++ b/themes/default/layouts/partials/following-list.html
@@ -5,15 +5,16 @@
{{- if .Params.feed -}}
{{-
$following = $following | append (dict
- "Name" .Params.feed.name
"Domain" .Params.feed.domain
+ "Name" .Params.feed.name
)
-}}
{{-
$unique = $unique | append (dict
- "Name" .Params.feed.name
"Domain" .Params.feed.domain
"Favicon" .Params.feed.image
+ "Home" .Params.feed.home
+ "Name" .Params.feed.name
)
-}}
{{- end -}}
@@ -26,9 +27,12 @@
{{- $name := .Name -}}
{{- $favicon := .Domain -}}
+ {{- $href := print "http://" $author.Domain -}}
+
{{- range $unique := uniq $unique -}}
{{- if and (eq $unique.Name $name) (eq $unique.Domain $favicon) -}}
{{- $favicon = $unique.Favicon -}}
+ {{- $href = or $unique.Home $href -}}
{{- end -}}
{{- end -}}
@@ -37,7 +41,7 @@
<micro-summary>
<micro-thumbnail>
<figure>
- <a title="{{ $author.Name }}" href="http://{{ $author.Name }}">
+ <a title="{{ $author.Name }}" href="{{ $href }}">
<picture>
<img
width="64"
@@ -51,9 +55,9 @@
</micro-thumbnail>
<micro-header>
<h2><b>{{ $author.Name }}</b></h2>
- <h3><a title="{{ $author.Name }}" href="http://{{ $author.Domain }}">@{{ $author.Domain }}</a></h3>
+ <h3><a title="{{ $author.Name }}" href="{{ $href }}">@{{ $author.Domain }}</a></h3>
</micro-header>
- <a title="Follow {{ $author.Name }}" href="http://{{ $author.Domain }}">
+ <a title="Follow {{ $author.Name }}" href="{{ $href }}">
{{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/rss.svg")) }}
<span>Follow</span>
</a>
diff --git a/themes/default/layouts/partials/function-strip-urlchars.html b/themes/default/layouts/partials/function-strip-urlchars.html
new file mode 100644
index 0000000..252d496
--- /dev/null
+++ b/themes/default/layouts/partials/function-strip-urlchars.html
@@ -0,0 +1,31 @@
+{{- $input := . -}}
+
+{{-
+ $output := $input |
+ replaceRE "{" "" |
+ replaceRE "}" "" |
+ replaceRE "|" "" |
+ replaceRE "\\\\" "" |
+ replaceRE "^" "" |
+ replaceRE "\\[" "" |
+ replaceRE "\\]" "" |
+ replaceRE "`" "" |
+ replaceRE ";" "" |
+ replaceRE "/" "" |
+ replaceRE "\\?" "" |
+ replaceRE ":" "" |
+ replaceRE "@" "" |
+ replaceRE "&" "" |
+ replaceRE "=" "" |
+ replaceRE "\\+" "" |
+ replaceRE "$" "" |
+ replaceRE "," "" |
+ replaceRE "\\." "" |
+ replaceRE "<" "" |
+ replaceRE ">" "" |
+ replaceRE "#" "" |
+ replaceRE "%" "" |
+ replaceRE "\"" ""
+-}}
+
+{{- return $output -}}
diff --git a/themes/default/layouts/partials/generate-feeds.html b/themes/default/layouts/partials/generate-feeds.html
index 62aba9d..76186fd 100644
--- a/themes/default/layouts/partials/generate-feeds.html
+++ b/themes/default/layouts/partials/generate-feeds.html
@@ -19,9 +19,10 @@
{{- $description := "No description found." -}}
{{- $enclosure := "" -}}
{{- $imageLink := "" -}}
- {{- $link := "https://example.com/link" -}}
+ {{- $link := "https://example.com/link/" -}}
{{- $sourceDescription := "No source description found." -}}
- {{- $sourceLink := "https://example.com/" -}}
+ {{- $sourceHome := "" -}}
+ {{- $sourceLink := "https://example.com/rss/" -}}
{{- $sourceTitle := "No source title found" -}}
{{- $title := "No Title Found" -}}
@@ -32,7 +33,8 @@
{{- if reflect.IsSlice .link -}}
{{- if reflect.IsMap (index .link 0) -}}
- {{- $sourceLink = index (index .link 0) "-href" -}}
+ {{- $sourceLink = index (first 1 .link) 0 "-href" -}}
+ {{- $sourceHome = index (last 1 .link) 0 -}}
{{- else -}}
{{- $sourceLink = index .link 0 -}}
{{- end -}}
@@ -167,6 +169,7 @@
"FeedSourceDescription" ($sourceDescription | plainify | htmlUnescape)
"FeedSourceDomain" ($sourceDomain)
"FeedSourceLink" ($sourceLink | plainify | htmlUnescape)
+ "FeedSourceHome" ($sourceHome | plainify | htmlUnescape)
"FeedSourceTitle" ($sourceTitle | plainify | htmlUnescape)
"FeedTitle" ($title | plainify | htmlUnescape)
)
@@ -203,7 +206,9 @@
-}}
{{- $template := resources.Get "templates/markdown-feed.yaml" -}}
- {{- $name := print (delimit (first 8 (split (.FeedTitle | urlize) "-")) "-" | humanize | urlize) "-" (.FeedLink | sha256 | truncate 8 "") | humanize | urlize -}}
+ {{- $name := print (delimit (first 8 (split (.FeedTitle | urlize) "-")) "-" | humanize | urlize) "-" (.FeedLink | sha256 | truncate 8 "") -}}
+ {{- $name = partial "function-strip-urlchars.html" $name -}}
+
{{- $path := print "/data/generates/content/" $author.user "/feeds/" $name ".md" -}}
{{- $description := .FeedDescriptionShort -}}
@@ -226,6 +231,7 @@
"domain" .FeedSourceDomain
"enclosure" .FeedEnclosure
"image" $imageSource
+ "home" .FeedSourceHome
"link" .FeedLink
"name" .FeedName
"raw" (strings.TrimLeft "/" $path)
@@ -265,7 +271,7 @@
<a
title="{{ .FeedSourceDescription }}"
- href="{{ .FeedSourceLink }}">
+ href="{{ or .FeedSourceHome .FeedSourceLink }}">
{{ .FeedSourceTitle }}
</a>
</web-ring-item>
diff --git a/themes/default/layouts/partials/meta-handle.html b/themes/default/layouts/partials/meta-handle.html
index 0fbba06..5fa9811 100644
--- a/themes/default/layouts/partials/meta-handle.html
+++ b/themes/default/layouts/partials/meta-handle.html
@@ -11,7 +11,7 @@
{{- with .Params.feed -}}
{{- $host = $.Params.feed.domain -}}
- {{- $href = print "http://" $.Params.feed.domain -}}
+ {{- $href = or $.Params.feed.home (print "http://" $.Params.feed.domain) -}}
{{- $title = $.Params.feed.domain -}}
{{- end -}}