From 183be1d9ce9618aa4439dd52f256f0e54eccfae7 Mon Sep 17 00:00:00 2001 From: paspo Date: Wed, 2 Oct 2024 13:22:48 +0000 Subject: [PATCH] ics calendar (#265) fixes #243 Reviewed-on: https://git.libreschool.org/BgLUG/bglug.it/pulls/265 Reviewed-by: omar Reviewed-by: amreo Co-authored-by: paspo Co-committed-by: paspo --- config.yml | 18 +++++ content/events/_index.en.md | 6 -- content/events/_index.it.md | 6 -- docker/rootfs/etc/nginx/http.d/default.conf | 4 + layouts/_default/home.calendar.ics | 83 +++++++++++++++++++++ 5 files changed, 105 insertions(+), 12 deletions(-) delete mode 100644 content/events/_index.en.md delete mode 100644 content/events/_index.it.md create mode 100644 layouts/_default/home.calendar.ics diff --git a/config.yml b/config.yml index e79e131..ab38084 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/index.ics - title: Facebook icon: fa-facebook-f pack: brands @@ -209,10 +216,21 @@ 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 - rss + - calendar page: - html - rss diff --git a/content/events/_index.en.md b/content/events/_index.en.md deleted file mode 100644 index 726fb10..0000000 --- a/content/events/_index.en.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -type: section -title: Events -#description: "TODO: please fill this with a description" -sidebar_right: sidebar-eventi ---- diff --git a/content/events/_index.it.md b/content/events/_index.it.md deleted file mode 100644 index 2059342..0000000 --- a/content/events/_index.it.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -type: section -title: Eventi -#description: "TODO: non so come descrivere la sezione eventi" -sidebar_right: sidebar-eventi ---- diff --git a/docker/rootfs/etc/nginx/http.d/default.conf b/docker/rootfs/etc/nginx/http.d/default.conf index 7961041..e481363 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/index.ics; + } + location ~ ^/wp\-content/uploads/2008/02/Statuto\.pdf$ { return 301 https://bglug.it/it/chi-siamo/Statuto.pdf; } diff --git a/layouts/_default/home.calendar.ics b/layouts/_default/home.calendar.ics new file mode 100644 index 0000000..4d20c12 --- /dev/null +++ b/layouts/_default/home.calendar.ics @@ -0,0 +1,83 @@ +{{- $numcaratteri := 66 }} +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 +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 +{{- 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" }} +UID:{{ md5 .Permalink }}@bglug.it +SEQUENCE:0 +STATUS:CONFIRMED +TRANSP:TRANSPARENT + {{- if ne $description "" }} + {{- $description = replace $description "\n" " " }} + {{- $description = (print "DESCRIPTION:" $description ) | truncate 400 }} + {{- $i := 0 }} + {{- range seq 0 $numcaratteri ($description | len) }} +{{ strings.Repeat $i " " }}{{- substr $description . $numcaratteri }} + {{- $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 }} +{{- $d := time.AsTime .Date }} +{{- $duration := .Params.duration | default "1h" }} +DTEND;TZID=Europe/Rome:{{dateFormat "20060102T150405" ($d.Add (time.ParseDuration $duration) ) }} +{{- end }} +END:VEVENT +{{- end }} +END:VCALENDAR