From 9c238619e53833378a168202fcc2b40bf5d2260a Mon Sep 17 00:00:00 2001 From: teldra Date: Thu, 7 Apr 2022 16:31:15 +0200 Subject: [PATCH] small fixes --- config.toml | 1 + content/news/foodsaving/index.de.md | 4 +- content/news/revista/index.de.md | 4 +- themes/buha/layouts/_default/archive.html | 3 +- themes/buha/layouts/_default/categories.html | 1 - themes/buha/layouts/_default/contact.html | 1 + themes/buha/layouts/_default/imprint.html | 13 +++-- themes/buha/layouts/_default/list.html | 41 -------------- themes/buha/layouts/_default/misc.html | 3 +- themes/buha/layouts/_default/news.html | 31 ++++++++++ themes/buha/layouts/_default/taxonomy.html | 24 +++++--- themes/buha/layouts/index.html | 34 ++++++----- .../layouts/partials/contentlayouts/list.html | 56 ++++++++++++++----- .../partials/contentlayouts/termlist.html | 29 ++++++++++ themes/buha/layouts/partials/debug.html | 6 ++ 15 files changed, 159 insertions(+), 92 deletions(-) delete mode 100644 themes/buha/layouts/_default/categories.html delete mode 100644 themes/buha/layouts/_default/list.html create mode 100644 themes/buha/layouts/_default/news.html create mode 100644 themes/buha/layouts/partials/contentlayouts/termlist.html create mode 100644 themes/buha/layouts/partials/debug.html diff --git a/config.toml b/config.toml index 4b5b85d0..57b29881 100644 --- a/config.toml +++ b/config.toml @@ -31,6 +31,7 @@ featured = 'featured' #do you want a contact page? contact = true + #do you want an archive? archive = true diff --git a/content/news/foodsaving/index.de.md b/content/news/foodsaving/index.de.md index ee59e2c2..03841d54 100644 --- a/content/news/foodsaving/index.de.md +++ b/content/news/foodsaving/index.de.md @@ -1,10 +1,12 @@ --- title: "Food Saving" -date: "2021-02-04T19:00:00+02:00" +date: "2021-04-06T19:00:00+02:00" +lastmod: "2021-04-06T19:00:00+02:00" about: true when: "Jeden Mittwoch 18:30-19:00Uhr & Samstags 15:00-15:30Uhr" events: ["Regelmäßig"] contact: "foodsavingcelle@riseup.net" +featured: true --- Die **kostenfreie** Verteilung von gespendeten und geretteten **Lebensmitteln** geht auch nach der Wiedereröffnung der Tafel weiter. Spenden? Mitmachen? Wer **mitmachen** oder uns unterstützen möchte, kann sich per Mail melden, sodass wir bei Bedarf nachfragen können. diff --git a/content/news/revista/index.de.md b/content/news/revista/index.de.md index fb1c7a6c..0c6d8b2c 100644 --- a/content/news/revista/index.de.md +++ b/content/news/revista/index.de.md @@ -1,6 +1,8 @@ --- title: "Zeitungsprojekt Revista" date: "1993-09-04T19:00:00+02:00" +lastmod: "2022-04-04T19:00:00+02:00" +featured: true about: true --- Was ist Revista? Revista ist spanisch und heißt Zeitung, und genau das sind wir, eine Zeitung. Die revista ist ein relativ neues Projekt, die erste Ausgabe erschien um Oktober 1999. @@ -25,4 +27,4 @@ c/o Buntes Haus Hannoversche Str. 30F 29221 Celle -Oder schreibt einfach eine Email an: revista.celle (at) gmx.de \ No newline at end of file +Oder schreibt einfach eine Email an: revista.celle (at) gmx.de diff --git a/themes/buha/layouts/_default/archive.html b/themes/buha/layouts/_default/archive.html index 591262b9..62ad30c8 100644 --- a/themes/buha/layouts/_default/archive.html +++ b/themes/buha/layouts/_default/archive.html @@ -7,6 +7,7 @@ {{ end }} {{ define "main" }} +{{ if site.Params.debug }}archive.html{{ end }}
{{ $prev := 3000}} {{range where .Site.RegularPages "Type" "in" site.Params.searchSections }} @@ -21,4 +22,4 @@ {{ $prev = $date.Format "2006"}} {{end}}
-{{ end }} \ No newline at end of file +{{ end }} diff --git a/themes/buha/layouts/_default/categories.html b/themes/buha/layouts/_default/categories.html deleted file mode 100644 index 9118d6c9..00000000 --- a/themes/buha/layouts/_default/categories.html +++ /dev/null @@ -1 +0,0 @@ -asdasd \ No newline at end of file diff --git a/themes/buha/layouts/_default/contact.html b/themes/buha/layouts/_default/contact.html index 8767f70e..4211409e 100644 --- a/themes/buha/layouts/_default/contact.html +++ b/themes/buha/layouts/_default/contact.html @@ -7,6 +7,7 @@ {{ end }} {{ define "main" }} +{{ if site.Params.debug }}contact.html{{ end }} {{- $pic := index (.Resources.ByType "image") 0 -}}
diff --git a/themes/buha/layouts/_default/imprint.html b/themes/buha/layouts/_default/imprint.html index 8cbbb401..a5cfc28f 100644 --- a/themes/buha/layouts/_default/imprint.html +++ b/themes/buha/layouts/_default/imprint.html @@ -7,13 +7,14 @@ {{ end }} {{ define "main" }} -{{ if .Resources.ByType "image" }} -
-
+ {{ if site.Params.debug }}imprint.html{{ end }} + {{ if .Resources.ByType "image" }} +
+
- {{ range .Resources.ByType "image" }} - - {{- end -}} + {{ range .Resources.ByType "image" }} + + {{- end -}} {{ end }} {{ if .Resources.ByType "image" }} diff --git a/themes/buha/layouts/_default/list.html b/themes/buha/layouts/_default/list.html deleted file mode 100644 index 506ee1be..00000000 --- a/themes/buha/layouts/_default/list.html +++ /dev/null @@ -1,41 +0,0 @@ -{{- define "title" -}} - {{ $name := .Name | lower }} - {{ if ne ($name | i18n) "" }} - {{ $name = $name | i18n }} - {{ else }} - {{ if ne .Section "events" }} - {{ $name = $name | singularize }} - {{ end }} - {{ $name = $name | humanize }} - {{ end }} -

{{ $name }}

-{{- end -}} - -{{- define "main" -}} - {{ $title := lower .Title }} - {{ $s := .Site.Params }} - {{- $paginator := slice -}} - {{ $what := printf ".Params.%s" $title }} - {{ if or (eq $title "about") (eq $title "featured") }} - {{- $paginator = .Paginate (where (where .Site.RegularPages "Type" "in" site.Params.searchSections) $what "eq" true) -}} - {{ else if eq $title "events" }} - {{- $paginator = .Paginate (where (where .Site.RegularPages "Type" "in" site.Params.searchSections) ".Params.when" "ne" nil) -}} - {{ else }} - {{- $paginator = .Paginate .Data.Pages -}} - {{ end }} - {{ if eq $paginator.PageNumber 1 }} - {{ if ne .Content "" }} -
- {{ .Content }} -
- {{ end }} - {{ end }} - {{- range first 5 $paginator.Pages.ByLastmod.Reverse -}} - {{ partial "contentlayouts/list.html" . }} - {{- end }} - {{ partial "structure/paginator" (dict "paginator" $paginator) }} -{{- end -}} - -{{ define "sidebar" }} - {{- partial "contentlayouts/menu.html" . }} -{{ end }} diff --git a/themes/buha/layouts/_default/misc.html b/themes/buha/layouts/_default/misc.html index 42d16b58..00eabb23 100644 --- a/themes/buha/layouts/_default/misc.html +++ b/themes/buha/layouts/_default/misc.html @@ -3,9 +3,10 @@ {{ end }} {{ define "main" }} + {{ if site.Params.debug }}misc.html{{ end }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/themes/buha/layouts/_default/news.html b/themes/buha/layouts/_default/news.html new file mode 100644 index 00000000..2fbe9eba --- /dev/null +++ b/themes/buha/layouts/_default/news.html @@ -0,0 +1,31 @@ +{{- define "title" -}} + {{ $name := .Name | lower }} + {{ if ne ($name | i18n) "" }} + {{ $name = $name | i18n }} + {{ else }} + {{ if ne .Section "events" }} + {{ $name = $name | singularize }} + {{ end }} + {{ $name = $name | humanize }} + {{ end }} +

{{ $name }}

+{{- end -}} + +{{- define "main" -}} + {{ partial "debug" (dict "context" . "filename" "news.html") }} + {{- $paginator := .Paginate .Data.Pages -}} + + {{ if eq $paginator.PageNumber 1 }} + {{ if ne .Content "" }} +
+ {{ .Content }} +
+ {{ end }} + {{ end }} + {{ partial "contentlayouts/list.html" (dict "context" . "paginator" $paginator "amount" "5") }} + {{ partial "structure/paginator" (dict "paginator" $paginator) }} +{{- end -}} + +{{ define "sidebar" }} + {{- partial "contentlayouts/menu.html" . }} +{{ end }} diff --git a/themes/buha/layouts/_default/taxonomy.html b/themes/buha/layouts/_default/taxonomy.html index 506ee1be..70413bf0 100644 --- a/themes/buha/layouts/_default/taxonomy.html +++ b/themes/buha/layouts/_default/taxonomy.html @@ -12,16 +12,24 @@ {{- end -}} {{- define "main" -}} + {{ if site.Params.debug }}taxonomy.html{{ end }} {{ $title := lower .Title }} - {{ $s := .Site.Params }} + {{ $title }} {{- $paginator := slice -}} - {{ $what := printf ".Params.%s" $title }} + {{ $partial := "contentlayouts/list.html" }} + {{ $what := printf ".Params.%s" $title }} + + {{- $posts := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.searchSections }} + {{ if or (eq $title "about") (eq $title "featured") }} - {{- $paginator = .Paginate (where (where .Site.RegularPages "Type" "in" site.Params.searchSections) $what "eq" true) -}} + {{- $paginator = .Paginate (where $posts $what "eq" true) -}} + {{ else if or (eq $title "tags") (eq $title "categories") }} + {{- $paginator = .Paginate $posts -}} + {{ $partial = "contentlayouts/termlist.html" }} {{ else if eq $title "events" }} - {{- $paginator = .Paginate (where (where .Site.RegularPages "Type" "in" site.Params.searchSections) ".Params.when" "ne" nil) -}} - {{ else }} - {{- $paginator = .Paginate .Data.Pages -}} + {{- $paginator = .Paginate (where $posts ".Params.when" "ne" nil) -}} + {{ else }} + {{- $paginator = .Paginate .Data.Pages -}} {{ end }} {{ if eq $paginator.PageNumber 1 }} {{ if ne .Content "" }} @@ -30,9 +38,7 @@
{{ end }} {{ end }} - {{- range first 5 $paginator.Pages.ByLastmod.Reverse -}} - {{ partial "contentlayouts/list.html" . }} - {{- end }} + {{ partial $partial (dict "context" . "paginator" $paginator "amount" "5") }} {{ partial "structure/paginator" (dict "paginator" $paginator) }} {{- end -}} diff --git a/themes/buha/layouts/index.html b/themes/buha/layouts/index.html index 0d6121c0..643b270e 100644 --- a/themes/buha/layouts/index.html +++ b/themes/buha/layouts/index.html @@ -5,35 +5,33 @@ {{ end }} {{ define "main" }} + {{ now }}
+ {{ $diffp := now.AddDate 0 0 14 }} + {{ $diffn := now.AddDate 0 0 -14 }} + {{ $diffp }}
+ {{ $diffn }}
+ + + + {{ partial "debug" (dict "context" . "filename" "index.html") }} - - {{ $s := .Site.Params }} - {{ $meta := false }} {{- $posts := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" $s.searchSections }} {{- $featured := where (where $posts ".Params.featured" "=" true) "Type" "in" $s.searchSections }} - {{- $paginator := slice -}} - {{- $paginator = .Paginate $posts.ByDate.Reverse -}} - + {{- $paginator := .Paginate $posts -}} {{ if eq $paginator.PageNumber 1 }} {{ if ne .Content "" }}
{{ .Content }}
{{ end }} - {{ range first 3 $featured.ByLastmod.Reverse }} - {{ $article_age := sub now.Unix (int .Date.Unix) }} - {{ if lt $article_age "1209600" }} - {{ partial "contentlayouts/list.html" . }} - {{ end }} - {{ end }} +

{{ "featured" | T }}

+ {{ partial "contentlayouts/list.html" (dict "context" . "pages" $featured "amount" "3" "max_age" "3" "featured" "true") }} {{ end }} - {{- range first 5 $paginator.Pages.ByLastmod.Reverse -}} - {{ $article_age := sub now.Unix (int .Date.Unix) }} - {{ if or (ne .Params.featured true) (ge $article_age "1209600") }} - {{ partial "contentlayouts/list.html" . }} - {{ end }} - {{- end }} +

{{ "news" | T }}

+ + {{ partial "contentlayouts/list.html" (dict "context" . "paginator" $paginator "amount" "5" "max_age" "-14") }} +
{{ partial "structure/paginator" (dict "paginator" $paginator) }}
diff --git a/themes/buha/layouts/partials/contentlayouts/list.html b/themes/buha/layouts/partials/contentlayouts/list.html index fd0149eb..ddb41d9f 100644 --- a/themes/buha/layouts/partials/contentlayouts/list.html +++ b/themes/buha/layouts/partials/contentlayouts/list.html @@ -1,14 +1,44 @@ -{{ if .Title }} -
- -
-

{{- .Title -}}

-
-
- -
- {{ partial "contentlayouts/article.html" (dict "context" . "type" "list") }} -
-
-
+{{ if or .paginator .pages }} + {{ if .amount }} + {{ $amount := .amount }} + {{ $pages := "" }} + {{ $max_age := int .max_age }} + {{ $featured := .featured }} + {{ if .pages }} + {{ $pages = .pages.ByLastmod.Reverse }} + {{ else if .paginator }} + {{ $pages = .paginator.Pages.ByLastmod.Reverse }} + {{ end }} + {{- range first $amount $pages -}} + {{ $true := true }} + + {{ if $featured }} + {{ if le (.Lastmod.AddDate 0 0 $max_age) now }} + {{ $true = false }} + {{ end }} + {{ else }} + {{ if $max_age }} + {{ if and (lt (.Lastmod.AddDate 0 0 $max_age) now) (eq .Params.featured true) }} + {{ $true = false }} + {{ end }} + {{ end }} + {{ end }} + {{ if eq $true true }} + {{ if .Title }} +
+ +
+

{{- .Title -}}

+
+
+ +
+ {{ partial "contentlayouts/article.html" (dict "context" . "type" "list") }} +
+
+
+ {{ end }} + {{ end }} + {{ end }} + {{ end }} {{ end }} diff --git a/themes/buha/layouts/partials/contentlayouts/termlist.html b/themes/buha/layouts/partials/contentlayouts/termlist.html new file mode 100644 index 00000000..39ac2a9b --- /dev/null +++ b/themes/buha/layouts/partials/contentlayouts/termlist.html @@ -0,0 +1,29 @@ +{{ $name := .context.Title }} +{{ $title := lower .context.Title }} + + +{{ range $taxonomyname, $taxonomy := .context.Site.Taxonomies }} + {{ if eq $title $taxonomyname }} + {{ range $key, $value := $taxonomy }} + {{ $key }} + {{ end }} + {{ end }} +{{ end }} + + +{{ if and site.Params.debug false }} + {{ range $taxonomyname, $taxonomy := .context.Site.Taxonomies }} +
  • {{ $taxonomyname }} + +
  • + {{ end }} +{{ end }} diff --git a/themes/buha/layouts/partials/debug.html b/themes/buha/layouts/partials/debug.html new file mode 100644 index 00000000..adcd05bb --- /dev/null +++ b/themes/buha/layouts/partials/debug.html @@ -0,0 +1,6 @@ +{{ if site.Params.debug }} +Title: {{ .context.Title }}
    +Name: {{ .context.Name }}
    +context: {{ .context }}
    +filename: {{ .filename }}
    +{{ end }}