diff --git a/config.toml b/config.toml index 826c181..1489f8a 100644 --- a/config.toml +++ b/config.toml @@ -3,6 +3,8 @@ languageCode = "en-gb" title = "lumbung.space" theme = "lumbung-theme" pluralizeListTitles = "false" +paginate = 20 + [params] logo = "/img/logo.svg" @@ -10,15 +12,22 @@ pluralizeListTitles = "false" description = 'a digital living room for the lumbung ekosistem' images = ['/img/logo.png'] title = 'lumbung dot space' + bundleCss = "/bundle.css" + bundleJs = "/bundle.js" + mainSections = ['social', 'shouts', 'events', 'tv', 'pen', 'pages'] [markup.goldmark.renderer] -unsafe = true + unsafe = true [taxonomies] author = "authors" + contributor = "contributors" tag = "tags" - category = "categories" + source = "sources" timeline = "timelines" + [permalinks] timelines = "/timeline/:slug/" + + diff --git a/content/contributors.md b/content/ls-contributors.md similarity index 100% rename from content/contributors.md rename to content/ls-contributors.md diff --git a/themes/lumbung-theme/layouts/_default/baseof.html b/themes/lumbung-theme/layouts/_default/baseof.html index 638faaa..007eb1a 100644 --- a/themes/lumbung-theme/layouts/_default/baseof.html +++ b/themes/lumbung-theme/layouts/_default/baseof.html @@ -11,6 +11,8 @@ {{- partial "news-ticker.html" . -}} {{- partial "footer.html" . -}} + + diff --git a/themes/lumbung-theme/layouts/_default/list.html b/themes/lumbung-theme/layouts/_default/list.html index e93d0c7..9178d35 100644 --- a/themes/lumbung-theme/layouts/_default/list.html +++ b/themes/lumbung-theme/layouts/_default/list.html @@ -1,48 +1,48 @@ {{ define "main" }}
-
- {{ range where (.Paginator 13).Pages "Params.hidden" "ne" "true" }} - - {{ if in .Params.categories "tv"}} +
+ {{ $range := where .Pages "Params.hidden" "ne" "true" }} + {{ $paginator := .Paginate $range }} + {{ $pageSize := $paginator.PageSize }} + {{ $totalPostsToShow := mul $paginator.PageNumber $pageSize }} + {{ range $index, $el := (first $totalPostsToShow $range) }} - {{- partial "video_box.html" . -}} +
+ {{if eq .Section "tv"}} + {{- partial "video_box.html" . -}} - {{ else if in .Params.categories "calendar" }} + {{ else if eq .Section "events" }} + {{- partial "partials/calendar_card.html" . -}} - {{- partial "calendar_card.html" . -}} + {{ else if eq .Section "shouts" }} + {{ if in .Params.sources "pen.lumbung.space" }} + {{- partial "partials/pen_card.html" . -}} + {{ else }} + {{- partial "partials/shout_card.html" . -}} + {{ end }} - {{ else if in .Params.categories "network" }} + {{ else if eq .Section "social" }} + {{- partial "partials/social_card.html" . -}} - {{- partial "network_card.html" . -}} + {{ else if eq .Section "publications"}} + {{- partial "partials/book_card.html" . -}} - {{ else if in .Params.categories "shouts" }} - - {{- partial "shout_card.html" . -}} - - {{ else if in .Params.categories "pen" }} - - {{- partial "pen_card.html" . -}} - - {{ else if in .Params.categories "book" }} - - {{- partial "book.html" . -}} - - {{ else if in .Params.categories "page" }} - - {{- partial "blank.html" . -}} - - {{ else }} - - {{- partial "card.html" . -}} - - {{ end }} + {{ else if eq .Section "sounds"}} + {{- partial "sounds_card.html" . -}} + {{ else }} + {{- partial "card.html" . -}} + {{ end }} +
{{ end }}
- - + + +
-{{ end }} +{{ end }} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/events/list.html b/themes/lumbung-theme/layouts/events/list.html new file mode 100644 index 0000000..739ad2c --- /dev/null +++ b/themes/lumbung-theme/layouts/events/list.html @@ -0,0 +1,39 @@ +{{ define "main" }} +
+
+ + {{ $now := (now.Format "060102" ) }} + + {{ $upcoming := slice }} + {{ $past := slice}} + + {{ range .Pages }} + {{ $t := (substr .Params.event_end 2 8) }} + {{ $time := ( replace $t "-" "") }} + {{ if ge $time $now }} + {{ $upcoming = $upcoming | append . }} + {{ else if gt $now $time }} + {{ $past = $past | append . }} + {{ end }} + {{ end }} + + {{ with $upcoming }} +
+
upcoming events
+ {{ range $upcoming}} + {{- partial "event_list_item.html" . -}} + {{end}} +
+ {{end}} + {{ with $past }} +
+
past events
+ {{ range $past }} + {{- partial "event_list_item.html" . -}} + {{ end }} +
+ {{ end }} + +
+
+{{ end }} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/index.html b/themes/lumbung-theme/layouts/index.html index 0f9408f..190ba06 100644 --- a/themes/lumbung-theme/layouts/index.html +++ b/themes/lumbung-theme/layouts/index.html @@ -1,32 +1,50 @@ {{ define "main" }}
-
-{{ range (.Paginate (.Site.RegularPages.GroupByDate "January 2006") 20 ).PageGroups }} + +
+ {{ $range := .Site.RegularPages }} + {{ $paginator := .Paginate $range }} + {{ $pageSize := $paginator.PageSize }} + {{ $totalPostsToShow := mul $paginator.PageNumber $pageSize }} + {{ range $index, $el := (first $totalPostsToShow .Site.RegularPages) }} + +
+ {{if eq .Section "tv"}} + {{- partial "video_box.html" . -}} - {{ .Key }} - {{ range .Pages }} - {{ if in .Params.categories "tv"}} - {{- partial "video_box.html" . -}} - {{ else if in .Params.categories "calendar" }} - {{- partial "calendar_card.html" . -}} - {{ else if in .Params.categories "network" }} - {{- partial "network_card.html" . -}} - {{ else if in .Params.categories "pen" }} - {{- partial "pen_card.html" . -}} - {{ else if in .Params.categories "shouts" }} - {{- partial "shout_card.html" . -}} - {{ else if in .Params.categories "books.lumbung.space"}} - {{- partial "book_card.html" . -}} - {{ else }} - {{- partial "card.html" . -}} - {{ end }} - {{ end }} + {{ else if eq .Section "events" }} + {{- partial "partials/calendar_card.html" . -}} + + {{ else if eq .Section "shouts" }} + {{ if in .Params.sources "pen.lumbung.space" }} + {{- partial "partials/pen_card.html" . -}} + {{ else }} + {{- partial "partials/shout_card.html" . -}} + {{ end }} + + {{ else if eq .Section "social" }} + {{- partial "partials/social_card.html" . -}} + + {{ else if eq .Section "publications"}} + {{- partial "partials/book_card.html" . -}} + + {{ else if eq .Section "sounds"}} + {{- partial "sounds_card.html" . -}} + + {{ else }} + {{- partial "card.html" . -}} + {{ end }} +
{{ end }}
- + + +
@@ -34,5 +52,8 @@ lumbung radio
+ +
+ {{ end }} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/page/filter.html b/themes/lumbung-theme/layouts/page/filter.html new file mode 100644 index 0000000..af5f844 --- /dev/null +++ b/themes/lumbung-theme/layouts/page/filter.html @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + +
+ + +{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} +{{ $sections := .Site.Params.mainSections }} + +{{ $.Scratch.Set "authors" (slice ) }} +{{ $.Scratch.Set "noAuthors" 0 }} + +{{ range where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ with .Params.authors }} + {{ if eq ( printf "%T" . ) "[]string" }} + {{ if ( not ( in ($.Scratch.Get "authors") . ) ) }} + {{ $.Scratch.Add "authors" . }} + {{ end }} + {{ else if ( printf "%T" . ) "[]string" }} + {{ range . }} + {{ if ( not ( in ($.Scratch.Get "authors") . ) ) }} + {{ $.Scratch.Add "authors" . }} + {{ end }} + {{ end }} + {{ end }} + {{ else }} + {{ $.Scratch.Add "noAuthors" 1 }} + {{ end }} +{{ end }} + + +{{ $tags := $.Site.Taxonomies.tags.ByCount }} + +{{ $.Scratch.Set "untagged" 0 }} +{{ range $pages }} + {{ with .Params.tags }}{{ else }}{{ $.Scratch.Add "untagged" 1 }}{{ end }} +{{ end }} + + +
+
+

Sections

+ + {{ range $sections }} + + {{ end }} + + + +

Authors

+ + {{ range $.Scratch.Get "authors" }} + + {{ end }} + {{ if gt ( $.Scratch.Get "noAuthors") 0 }} + + {{ end }} + + + +

Tags

+ + {{ range $tags }} + {{ if .Term }} + + {{ end }} + {{ end }} + {{ if gt ( $.Scratch.Get "untagged") 0 }} + + {{ end }} + + +
+
+ + + +
+

Items

+
+ {{ range $pages.ByPublishDate.Reverse }} + {{ if in .Params.categories "tv"}} + {{- partial "video_box.html" . -}} +{{ else if in .Params.categories "calendar" }} + {{- partial "calendar_card.html" . -}} +{{ else if in .Params.categories "network" }} + {{- partial "network_card.html" . -}} +{{ else if in .Params.categories "pen" }} + {{- partial "pen_card.html" . -}} +{{ else if in .Params.categories "shouts" }} + {{- partial "shout_card.html" . -}} +{{ else if in .Params.categories "books.lumbung.space"}} +{{- partial "book_card.html" . -}} +{{ else }} + {{- partial "card.html" . -}} +{{ end }} + {{ end }} +
+ +
+ + + + + + +
+ + + + + diff --git a/themes/lumbung-theme/layouts/partials/book_card.html b/themes/lumbung-theme/layouts/partials/book_card.html new file mode 100644 index 0000000..2bd0975 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/book_card.html @@ -0,0 +1,39 @@ +
+
+
+ + {{ $postPermalink := .Permalink}} + + + {{ with (index (.Resources.ByType "image") 0) }} + {{ $height := add .Height 0.0}} + {{ $ratio := div $height .Width}} + {{ $thumb := .Fit "540x540 q80 webp"}} +
+
+ {{ .Title }} +
+ {{ else }} +
+ {{ end }} +
+

+ {{.Title}}

+
+
+ {{ .Summary }} +
+
+
+ +
+
+
+
diff --git a/themes/lumbung-theme/layouts/partials/calendar_card.html b/themes/lumbung-theme/layouts/partials/calendar_card.html index c41cfa9..3a20ffc 100644 --- a/themes/lumbung-theme/layouts/partials/calendar_card.html +++ b/themes/lumbung-theme/layouts/partials/calendar_card.html @@ -1,5 +1,5 @@ {{ $t := (time .Params.event_end) }} -
+
{{ substr .Params.date 0 11}}
diff --git a/themes/lumbung-theme/layouts/partials/card.html b/themes/lumbung-theme/layouts/partials/card.html index 9154a32..5cbaa86 100644 --- a/themes/lumbung-theme/layouts/partials/card.html +++ b/themes/lumbung-theme/layouts/partials/card.html @@ -1,4 +1,4 @@ -
+

{{ .Title }}

diff --git a/themes/lumbung-theme/layouts/partials/data/authors.html b/themes/lumbung-theme/layouts/partials/data/authors.html new file mode 100644 index 0000000..69be009 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/data/authors.html @@ -0,0 +1 @@ +{{ with .Params.authors }}{{ if eq ( printf "%T" . ) "string" }}{{ . | replaceRE "[.]" "_" | urlize }}{{ else if eq ( printf "%T" . ) "[]string" }}{{ range . }}{{ . | replaceRE "[.]" "_" | urlize }} {{end}}{{end}}{{else}}no-author{{end}} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/data/categories.html b/themes/lumbung-theme/layouts/partials/data/categories.html new file mode 100644 index 0000000..9303037 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/data/categories.html @@ -0,0 +1 @@ +{{ with .Params.categories }}{{ if eq ( printf "%T" . ) "string" }}{{ . | replaceRE "[.]" "_" | urlize }}{{ else if eq ( printf "%T" . ) "[]string" }}{{ range . }}{{ . | replaceRE "[.]" "_" | urlize }} {{end}}{{end}}{{else}}no-cat{{end}} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/data/contributors.html b/themes/lumbung-theme/layouts/partials/data/contributors.html new file mode 100644 index 0000000..20dce32 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/data/contributors.html @@ -0,0 +1 @@ +{{ with .Params.contributors }}{{ if eq ( printf "%T" . ) "string" }}{{ . | replaceRE "[.]" "_" | urlize }}{{ else if eq ( printf "%T" . ) "[]string" }}{{ range . }}{{ . | replaceRE "[.]" "_" | urlize }} {{end}}{{end}}{{else}}no-contributor{{end}} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/data/sources.html b/themes/lumbung-theme/layouts/partials/data/sources.html new file mode 100644 index 0000000..d39e141 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/data/sources.html @@ -0,0 +1 @@ +{{ with .Params.sources }}{{ if eq ( printf "%T" . ) "string" }}{{ . | replaceRE "[.]" "_" | urlize }}{{ else if eq ( printf "%T" . ) "[]string" }}{{ range . }}{{ . | replaceRE "[.]" "_" | urlize }} {{end}}{{end}}{{else}}no-sources{{end}} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/data/tags.html b/themes/lumbung-theme/layouts/partials/data/tags.html new file mode 100644 index 0000000..6cb4851 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/data/tags.html @@ -0,0 +1 @@ +{{ with .Params.tags }}{{ range . }}{{ . | replaceRE "[.]" "_" | urlize }} {{ end }}{{ else }} tfuntagged{{ end }} \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/event_list_item.html b/themes/lumbung-theme/layouts/partials/event_list_item.html new file mode 100644 index 0000000..524ea99 --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/event_list_item.html @@ -0,0 +1,19 @@ +{{ $t := (time .Params.event_end) }} +
+
{{ substr .Params.event_begin 0 11}}
+ +
+
+ + {{ .Params.localized_begin | markdownify }} + +
+
+
Duration: {{ .Params.duration }}
+
{{ .Params.location | markdownify }}
+ + +
+ {{.Content}} +
+
\ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/filter-nav.html b/themes/lumbung-theme/layouts/partials/filter-nav.html new file mode 100644 index 0000000..373c62b --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/filter-nav.html @@ -0,0 +1,91 @@ +
+ + + {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ $sections := .Site.Params.mainSections }} + {{ $tags := $.Site.Taxonomies.tags.ByCount }} + {{ $.Scratch.Set "untagged" 0 }} + {{ range $pages }} + {{ with .Params.tags }}{{ else }}{{ $.Scratch.Add "untagged" 1 }}{{ end }} + {{ end }} + +
+
+
Cards
+
load more cards
+
+
+
+ +
+ {{ range $sections }} + + {{ end }} + +
+
+ +
+ +
+ {{ range .Site.Taxonomies.contributors }} + + {{ end }} + + + +
+
+ +
+ +
+ {{ range .Site.Taxonomies.sources }} + + {{ end }} + + +
+
+ +
+ +
+ {{ range $tags }} + {{ if .Term }} + + {{ end }} + {{ end }} + + +
+
+ +
+
+ +
\ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/footer.html b/themes/lumbung-theme/layouts/partials/footer.html index c8c9ced..c75a630 100644 --- a/themes/lumbung-theme/layouts/partials/footer.html +++ b/themes/lumbung-theme/layouts/partials/footer.html @@ -1,7 +1,7 @@
- +
lumbung.space is a social and publishing platform for sharing harvests by all members online. It is non-extractive, co governed by the users, and is built on open platforms.
diff --git a/themes/lumbung-theme/layouts/partials/head.html b/themes/lumbung-theme/layouts/partials/head.html index 38b375f..11ab989 100644 --- a/themes/lumbung-theme/layouts/partials/head.html +++ b/themes/lumbung-theme/layouts/partials/head.html @@ -25,4 +25,5 @@ {{ with .OutputFormats.Get "rss" -}} {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end -}} + diff --git a/themes/lumbung-theme/layouts/partials/header.html b/themes/lumbung-theme/layouts/partials/header.html index 41f0da3..ba3b1a0 100644 --- a/themes/lumbung-theme/layouts/partials/header.html +++ b/themes/lumbung-theme/layouts/partials/header.html @@ -1,36 +1,26 @@
-
- - login + - - - - - -
+
+ + +
diff --git a/themes/lumbung-theme/layouts/partials/network_card.html b/themes/lumbung-theme/layouts/partials/network_card.html deleted file mode 100644 index dae6e92..0000000 --- a/themes/lumbung-theme/layouts/partials/network_card.html +++ /dev/null @@ -1,47 +0,0 @@ -
-
-
- {{ $postPermalink := .Permalink}} - -

{{ .Title }}

-
- -
From {{ if .Params.authors }}{{range .Params.authors}} {{ . }} {{end}} at {{ end }}{{ .Params.feed_name }}
- - {{ if .Params.featured_image }} - {{ $img := .Resources.GetMatch .Params.featured_image }} - {{ $height := add $img.Height 0.0}} - {{ $ratio := div $height $img.Width}} - {{ $thumb := $img.Fit "540x540 q80 webp"}} -
-
- {{ .Title }} -
- {{ else if (.Resources.ByType "image") }} - {{ with (index (.Resources.ByType "image") 0) }} - {{ $img := . }} - {{ $height := add .Height 0.0}} - {{ $ratio := div $height .Width}} - {{ $thumb := .Fit "540x540 q80 webp"}} -
-
- {{ .Title }} -
- {{ end }} - {{ else }} -
- {{ end }} -
- {{ .Summary }} -
-
- - -
-
diff --git a/themes/lumbung-theme/layouts/partials/pen_card.html b/themes/lumbung-theme/layouts/partials/pen_card.html index ef2b213..4accc6d 100644 --- a/themes/lumbung-theme/layouts/partials/pen_card.html +++ b/themes/lumbung-theme/layouts/partials/pen_card.html @@ -1,4 +1,4 @@ -
+
From {{ if .Params.author }}{{.Params.author}} at {{ end }}{{ .Params.feed_name }}
diff --git a/themes/lumbung-theme/layouts/partials/shout_card.html b/themes/lumbung-theme/layouts/partials/shout_card.html index 625164e..c3ee38b 100644 --- a/themes/lumbung-theme/layouts/partials/shout_card.html +++ b/themes/lumbung-theme/layouts/partials/shout_card.html @@ -1,49 +1,48 @@ -
-
-
- {{ $postPermalink := .Permalink}} -

- {{ range $i, $e := .Params.tags -}} - {{- if $i -}} {{ end -}} - #{{ $e | humanize | lower }} - {{- end -}} -

-
+
+
+
+ {{ $postPermalink := .Permalink}} + +

{{ .Title }}

+
+ +
From {{ if .Params.contributors }}{{range .Params.contributors}} {{ . }} {{end}} at {{ end }}{{ .Params.feed_name }}
- {{ with (index (.Resources.ByType "video") 0) }} - {{/* TODO this current logic does not suport video & image mixed */}} -
- - {{ else}} - {{ with (index (.Resources.ByType "image") 0) }} - {{ $height := add .Height 0.0}} - {{ $ratio := div $height .Width}} - {{ $thumb := .Fit "540x540 q80 webp"}} -
-
- {{ .Title }} -
- {{ else }} -
- {{ end }} - {{ end }} -
- {{ .Summary }} -
-
-
- -
- - {{ if .Truncated }} - - - {{ end }} -
-
+ {{ if .Params.featured_image }} + {{ with $img := .Resources.GetMatch .Params.featured_image }} + {{ $height := add $img.Height 0.0}} + {{ $ratio := div $height $img.Width}} + {{ $thumb := $img.Fit "540x540 q80 webp"}} +
+
+ {{ .Title }} +
+ {{end}} + {{ else if (.Resources.ByType "image") }} + {{ with (index (.Resources.ByType "image") 0) }} + {{ $img := . }} + {{ $height := add .Height 0.0}} + {{ $ratio := div $height .Width}} + {{ $thumb := .Fit "540x540 q80 webp"}} +
+
+ {{ .Title }} +
+ {{ end }} + {{ else }} +
+ {{ end }} +
+ {{ .Summary }} +
+ + +
+
diff --git a/themes/lumbung-theme/layouts/partials/social_card.html b/themes/lumbung-theme/layouts/partials/social_card.html new file mode 100644 index 0000000..464150e --- /dev/null +++ b/themes/lumbung-theme/layouts/partials/social_card.html @@ -0,0 +1,49 @@ + \ No newline at end of file diff --git a/themes/lumbung-theme/layouts/partials/video_box.html b/themes/lumbung-theme/layouts/partials/video_box.html index 54170a6..4a9f418 100644 --- a/themes/lumbung-theme/layouts/partials/video_box.html +++ b/themes/lumbung-theme/layouts/partials/video_box.html @@ -1,4 +1,4 @@ -
+
+ + + + + + + + + diff --git a/themes/lumbung-theme/static/img/logo-big.svg b/themes/lumbung-theme/static/img/logo-big.svg new file mode 100644 index 0000000..9409ee3 --- /dev/null +++ b/themes/lumbung-theme/static/img/logo-big.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/lumbung-theme/static/img/logo.svg b/themes/lumbung-theme/static/img/logo.svg index 9409ee3..c60c548 100644 --- a/themes/lumbung-theme/static/img/logo.svg +++ b/themes/lumbung-theme/static/img/logo.svg @@ -1,21 +1,17 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/themes/lumbung-theme/static/js/hugotagsfilter-1.2.2.min.js b/themes/lumbung-theme/static/js/hugotagsfilter-1.2.2.min.js new file mode 100644 index 0000000..e89770b --- /dev/null +++ b/themes/lumbung-theme/static/js/hugotagsfilter-1.2.2.min.js @@ -0,0 +1,221 @@ +!(function l(r, a, o) { + function h(e, t) { + if (!a[e]) { + if (!r[e]) { + var s = "function" == typeof require && require; + if (!t && s) return s(e, !0); + if (u) return u(e, !0); + var i = new Error("Cannot find module '" + e + "'"); + throw ((i.code = "MODULE_NOT_FOUND"), i); + } + var n = (a[e] = { exports: {} }); + r[e][0].call( + n.exports, + function (t) { + return h(r[e][1][t] || t); + }, + n, + n.exports, + l, + r, + a, + o + ); + } + return a[e].exports; + } + for (var u = "function" == typeof require && require, t = 0; t < o.length; t++) h(o[t]); + return h; +})( + { + 1: [ + function (t, e, s) { + "use strict"; + var i = (function () { + function i(t, e) { + for (var s = 0; s < e.length; s++) { + var i = e[s]; + (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i); + } + } + return function (t, e, s) { + return e && i(t.prototype, e), s && i(t, s), t; + }; + })(); + /** + * @name 'Hugo Tags Filter' + * @version 1.2.2 + * @license MIT + * @author PointyFar + */ + var n = (function () { + function l(t) { + !(function (t, e) { + if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); + })(this, l); + (this.FILTERS = + t && t.filters + ? t.filters + : [ + { name: "tag", prefix: "tft-", buttonClass: "tft-button", allSelector: "#tfSelectAllTags", attrName: "data-tags" }, + { name: "section", prefix: "tfs-", buttonClass: "tfs-button", allSelector: "#tfSelectAllSections", attrName: "data-section" }, + ]), + (this.showItemClass = t && t.showItemClass ? t.showItemClass : "tf-show"), + (this.activeButtonClass = t && t.activeButtonClass ? t.activeButtonClass : "active"), + (this.filterItemClass = t && t.filterItemClass ? t.filterItemClass : "tf-filter-item"), + (this.counterSelector = t && t.counterSelector ? t.counterSelector : "selectedItemCount"), + (this.populateCount = !(!t || !t.populateCount) && t.populateCount), + (this.setDisabledButtonClass = !(!t || !t.setDisabledButtonClass) && t.setDisabledButtonClass), + (this.filterItems = document.getElementsByClassName(this.filterItemClass)), + (this.selectedItemCount = 0), + (this.filterValues = {}); + for (var e = 0; e < this.FILTERS.length; e++) { + (this.FILTERS[e].buttonTotal = document.getElementsByClassName(this.FILTERS[e].buttonClass).length), (this.FILTERS[e].selected = []), (this.FILTERS[e].values = []); + var s = document.getElementsByClassName(this.FILTERS[e].buttonClass); + this.filterValues[this.FILTERS[e].name] = []; + for (var i = 0; i < s.length; i++) { + var n = s[i].id.replace(this.FILTERS[e].prefix, ""); + this.filterValues[this.FILTERS[e].name][n] = { count: 0, selected: 0 }; + } + } + this.showCheck(this.FILTERS[0].name, !0); + } + return ( + i(l, [ + { + key: "initFilterCount", + value: function (t, e) { + if (e) for (var s in t) for (var i = 0; i < this.filterItems.length; i++) for (var n = this.getAttrs(s, this.filterItems[i]), l = 0; l < n.length; l++) t[s][n[l]].count++, t[s][n[l]].selected++; + else { + var r = document.getElementsByClassName(this.showItemClass); + for (var s in t) for (var a in t[s]) t[s][a].selected = 0; + for (l = 0; l < r.length; l++) + for (s in t) { + n = this.getAttrs(s, r[l]); + for (var o = 0; o < n.length; o++) t[s][n[o]].selected++; + } + } + return t; + }, + }, + { + key: "populateCounters", + value: function (t) { + if (this.populateCount) + for (var e = 0; e < this.FILTERS.length; e++) { + var s = this.FILTERS[e].name, + i = this.FILTERS[e].countPrefix, + n = this.FILTERS[e].selectedPrefix; + if (i || n) + for (var l in t[s]) { + if (i) document.getElementById("" + i + l).textContent = t[s][l].count; + if (n) { + var r = document.getElementById("" + n + l); + (r.textContent = t[s][l].selected), + this.setDisabledButtonClass && + (0 == r.textContent + ? this.addClassIfMissing(document.getElementById(this.FILTERS[e].prefix + l), this.setDisabledButtonClass) + : this.delClassIfPresent(document.getElementById(this.FILTERS[e].prefix + l), this.setDisabledButtonClass)); + } + } + } + }, + }, + { + key: "getAttrs", + value: function (t, e) { + return e + .getAttribute("data-" + t) + .split(" ") + .filter(function (t) { + return 0 < t.length; + }); + }, + }, + { + key: "showAll", + value: function (t) { + for (var e = 0; e < this.FILTERS.length; e++) t ? this.FILTERS[e].name === t && (this.FILTERS[e].selected = []) : (this.FILTERS[e].selected = []); + this.showCheck(t); + }, + }, + { + key: "checkFilter", + value: function (t, e) { + for (var s = document.querySelector("#" + e + t), i = 0; i < this.FILTERS.length; i++) + this.FILTERS[i].prefix === e && + (0 <= this.FILTERS[i].selected.indexOf(t) + ? (this.FILTERS[i].selected.splice(t, 1), this.delClassIfPresent(s, this.activeButtonClass)) + : (this.FILTERS[i].selected.push(t), this.addClassIfMissing(s, this.activeButtonClass)), + this.delClassIfPresent(document.querySelector(this.FILTERS[i].allSelector), this.activeButtonClass), + this.showCheck(this.FILTERS[i].name)); + }, + }, + { + key: "showCheck", + value: function (t, e) { + for (var s = 0; s < this.FILTERS.length; s++) + if (this.FILTERS[s].name === t && (0 === this.FILTERS[s].selected.length || this.FILTERS[s].selected.length === this.FILTERS[s].buttonTotal)) { + for (var i = document.getElementsByClassName(this.FILTERS[s].buttonClass), n = 0; n < i.length; n++) this.delClassIfPresent(i[n], this.activeButtonClass); + this.addClassIfMissing(document.querySelector(this.FILTERS[s].allSelector), this.activeButtonClass); + } + for (s = this.selectedItemCount = 0; s < this.filterItems.length; s++) { + this.delClassIfPresent(this.filterItems[s], this.showItemClass); + var l = 0; + for (n = 0; n < this.FILTERS.length; n++) this.checkVisibility(this.FILTERS[n].selected, this.filterItems[s].getAttribute(this.FILTERS[n].attrName)) && l++; + l === this.FILTERS.length && (this.filterItems[s].classList.contains(this.showItemClass) || (this.selectedItemCount++, this.addClassIfMissing(this.filterItems[s], this.showItemClass))); + } + document.getElementById(this.counterSelector) && (document.getElementById(this.counterSelector).textContent = "" + this.selectedItemCount), this.checkButtonCounts(e); + }, + }, + { + key: "checkButtonCounts", + value: function (t) { + (this.filterValues = this.initFilterCount(this.filterValues, t)), this.populateCounters(this.filterValues); + }, + }, + { + key: "checkVisibility", + value: function (t, e) { + if (0 < t.length) { + for (var s = 0; s < t.length; s++) { + if ( + 0 <= + e + .split(" ") + .filter(function (t) { + return 0 < t.length; + }) + .indexOf(t[s]) + ) + return !0; + } + return !1; + } + return !0; + }, + }, + { + key: "addClassIfMissing", + value: function (t, e) { + t.classList.contains(e) || t.classList.add(e); + }, + }, + { + key: "delClassIfPresent", + value: function (t, e) { + t.classList.contains(e) && t.classList.remove(e); + }, + }, + ]), + l + ); + })(); + window.HugoTagsFilter = n; + }, + {}, + ], + }, + {}, + [1] +);