From 6c5f87998aed7b9157439110dc23f574a74d602f Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Mon, 8 Aug 2005 09:30:15 +0000 Subject: [PATCH] Atom 1.0 support --- docs/NEWS | 2 ++ include/functions.inc.php | 10 ++++--- include/functions_entries.inc.php | 41 ++++++++++++++++++++++++++++ include/functions_permalinks.inc.php | 2 +- include/plugin_internal.inc.php | 25 +++++++++++++++-- index.php | 2 +- rss.php | 39 +++++++++++++++++++++++++- 7 files changed, 112 insertions(+), 9 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 02f83f3..83a1708 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,8 @@ 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 diff --git a/include/functions.inc.php b/include/functions.inc.php index d926ff3..04a9142 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -551,13 +551,15 @@ function serendipity_discover_rss($name, $ext) { } /* 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; diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 40dd30e..789385d 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -817,6 +817,47 @@ function serendipity_printEntries_rss($entries, $version, $comments = false, $fu + + + + + + + + + + wfwcomment.php?cid= + + + + rss.php?version=&type=comments&cid= + $cat) { + $name = serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?> + + + + + <?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?> + +
+ +
+
+
+ diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index 9a3a9a7..4a969a3 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -192,7 +192,7 @@ function serendipity_initPermalinks() { */ @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; diff --git a/include/plugin_internal.inc.php b/include/plugin_internal.inc.php index 1c95550..971d367 100644 --- a/include/plugin_internal.inc.php +++ b/include/plugin_internal.inc.php @@ -546,6 +546,7 @@ class serendipity_syndication_plugin extends serendipity_plugin { 'show_2.0', 'show_2.0c', 'show_atom0.3', + 'show_atom1.0', 'show_opml1.0', 'show_feedburner', 'seperator', @@ -610,6 +611,13 @@ class serendipity_syndication_plugin extends serendipity_plugin { $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; @@ -758,8 +766,17 @@ class serendipity_syndication_plugin extends serendipity_plugin { if (serendipity_db_bool($this->get_config('show_atom0.3', true))) { ?>
- ATOM/XML - ATOM 0.3 feed + ATOM/XML + ATOM 0.3 feed +
+get_config('show_atom1.0', true))) { +?> +
+ ATOM/XML + ATOM 1.0 feed
IMAGE; + $additional_fields['image_atom1.0'] = <<$img +IMAGE; + $additional_fields['image_rss1.0_channel'] = ''; $additional_fields['image_rss1.0_rdf'] = << diff --git a/index.php b/index.php index 8225170..f317b45 100644 --- a/index.php +++ b/index.php @@ -236,7 +236,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range } 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]); } diff --git a/rss.php b/rss.php index 55d8f7a..3d05a54 100644 --- a/rss.php +++ b/rss.php @@ -10,7 +10,7 @@ $description = $serendipity['blogDescription']; $title = $serendipity['blogTitle']; $comments = FALSE; -if ( empty($version) ) { +if (empty($version)) { list($version) = serendipity_discover_rss($_GET['file'], $_GET['ext']); } @@ -263,6 +263,42 @@ case 'atom0.3': 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 = ""; + } else { + $head_mail = ''; + } + + print << + + + + {$metadata['title']} + {$metadata['description']} + {$metadata['additional_fields']['image_atom1.0']} + {$metadata['link']} + $modified + Serendipity {$serendipity['version']} - http://www.s9y.org/ + {$metadata['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'])); @@ -301,6 +337,7 @@ case '1.0': } print ''; break; +case 'atom1.0': case 'atom0.3': print ''; break; -- 2.39.5