From 7558fc721fcc458b73867ebf8ef5e18918ef33ce Mon Sep 17 00:00:00 2001 From: Cedric Abonnel Date: Tue, 12 May 2026 10:19:06 +0200 Subject: [PATCH] feat: page HTML pour navigateurs sur /feed (/rss, /rss.xml) --- public/feed.php | 93 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/public/feed.php b/public/feed.php index ae13e00..1c63f97 100644 --- a/public/feed.php +++ b/public/feed.php @@ -4,12 +4,8 @@ declare(strict_types=1); define('BASE_PATH', realpath(__DIR__ . '/../')); -if (session_status() === PHP_SESSION_NONE) { - $isHttps = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; - session_set_cookie_params(['lifetime' => 0, 'path' => '/', 'secure' => $isHttps, 'httponly' => true, 'samesite' => 'Lax']); - session_start(); -} - +require_once BASE_PATH . '/bootstrap.php'; +require_once BASE_PATH . '/src/helpers.php'; require_once BASE_PATH . '/src/auth.php'; require_once BASE_PATH . '/config/config.php'; require_once BASE_PATH . '/src/ArticleManager.php'; @@ -26,12 +22,85 @@ $all = array_values(array_filter( static fn (array $a): bool => strtotime((string)($a['published_at'] ?? '')) <= $now )); +// ─── Détection navigateur ──────────────────────────────────────────────────── +$accept = $_SERVER['HTTP_ACCEPT'] ?? ''; +$isBrowser = str_contains($accept, 'text/html') + && !str_contains($accept, 'application/rss+xml'); + +if ($isBrowser) { + require_once BASE_PATH . '/src/Parsedown.php'; + $Parsedown = new Parsedown(); + + $feedUrl = $base . '/feed'; + $recentItems = array_slice($all, 0, 10); + + ob_start(); + ?> +
+
+ +
+

Flux RSS — varlog

+

Journal personnel de Cédrix — informatique, hack et loisirs techniques.

+
+ +
+
+

S'abonner

+

+ Copiez cette URL dans votre lecteur RSS (Miniflux, Feedly, NetNewsWire…) + pour recevoir les nouveaux articles automatiquement. +

+
+ + +
+
+
+ +

Derniers articles

+
+ text($a['content'] ?? '')), 0, 100, '…'); + $cat = trim($a['category'] ?? ''); + ?> + +
+ + +
+ + + +

+
+ +
+ +
+
+ $base . '/feed' . ($p > 1 ? '?page=' . $p : ''); +$feedUrlFn = static fn (int $p): string => $base . '/feed' . ($p > 1 ? '?page=' . $p : ''); $lastBuild = ''; foreach ($all as $a) { @@ -60,16 +129,16 @@ echo '' . "\n"; - + 1): ?> - - + + -