Home: Add calendar

This commit is contained in:
jtbx 2023-10-20 23:36:39 +02:00
parent 49e0179832
commit db0000244a
6 changed files with 37 additions and 1 deletions

2
.gitignore vendored
View file

@ -17,3 +17,5 @@ hugo.linux
/.hugo_build.lock /.hugo_build.lock
# End of https://www.toptal.com/developers/gitignore/api/hugo # End of https://www.toptal.com/developers/gitignore/api/hugo
data/

View file

@ -24,6 +24,8 @@ All other information like details on groups, projects and recurring events shou
### Build and Deploy ### Build and Deploy
To populate the calendar data, please run `fetch-calendar.sh` before running hugo.
Running the hugo command without and parameters will re-generate the site in the `public` directory. Running the hugo command without and parameters will re-generate the site in the `public` directory.
To deploy the website, just copy the whole folder to a directory which is servered by the webserver of your preference. To deploy the website, just copy the whole folder to a directory which is servered by the webserver of your preference.

View file

@ -5,4 +5,4 @@ draft: false
headless: true headless: true
--- ---
TODO: Termine (next 5 events or full calendar?) {{< calendar-table >}}

9
fetch-calendar.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
set -eu
ICAL_URL=https://cloud.hamburg.ccc.de/remote.php/dav/public-calendars/6CJcM7XDfoYire5d
START_TIME=$(date -v-1d +%s) # yesterday
END_TIME=$(date -v+1m +%s) # now + 1 month
OUTFILE=data/calendar.json
curl -s $ICAL_URL\?export\&accept=jcal\&expand\=1\&start\=$START_TIME\&end\=$END_TIME | jq '.[2]|map({_type:.[0]}+(.[1]|map({key:.[0],value:.[3]})|from_entries))' > $OUTFILE

View file

@ -1,6 +1,7 @@
baseURL = 'https://hamburg.ccc.de/' baseURL = 'https://hamburg.ccc.de/'
languageCode = 'de-de' languageCode = 'de-de'
defaultContentLanguage = 'de' defaultContentLanguage = 'de'
timeZone = 'Europe/Berlin'
title = 'CCC Hansestadt Hamburg e.V.' title = 'CCC Hansestadt Hamburg e.V.'
theme = 'ccchh' theme = 'ccchh'

View file

@ -0,0 +1,22 @@
{{- index .Site.Data "calendar.json" }}
<table>
<thead>
<tr>
<td>Datum</td>
<td>Titel</td>
<td>Ort</td>
</tr>
</thead>
<tbody>
{{- range first 10 (sort $.Site.Data.calendar "dtstart" ) }}
{{- if eq ._type "vevent"}}
<tr>
{{- $start := time .dtstart }}
<td style="font-variant-numeric: tabular-nums;">{{ $start.Local | time.Format "Mon, 2006-01-02 15:04" }}</td>
<td>{{ .summary }}</td>
<td>{{ .location }}</td>
</tr>
{{- end }}
{{- end }}
</tbody>
</table>