-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss.php
More file actions
61 lines (54 loc) · 2.73 KB
/
Copy pathrss.php
File metadata and controls
61 lines (54 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Générateur de flux RSS dynamique pour le blog
*/
header('Content-Type: application/rss+xml; charset=utf-8');
include_once __DIR__ . '/api/notion-blog.php';
include_once __DIR__ . '/includes/lang.php';
// Récupérer les 20 derniers articles pour le flux
$articles = getBlogArticles(20);
$siteUrl = 'https://www.slapia.com';
$blogUrl = $siteUrl . '/blog';
$rssUrl = $siteUrl . '/rss.xml';
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>SlapIA Blog</title>
<link><?php echo htmlspecialchars($blogUrl); ?></link>
<description><?php echo htmlspecialchars(t('meta_description') ?? "Derniers articles sur l'IA et l'Automatisation par SlapIA."); ?></description>
<language><?php echo isset($lang) ? $lang : 'fr'; ?>-FR</language>
<atom:link href="<?php echo htmlspecialchars($rssUrl); ?>" rel="self" type="application/rss+xml" />
<?php if (!empty($articles)): ?>
<lastBuildDate><?php echo htmlspecialchars($articles[0]['date_rss']); ?></lastBuildDate>
<?php endif; ?>
<?php foreach ($articles as $article):
// Récupérer le contenu complet via les blocs Notion pour le flux RSS
$fullContent = getNotionBlocks($article['id']);
if (empty($fullContent)) {
$fullContent = !empty($article['extrait']) ? $article['extrait'] : $article['contenu_raw'];
}
// Nettoyage et formatage minimal pour XML
$description = htmlspecialchars($article['extrait'] ?: mb_strimwidth(strip_tags($fullContent), 0, 300, "..."));
?>
<item>
<title><?php echo htmlspecialchars($article['titre']); ?></title>
<link><?php echo htmlspecialchars($article['url']); ?></link>
<guid isPermaLink="true"><?php echo htmlspecialchars($article['url']); ?></guid>
<pubDate><?php echo htmlspecialchars($article['date_rss']); ?></pubDate>
<description><?php echo $description; ?></description>
<content:encoded><![CDATA[<?php echo $fullContent; ?>]]></content:encoded>
<?php if (!empty($article['image'])):
// Extract extension or fallback to jpeg
$ext = pathinfo(parse_url($article['image'], PHP_URL_PATH), PATHINFO_EXTENSION);
$mime = 'image/jpeg';
if (in_array(strtolower($ext), ['png'])) $mime = 'image/png';
elseif (in_array(strtolower($ext), ['gif'])) $mime = 'image/gif';
elseif (in_array(strtolower($ext), ['webp'])) $mime = 'image/webp';
?>
<enclosure url="<?php echo htmlspecialchars($article['image']); ?>" type="<?php echo $mime; ?>" length="0" />
<?php endif; ?>
</item>
<?php endforeach; ?>
</channel>
</rss>