feat: agrégateur RSS /flux + gestion feeds dans /profile

This commit is contained in:
Cedric Abonnel
2026-05-12 23:59:09 +02:00
parent 03177dc732
commit 2e8302dad4
7 changed files with 432 additions and 7 deletions
+48
View File
@@ -0,0 +1,48 @@
<?php ob_start(); ?>
<div class="d-flex align-items-center gap-3 mb-5">
<h1 class="h4 mb-0">Flux agrégés</h1>
</div>
<?php if (empty($fluxItems)): ?>
<p class="text-muted">Aucun article disponible pour l'instant.</p>
<?php else: ?>
<div class="flux-list">
<?php foreach ($fluxItems as $_item):
$_date = $_item['date'] > 0 ? date('d/m/Y', $_item['date']) : '';
$_authorName = $_item['author_name'] ?? '';
$_authorSlug = $_item['author_slug'] ?? '';
?>
<article class="flux-item">
<div class="flux-item-meta">
<?php if ($_authorSlug !== ''): ?>
<a href="/profil/<?= rawurlencode($_authorSlug) ?>" class="flux-author"><?= htmlspecialchars($_authorName) ?></a>
<?php elseif ($_authorName !== ''): ?>
<span class="flux-author"><?= htmlspecialchars($_authorName) ?></span>
<?php endif; ?>
<?php if ($_item['feed_title'] !== ''): ?>
<span class="flux-feed-name"><?= htmlspecialchars($_item['feed_title']) ?></span>
<?php endif; ?>
<?php if ($_date !== ''): ?>
<span class="flux-date"><?= $_date ?></span>
<?php endif; ?>
</div>
<h2 class="flux-item-title">
<a href="<?= htmlspecialchars($_item['url']) ?>" target="_blank" rel="noopener">
<?= htmlspecialchars($_item['title']) ?> ↗
</a>
</h2>
<?php if ($_item['summary'] !== ''): ?>
<p class="flux-item-summary"><?= htmlspecialchars($_item['summary']) ?></p>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
$content = ob_get_clean();
$title = 'Flux — ' . siteTitle();
$canonical = rtrim(APP_URL, '/') . '/flux';
$mainClass = 'container-fluid';
include __DIR__ . '/layout.php';
+48 -6
View File
@@ -1,7 +1,9 @@
<?php ob_start(); ?>
<div class="d-flex align-items-center gap-3 mb-4">
<form method="post" action="/profile">
<div class="d-flex align-items-center justify-content-between gap-3 mb-4">
<h1 class="h4 mb-0">Mon profil</h1>
<button type="submit" class="btn btn-primary btn-sm">Enregistrer</button>
</div>
<?php if ($profileSuccess): ?>
@@ -10,8 +12,6 @@
<?php if ($profileError !== ''): ?>
<div class="alert alert-danger py-2 small mb-3"><?= htmlspecialchars($profileError) ?></div>
<?php endif; ?>
<form method="post" action="/profile">
<div class="row g-4">
<!-- Colonne gauche : identité -->
@@ -36,9 +36,6 @@
<label class="form-label fw-semibold text-muted">Email</label>
<input type="text" class="form-control" value="<?= htmlspecialchars(currentUserEmail() ?? '') ?>" disabled>
</div>
<div class="mt-auto">
<button type="submit" class="btn btn-primary w-100">Enregistrer</button>
</div>
</div>
</div>
</div>
@@ -69,6 +66,51 @@
</div>
</form>
<!-- Flux RSS -->
<div class="mt-4" id="feeds">
<h2 class="h6 text-muted mb-3">Flux RSS</h2>
<div class="row g-3 align-items-start">
<div class="col-md-8">
<?php if (!empty($profileFeeds)): ?>
<div class="card mb-3">
<ul class="list-group list-group-flush">
<?php foreach ($profileFeeds as $_feed): ?>
<li class="list-group-item d-flex align-items-center gap-2 py-2">
<div class="flex-grow-1 min-w-0">
<div class="fw-semibold small text-truncate"><?= htmlspecialchars($_feed['label'] ?: $_feed['feed_url']) ?></div>
<div class="text-muted small text-truncate"><?= htmlspecialchars($_feed['feed_url']) ?></div>
</div>
<form method="post" action="/feed/delete" class="flex-shrink-0">
<input type="hidden" name="feed_id" value="<?= (int)$_feed['id'] ?>">
<button class="btn btn-sm btn-outline-danger py-0" data-confirm="Supprimer ce flux ?">✕</button>
</form>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header small fw-semibold">Ajouter un flux</div>
<div class="card-body">
<form method="post" action="/feed/add">
<div class="mb-2">
<input type="url" name="feed_url" class="form-control form-control-sm"
placeholder="https://example.com/feed.xml" required>
</div>
<div class="mb-3">
<input type="text" name="feed_label" class="form-control form-control-sm"
placeholder="Libellé (optionnel)" maxlength="100">
</div>
<button class="btn btn-primary btn-sm w-100">Ajouter</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
$pdo = dbPdo();
$_profileRoles = [];