From 05a31b3b531db94b3f9e6ffc6bda5f2235935209 Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Wed, 4 Nov 2026 11:13:49 +0100 Subject: [PATCH 1/2] fix(events): make the ICS feed work as a subscription Give each event a UID derived from its file name, so subscribed calendars stop seeing every event as new at each build. Add refresh hints to the calendar header, switch the page link to webcal:// and explain how to subscribe. --- ics_generator.py | 29 ++++++++++++++++----- themes/hpc_math_theme/templates/events.html | 6 ++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ics_generator.py b/ics_generator.py index 64e6a7e..b262d7d 100644 --- a/ics_generator.py +++ b/ics_generator.py @@ -15,17 +15,21 @@ reader = readers.RstReader(settings=DEFAULT_CONFIG.copy()) calendar = ics.Calendar(creator="HPC@Maths") - -for event_file in glob.glob(f"{EVENTS_PATH}/*.rst"): +# Sorted so that the output does not depend on the filesystem order. +for event_file in sorted(glob.glob(f"{EVENTS_PATH}/*.rst")): content, metadata = reader.read(event_file) event = ics.Event() + # The UID must stay the same from one build to the next, otherwise + # subscribed calendars treat every event as new at each refresh. + slug = os.path.splitext(os.path.basename(event_file))[0] + event.uid = f"{slug}@{SITE_DOMAIN.split('://')[-1]}" # event.replace_timezone(tzinfo=tz.gettz("Europe/Paris")) if 'speaker' in metadata: event.summary = f"{metadata['title']} - {metadata['speaker']}" else: event.summary = f"{metadata['title']}" - event.description = f"More information: {SITE_DOMAIN}{SITEURL}/pages/{os.path.splitext(os.path.basename(event_file))[0]}.html" + event.description = f"More information: {SITE_DOMAIN}{SITEURL}/pages/{slug}.html" d = datetime.datetime( year=metadata['date'].year, month=metadata['date'].month, @@ -41,6 +45,19 @@ calendar.events.append(event) -with open(OUTPUT_ICS, "w", newline='') as f: - f.write("\n".join([line.replace('/ics.py/2020.1/', '') - for line in calendar.serialize().split(r"\n")])) +# Hints for subscribed clients. Not all of them honour these (Google ignores +# them), but Apple Calendar and Outlook do. RFC 5545 wants calendar properties +# before the components, so they are inserted right after the header instead of +# going through calendar.extra, which ics writes at the end of the file. +SUBSCRIPTION_HINTS = [ + "X-WR-CALNAME:Séminaires HPC@Maths", + "REFRESH-INTERVAL;VALUE=DURATION:PT6H", + "X-PUBLISHED-TTL:PT6H", +] + +lines = calendar.serialize().replace('/ics.py/2020.1/', '').splitlines() +header_end = lines.index("BEGIN:VTIMEZONE") +lines[header_end:header_end] = SUBSCRIPTION_HINTS + +with open(OUTPUT_ICS, "w", newline='', encoding="utf-8") as f: + f.write("\r\n".join(lines) + "\r\n") diff --git a/themes/hpc_math_theme/templates/events.html b/themes/hpc_math_theme/templates/events.html index 25f6486..4c94967 100644 --- a/themes/hpc_math_theme/templates/events.html +++ b/themes/hpc_math_theme/templates/events.html @@ -5,8 +5,12 @@

Événements

Cette page réunit toutes les informations concernant les événements promus par l'équipe.

Il est possible de s'abonner aux évènements via le lien {{ SITE_DOMAIN }}{{ + href="{{ SITE_DOMAIN|replace('https://', 'webcal://') }}{{ SITEURL }}/hpcmaths_seminars.ics">{{ SITE_DOMAIN }}{{ SITEURL }}/hpcmaths_seminars.ics

+

Abonnez-vous à ce lien plutôt que d'importer le fichier : votre agenda + recevra alors automatiquement les nouveaux séminaires. Avec Google Agenda, utilisez + « Autres agendas > À partir de l'URL » et collez l'adresse ci-dessus. La mise à jour + peut prendre quelques heures.

{%for p in pages|sort(attribute='date', reverse=True) %} {% if p.category == 'event' %} From 88daaa3b91d5a09cf9c4da7440572451c72b9d88 Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Wed, 4 Nov 2026 11:16:10 +0100 Subject: [PATCH 2/2] ci(pages): trigger the deploy workflow on main instead of master --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index d95f0ed..0860223 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -2,7 +2,7 @@ name: Deploy site to GitHub Pages on: push: - branches: [master] + branches: [main] pull_request: workflow_dispatch: