Version 1.0 ()
------------------------------------------------------------------------
+ * Make RSS feeds templatable with Smarty .tpl files (feed_*.tpl), so
+ that you can easily customize your feeds layouts, inject nagging
+ ads and so on (garvinhicking)
+
* Fix certain plugins to correctly behave when using entry-
properties caching, by re-executing plugins that were not executed
because they "scramble" the true content. (garvinhicking)
Version 0.9.1 ()
------------------------------------------------------------------------
+ * Fix thumbnail generation for imageMagick when target image is
+ smaller than the target size, it should not be blown up
+ (garvinhicking)
+
* Fix spartacus plugin to not properly indicate updatable versions
of plugins (garvinhicking)
-<?php # $Id: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $
+<?php # $entry['feed_id']: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
-function serendipity_printEntries_rss($entries, $version, $comments = false, $fullFeed = false, $showMail = true) {
+function serendipity_printEntries_rss(&$entries, $version, $comments = false, $fullFeed = false, $showMail = true) {
global $serendipity;
$options = array(
serendipity_plugin_api::hook_event('frontend_entries_rss', $entries, $options);
if (is_array($entries)) {
- foreach ($entries as $entry) {
- $id = (isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id']);
- $guid = serendipity_rss_getguid($entry, $options['comments']);
- $entryLink = serendipity_archiveURL($id, $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
+ foreach ($entries as $key => $_entry) {
+ $entry = &$entries[$key];
+ $entry['feed_id'] = (isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id']);
+ $entry['feed_guid'] = serendipity_rss_getguid($entry, $options['comments']);
+ $entry['feed_entryLink'] = serendipity_archiveURL($entry['feed_id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
if ($options['comments'] == true) {
// Display username as part of the title for easier feed-readability
$entry['title'] = $entry['author'] . ': ' . $entry['title'];
$entry['body'] .= ' ' . $entry['extended'];
$ext = '';
} elseif ($entry['exflag']) {
- $ext = '<br /><a href="' . $guid . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';
+ $ext = '<br /><a href="' . $entry['feed_guid'] . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';
} else {
$ext = '';
}
}
if (!is_array($entry['categories'])) {
- $entry['categories'] = array(0 => array('category_name' => $entry['category_name']));
- }
-
- if ($options['version'] == 'atom0.3') {
- /*********** ATOM 0.3 FEED *************/
-?>
-<entry>
- <link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="text/html" />
- <author>
- <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>
- <email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>
- </author>
-
- <issued><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></issued>
- <created><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></created>
- <modified><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified'])); ?></modified>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-
-<?php
- if ($options['comments'] === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $options['version']; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-?>
-
- <id><?php echo $guid; ?></id>
- <title mode="escaped" type="text/html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
-<?php if (!empty($entry['body'])) { ?>
- <content type="application/xhtml+xml" xml:base="<?php echo $serendipity['baseURL']; ?>">
- <div xmlns="http://www.w3.org/1999/xhtml">
-<?php
- echo serendipity_utf8_encode($entry['body'].$ext);
-?>
- </div>
- </content>
-<?php
- }
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:atom-0.3:per_entry', $entry);
- echo $entry['display_dat'];
-?>
-</entry>
-<?php
- } elseif ($options['version'] == 'atom1.0') {
- /*********** ATOM 1.0 FEED *************/
-?>
-<entry>
- <link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" />
- <author>
- <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>
- <email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>
- </author>
-
- <published><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></published>
- <updated><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified'])); ?></updated>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-
-<?php
- if ($options['comments'] === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $options['version']; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-
- foreach ($entry['categories'] AS $idx => $cat) {
- $name = serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?>
- <category scheme="<?php echo serendipity_categoryURL($cat, 'baseURL'); ?>" label="<?php echo $name; ?>" term="<?php echo $name; ?>" />
-<?php
- }
-?>
- <id><?php echo $guid; ?></id>
- <title type="html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
-<?php if (!empty($entry['body'])) { ?>
- <content type="xhtml" xml:base="<?php echo $serendipity['baseURL']; ?>">
- <div xmlns="http://www.w3.org/1999/xhtml">
-<?php
- echo serendipity_utf8_encode($entry['body'].$ext);
-?>
- </div>
- </content>
-<?php
- }
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:atom-1.0:per_entry', $entry);
- echo $entry['display_dat'];
-?>
-</entry>
-<?php
-
- } elseif ($options['version'] == '0.91' || $options['version'] == '2.0') {
- /*********** BEGIN RSS 0.91/2.0 FEED *************/
-?>
-<item>
- <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
- <link><?php echo $entryLink; ?></link>
-<?php
- /*********** END RSS 0.91/2.0 FEED *************/
-
- if ($options['version'] == '2.0') {
- /*********** RSS 2.0 FEED EXTRAS *************/
- foreach ($entry['categories'] AS $idx => $cat) {
- ?><category><?php echo serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?></category><?php
- }
-?>
- <comments><?php echo $entryLink; ?>#comments</comments>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-<?php
- if ($options['comments'] === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $options['version']; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-?>
- <author><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></author>
-<?php if (!empty($entry['body'])) { ?>
- <content:encoded>
-<?php
- echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));
-?>
- </content:encoded>
-<?php
- }
-?>
- <pubDate><?php echo date('r', serendipity_serverOffsetHour($entry['timestamp'])); ?></pubDate>
- <guid isPermaLink="false"><?php echo $guid; ?></guid>
- <?php
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-2.0:per_entry', $entry);
- echo $entry['display_dat'];
- ?>
-</item>
-<?php
- /*********** END 2.0 FEED EXTRAS *************/
- } else {
- /*********** BEGIN RSS 0.91 FEED EXTRAS *************/
- if (!empty($entry['body'])) { ?>
-?>
- <description>
- <?php echo serendipity_utf8_encode(htmlspecialchars($entry['body'] . $ext)); ?>
- </description>
-<?php
- }
-?>
-</item>
-<?php
- /*********** END RSS 0.91 FEED EXTRAS *************/
- }
- } else if ($options['version'] == '1.0') {
- $categories = array();
- foreach ($entry['categories'] AS $idx => $cat) {
- $categories[] = $cat['category_name'];
- }
-
-?>
-<item rdf:about="<?php echo $guid; ?>">
- <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
- <link><?php echo $entryLink; ?></link>
-<?php if (!empty($entry['body'])) { ?>
- <description>
-<?php
- echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));
-?>
- </description>
-<?php
+ $entry['categories'] = array(0 => array(
+ 'category_name' => $entry['category_name'],
+ 'feed_category_name' => serendipity_utf8_encode(htmlspecialchars($entry['category_name'])),
+ 'categoryURL' => serendipity_categoryURL($cat, 'baseURL')
+ ));
+ } else {
+ foreach($entry['categories'] AS $cid => $_cat) {
+ $cat = &$entry['categories'][$cid];
+ $cat['categoryURL'] = serendipity_categoryURL($cat, 'baseURL');
+ $cat['feed_category_name'] = serendipity_utf8_encode(htmlspecialchars($cat['category_name']));
}
-
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-1.0:per_entry', $entry);
- echo $entry['display_dat'];
-?>
- <dc:publisher><?php echo serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle'])); ?></dc:publisher>
- <dc:creator><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></dc:creator>
- <dc:subject><?php echo serendipity_utf8_encode(htmlspecialchars(implode(', ', $categories))); ?></dc:subject>
- <dc:date><?php echo date('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></dc:date>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-<?php
- if ($options['comments'] === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $options['version']; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-?>
-</item>
-<?php
- } elseif ($options['version'] == 'opml1.0') {
-?>
- <outline text="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="url" htmlUrl="<?php echo $entryLink; ?>" urlHTTP="<?php echo $entryLink; ?>" />
-<?php
}
+
+ // Prepare variables
+ // 1. UTF8 encoding + htmlspecialchars.
+ $entry['feed_title'] = serendipity_utf8_encode(htmlspecialchars($entry['title']));
+ $entry['feed_blogTitle'] = serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle']));
+ $entry['feed_title'] = serendipity_utf8_encode(htmlspecialchars($entry['title']));
+ $entry['feed_author'] = serendipity_utf8_encode(htmlspecialchars($entry['author']));
+ $entry['feed_email'] = serendipity_utf8_encode(htmlspecialchars($entry['email']));
+
+ // 2. gmdate
+ $entry['feed_timestamp'] = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp']));
+ $entry['feed_last_modified'] = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified']));
+ $entry['feed_timestamp_r'] = date('r', serendipity_serverOffsetHour($entry['timestamp']));
+
+ // 3. UTF8 encoding
+ $entry['feed_body'] = serendipity_utf8_encode($entry['body']);
+ $entry['feed_ext'] = serendipity_utf8_encode($ext);
+
+ $entry_hook = 'frontend_display:unknown:per-entry';
+ switch($version) {
+ case 'opml1.0':
+ $entry_hook = 'frontend_display:opml-1.0:per_entry';
+ break;
+
+ case '0.91':
+ $entry_hook = 'frontend_display:rss-0.91:per_entry';
+ break;
+
+ case '1.0':
+ $entry_hook = 'frontend_display:rss-1.0:per_entry';
+ break;
+
+ case '2.0':
+ $entry_hook = 'frontend_display:rss-2.0:per_entry';
+ break;
+
+ case 'atom0.3':
+ $entry_hook = 'frontend_display:atom-0.3:per_entry';
+ break;
+
+ case 'atom1.0':
+ $entry_hook = 'frontend_display:atom-1.0:per_entry';
+ break;
+ }
+
+ serendipity_plugin_api::hook_event($entry_hook, $entry);
+ $entry['per_entry_display_dat'] = $entry['display_dat'];
}
}
}
return serendipity_getTemplateFile($params['file']);
}
+function serendipity_smarty_rss_getguid($params, &$smarty) {
+ if ( !isset($params['entry']) ) {
+ $smarty->trigger_error(__FUNCTION__ .": missing 'entry' parameter");
+ return;
+ }
+ if ( !isset($params['is_comments']) ) {
+ $smarty->trigger_error(__FUNCTION__ .": missing 'is_comments' parameter");
+ return;
+ }
+
+ return serendipity_rss_getguid($params['entry'], $params['is_comments']);
+}
function serendipity_smarty_formatTime($timestamp, $format, $useOffset = true) {
if (defined($format)) {
$serendipity['smarty']->register_modifier('xhtml_target', 'serendipity_xhtml_target');
$serendipity['smarty']->register_modifier('emptyPrefix', 'serendipity_emptyPrefix');
$serendipity['smarty']->register_modifier('formatTime', 'serendipity_smarty_formatTime');
+ $serendipity['smarty']->register_modifier('serendipity_utf8_encode', 'serendipity_utf8_encode');
+
$serendipity['smarty']->register_function('serendipity_printSidebar', 'serendipity_smarty_printSidebar');
$serendipity['smarty']->register_function('serendipity_hookPlugin', 'serendipity_smarty_hookPlugin');
$serendipity['smarty']->register_function('serendipity_showPlugin', 'serendipity_smarty_showPlugin');
$serendipity['smarty']->register_function('serendipity_getFile', 'serendipity_smarty_getFile');
$serendipity['smarty']->register_function('serendipity_printComments', 'serendipity_smarty_printComments');
$serendipity['smarty']->register_function('serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks');
+ $serendipity['smarty']->register_function('serendipity_rss_getguid', 'serendipity_smarty_rss_getguid');
+
$serendipity['smarty']->register_prefilter('serendipity_replaceSmartyVars');
}
if (!isset($_GET['nocache'])) {
switch ($_GET['type']) {
- case 'comments':
+ case 'comments':
$latest_entry = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, 1, 'desc');
- break;
- case 'content':
- default:
- $latest_entry = serendipity_fetchEntries(null, false, 1, false, false, 'last_modified DESC', '', false, true);
+ break;
+ case 'content':
+ default:
+ $latest_entry = serendipity_fetchEntries(null, false, 1, false, false, 'last_modified DESC', '', false, true);
break;
}
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);
$metadata['additional_fields'] = $plugin->generate_rss_fields($metadata['title'], $metadata['description'], $entries);
+ if (is_array($metadata['additional_fields'])) {
+ // Fix up array keys, because "." are not allowed when wanting to output using Smarty
+ foreach($metadata['additional_fields'] AS $_aid => $af) {
+ $aid = str_replace('.', '', $_aid);
+ $metadata['additional_fields'][$aid] = $af;
+ }
+ }
$metadata['fullFeed'] = $plugin->get_config('fullfeed', false);
$metadata['showMail'] = serendipity_db_bool($plugin->get_config('show_mail', $metadata['showMail']));
break;
serendipity_plugin_api::hook_event('frontend_rss', $metadata);
$self_url = 'http://' . $_SERVER['HTTP_HOST'] . htmlspecialchars($_SERVER['REQUEST_URI']);
-echo '<?xml version="1.0" encoding="utf-8" ?>';
-
-if (strstr($version, 'atom')) {
- echo "\n" . '<?xml-stylesheet href="' . serendipity_getTemplateFile('atom.css') . '" type="text/css" ?>';
+if (!is_array($entries)) {
+ $entries = array();
}
-echo "\n";
-switch ($version) {
-case '0.91':
- print <<<HEAD
-<rss version="0.91">
-<channel>
-<title>{$metadata['title']}</title>
-<link>{$metadata['link']}</link>
-<description>{$metadata['description']}</description>
-<language>{$metadata['language']}</language>
-{$metadata['additional_fields']['image']}
-
-HEAD;
-break;
-
-case '1.0':
- $rdf_seq_li = "\n";
- if (is_array($entries)) {
- foreach($entries AS $entry) {
- $rdf_seq_li .= ' <rdf:li resource="' . serendipity_rss_getguid($entry, $comments) . '" />' . "\n";
- }
-
- $entries['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-1.0:namespace', $entries);
- } else {
- $entries = array();
- }
-
- if ($metadata['showMail']) {
- $head_mail = "<admin:errorReportsTo rdf:resource=\"mailto:{$metadata['email']}\" />";
- } else {
- $head_mail = '';
- }
+if ($entries[0]['last_modified']) {
+ $gm_modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entries[0]['last_modified']));
+} else {
+ $gm_modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour());
+}
- print <<<HEAD
-<rdf:RDF {$entries['display_dat']}
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:admin="http://webns.net/mvcb/"
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
- xmlns:wfw="http://wellformedweb.org/CommentAPI/"
- xmlns="http://my.netscape.com/rdf/simple/0.9/">
-<channel>
- <title>{$metadata['title']}</title>
- <link>{$metadata['link']}</link>
- <description>{$metadata['description']}</description>
- <dc:language>{$metadata['language']}</dc:language>
- $head_mail
-
- {$metadata['additional_fields']['image_rss1.0_channel']}
-
- <items>
- <rdf:Seq>{$rdf_seq_li}</rdf:Seq>
- </items>
-</channel>
-
-{$metadata['additional_fields']['image_rss1.0_rdf']}
-
-HEAD;
-break;
-
-case '2.0':
- if (is_array($entries)) {
- $entries['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-2.0:namespace', $entries);
- } else {
- $entries = array();
- }
+$file_version = preg_replace('@[^0-9a-z\.-_]@i', '', $version);
+$template_file = serendipity_getTemplateFile('feed_' . $file_version . '.tpl', 'serendipityPath');
+if (!$template_file) {
+ die("Invalid RSS version specified\n");
+}
- if ($metadata['showMail']) {
- $head_mail = "<admin:errorReportsTo rdf:resource=\"mailto:{$metadata['email']}\" />";
- } else {
- $head_mail = '';
- }
+serendipity_printEntries_rss($entries, $version, $comments, $metadata['fullFeed'], $metadata['showMail']);
- print <<<HEAD
-<rss version="2.0"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:admin="http://webns.net/mvcb/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
- xmlns:wfw="http://wellformedweb.org/CommentAPI/"
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
- {$entries['display_dat']}>
-<channel>
- <title>{$metadata['title']}</title>
- <link>{$metadata['link']}</link>
- <description>{$metadata['description']}</description>
- <dc:language>{$metadata['language']}</dc:language>
- $head_mail
- <generator>Serendipity {$serendipity['version']} - http://www.s9y.org/</generator>
- {$metadata['additional_fields']['channel']}
- {$metadata['additional_fields']['image']}
-
-HEAD;
-break;
-
-case 'atom0.3':
- if (is_array($entries)) {
- $modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entries[0]['last_modified']));
- } else {
- $modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour());
- }
+$namespace_hook = 'frontend_display:unknown:namespace';
+$once_display_dat = '';
+switch($version) {
+ case 'opml1.0':
+ $namespace_hook = 'frontend_display:opml-1.0:namespace';
+ break;
- if ($metadata['showMail']) {
- $head_mail = "<admin:errorReportsTo rdf:resource=\"mailto:{$metadata['email']}\" />";
- } else {
- $head_mail = '';
- }
+ case '0.91':
+ $namespace_hook = 'frontend_display:rss-0.91:namespace';
+ break;
- print <<<HEAD
-<feed version="0.3"
- xmlns="http://purl.org/atom/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:admin="http://webns.net/mvcb/"
- xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
- xmlns:wfw="http://wellformedweb.org/CommentAPI/">
- <link href="{$serendipity['baseURL']}rss.php?version=atom0.3" rel="service.feed" title="{$metadata['title']}" type="application/x.atom+xml" />
- <link href="{$serendipity['baseURL']}" rel="alternate" title="{$metadata['title']}" type="text/html" />
- <link href="{$serendipity['baseURL']}rss.php?version=2.0" rel="alternate" title="{$metadata['title']}" type="application/rss+xml" />
- <title mode="escaped" type="text/html">{$metadata['title']}</title>
- <tagline mode="escaped" type="text/html">{$metadata['description']}</tagline>
- <id>{$metadata['link']}</id>
- <modified>$modified</modified>
- <generator url="http://www.s9y.org/" version="{$serendipity['version']}">Serendipity {$serendipity['version']} - http://www.s9y.org/</generator>
- <dc:language>{$metadata['language']}</dc:language>
- $head_mail
- <info mode="xml" type="text/html">
- <div xmlns="http://www.w3.org/1999/xhtml">You are viewing an ATOM formatted XML site feed. Usually this file is inteded to be viewed in an aggregator or syndication software. If you want to know more about ATOM, please visist <a href="http://atomenabled.org/">Atomenabled.org</a></div>
- </info>
-
-HEAD;
-break;
-
-case 'atom1.0':
- if (is_array($entries)) {
- $modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entries[0]['last_modified']));
- } else {
- $modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour());
- }
+ case '1.0':
+ $namespace_hook = 'frontend_display:rss-1.0:namespace';
+ serendipity_plugin_api::hook_event('frontend_display:rss-1.0:once', $entries);
+ $once_display_dat = $entries['display_dat'];
+ unset($entries['display_dat']);
+ break;
- if ($metadata['showMail']) {
- $head_mail = "<admin:errorReportsTo rdf:resource=\"mailto:{$metadata['email']}\" />";
- } else {
- $head_mail = '';
- }
+ case '2.0':
+ $namespace_hook = 'frontend_display:rss-2.0:namespace';
+ break;
- print <<<HEAD
-<feed
- xmlns="http://www.w3.org/2005/Atom"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:admin="http://webns.net/mvcb/"
- xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
- xmlns:wfw="http://wellformedweb.org/CommentAPI/">
- <link href="{$self_url}" rel="self" title="{$metadata['title']}" type="application/x.atom+xml" />
- <link href="{$serendipity['baseURL']}" rel="alternate" title="{$metadata['title']}" type="text/html" />
- <link href="{$serendipity['baseURL']}rss.php?version=2.0" rel="alternate" title="{$metadata['title']}" type="application/rss+xml" />
- <title type="html">{$metadata['title']}</title>
- <subtitle type="html">{$metadata['description']}</subtitle>
- {$metadata['additional_fields']['image_atom1.0']}
- <id>{$metadata['link']}</id>
- <updated>$modified</updated>
- <generator uri="http://www.s9y.org/" version="{$serendipity['version']}">Serendipity {$serendipity['version']} - http://www.s9y.org/</generator>
- <dc:language>{$metadata['language']}</dc:language>
- $head_mail
-
-HEAD;
-break;
-
-case 'opml1.0':
- if (is_array($entries)) {
- $modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entries[0]['last_modified']));
- } else {
- $modified = gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour());
- }
- print <<<HEAD
-<opml version="{$version}">
-<head>
- <title>{$metadata['title']}</title>
- <dateModified>$modified</dateModified>
- <ownerName>Serendipity {$serendipity['version']} - http://www.s9y.org/</ownerName>
-</head>
-<body>
-HEAD;
-break;
+ case 'atom0.3':
+ $namespace_hook = 'frontend_display:atom-0.3:namespace';
+ break;
-default:
- die("Invalid RSS version specified\n");
+ case 'atom1.0':
+ $namespace_hook = 'frontend_display:atom-1.0:namespace';
+ break;
}
-unset($entries['display_dat']); // Only needed for headers.
-serendipity_printEntries_rss($entries, $version, $comments, $metadata['fullFeed'], $metadata['showMail']);
-
-switch ($version) {
-case '0.91':
-case '2.0':
- print "</channel>\n";
- print "</rss>\n";
- break;
-case '1.0':
- if (is_array($entries)) {
- $entries['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-1.0:once', $entries);
- echo $entries['display_dat'];
- }
- print '</rdf:RDF>';
- break;
-case 'atom1.0':
-case 'atom0.3':
- print '</feed>';
- break;
-case 'opml1.0':
- print "</body>\n</opml>";
-}
+serendipity_plugin_api::hook_event($namespace_hook, $entries);
+$namespace_display_dat = $entries['display_dat'];
+unset($entries['display_dat']);
+
+serendipity_smarty_init();
+$serendipity['smarty']->assign(
+ array(
+ 'metadata' => $metadata,
+ 'entries' => $entries,
+ 'is_comments' => $comments,
+ 'last_modified' => $gm_modified,
+ 'self_url' => $self_url,
+ 'namespace_display_dat' => $namespace_display_dat,
+ 'once_display_dat' => $once_display_dat
+ )
+);
+$serendipity['smarty']->display($template_file);
/* vim: set sts=4 ts=4 expandtab : */
-?>
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+
+<rss version="0.91" {$namespace_display_dat}>
+<channel>
+<title>{$metadata.title}</title>
+<link>{$metadata.link}</link>
+<description>{$metadata.description}</description>
+<language>{$metadata.language}</language>
+{$metadata.additional_fields.image}
+
+{foreach from=$entries item="entry"}
+<item>
+ <title>{$entry.feed_title}</title>
+ <link>{$entry.feed_entryLink}</link>
+
+{if !empty($entry.body)}
+ <description>
+ {$entry.feed_body|@escape} {$entry.feed_ext|@escape}
+ </description>
+{/if}
+</item>
+{/foreach}
+
+</channel>
+</rss>
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+
+<rdf:RDF {$namespace_display_dat}
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:admin="http://webns.net/mvcb/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns="http://my.netscape.com/rdf/simple/0.9/">
+<channel>
+ <title>{$metadata.title}</title>
+ <link>{$metadata.link}</link>
+ <description>{$metadata.description}</description>
+ <dc:language>{$metadata.language}</dc:language>
+{if $metadata.showMail}
+ <admin:errorReportsTo rdf:resource="mailto:{$metadata.email}" />
+{/if}
+
+ {$metadata.additional_fields.image_rss10_channel}
+
+ <items>
+ <rdf:Seq>
+{foreach from=$entries item="entry"}
+ <rdf:li resource="{serendipity_rss_getguid entry=$entry is_comments=$is_comments}" />
+{/foreach}
+ </rdf:Seq>
+ </items>
+</channel>
+
+{$metadata.additional_fields.image_rss10_rdf}
+{$once_display_dat}
+
+{foreach from=$entries item="entry"}
+<item rdf:about="{$entry.feed_guid}">
+ <title>{$entry.feed_title}</title>
+ <link>{$entry.feed_entryLink}</link>
+{if !empty($entry.body)}
+ <description>
+ {$entry.feed_body|@escape} {$entry.feed_ext|@escape}
+ </description>
+{/if}
+
+ <dc:publisher>{$entry.feed_blogTitle}</dc:publisher>
+ <dc:creator>{$entry.feed_email} ({$entry.feed_author})</dc:creator>
+ <dc:subject>
+ {foreach from=$entry.categories item="cat"}{$cat.feed_category_name}, {/foreach}</dc:subject>
+ <dc:date>{$entry.feed_timestamp}</dc:date>
+ <wfw:comment>{$serendipityBaseURL}wfwcomment.php?cid={$entry.feed_id}</wfw:comment>
+{if !$is_comments}
+ <slash:comments>{$entry.comments}</slash:comments>
+ <wfw:commentRss>{$serendipityBaseURL}rss.php?version={$metadata.version}&type=comments&cid={$entry.feed_id}</wfw:commentRss>
+{/if}
+ {$entry.per_entry_display_dat}
+</item>
+{/foreach}
+
+</rdf:RDF>
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+
+<rss version="2.0"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:admin="http://webns.net/mvcb/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ {$namespace_display_dat}>
+<channel>
+ <title>{$metadata.title}</title>
+ <link>{$metadata.link}</link>
+ <description>{$metadata.description}</description>
+ <dc:language>{$metadata.language}</dc:language>
+{if $metadata.showMail}
+ <admin:errorReportsTo rdf:resource="mailto:{$metadata.email}" />
+{/if}
+ <generator>Serendipity {$serendipityVersion} - http://www.s9y.org/</generator>
+ {$metadata.additional_fields.channel}
+ {$metadata.additional_fields.image}
+
+{foreach from=$entries item="entry"}
+<item>
+ <title>{$entry.feed_title}</title>
+ <link>{$entry.feed_entryLink}</link>
+ {foreach from=$entry.categories item="cat"}
+ <category>{$cat.feed_category_name}</category>
+ {/foreach}
+
+ <comments>{$entry.feed_entryLink}#comments</comments>
+ <wfw:comment>{$serendipityBaseURL}wfwcomment.php?cid={$entry.feed_id}</wfw:comment>
+
+{if !$is_comments}
+ <slash:comments>{$entry.comments}</slash:comments>
+ <wfw:commentRss>{$serendipityBaseURL}rss.php?version={$metadata.version}&type=comments&cid={$entry.feed_id}</wfw:commentRss>
+{/if}
+
+ <author>{$entry.feed_email} ({$entry.feed_author})</author>
+{if !empty($entry.body)}
+ <content:encoded>
+ {$entry.feed_body|@escape} {$entry.feed_ext|@escape}
+ </content:encoded>
+{/if}
+
+ <pubDate>{$entry.feed_timestamp_r}</pubDate>
+ <guid isPermaLink="false">{$entry.feed_guid}</guid>
+ {$entry.per_entry_display_dat}
+</item>
+{/foreach}
+
+</channel>
+</rss>
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<?xml-stylesheet href="{serendipity_getFile file='atom.css'}" type="text/css" ?>
+
+<feed version="0.3" {$namespace_display_dat}
+ xmlns="http://purl.org/atom/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:admin="http://webns.net/mvcb/"
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/">
+ <link href="{$serendipityBaseURL}rss.php?version=atom0.3" rel="service.feed" title="{$metadata.title}" type="application/x.atom+xml" />
+ <link href="{$serendipityBaseURL}" rel="alternate" title="{$metadata.title}" type="text/html" />
+ <link href="{$serendipityBaseURL}rss.php?version=2.0" rel="alternate" title="{$metadata.title}" type="application/rss+xml" />
+ <title mode="escaped" type="text/html">{$metadata.title}</title>
+ <tagline mode="escaped" type="text/html">{$metadata.description}</tagline>
+ <id>{$metadata.link}</id>
+ <modified>{$last_modified}</modified>
+ <generator url="http://www.s9y.org/" version="{$serendipityVersion}">Serendipity {$serendipityVersion} - http://www.s9y.org/</generator>
+ <dc:language>{$metadata.language}</dc:language>
+{if $metadata.showMail}
+ <admin:errorReportsTo rdf:resource="mailto:{$metadata.email}" />
+{/if}
+ <info mode="xml" type="text/html">
+ <div xmlns="http://www.w3.org/1999/xhtml">You are viewing an ATOM formatted XML site feed. Usually this file is inteded to be viewed in an aggregator or syndication software. If you want to know more about ATOM, please visist <a href="http://atomenabled.org/">Atomenabled.org</a></div>
+ </info>
+
+{foreach from=$entries item="entry"}
+ <entry>
+ <link href="{$entry.feed_entryLink}" rel="alternate" title="{$entry.feed_title}" type="text/html" />
+ <author>
+ <name>{$entry.feed_author}</name>
+ <email>{$entry.feed_email}</email>
+ </author>
+
+ <issued>{$entry.feed_timestamp}</issued>
+ <created>{$entry.feed_timestamp}</created>
+ <modified>{$entry.feed_last_modified}</modified>
+ <wfw:comment>{$serendipityBaseURL}wfwcomment.php?cid={$entry.feed_id}</wfw:comment>
+{if !$is_comments}
+ <slash:comments>{$entry.comments}</slash:comments>
+ <wfw:commentRss>{$serendipityBaseURL}rss.php?version={$metadata.version}&type=comments&cid={$entry.feed_id}</wfw:commentRss>
+{/if}
+ <id>{$entry.feed_guid}</id>
+ <title mode="escaped" type="text/html">{$entry.feed_title}</title>
+{if !empty($entry.body)}
+ <content type="application/xhtml+xml" xml:base="{$serendipityBaseURL}">
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ {$entry.feed_body} {$entry.feed_ext}
+ </div>
+ </content>
+{/if}
+
+ {$entry.per_entry_display_dat}
+ </entry>
+{/foreach}
+</feed>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<?xml-stylesheet href="{serendipity_getFile file='atom.css'}" type="text/css" ?>
+
+<feed {$namespace_display_dat}
+ xmlns="http://www.w3.org/2005/Atom"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:admin="http://webns.net/mvcb/"
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/">
+ <link href="{$self_url}" rel="self" title="{$metadata.title}" type="application/x.atom+xml" />
+ <link href="{$serendipityBaseURL}" rel="alternate" title="{$metadata.title}" type="text/html" />
+ <link href="{$serendipityBaseURL}rss.php?version=2.0" rel="alternate" title="{$metadata.title}" type="application/rss+xml" />
+ <title type="html">{$metadata.title}</title>
+ <subtitle type="html">{$metadata.description}</subtitle>
+ {$metadata.additional_fields.image_atom10}
+ <id>{$metadata.link}</id>
+ <updated>{$last_modified}</updated>
+ <generator uri="http://www.s9y.org/" version="{$serendipityVersion}">Serendipity {$serendipityVersion} - http://www.s9y.org/</generator>
+ <dc:language>{$metadata.language}</dc:language>
+{if $metadata.showMail}
+ <admin:errorReportsTo rdf:resource="mailto:{$metadata.email}" />
+{/if}
+
+{foreach from=$entries item="entry"}
+ <entry>
+ <link href="{$entry.feed_entryLink}" rel="alternate" title="{$entry.feed_title}" />
+ <author>
+ <name>{$entry.feed_author}</name>
+ <email>{$entry.feed_email}</email>
+ </author>
+
+ <published>{$entry.feed_timestamp}</published>
+ <updated>{$entry.feed_last_modified}</updated>
+ <wfw:comment>{$serendipityBaseURL}wfwcomment.php?cid={$entry.feed_id}</wfw:comment>
+
+{if !$is_comments}
+ <slash:comments>{$entry.comments}</slash:comments>
+ <wfw:commentRss>{$serendipityBaseURL}rss.php?version={$metadata.version}&type=comments&cid={$entry.feed_id}</wfw:commentRss>
+{/if}
+
+ {foreach from=$entry.categories item="cat"}
+ <category scheme="{$cat.categoryURL}" label="{$cat.feed_category_name}" term="{$cat.feed_category_name}" />
+ {/foreach}
+
+ <id>{$entry.feed_guid}</id>
+ <title type="html">{$entry.feed_title}</title>
+{if !empty($entry.body)}
+ <content type="xhtml" xml:base="{$serendipityBaseURL}">
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ {$entry.feed_body} {$entry.feed_ext}
+ </div>
+ </content>
+{/if}
+ {$entry.per_entry_display_dat}
+ </entry>
+{/foreach}
+
+</feed>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+\r
+<opml version="{$metadata.version}" {$namespace_display_dat}>
+<head>
+ <title>{$metadata.title}</title>
+ <dateModified>{$last_modified}</dateModified>
+ <ownerName>Serendipity {$serendipityVersion} - http://www.s9y.org/</ownerName>
+</head>
+<body>
+\r
+{foreach from=$entries item="entry"}
+ <outline text="{$entry.feed_title}" type="url" htmlUrl="{$entry.feed_entryLink}" urlHTTP="{$entry.feed_entryLink}" />
+{/foreach}\r
+
+</body>\r
+</opml>
\ No newline at end of file