From fe340ce68c9423e3551d475b0d32d2fbed0c209c Mon Sep 17 00:00:00 2001 From: paspo Date: Sun, 29 Sep 2024 00:06:03 +0200 Subject: [PATCH 1/6] ics calendar --- config.yml | 18 +++++++++ content/events/_index.en.md | 7 ++++ content/events/_index.it.md | 7 ++++ docker/rootfs/etc/nginx/http.d/default.conf | 4 ++ layouts/events/list.ics | 43 +++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 layouts/events/list.ics diff --git a/config.yml b/config.yml index e79e131..c0ae508 100644 --- a/config.yml +++ b/config.yml @@ -10,7 +10,10 @@ copyright: 2024 © Bergamo Linux Users Group paginate: 20 timeout: 1800s enableRobotsTXT: true +enableGitInfo: true params: + ics: + organizer: CN="BgLUG":MAILTO:info@bglug.it description: Bergamo Linux Users Group social: - title: Mattermost @@ -41,6 +44,10 @@ params: icon: fa-mail-bulk pack: solid url: https://lists.linux.it/listinfo/bglug + - title: Events Caledar + icon: fa-calendar-alt + pack: solid + url: https://bglug.it/it/eventi/index.ics - title: Facebook icon: fa-facebook-f pack: brands @@ -209,6 +216,16 @@ languages: defaultContentLanguage: it defaultContentLanguageInSubdir: true +outputFormats: + calendar: + baseName: index + isPlainText: true + mediaType: text/calendar + noUgly: false + permalinkable: false + root: false + protocol: webcal:// + outputs: home: - html @@ -220,6 +237,7 @@ outputs: - rss section: - html + - calendar - rss taxonomy: - html diff --git a/content/events/_index.en.md b/content/events/_index.en.md index 726fb10..bbbe92b 100644 --- a/content/events/_index.en.md +++ b/content/events/_index.en.md @@ -3,4 +3,11 @@ type: section title: Events #description: "TODO: please fill this with a description" sidebar_right: sidebar-eventi +output: + - calendar: + mediaType: text/calendar +mediaTypes: + text/calendar: + suffixes: + - ics --- diff --git a/content/events/_index.it.md b/content/events/_index.it.md index 2059342..236c850e 100644 --- a/content/events/_index.it.md +++ b/content/events/_index.it.md @@ -3,4 +3,11 @@ type: section title: Eventi #description: "TODO: non so come descrivere la sezione eventi" sidebar_right: sidebar-eventi +output: + - calendar: + mediaType: text/calendar +mediaTypes: + text/calendar: + suffixes: + - ics --- diff --git a/docker/rootfs/etc/nginx/http.d/default.conf b/docker/rootfs/etc/nginx/http.d/default.conf index 7961041..2bc5954 100644 --- a/docker/rootfs/etc/nginx/http.d/default.conf +++ b/docker/rootfs/etc/nginx/http.d/default.conf @@ -12,6 +12,10 @@ server { rewrite ^/feed/.*$ /it/index.xml last; } + location ~ /events/elenco/ { + try_files $uri /it/eventi/index.ics; + } + location ~ ^/wp\-content/uploads/2008/02/Statuto\.pdf$ { return 301 https://bglug.it/it/chi-siamo/Statuto.pdf; } diff --git a/layouts/events/list.ics b/layouts/events/list.ics new file mode 100644 index 0000000..047cb0b --- /dev/null +++ b/layouts/events/list.ics @@ -0,0 +1,43 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//BgLUG//BgLUG Events Calendar//EN +X-WR-CALNAME:BgLUG Events Calendar +X-WR-TIMEZONE:Europe/Rome +CALSCALE:GREGORIAN +METHOD:PUBLISH + +{{range .Pages -}} + +{{- $location := "" -}} +{{- $locations := .Params.locations -}} +{{- with (eq (printf "%T" $locations ) "string" ) -}} + {{- $location = $locations -}} +{{- end -}} +{{- with (eq (printf "%T" $locations ) "[]string" ) -}} + {{- $location = (index $locations 0) -}} +{{- end -}} +{{ if .Params.location_ics }} + {{- $location = .Params.location_ics }} +{{- end }} + +BEGIN:VEVENT +SUMMARY:{{.Title}} +ORGANIZER;{{ .Site.Param "ics.organizer" }} +UID:{{ md5 .Permalink }}@bglug.it +SEQUENCE:0 +STATUS:CONFIRMED +TRANSP:TRANSPARENT +LOCATION:{{ $location }} +URL:{{ .Permalink }} +{{ with .Lastmod }}DTSTAMP:{{dateFormat "20060102T150405Z" . }} +{{ end -}} +{{ if .Date }}DTSTART;TZID=Europe/Rome:{{dateFormat "20060102T150405Z" .Date }} +{{- $d := time.AsTime .Date }} +{{- $duration := .Params.duration | default "1h" }} +DTEND;TZID=Europe/Rome:{{dateFormat "20060102T150405Z" ($d.Add (time.ParseDuration $duration) ) }} +{{ end -}} +END:VEVENT + +{{end -}} + +END:VCALENDAR -- 2.47.2 From b02e2a0c4ab5d7933535ab06f100778fac118301 Mon Sep 17 00:00:00 2001 From: paspo Date: Mon, 30 Sep 2024 19:24:15 +0200 Subject: [PATCH 2/6] supporto ics per tutte le pagine --- config.yml | 4 ++-- content/events/_index.en.md | 13 ------------- content/events/_index.it.md | 13 ------------- docker/rootfs/etc/nginx/http.d/default.conf | 2 +- .../{events/list.ics => _default/home.calendar.ics} | 2 +- 5 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 content/events/_index.en.md delete mode 100644 content/events/_index.it.md rename layouts/{events/list.ics => _default/home.calendar.ics} (94%) diff --git a/config.yml b/config.yml index c0ae508..ab38084 100644 --- a/config.yml +++ b/config.yml @@ -47,7 +47,7 @@ params: - title: Events Caledar icon: fa-calendar-alt pack: solid - url: https://bglug.it/it/eventi/index.ics + url: https://bglug.it/it/index.ics - title: Facebook icon: fa-facebook-f pack: brands @@ -230,6 +230,7 @@ outputs: home: - html - rss + - calendar page: - html - rss @@ -237,7 +238,6 @@ outputs: - rss section: - html - - calendar - rss taxonomy: - html diff --git a/content/events/_index.en.md b/content/events/_index.en.md deleted file mode 100644 index bbbe92b..0000000 --- a/content/events/_index.en.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -type: section -title: Events -#description: "TODO: please fill this with a description" -sidebar_right: sidebar-eventi -output: - - calendar: - mediaType: text/calendar -mediaTypes: - text/calendar: - suffixes: - - ics ---- diff --git a/content/events/_index.it.md b/content/events/_index.it.md deleted file mode 100644 index 236c850e..0000000 --- a/content/events/_index.it.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -type: section -title: Eventi -#description: "TODO: non so come descrivere la sezione eventi" -sidebar_right: sidebar-eventi -output: - - calendar: - mediaType: text/calendar -mediaTypes: - text/calendar: - suffixes: - - ics ---- diff --git a/docker/rootfs/etc/nginx/http.d/default.conf b/docker/rootfs/etc/nginx/http.d/default.conf index 2bc5954..e481363 100644 --- a/docker/rootfs/etc/nginx/http.d/default.conf +++ b/docker/rootfs/etc/nginx/http.d/default.conf @@ -13,7 +13,7 @@ server { } location ~ /events/elenco/ { - try_files $uri /it/eventi/index.ics; + try_files $uri /it/index.ics; } location ~ ^/wp\-content/uploads/2008/02/Statuto\.pdf$ { diff --git a/layouts/events/list.ics b/layouts/_default/home.calendar.ics similarity index 94% rename from layouts/events/list.ics rename to layouts/_default/home.calendar.ics index 047cb0b..98d4042 100644 --- a/layouts/events/list.ics +++ b/layouts/_default/home.calendar.ics @@ -6,7 +6,7 @@ X-WR-TIMEZONE:Europe/Rome CALSCALE:GREGORIAN METHOD:PUBLISH -{{range .Pages -}} +{{range where .Site.Pages ".Page.Params.add_to_ics" true -}} {{- $location := "" -}} {{- $locations := .Params.locations -}} -- 2.47.2 From 01625aa2e080a08062be35dd907b8fc2b680f016 Mon Sep 17 00:00:00 2001 From: paspo Date: Tue, 1 Oct 2024 21:09:47 +0200 Subject: [PATCH 3/6] fix validar warnings --- layouts/_default/home.calendar.ics | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/layouts/_default/home.calendar.ics b/layouts/_default/home.calendar.ics index 98d4042..8fc04a4 100644 --- a/layouts/_default/home.calendar.ics +++ b/layouts/_default/home.calendar.ics @@ -5,9 +5,7 @@ X-WR-CALNAME:BgLUG Events Calendar X-WR-TIMEZONE:Europe/Rome CALSCALE:GREGORIAN METHOD:PUBLISH - -{{range where .Site.Pages ".Page.Params.add_to_ics" true -}} - +{{- range where .Site.Pages ".Page.Params.add_to_ics" true -}} {{- $location := "" -}} {{- $locations := .Params.locations -}} {{- with (eq (printf "%T" $locations ) "string" ) -}} @@ -16,10 +14,9 @@ METHOD:PUBLISH {{- with (eq (printf "%T" $locations ) "[]string" ) -}} {{- $location = (index $locations 0) -}} {{- end -}} -{{ if .Params.location_ics }} +{{- if .Params.location_ics }} {{- $location = .Params.location_ics }} {{- end }} - BEGIN:VEVENT SUMMARY:{{.Title}} ORGANIZER;{{ .Site.Param "ics.organizer" }} @@ -35,9 +32,7 @@ URL:{{ .Permalink }} {{- $d := time.AsTime .Date }} {{- $duration := .Params.duration | default "1h" }} DTEND;TZID=Europe/Rome:{{dateFormat "20060102T150405Z" ($d.Add (time.ParseDuration $duration) ) }} -{{ end -}} +{{- end -}} END:VEVENT - -{{end -}} - +{{- end -}} END:VCALENDAR -- 2.47.2 From 60e00673a6a64be488ff1d7e34c76dc14eae0907 Mon Sep 17 00:00:00 2001 From: paspo Date: Tue, 1 Oct 2024 21:46:34 +0200 Subject: [PATCH 4/6] validator->happy --- layouts/_default/home.calendar.ics | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/layouts/_default/home.calendar.ics b/layouts/_default/home.calendar.ics index 8fc04a4..2ad3dee 100644 --- a/layouts/_default/home.calendar.ics +++ b/layouts/_default/home.calendar.ics @@ -17,6 +17,26 @@ METHOD:PUBLISH {{- if .Params.location_ics }} {{- $location = .Params.location_ics }} {{- end }} +BEGIN:VTIMEZONE +TZID:Europe/Rome +LAST-MODIFIED:20240422T053451Z +TZURL:https://www.tzurl.org/zoneinfo-outlook/Europe/Rome +X-LIC-LOCATION:Europe/Rome +BEGIN:DAYLIGHT +TZNAME:CEST +TZOFFSETFROM:+0100 +TZOFFSETTO:+0200 +DTSTART:19700329T020000 +RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU +END:DAYLIGHT +BEGIN:STANDARD +TZNAME:CET +TZOFFSETFROM:+0200 +TZOFFSETTO:+0100 +DTSTART:19701025T030000 +RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU +END:STANDARD +END:VTIMEZONE BEGIN:VEVENT SUMMARY:{{.Title}} ORGANIZER;{{ .Site.Param "ics.organizer" }} @@ -28,11 +48,11 @@ LOCATION:{{ $location }} URL:{{ .Permalink }} {{ with .Lastmod }}DTSTAMP:{{dateFormat "20060102T150405Z" . }} {{ end -}} -{{ if .Date }}DTSTART;TZID=Europe/Rome:{{dateFormat "20060102T150405Z" .Date }} +{{ if .Date }}DTSTART;TZID=Europe/Rome:{{dateFormat "20060102T150405" .Date }} {{- $d := time.AsTime .Date }} {{- $duration := .Params.duration | default "1h" }} -DTEND;TZID=Europe/Rome:{{dateFormat "20060102T150405Z" ($d.Add (time.ParseDuration $duration) ) }} -{{- end -}} +DTEND;TZID=Europe/Rome:{{dateFormat "20060102T150405" ($d.Add (time.ParseDuration $duration) ) }} +{{- end }} END:VEVENT -{{- end -}} +{{- end }} END:VCALENDAR -- 2.47.2 From a8bdce6e872a566d4c320a0afb7856b093048104 Mon Sep 17 00:00:00 2001 From: paspo Date: Tue, 1 Oct 2024 22:52:48 +0200 Subject: [PATCH 5/6] description --- layouts/_default/home.calendar.ics | 44 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/layouts/_default/home.calendar.ics b/layouts/_default/home.calendar.ics index 2ad3dee..271a377 100644 --- a/layouts/_default/home.calendar.ics +++ b/layouts/_default/home.calendar.ics @@ -1,3 +1,4 @@ +{{- $numcaratteri := 66 }} BEGIN:VCALENDAR VERSION:2.0 PRODID:-//BgLUG//BgLUG Events Calendar//EN @@ -5,18 +6,6 @@ X-WR-CALNAME:BgLUG Events Calendar X-WR-TIMEZONE:Europe/Rome CALSCALE:GREGORIAN METHOD:PUBLISH -{{- range where .Site.Pages ".Page.Params.add_to_ics" true -}} -{{- $location := "" -}} -{{- $locations := .Params.locations -}} -{{- with (eq (printf "%T" $locations ) "string" ) -}} - {{- $location = $locations -}} -{{- end -}} -{{- with (eq (printf "%T" $locations ) "[]string" ) -}} - {{- $location = (index $locations 0) -}} -{{- end -}} -{{- if .Params.location_ics }} - {{- $location = .Params.location_ics }} -{{- end }} BEGIN:VTIMEZONE TZID:Europe/Rome LAST-MODIFIED:20240422T053451Z @@ -37,6 +26,25 @@ DTSTART:19701025T030000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU END:STANDARD END:VTIMEZONE +{{- range where .Site.Pages ".Page.Params.add_to_ics" true -}} + {{- $location := "" -}} + {{- $locations := .Params.locations -}} + {{- with (eq (printf "%T" $locations ) "string" ) -}} + {{- $location = $locations -}} + {{- end -}} + {{- with (eq (printf "%T" $locations ) "[]string" ) -}} + {{- $location = (index $locations 0) -}} + {{- end -}} + {{- if .Params.location_ics }} + {{- $location = .Params.location_ics }} + {{- end }} + {{- $description := "" }} + {{- with .Description }} + {{- $description = . }} + {{- end }} + {{- with .Summary }} + {{- $description = . }} + {{- end }} BEGIN:VEVENT SUMMARY:{{.Title}} ORGANIZER;{{ .Site.Param "ics.organizer" }} @@ -44,6 +52,18 @@ UID:{{ md5 .Permalink }}@bglug.it SEQUENCE:0 STATUS:CONFIRMED TRANSP:TRANSPARENT + + {{- if ne $description "" }} + {{- $description = replace $description "\n" " " }} + {{- $description = (print "DESCRIPTION:" $description ) | truncate 400 }} + {{- $l := $description | len }} + {{- $i := 0 }} + {{- range seq 0 $numcaratteri $l }} +{{ strings.Repeat $i " " }}{{- substr $description . $numcaratteri }} + {{- $i = add $i 1 }} + {{- end }} + + {{- end }} LOCATION:{{ $location }} URL:{{ .Permalink }} {{ with .Lastmod }}DTSTAMP:{{dateFormat "20060102T150405Z" . }} -- 2.47.2 From 5d608c7aa6053cb813532aa3c27c3783857c51c3 Mon Sep 17 00:00:00 2001 From: paspo Date: Tue, 1 Oct 2024 23:12:52 +0200 Subject: [PATCH 6/6] image --- layouts/_default/home.calendar.ics | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/layouts/_default/home.calendar.ics b/layouts/_default/home.calendar.ics index 271a377..4d20c12 100644 --- a/layouts/_default/home.calendar.ics +++ b/layouts/_default/home.calendar.ics @@ -52,20 +52,25 @@ UID:{{ md5 .Permalink }}@bglug.it SEQUENCE:0 STATUS:CONFIRMED TRANSP:TRANSPARENT - {{- if ne $description "" }} {{- $description = replace $description "\n" " " }} {{- $description = (print "DESCRIPTION:" $description ) | truncate 400 }} - {{- $l := $description | len }} {{- $i := 0 }} - {{- range seq 0 $numcaratteri $l }} + {{- range seq 0 $numcaratteri ($description | len) }} {{ strings.Repeat $i " " }}{{- substr $description . $numcaratteri }} - {{- $i = add $i 1 }} + {{- $i = add $i 1 }} {{- end }} - {{- end }} LOCATION:{{ $location }} URL:{{ .Permalink }} + {{- with (.Page.Resources.GetMatch .Params.image ) -}} + {{- $image := print "IMAGE;VALUE=URI;DISPLAY=BADGE;FMTTYPE=" .MediaType.String ":" .Permalink }} + {{- $i := 0 }} + {{- range seq 0 $numcaratteri ($image | len) }} +{{ strings.Repeat $i " " }}{{- substr $image . $numcaratteri }} + {{- $i = add $i 1 }} + {{- end }} +{{ end -}} {{ with .Lastmod }}DTSTAMP:{{dateFormat "20060102T150405Z" . }} {{ end -}} {{ if .Date }}DTSTART;TZID=Europe/Rome:{{dateFormat "20060102T150405" .Date }} -- 2.47.2