diff options
| author | tdro <tdro@noreply.example.com> | 2025-03-05 00:00:00 +0000 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2025-03-05 00:00:00 +0000 |
| commit | a9a2e531e9c5dca0a87c520a8311e173daac3599 (patch) | |
| tree | 363af58aa674437ab40e6cbba99f85b0bde5ae27 | |
| parent | 0f44e3e17f84fd733616969f5804b5abf796e87b (diff) | |
| download | canory-a9a2e531e9c5dca0a87c520a8311e173daac3599.tar.gz canory-a9a2e531e9c5dca0a87c520a8311e173daac3599.tar.bz2 canory-a9a2e531e9c5dca0a87c520a8311e173daac3599.zip | |
themes/default/layouts: Normalize indeterminate URLs
10 files changed, 34 insertions, 15 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index 98f5e18..1c0d4ba 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -91,6 +91,11 @@ {{- $href = print ("" | relURL) $source -}} {{- end -}} +{{- $cache = replaceRE `:\/` "://" ($cache | replaceRE `\/+` "/") 1 -}} +{{- $source = replaceRE `:\/` "://" ($source | replaceRE `\/+` "/") 1 -}} +{{- $srcset = replaceRE `:\/` "://" ($srcset | replaceRE `\/+` "/") 1 -}} +{{- $href = replaceRE `:\/` "://" ($href | replaceRE `\/+` "/") 1 -}} + {{- with $caption := $.Title -}} {{- $figcaption = $caption | markdownify -}} {{ end }} diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml index 1239c30..6fb59f0 100644 --- a/themes/default/layouts/_default/rss.xml +++ b/themes/default/layouts/_default/rss.xml @@ -48,7 +48,7 @@ {{- $filteredPages := partial "function-filters-content.html" .Paginator.Pages -}} -{{- $xsl := replace (print ("" | relURL) "/rss.xsl") "//" "/" -}} +{{- $xsl := replaceRE `:\/` "://" (print ("" | relURL) "/rss.xsl" | replaceRE `\/+` "/") 1 -}} {{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} {{ printf `<?xml-stylesheet href=%q type="text/xsl"?>` $xsl | safeHTML }} @@ -67,7 +67,7 @@ <lastBuildDate>{{ $lastBuildDate }}</lastBuildDate> <image> <title>{{ $title }}</title> - <url>{{ $absURL }}{{ $image }}</url> + <url>{{ replaceRE `:\/` "://" (print $absURL $image | replaceRE `\/+` "/") 1 }}</url> <link>{{ .Permalink }}</link> </image> @@ -104,7 +104,7 @@ </description> <atom:author> <atom:name>{{ $atomAuthorName }}</atom:name> - <atom:uri>{{ $atomAuthorUri }}</atom:uri> + <atom:uri>{{ replaceRE `:\/` "://" ($atomAuthorUri | replaceRE `\/+` "/") 1 }}</atom:uri> </atom:author> </item> diff --git a/themes/default/layouts/_default/sitemap.xml b/themes/default/layouts/_default/sitemap.xml index 3afd95c..9b6720a 100644 --- a/themes/default/layouts/_default/sitemap.xml +++ b/themes/default/layouts/_default/sitemap.xml @@ -1,4 +1,4 @@ -{{- $xsl := replace (print ("" | relURL) "/sitemap.xsl") "//" "/" -}} +{{- $xsl := replaceRE `:\/` "://" (print ("" | relURL) "/sitemap.xsl" | replaceRE `\/+` "/") 1 -}} {{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} {{ printf `<?xml-stylesheet href=%q type="text/xsl"?>` $xsl | safeHTML }} diff --git a/themes/default/layouts/partials/function-page-modified.html b/themes/default/layouts/partials/function-page-modified.html index 467829d..9f56f6d 100644 --- a/themes/default/layouts/partials/function-page-modified.html +++ b/themes/default/layouts/partials/function-page-modified.html @@ -9,6 +9,8 @@ ) $format -}} +{{- $page = replaceRE `:\/` "://" ($page | replaceRE `\/+` "/") 1 -}} + {{- with $pageContext.Page.File -}} {{- $file = print $pageContext.Page.File.Dir $pageContext.Page.File.BaseFileName "." $pageContext.Page.File.Ext -}} {{- end -}} diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html index 090eabe..e5b8f90 100644 --- a/themes/default/layouts/partials/gallery-walk.html +++ b/themes/default/layouts/partials/gallery-walk.html @@ -5,15 +5,15 @@ {{- range (where $filteredPages "Section" $author.user) -}} {{- if in .Content "<picture>" -}} {{- $data = $data | append (dict - "srcset" (delimit (findRE `(?sU)\s{8}srcset=".*"` .Content 1) "") + "relatedHref" (.Permalink) "type" (delimit (findRE `(?sU)\s{8}type=".*"` .Content 1) "") "alt" (delimit (findRE `(?sU)\s{8}alt=".*"` .Content 1) "") "height" (delimit (findRE `(?sU)\s{8}height=".*"` .Content 1) "") - "src" (delimit (findRE `(?sU)\s{8}src=".*"` .Content 1) "") "style" (delimit (findRE `(?sU)\s{8}style=".*"` .Content 1) "") "title" (delimit (findRE `(?sU)\s{8}title=".*"` .Content 1) "") "width" (delimit (findRE `(?sU)\s{8}width=".*"` .Content 1) "") - "relatedHref" .Permalink + "srcset" (replaceRE `:\/` "://" (delimit (findRE `(?sU)\s{8}srcset=".*"` .Content 1) "" | replaceRE `\/+` "/") 1) + "src" (replaceRE `:\/` "://" (delimit (findRE `(?sU)\s{8}src=".*"` .Content 1) "" | replaceRE `\/+` "/") 1) ) -}} {{- end -}} diff --git a/themes/default/layouts/partials/menu-markdown.html b/themes/default/layouts/partials/menu-markdown.html index 4d8016d..bd78f74 100644 --- a/themes/default/layouts/partials/menu-markdown.html +++ b/themes/default/layouts/partials/menu-markdown.html @@ -1,9 +1,11 @@ {{- if not .ExpiryDate -}} {{- $relURL := strings.TrimPrefix .Page.Site.BaseURL .Page.Permalink -}} {{- $source := print (path.Dir $relURL) ".md" -}} - {{- $href := print (partial "function-paths.html").markdown $source | relURL -}} + {{- $href := print (partial "function-paths.html").markdown "/" $source | relURL -}} {{- $title := .File.LogicalName -}} + {{- $href = replaceRE `:\/` "://" ($href | replaceRE `\/+` "/") 1 -}} + <meta-source> <a href="{{ $href }}" title="{{ $title }}"> {{- safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/square-letter-m.svg")) -}} diff --git a/themes/default/layouts/partials/navigator.css.html b/themes/default/layouts/partials/navigator.css.html index 56cd78d..3545096 100644 --- a/themes/default/layouts/partials/navigator.css.html +++ b/themes/default/layouts/partials/navigator.css.html @@ -1,6 +1,6 @@ {{- $href := print ("" | relURL) .Link -}} -{{- $href = replace $href "//" "/" -}} +{{- $href = replaceRE `:\/` "://" ($href | replaceRE `\/+` "/") 1 -}} icon-navigator a[href="{{ $href }}"], column-base[position="left"] nav a[href="{{ $href }}"] { diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index 070e3cb..0463505 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -45,7 +45,7 @@ {{- end -}} {{- else -}} {{- with $cache = resources.Get (path.Join "public/" $storage) -}} - {{- $cache = (strings.TrimPrefix "public/" $cache) -}} + {{- $cache = $cache | strings.TrimPrefix "public/" | strings.TrimPrefix "/public/" -}} {{- end -}} {{- end -}} @@ -57,6 +57,9 @@ {{- $source = .Source -}} {{- end -}} +{{- $cache = replaceRE `:\/` "://" ($cache | replaceRE `\/+` "/") 1 -}} +{{- $source = replaceRE `:\/` "://" ($source | replaceRE `\/+` "/") 1 -}} + <video-container> <video title="{{ .Title }}" diff --git a/themes/default/layouts/shortcodes/attach.html b/themes/default/layouts/shortcodes/attach.html index a3506b7..f8e78dc 100644 --- a/themes/default/layouts/shortcodes/attach.html +++ b/themes/default/layouts/shortcodes/attach.html @@ -48,7 +48,7 @@ {{- with $cache = resources.Get (path.Join "public/" $storage) -}} {{- $type = $cache.MediaType -}} - {{- $cache = (strings.TrimPrefix "public/" $cache) -}} + {{- $cache = $cache | strings.TrimPrefix "public/" | strings.TrimPrefix "/public/" -}} {{- end -}} {{- end -}} @@ -71,6 +71,11 @@ {{- if (in $data "pdf") -}} {{- $type = "application/pdf" -}} {{- end -}} +{{- $cache = replaceRE `:\/` "://" ($cache | replaceRE `\/+` "/") 1 -}} +{{- $canonical = replaceRE `:\/` "://" ($canonical | replaceRE `\/+` "/") 1 -}} +{{- $data = replaceRE `:\/` "://" ($data | replaceRE `\/+` "/") 1 -}} +{{- $url = replaceRE `:\/` "://" ($url | replaceRE `\/+` "/") 1 -}} + <document-attachment title="{{ $title }}"> <object type="{{ $type }}" data="{{ $data }}"> <p> diff --git a/themes/default/layouts/shortcodes/markdown.html b/themes/default/layouts/shortcodes/markdown.html index 4d7fd08..3a8b082 100644 --- a/themes/default/layouts/shortcodes/markdown.html +++ b/themes/default/layouts/shortcodes/markdown.html @@ -1,7 +1,9 @@ -{{- $link := default (print "/" (partial "function-paths.html").markdown "/" .Page.File ) (.Get "link" | default (.Get 0)) -}} -{{- $text := default (path.Base .Page.File) (.Get "text" | default (.Get 1)) -}} -{{- $title := default "" (.Get "title" | default (.Get 2)) -}} -{{- $embed := default false (.Get "embed" | default (.Get 3)) -}} +{{- $file := print .Page.File.Dir .Page.File.BaseFileName "." .Page.File.Ext -}} + +{{- $link := default (print "/" (partial "function-paths.html").markdown "/" $file) (.Get "link" | default (.Get 0)) -}} +{{- $text := default (path.Base $file) (.Get "text" | default (.Get 1)) -}} +{{- $title := default "" (.Get "title" | default (.Get 2)) -}} +{{- $embed := default false (.Get "embed" | default (.Get 3)) -}} {{- if $embed -}} {{- if not $title -}} |
