Home: Add calendar
This commit is contained in:
parent
49e0179832
commit
db0000244a
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -17,3 +17,5 @@ hugo.linux
|
|||
/.hugo_build.lock
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/hugo
|
||||
|
||||
data/
|
||||
|
|
|
@ -24,6 +24,8 @@ All other information like details on groups, projects and recurring events shou
|
|||
|
||||
### 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.
|
||||
To deploy the website, just copy the whole folder to a directory which is servered by the webserver of your preference.
|
||||
|
||||
|
|
|
@ -5,4 +5,4 @@ draft: false
|
|||
headless: true
|
||||
---
|
||||
|
||||
TODO: Termine (next 5 events or full calendar?)
|
||||
{{< calendar-table >}}
|
||||
|
|
9
fetch-calendar.sh
Executable file
9
fetch-calendar.sh
Executable 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
|
|
@ -1,6 +1,7 @@
|
|||
baseURL = 'https://hamburg.ccc.de/'
|
||||
languageCode = 'de-de'
|
||||
defaultContentLanguage = 'de'
|
||||
timeZone = 'Europe/Berlin'
|
||||
title = 'CCC Hansestadt Hamburg e.V.'
|
||||
theme = 'ccchh'
|
||||
|
||||
|
|
22
themes/ccchh/layouts/shortcodes/calendar-table.html
Normal file
22
themes/ccchh/layouts/shortcodes/calendar-table.html
Normal 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>
|
Loading…
Reference in a new issue