]> git.wh0rd.org - tt-rss.git/commitdiff
syndicated feeds: add orig_guid to optionally alter item id to workaround duplicate...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 6 Jul 2013 20:59:23 +0000 (00:59 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 6 Jul 2013 20:59:23 +0000 (00:59 +0400)
classes/handler/public.php
templates/generated_feed.txt

index 205853eae6765211d8e03e6c1ac7e11eef453e6a..1be322006ca1d0d58cf02f4739022aeae7aac7e4 100644 (file)
@@ -3,7 +3,7 @@ class Handler_Public extends Handler {
 
        private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
                $limit, $offset, $search, $search_mode,
-               $view_mode = false, $format = 'atom', $order = false) {
+               $view_mode = false, $format = 'atom', $order = false, $orig_guid = false) {
 
                require_once "lib/MiniTemplator.class.php";
 
@@ -88,7 +88,10 @@ class Handler_Public extends Handler {
 
                        while ($line = $this->dbh->fetch_assoc($result)) {
 
-                               $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
+                               $tpl->setVariable('ARTICLE_ID',
+                                       htmlspecialchars($orig_guid ? $line['link'] :
+                                               get_self_url_prefix() .
+                                                       "/public.php?url=" . urlencode($line['link'])), true);
                                $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
                                $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
                                $tpl->setVariable('ARTICLE_EXCERPT',
@@ -110,7 +113,8 @@ class Handler_Public extends Handler {
                                        date(DATE_RFC822, strtotime($line["updated"])), true);
 
                                $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
-                               
+
+                               $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url']), true);
                                $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title']), true);
 
                                $tags = get_article_tags($line["id"], $owner_uid);
@@ -344,7 +348,7 @@ class Handler_Public extends Handler {
        function rss() {
                $feed = $this->dbh->escape_string($_REQUEST["id"]);
                $key = $this->dbh->escape_string($_REQUEST["key"]);
-               $is_cat = $_REQUEST["is_cat"] != false;
+               $is_cat = $_REQUEST["is_cat"] != "false";
                $limit = (int)$this->dbh->escape_string($_REQUEST["limit"]);
                $offset = (int)$this->dbh->escape_string($_REQUEST["offset"]);
 
@@ -354,6 +358,7 @@ class Handler_Public extends Handler {
                $order = $this->dbh->escape_string($_REQUEST["order"]);
 
                $format = $this->dbh->escape_string($_REQUEST['format']);
+               $orig_guid = $_REQUEST["orig_guid"] != "false";
 
                if (!$format) $format = 'atom';
 
@@ -373,7 +378,7 @@ class Handler_Public extends Handler {
 
                if ($owner_id) {
                        $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
-                               $offset, $search, $search_mode, $view_mode, $format, $order);
+                               $offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid);
                } else {
                        header('HTTP/1.1 403 Forbidden');
                }
index 6a673e86677393caa9a0d3c23eee6d8e6ca0d03f..c1f921c45ad78117ef40c8b5b8e1d517e006e2a0 100644 (file)
@@ -20,7 +20,9 @@
        <content type="html"><![CDATA[${ARTICLE_CONTENT}]]></content>
        <updated>${ARTICLE_UPDATED_ATOM}</updated>
        <author><name>${ARTICLE_AUTHOR}</name></author>
-       <source><title>${ARTICLE_SOURCE_TITLE}</title></source>
+       <source>
+               <link rel="self" href="${ARTICLE_SOURCE_LINK}"/>
+               <title>${ARTICLE_SOURCE_TITLE}</title></source>
 <!-- $BeginBlock category -->
        <category term="${ARTICLE_CATEGORY}"/>
 <!-- $EndBlock category -->