diff options
| author | tdro <tdro@noreply.example.com> | 2025-03-11 00:00:00 +0000 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2025-03-11 00:00:00 +0000 |
| commit | 7cada9c55b73297532bcd3e2e6c20ba852e1b881 (patch) | |
| tree | 35dcfc7162378984342f775892db68d67630c2c5 | |
| parent | 6d4268e9f8a5124d48aecd7d5deff5eb5c2e3b51 (diff) | |
| download | canory-7cada9c55b73297532bcd3e2e6c20ba852e1b881.tar.gz canory-7cada9c55b73297532bcd3e2e6c20ba852e1b881.tar.bz2 canory-7cada9c55b73297532bcd3e2e6c20ba852e1b881.zip | |
themes/default/layouts/partials/function-page-modified: Control paginators and mark segments
Carefully negate the pagination
| -rw-r--r-- | config/_default/config.json | 37 | ||||
| -rw-r--r-- | config/_default/config.toml | 10 | ||||
| -rw-r--r-- | config/_default/config.yaml | 10 | ||||
| -rw-r--r-- | themes/default/layouts/_default/_markup/render-image.html | 8 | ||||
| -rw-r--r-- | themes/default/layouts/_default/baseof.html | 2 | ||||
| -rw-r--r-- | themes/default/layouts/_default/baseof.json | 1 | ||||
| -rw-r--r-- | themes/default/layouts/_default/baseof.txt | 2 | ||||
| -rw-r--r-- | themes/default/layouts/_default/baseof.xml | 1 | ||||
| -rw-r--r-- | themes/default/layouts/_default/section.gallery.html | 2 | ||||
| -rw-r--r-- | themes/default/layouts/_default/section.webfeeds.html | 2 | ||||
| -rw-r--r-- | themes/default/layouts/_default/section.weblinks.html | 2 | ||||
| -rw-r--r-- | themes/default/layouts/_default/single.embed.html | 2 | ||||
| -rw-r--r-- | themes/default/layouts/_default/single.plain.txt | 10 | ||||
| -rw-r--r-- | themes/default/layouts/partials/author-data.html | 1 | ||||
| -rw-r--r-- | themes/default/layouts/partials/function-page-modified.html | 86 |
15 files changed, 142 insertions, 34 deletions
diff --git a/config/_default/config.json b/config/_default/config.json index 97cedc3..348c53c 100644 --- a/config/_default/config.json +++ b/config/_default/config.json @@ -150,6 +150,43 @@ "default": { "footer": "A Micro Blog" } + }, + "segments": { + "render": { + "pagers": [ + "home", + "section", + "taxonomy", + "term" + ], + "kinds": [ + "page", + "home", + "section", + "taxonomy", + "term" + ], + "labels": { + "page": [ + "baseof.html" + ], + "home": [ + "baseof.html" + ], + "section": [ + "baseof.html", + "gallery.html", + "webfeeds.html", + "weblinks.html" + ], + "taxonomy": [ + "baseof.html" + ], + "term": [ + "baseof.html" + ] + } + } } }, "related": { diff --git a/config/_default/config.toml b/config/_default/config.toml index 7d954f6..f18d77b 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -97,6 +97,16 @@ enableRobotsTXT = true list = ["canory", "default", "nobody"] [params.authors.default] footer = "A Micro Blog" + [params.segments] + [params.segments.render] + pagers = ["home", "section", "taxonomy", "term"] + kinds = ["page", "home", "section", "taxonomy", "term"] + [params.segments.render.labels] + page = ["baseof.html"] + home = ["baseof.html"] + section = ["baseof.html", "gallery.html", "webfeeds.html", "weblinks.html"] + taxonomy = ["baseof.html"] + term = ["baseof.html"] [related] includeNewer = false diff --git a/config/_default/config.yaml b/config/_default/config.yaml index 7b71ffd..15d5dc6 100644 --- a/config/_default/config.yaml +++ b/config/_default/config.yaml @@ -93,6 +93,16 @@ params: - nobody default: footer: A Micro Blog + segments: + render: + pagers: [home, section, taxonomy, term] + kinds: [page, home, section, taxonomy, term] + labels: + page: [baseof.html] + home: [baseof.html] + section: [baseof.html, gallery.html, webfeeds.html, weblinks.html] + taxonomy: [baseof.html] + term: [baseof.html] related: includeNewer: false diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index 018b225..b562641 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -1,3 +1,10 @@ +{{- $modified := partial "function-page-modified.html" + (dict + "Context" . + ) +-}} + +{{- if $modified -}} {{- $href := "" -}} {{- $cache := "" -}} {{- $width := "" -}} @@ -130,3 +137,4 @@ </figcaption> </figure> {{- /* This comment removes trailing newlines and white spaces. */ -}} +{{- end -}} diff --git a/themes/default/layouts/_default/baseof.html b/themes/default/layouts/_default/baseof.html index c277115..abd2bd0 100644 --- a/themes/default/layouts/_default/baseof.html +++ b/themes/default/layouts/_default/baseof.html @@ -1,7 +1,7 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true + "Label" "baseof.html" ) -}} diff --git a/themes/default/layouts/_default/baseof.json b/themes/default/layouts/_default/baseof.json index e1203cc..6a9b2d9 100644 --- a/themes/default/layouts/_default/baseof.json +++ b/themes/default/layouts/_default/baseof.json @@ -1,7 +1,6 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true ) -}} diff --git a/themes/default/layouts/_default/baseof.txt b/themes/default/layouts/_default/baseof.txt index c354667..63e47d5 100644 --- a/themes/default/layouts/_default/baseof.txt +++ b/themes/default/layouts/_default/baseof.txt @@ -1,7 +1,7 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true + "Format" "index.txt" ) -}} diff --git a/themes/default/layouts/_default/baseof.xml b/themes/default/layouts/_default/baseof.xml index 73f129f..f0a70c5 100644 --- a/themes/default/layouts/_default/baseof.xml +++ b/themes/default/layouts/_default/baseof.xml @@ -1,7 +1,6 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true ) -}} diff --git a/themes/default/layouts/_default/section.gallery.html b/themes/default/layouts/_default/section.gallery.html index 761a276..c345ac1 100644 --- a/themes/default/layouts/_default/section.gallery.html +++ b/themes/default/layouts/_default/section.gallery.html @@ -3,7 +3,7 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true + "Label" "gallery.html" ) -}} diff --git a/themes/default/layouts/_default/section.webfeeds.html b/themes/default/layouts/_default/section.webfeeds.html index 6a23a1e..0647e6f 100644 --- a/themes/default/layouts/_default/section.webfeeds.html +++ b/themes/default/layouts/_default/section.webfeeds.html @@ -3,7 +3,7 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true + "Label" "webfeeds.html" ) -}} diff --git a/themes/default/layouts/_default/section.weblinks.html b/themes/default/layouts/_default/section.weblinks.html index 78bf4a4..8d0e357 100644 --- a/themes/default/layouts/_default/section.weblinks.html +++ b/themes/default/layouts/_default/section.weblinks.html @@ -3,7 +3,7 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" . - "Disable" true + "Label" "weblinks.html" ) -}} diff --git a/themes/default/layouts/_default/single.embed.html b/themes/default/layouts/_default/single.embed.html index 73a3add..f1cdc66 100644 --- a/themes/default/layouts/_default/single.embed.html +++ b/themes/default/layouts/_default/single.embed.html @@ -22,5 +22,5 @@ {{- if $modified -}} {{- partial "head-embed.html" . -}} - {{- .Render "summary" -}} + {{- $pageContext.Render "summary" -}} {{- end -}} diff --git a/themes/default/layouts/_default/single.plain.txt b/themes/default/layouts/_default/single.plain.txt index f46e495..94efa49 100644 --- a/themes/default/layouts/_default/single.plain.txt +++ b/themes/default/layouts/_default/single.plain.txt @@ -1,3 +1,11 @@ {{- define "main" -}} - {{- partial "function-content.html" . | plainify | htmlUnescape -}} + {{- $modified := partial "function-page-modified.html" + (dict + "Context" . + "Format" "index.txt" + ) + -}} + {{- if $modified -}} + {{- partial "function-content.html" . | plainify | htmlUnescape -}} + {{- end -}} {{- end -}} diff --git a/themes/default/layouts/partials/author-data.html b/themes/default/layouts/partials/author-data.html index f26451e..46d0822 100644 --- a/themes/default/layouts/partials/author-data.html +++ b/themes/default/layouts/partials/author-data.html @@ -4,7 +4,6 @@ {{- $modified := partial "function-page-modified.html" (dict "Context" $pageContext - "Disable" true ) -}} diff --git a/themes/default/layouts/partials/function-page-modified.html b/themes/default/layouts/partials/function-page-modified.html index 959a25a..26cf9ca 100644 --- a/themes/default/layouts/partials/function-page-modified.html +++ b/themes/default/layouts/partials/function-page-modified.html @@ -1,45 +1,83 @@ {{- $file := "/:" -}} +{{- $modified := false -}} {{- $pageContext := .Context -}} -{{- $disable := or .Disable false -}} +{{- $label := or .Label "label.html" -}} {{- $format := or .Format "index.html" -}} +{{- $segments := or site.Params.segments (dict "render" (dict "" "")) -}} -{{- $page := print "public/" (strings.TrimPrefix - $pageContext.Page.Site.BaseURL - $pageContext.Page.Permalink - ) $format --}} - +{{- $page := print "public/" (strings.TrimPrefix $pageContext.Page.Site.BaseURL $pageContext.Page.Permalink) $format -}} {{- $page = partial "function-normalize-url.html" $page -}} {{- with $pageContext.Page.File -}} {{- $file = print $pageContext.Page.File.Dir $pageContext.Page.File.BaseFileName "." $pageContext.Page.File.Ext -}} {{- end -}} -{{- $pageModTime := "" -}} -{{- $markdownModTime := "" -}} +{{- $pageTime := 0 -}} +{{- $markTime := 0 -}} + {{- $markdownContent := print "content/" $file -}} {{- $markdownPublic := print "public/data/generates/content/" $file -}} -{{- with fileExists $markdownContent -}} - {{- $markdownModTime = (os.Stat $markdownContent).ModTime -}} +{{- with fileExists $markdownPublic -}} {{- $markTime = (os.Stat $markdownPublic).ModTime.Unix -}} {{- end -}} +{{- with fileExists $markdownContent -}} {{- $markTime = (os.Stat $markdownContent).ModTime.Unix -}} {{- end -}} +{{- with fileExists $page -}} {{- $pageTime = (os.Stat $page).ModTime.Unix -}} {{- end -}} + +{{- if (in $segments.render.kinds "page") -}} {{- $modified = gt (sub $markTime $pageTime) 0 -}} {{- end -}} + +{{- if or + (not (isset $segments.render "kinds")) + (and (in $segments.render.kinds "home") (in "home" $pageContext.Page.Kind)) + (and (in $segments.render.kinds "section") (in "section" $pageContext.Page.Kind)) + (and (in $segments.render.kinds "taxonomy") (in "taxonomy" $pageContext.Page.Kind)) + (and (in $segments.render.kinds "term") (in "term" $pageContext.Page.Kind)) +-}} + {{- $modified = true -}} {{- end -}} -{{- with fileExists $markdownPublic -}} - {{- $markdownModTime = (os.Stat $markdownPublic).ModTime -}} +{{- if or + (not (isset $segments.render "labels")) + (and (in $segments.render.kinds "page") (in $segments.render.labels.page "baseof.html") (in "page" $pageContext.Page.Kind) (in (slice "baseof.html") $label)) + (and (in $segments.render.kinds "home") (in $segments.render.labels.home "baseof.html") (in "home" $pageContext.Page.Kind) (in (slice "baseof.html") $label)) + + (and (in $segments.render.kinds "section") (in $pageContext.Page.Layout "section.feeds") (in $segments.render.labels.section $label)) + + (and (in $segments.render.kinds "taxonomy") (in $segments.render.labels.taxonomy "baseof.html") (in "taxonomy" $pageContext.Page.Kind) (in (slice "baseof.html") $label)) + (and (in $segments.render.kinds "term") (in $segments.render.labels.term "baseof.html") (in "term" $pageContext.Page.Kind) (in (slice "baseof.html") $label)) +-}} + {{- $modified = true -}} {{- end -}} -{{- with fileExists $page -}} - {{- $pageModTime = (os.Stat $page).ModTime -}} +{{- if and + (not (in "page" $pageContext.Page.Kind)) + (or + (and (not (in $segments.render.pagers "home")) (in "home" $pageContext.Page.Kind)) + (and (not (in $segments.render.pagers "section")) (in "section" $pageContext.Page.Kind)) + (and (not (in $segments.render.pagers "taxonomy")) (in "taxonomy" $pageContext.Page.Kind)) + (and (not (in $segments.render.pagers "term")) (in "term" $pageContext.Page.Kind)) + ) +-}} + {{- with $pageContext.Page.Paginator -}} + {{- if and ($pageContext.Page.Pages) (gt $pageContext.Page.Paginator.PageNumber 1) -}} + {{- $modified = false -}} + {{- end -}} + {{- end -}} {{- end -}} -{{- $page = gt $markdownModTime $pageModTime -}} +{{- with $embed := resources.Get $page -}} + {{- if (in $embed.Content "/data/media/404.png") -}} + {{- $modified = true -}} + {{- end -}} +{{- end -}} -{{- $modified := or $page (in (slice - "home" - "section" - "taxonomy" - "term" - ) $pageContext.Page.Kind) --}} +{{- if (and (in $segments.render.debug true) (in $segments.render.debug false)) -}} + {{- warnf "%b %s %s %s %s" $modified $pageContext.Page.Kind $label $pageContext.Page.Type $page -}} +{{- else -}} + {{- if (and ($modified) (in $segments.render.debug true)) -}} + {{- warnf "%b %s %s %s %s" $modified $pageContext.Page.Kind $label $pageContext.Page.Type $page -}} + {{- end -}} + {{- if (and (not $modified) (in $segments.render.debug false)) -}} + {{- warnf "%b %s %s %s %s" $modified $pageContext.Page.Kind $label $pageContext.Page.Type $page -}} + {{- end -}} +{{- end -}} -{{- return (or $disable $modified) -}} +{{- return $modified -}} |
