Skip to content

Commit e194803

Browse files
authored
Merge pull request #115 from CloudNativeLinz/feature/event-calendar
Adding a calendar file to subscribe to
2 parents 50430c7 + 702a8ee commit e194803

File tree

8 files changed

+687
-3
lines changed

8 files changed

+687
-3
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ ARG NODE_VERSION="none"
99
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
1010

1111
# [Optional] Uncomment this section to install additional OS packages.
12-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13-
# && apt-get -y install --no-install-recommends <your-package-list-here>
12+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13+
&& apt-get -y install --no-install-recommends python3-venv python3-pip
1414

1515
# [Optional] Uncomment this line to install global node packages.
1616
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
}
1414
},
1515

16+
// Features to add to the dev container. More info: https://containers.dev/features.
17+
"features": {
18+
"ghcr.io/devcontainers/features/github-cli:1": {}
19+
},
20+
1621
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1722
"forwardPorts": [
1823
// Jekyll server
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Generate Calendar
2+
3+
on:
4+
push:
5+
paths:
6+
- '_data/events.yml'
7+
workflow_dispatch: # Allow manual triggering
8+
9+
jobs:
10+
generate-calendar:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.9'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt
26+
27+
- name: Generate calendar
28+
run: python generate_calendar.py
29+
30+
- name: Commit and push if changed
31+
run: |
32+
git config --local user.email "[email protected]"
33+
git config --local user.name "GitHub Action"
34+
git add calendar.ics
35+
git diff --staged --quiet || git commit -m "Update calendar.ics"
36+
git push

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ package.json
1212
.jekyll-cache
1313
/vendor/
1414
vendor/
15+
16+
# ignore the python virtual environment
17+
.venv/
18+
__pycache__/

calendar.ics

Lines changed: 556 additions & 0 deletions
Large diffs are not rendered by default.

generate_calendar.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import yaml
2+
import hashlib
3+
from datetime import datetime
4+
from icalendar import Calendar, Event
5+
import pytz
6+
7+
# ---- SETTINGS ----
8+
TIMEZONE = "Europe/Berlin" # Change to your time zone, e.g. "America/New_York"
9+
10+
# Load YAML
11+
with open("_data/events.yml", "r") as f:
12+
data = yaml.safe_load(f)
13+
14+
# Prepare calendar
15+
cal = Calendar()
16+
cal.add("prodid", "-//My GitHub Calendar//EN")
17+
cal.add("version", "2.0")
18+
19+
tz = pytz.timezone(TIMEZONE)
20+
21+
for ev in data:
22+
event = Event()
23+
24+
# Parse date and assume meetup is from 18:00 to 20:00
25+
event_date = datetime.strptime(ev["date"], "%Y-%m-%d")
26+
start_dt = tz.localize(event_date.replace(hour=18, minute=0))
27+
end_dt = tz.localize(event_date.replace(hour=21, minute=0))
28+
29+
event.add("summary", ev["title"])
30+
event.add("dtstart", start_dt)
31+
event.add("dtend", end_dt)
32+
33+
# Add location information with enhanced mapping
34+
location = ev.get('host', 'TBA')
35+
if location and location.lower() != 'online':
36+
event.add("location", location)
37+
elif location and location.lower() == 'online':
38+
event.add("location", "Online Event")
39+
40+
# Add the event link as URL
41+
if 'event_link' in ev:
42+
event.add("url", ev['event_link'])
43+
44+
# Create description from talks if available
45+
description = f"Host: {ev.get('host', 'TBA')}\n"
46+
if 'talks' in ev and ev['talks']:
47+
description += "Talks:\n"
48+
for talk in ev['talks']:
49+
description += f"- {talk['title']} by {talk['speaker']}\n"
50+
if 'event_link' in ev:
51+
description += f"\nEvent link (RSVP): {ev['event_link']}"
52+
53+
event.add("description", description)
54+
55+
# Create stable UID by hashing title + date
56+
uid_base = f"{ev['id']}"
57+
uid_hash = hashlib.md5(uid_base.encode("utf-8")).hexdigest()
58+
event.add("uid", f"{uid_hash}@cncflinz.at")
59+
60+
cal.add_component(event)
61+
62+
# Save ICS
63+
with open("calendar.ics", "wb") as f:
64+
f.write(cal.to_ical())

makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,20 @@ install:
3535
@bundle install
3636
@bundle exec jekyll build
3737

38-
.PHONY: all serve serve-livereload serve-windows
38+
# Generate calendar.ics from events data
39+
calendar: setup-python
40+
@echo "Generating calendar.ics from events data..."
41+
@./.venv/bin/python generate_calendar.py
42+
@echo "Calendar generated successfully!"
43+
44+
# Setup Python environment for calendar generation
45+
setup-python:
46+
@if [ ! -d ".venv" ]; then \
47+
echo "Setting up Python environment..."; \
48+
python3 -m venv .venv --upgrade-deps; \
49+
.venv/bin/pip install -r requirements.txt; \
50+
echo "Python environment ready!"; \
51+
fi
52+
53+
.PHONY: all serve serve-livereload serve-windows calendar setup-python
54+

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PyYAML
2+
icalendar
3+
pytz

0 commit comments

Comments
 (0)