Version 0.9 ()
------------------------------------------------------------------------
+ * Atom 1.0 feed support (garvinhicking)
+
* Make template directory allow to contain subdirectories with more
templates. This allows you to symbolically link the "additional_themes"
CVS directory within your templates path, just like you can do
}
/* Detect version */
- if ( $name == 'atom' || $ext == 'atom' ) {
+ if ($name == 'atom' || $name == 'atom10' || $ext == 'atom') {
+ $ver = 'atom1.0';
+ } elseif ($name == 'atom03') {
$ver = 'atom0.3';
- } elseif ( $name == 'opml' || $ext == 'opml' ) {
+ } elseif ($name == 'opml' || $ext == 'opml') {
$ver = 'opml1.0';
- } elseif ( $ext == 'rss' ) {
+ } elseif ($ext == 'rss') {
$ver = '0.91';
- } elseif ( $ext == 'rss1' ) {
+ } elseif ($ext == 'rss1') {
$ver = '1.0';
} else {
$ver = $default;
</content>
</entry>
<?php
+ } elseif ($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 ($comments === false) {
+?>
+ <slash:comments><?php echo $entry['comments']; ?></slash:comments>
+ <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $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>
+ <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>
+</entry>
+<?php
+
} elseif ($version == '0.91' || $version == '2.0') {
/*********** BEGIN RSS 0.91/2.0 FEED *************/
?>
*/
@define('PAT_FILENAME', '0-9a-z\.\_!;,\+\-');
@define('PAT_CSS', '@/(serendipity\.css|serendipity_admin\.css)@');
- @define('PAT_FEED', '@/(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$@');
+ @define('PAT_FEED', '@/(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)@');
@define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i');
return true;
'show_2.0',
'show_2.0c',
'show_atom0.3',
+ 'show_atom1.0',
'show_opml1.0',
'show_feedburner',
'seperator',
$propbag->add('type', 'boolean');
$propbag->add('name', SYNDICATION_PLUGIN_ATOM03);
$propbag->add('description', '');
+ $propbag->add('default', 'false');
+ break;
+
+ case 'show_atom0.3':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', SYNDICATION_PLUGIN_ATOM10);
+ $propbag->add('description', '');
$propbag->add('default', 'true');
break;
if (serendipity_db_bool($this->get_config('show_atom0.3', true))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom.xml', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" alt="ATOM/XML" style="border: 0px" /></a>
- <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom.xml', 'serendipityHTTPPath') ?>">ATOM 0.3 feed</a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom03.xml', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" alt="ATOM/XML" style="border: 0px" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom03.xml', 'serendipityHTTPPath') ?>">ATOM 0.3 feed</a>
+ </div>
+<?php
+ }
+
+ if (serendipity_db_bool($this->get_config('show_atom1.0', true))) {
+?>
+ <div style="padding-bottom: 2px;">
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom10.xml', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" alt="ATOM/XML" style="border: 0px" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom10.xml', 'serendipityHTTPPath') ?>">ATOM 1.0 feed</a>
</div>
<?php
}
</image>
IMAGE;
+ $additional_fields['image_atom1.0'] = <<<IMAGE
+<icon>$img</icon>
+IMAGE;
+
$additional_fields['image_rss1.0_channel'] = '<image rdf:resource="' . $img . '" />';
$additional_fields['image_rss1.0_rdf'] = <<<IMAGE
<image rdf:about="$img">
} elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) {
header('Content-Type: text/html; charset=utf-8');
- if (preg_match('@/(index|atom|rss|comments|opml)\.(rss[0-9]?|rdf|rss|xml|atom)$@', $uri, $vmatches)) {
+ if (preg_match('@/(index|atom[0-9]*|rss|comments|opml)\.(rss[0-9]?|rdf|rss|xml|atom)@', $uri, $vmatches)) {
list($_GET['version'], $_GET['type']) = serendipity_discover_rss($vmatches[1], $vmatches[2]);
}
$title = $serendipity['blogTitle'];
$comments = FALSE;
-if ( empty($version) ) {
+if (empty($version)) {
list($version) = serendipity_discover_rss($_GET['file'], $_GET['ext']);
}
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());
+ }
+
+ if ($showMail) {
+ $head_mail = "<admin:errorReportsTo rdf:resource=\"mailto:{$metadata['email']}\" />";
+ } else {
+ $head_mail = '';
+ }
+
+ 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="{$serendipity['baseURL']}rss.php?version=atom1.0" 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']));
}
print '</rdf:RDF>';
break;
+case 'atom1.0':
case 'atom0.3':
print '</feed>';
break;