Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7389
Modified Files:
Tag: branch-0-5
NEWS rss.php serendipity_functions.inc.php
serendipity_sidebar_items.php
Log Message:
MFH
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.54.2.1
retrieving revision 1.54.2.2
diff -u -d -r1.54.2.1 -r1.54.2.2
--- NEWS 3 Feb 2004 10:34:09 -0000 1.54.2.1
+++ NEWS 3 Feb 2004 16:33:33 -0000 1.54.2.2
@@ -1,7 +1,8 @@
# $Id$
-Version 0.5 (January 31, 2004)
+Version 0.5 ()
------------------------------------
+ * RSS 1.0 feed supported (garvinhicking)
* Redirection after a comment has been added to prevent users refreshing a page and double-submitting. (garvinhicking)
* Fixed RSS feed to only show comments when they are associated with an entry_id (garvinhicking)
* Fixed page counter to count pages depending on the entries per page, and not hardcoded 15 entries (garvinhicking)
Index: rss.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/rss.php,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- rss.php 29 Jan 2004 12:08:28 -0000 1.18
+++ rss.php 3 Feb 2004 16:33:33 -0000 1.18.2.1
@@ -72,9 +72,44 @@
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";
+ }
+ }
+ print <<<HEAD
+<rdf:RDF
+ 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/">
+<channel rdf:about="{$serendipity['baseURL']}rss.php?version=1.0">
+ <title>$title</title>
+ <link>{$serendipity['baseURL']}</link>
+ <description>$description</description>
+ <dc:language>{$serendipity['lang']}</dc:language>
+ <admin:errorReportsTo rdf:resource="mailto:{$serendipity['CONFIG']['email']}" />
+
+ {$additional_fields['image_rss1.0_channel']}
+
+ <items>
+ <rdf:Seq>{$rdf_seq_li}</rdf:Seq>
+ </items>
+</channel>
+
+{$additional_fields['image_rss1.0_rdf']}
+
+HEAD;
+break;
+
case '2.0':
print <<<HEAD
-<rss version="2.0/XSS-extensible"
+<rss version="2.0"
xmlns="http://purl.org/rss/2.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:admin="http://webns.net/mvcb/"
@@ -98,7 +133,12 @@
$modified = date('Y-m-d\TH:i:s\Z', $entries[0]['timestamp']);
print <<<HEAD
<feed version="0.3"
- xmlns="http://purl.org/atom/ns#">
+ 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="$title" type="application/x.atom+xml" />
<link href="{$serendipity['baseURL']}" rel="alternate" title="$title" type="text/html" />
<link href="{$serendipity['baseURL']}rss.php?version=2.0" rel="alternate" title="$title" type="application/rss+xml" />
@@ -107,6 +147,8 @@
<id>{$serendipity['baseURL']}</id>
<modified>$modified</modified>
<generator name="Serendipity" url="http://www.s9y.org/" version="{$serendipity['version']}">Serendipity {$serendipity['version']} - http://www.s9y.org/</generator>
+ <dc:language>{$serendipity['lang']}</dc:language>
+ <admin:errorReportsTo rdf:resource="mailto:{$serendipity['CONFIG']['email']}" />
<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>
@@ -125,8 +167,11 @@
print "</channel>\n";
print "</rss>\n";
break;
+case '1.0':
+ print '</rdf:RDF>';
+ break;
case 'atom0.3':
- print "</feed>";
+ print '</feed>';
}
/* vim: set sts=4 ts=4 expandtab : */
?>
\ No newline at end of file
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.193
retrieving revision 1.193.2.1
diff -u -d -r1.193 -r1.193.2.1
--- serendipity_functions.inc.php 30 Jan 2004 12:53:29 -0000 1.193
+++ serendipity_functions.inc.php 3 Feb 2004 16:33:33 -0000 1.193.2.1
@@ -1205,18 +1205,27 @@
}
+function serendipity_rss_getguid($entry, $comments = false) {
+ $guid = serendipity_archiveURL((isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']), $entry['title']);
+ if ($comments == true) {
+ $guid .= '#c' . $entry['commentid'];
+ }
+
+ return $guid;
+}
+
function serendipity_printEntries_rss($entries, $version, $comments = false) {
global $serendipity;
- if (($version == '0.91' || $version == '2.0' || $version == 'atom0.3') && is_array($entries)) {
+ if (is_array($entries)) {
foreach ($entries as $entry) {
- $guid = serendipity_archiveURL((isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']), $entry['title']);
+ $guid = serendipity_rss_getguid($entry, $comments);
+
if ($comments == true) {
// Display username as part of the title for easier feed-readability
$entry['title'] = $entry['username'] . ': ' . $entry['title'];
- $guid .= '#c' . $entry['commentid'];
}
-
+
// Embed a link to extended entry, if existing
if ($entry['exflag']) {
$ext = '<br /><a href="' . $guid . '#extended">' . VIEW_EXTENDED_ENTRY . '</a>';
@@ -1248,6 +1257,15 @@
<created><?php echo date('Y-m-d\TH:i:s\Z', $entry['timestamp']); ?></created>
<modified><?php echo date('Y-m-d\TH:i:s\Z', $entry['timestamp']); ?></modified>
+<?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 (isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']); ?></wfw:commentRss>
+<?php
+ }
+?>
+
<id><?php echo $guid; ?></id>
<title mode="escaped" type="text/html"><?php echo utf8_encode(htmlspecialchars($entry['title'])); ?></title>
<content type="application/xhtml+xml" xml:base="<?php echo $serendipity['baseURL']; ?>" xml:space="preserve">
@@ -1257,7 +1275,7 @@
</content>
</entry>
<?php
- } else {
+ } elseif ($version == '0.92' || $version == '2.0') {
/*********** BEGIN RSS 0.91/2.0 FEED *************/
?>
<item>
@@ -1298,9 +1316,30 @@
<?php
/*********** END RSS 0.91 FEED EXTRAS *************/
}
+ } else if ($version == '1.0') {
+?>
+<item rdf:about="<?php echo $guid; ?>">
+ <title><?php echo utf8_encode(htmlspecialchars($entry['title'])); ?></title>
+ <link><?php echo $guid; ?></link>
+ <description>
+ <?php echo utf8_encode(htmlspecialchars(nl2br(serendipity_emoticate(serendipity_markup_text($entry['body'] . $ext))))); ?>
+ </description>
+ <dc:publisher><?php echo utf8_encode(htmlspecialchars($serendipity['blogTitle'])); ?></dc:publisher>
+ <dc:creator><?php echo utf8_encode(htmlspecialchars($entry['email'])) . ' (' . utf8_encode(htmlspecialchars($entry['username'])) . ')'; ?></dc:creator>
+ <dc:subject><?php echo utf8_encode(htmlspecialchars($entry['category_name'])); ?></dc:subject>
+ <dc:date><?php echo date('Y-m-d\TH:i:s\Z', $entry['timestamp']); ?></dc:date>
+<?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 (isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']); ?></wfw:commentRss>
+<?php
+ }
+?>
+</item>
+<?php
}
}
- } else if ($version == '1.0') {
}
}
Index: serendipity_sidebar_items.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_sidebar_items.php,v
retrieving revision 1.37
retrieving revision 1.37.2.1
diff -u -d -r1.37 -r1.37.2.1
--- serendipity_sidebar_items.php 29 Jan 2004 12:08:28 -0000 1.37
+++ serendipity_sidebar_items.php 3 Feb 2004 16:33:33 -0000 1.37.2.1
@@ -132,6 +132,7 @@
'show_0.91',
'show_2.0',
'show_2.0c',
+ 'show_1.0',
'show_atom0.3',
'seperator',
'field_managingEditor',
@@ -155,6 +156,12 @@
$propbag->add('description', '');
break;
+ case 'show_1.0':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', SYNDICATION_PLUGIN_10);
+ $propbag->add('description', '');
+ break;
+
case 'show_2.0':
$propbag->add('type', 'boolean');
$propbag->add('name', SYNDICATION_PLUGIN_20);
@@ -247,6 +254,14 @@
<?php
}
+ if ($this->get_config('show_1.0') != 'false') {
+?>
+ <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=1.0"><img src="<?php echo $serendipity['serendipityHTTPPath']; ?>xml.gif" border="0" alt="XML" /></a>
+ <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=1.0">RSS 1.0 feed</a>
+ <br />
+<?php
+ }
+
if ($this->get_config('show_atom0.3') != 'false') {
?>
<a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=atom0.3"><img src="<?php echo $serendipity['serendipityHTTPPath']; ?>xml.gif" border="0" alt="ATOM/XML" /></a>
@@ -277,7 +292,18 @@
$img = $this->get_config('bannerURL');
$w = $this->get_config('bannerWidth');
$h = $this->get_config('bannerHeight');
- $additional_fields['image'] = <<<IMAGE
+ } elseif (file_exists($serendipity['serendipityPath'] . 'pixel/rss_banner.png')) {
+ $i = getimagesize($serendipity['serendipityPath'] . 'pixel/rss_banner.png');
+ $img = $serendipity['baseURL'] . 'pixel/rss_banner.png';
+ $w = $i[0];
+ $h = $i[1];
+ } else {
+ $img = $serendipity['baseURL'] . 'pixel/s9y_banner_tiny.png';
+ $w = 100;
+ $h = 21;
+ }
+
+ $additional_fields['image'] = <<<IMAGE
<image>
<url>$img</url>
<title>RSS: $title - $description</title>
@@ -286,28 +312,17 @@
<height>$h</height>
</image>
IMAGE;
- } elseif (file_exists($serendipity['serendipityPath'] . 'pixel/rss_banner.png')) {
- $i = getimagesize($serendipity['serendipityPath'] . 'pixel/rss_banner.png');
- $additional_fields['image'] = <<<IMAGE
-<image>
- <url>{$serendipity['baseURL']}pixel/rss_banner.png</url>
- <title>RSS: $title - $description</title>
- <link>{$serendipity['baseURL']}</link>
- <width>{$i[0]}</width>
- <height>{$i[1]}</height>
- </image>
-IMAGE;
- } else {
- $additional_fields['image'] = <<<IMAGE
-<image>
- <url>{$serendipity['baseURL']}pixel/s9y_banner_tiny.png</url>
+
+ $additional_fields['image_rss1.0_channel'] = '<image rdf:resource="' . $img . '" />';
+ $additional_fields['image_rss1.0_rdf'] = <<<IMAGE
+<image rdf:about="$img">
+ <url>$img</url>
<title>RSS: $title - $description</title>
<link>{$serendipity['baseURL']}</link>
- <width>100</width>
- <height>21</height>
+ <width>$w</width>
+ <height>$h</height>
</image>
IMAGE;
- }
// Now, if set, stitch together any fields that have been configured in the syndication plugin.
// First, do some sanity checks
|