diff --git a/php/actualites.php b/php/actualites.php index ab8b87d..cab6391 100644 --- a/php/actualites.php +++ b/php/actualites.php @@ -44,7 +44,8 @@ function build_news_feed(): string 'Silly.be - Actualités', SITE . '/actualites', 'Actualités de la commune de Silly (Belgique)', - $items + $items, + 'https://sillycone-village.be/silly-rss/actualites.php' ); } diff --git a/php/agenda.php b/php/agenda.php index f2006bb..adc792a 100644 --- a/php/agenda.php +++ b/php/agenda.php @@ -56,10 +56,14 @@ function build_events_feed(): string $meta = format_event_meta($item); $description = ($meta !== '' ? '
' . htmlspecialchars($meta, ENT_QUOTES, 'UTF-8') . '
' : '') . full_body_html($item); + // Un evenement recurrent partage le meme UID sur toutes ses + // occurrences (memes UID, dates differentes) : on suffixe le guid + // avec la date de debut pour rester unique par occurrence, comme + // l'exige la spec RSS. $items[] = [ 'title' => $title, 'link' => SITE . '/agenda/' . slugify($title) . '?u=' . rawurlencode($uid), - 'guid' => $uid, + 'guid' => $uid . '-' . ($item['start'] ?? ''), 'pubDate' => $item['created'] ?? $item['start'] ?? null, 'description' => $description, ]; @@ -68,7 +72,8 @@ function build_events_feed(): string 'Silly.be - Agenda', SITE . '/agenda', "Agenda / événements de la commune de Silly (Belgique)", - $items + $items, + 'https://sillycone-village.be/silly-rss/agenda.php' ); } diff --git a/php/common.php b/php/common.php index f4a3113..6688553 100644 --- a/php/common.php +++ b/php/common.php @@ -166,14 +166,17 @@ function xml_escape(string $text): string /** * Construit un flux RSS 2.0 complet a partir d'une liste d'items deja * formates (chacun un tableau title/link/guid/pubDate/description). + * $selfUrl est l'URL du flux lui-meme (atom:link rel="self", recommande + * par le validateur W3C). */ -function build_rss(string $title, string $link, string $description, array $items): string +function build_rss(string $title, string $link, string $description, array $items, string $selfUrl): string { $now = rfc822(null); $xml = '' . "\n"; - $xml .= '{html.escape(meta)}
" if meta else "") + full_body_html(item) pub_dt = parse_dt(item.get("created") or item.get("start")) + # Un evenement recurrent partage le meme UID sur toutes ses + # occurrences : on suffixe le guid avec la date de debut pour + # rester unique par occurrence, comme l'exige la spec RSS. + occurrence_guid = f"{guid}-{item.get('start', '')}" entries.append( "