]> git.mjollnir.org Git - s9y.git/commitdiff
Fix some Atom parsing issues, and fix GUID when using permalinks without %id%.
authorgarvinhicking <garvinhicking>
Tue, 23 Aug 2005 11:34:02 +0000 (11:34 +0000)
committergarvinhicking <garvinhicking>
Tue, 23 Aug 2005 11:34:02 +0000 (11:34 +0000)
Thanks to Riscky!

include/functions.inc.php
rss.php

index 9ae649b1a23317c9dccef6d1e34ff34a1ace6a33..36e5038a0e975a831cd80ce090d273b6908b158a 100644 (file)
@@ -282,7 +282,26 @@ function serendipity_utf8_encode($string) {
 }
 
 function serendipity_rss_getguid($entry, $comments = false) {
-    $guid = serendipity_archiveURL((isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']), 'guid', 'baseURL', true, array('timestamp' => $entry['timestamp']));
+    global $serendipity;
+
+    $id = (isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']);
+
+    // When using %id%, we can make the GUID shorter and independent from the title.
+    // If not using %id%, the entryid needs to be used for uniqueness.
+    if (stristr($serendipity['permalinkStructure'], '%id%') !== FALSE) {
+        $title = 'guid';
+    } else {
+        $title = $id;
+    }
+
+    $guid = serendipity_archiveURL(
+        $id, 
+        $title, 
+        'baseURL', 
+        true, 
+        array('timestamp' => $entry['timestamp'])
+    );
+
     if ($comments == true) {
         $guid .= '#c' . $entry['commentid'];
     }
diff --git a/rss.php b/rss.php
index 3d05a547d67239ee53fddad7abbff135f0bbe27e..0a685c5b9c92df278e804e4cdedae085afc120b6 100644 (file)
--- a/rss.php
+++ b/rss.php
@@ -121,6 +121,7 @@ if (is_array($plugins)) {
 
 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')) {
@@ -284,7 +285,7 @@ case 'atom1.0':
    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="{$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>