]> git.mjollnir.org Git - s9y.git/commitdiff
Patch by stm: Support trackback and trackback+comment Feeds
authorgarvinhicking <garvinhicking>
Tue, 25 Jul 2006 09:42:28 +0000 (09:42 +0000)
committergarvinhicking <garvinhicking>
Tue, 25 Jul 2006 09:42:28 +0000 (09:42 +0000)
16 files changed:
docs/NEWS
include/functions.inc.php
include/functions_comments.inc.php
include/functions_rss.inc.php
index.php
plugins/serendipity_plugin_comments/serendipity_plugin_comments.php
rss.php
templates/default-php/trackbacks.tpl
templates/default/feed_0.91.tpl
templates/default/feed_1.0.tpl
templates/default/feed_2.0.tpl
templates/default/feed_atom0.3.tpl
templates/default/feed_atom1.0.tpl
templates/default/feed_opml1.0.tpl
templates/default/trackbacks.tpl
templates/kubrick/trackbacks.tpl

index 8a056ec5cf3b37015830b1e052e5ce085f1538f8..795a6a660fb20c7fd0da1507cab9b2299dc3be4b 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,8 @@
 Version 1.1-alpha7()
 ------------------------------------------------------------------------
 
+    * Add "Comments and Trackbacks" feed feature (stm99..)
+
     * Add LiveJournal XML importer (garvinhicking)
 
     * Fix not fetching allow_comments/moderate_comments value when
index 4e23b5126d7e75dfca4f231eaddd463616963e75..cc57e2333262ba4e310b5df9b66d2fcae360ebe8 100644 (file)
@@ -927,8 +927,12 @@ function serendipity_discover_rss($name, $ext) {
     static $default = '2.0';
 
     /* Detect type */
-    if ( $name == 'comments' ) {
+    if ($name == 'comments') {
         $type = 'comments';
+    } elseif ($name == 'comments_and_trackbacks') {
+        $type = 'comments_and_trackbacks';
+    } elseif ($name == 'trackbacks') {
+        $type = 'trackbacks';
     } else {
         $type = 'content';
     }
index 86ee43a28813822f4e32fcfed0ed687aa1a3c570..fd4bcc0f23e26d6b269f30050294762a577e6143 100644 (file)
@@ -114,9 +114,10 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data
  * @param   int     How many comments to fetch (empty: all)
  * @param   string  How shall comments be ordered (ASC|DESC)
  * @param   boolean Shall non-approved comments be displayed?
+ * @param   string  Comment type to fetch
  * @return  array   The SQL result of comments
  */
-function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = false) {
+function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = false, $type = 'NORMAL') {
     global $serendipity;
     $and = '';
 
@@ -125,6 +126,14 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f
     } else {
         $limit = '';
     }
+    
+    if ($type == 'comments') {
+        $type = 'NORMAL';
+    } elseif ($type == 'trackbacks') {
+        $type = 'TRACKBACK';
+    } elseif ($type == 'comments_and_trackbacks') {
+        $type = '%';
+    }
 
     if (!empty($id)) {
         $and .= " AND co.entry_id = '" . (int)$id ."'";
@@ -154,7 +163,7 @@ function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = f
               FROM
                     {$serendipity['dbPrefix']}comments co
                     LEFT JOIN {$serendipity['dbPrefix']}entries e ON (co.entry_id = e.id)
-              WHERE co.type LIKE 'NORMAL' AND co.entry_id > 0 $and
+              WHERE co.type LIKE '" . $type . "' AND co.entry_id > 0 $and
               $group
               ORDER BY
                     co.id " . ($order != '' ? $order : '') . "
index e9a8f3c207e728ed6deb111fdba2c33bb05cbc35..b397b5231ccebba32b0d620420e7fea1605352a1 100644 (file)
@@ -41,6 +41,9 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
             $entry['feed_entryLink'] = serendipity_archiveURL($entry['feed_id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
             if ($options['comments'] == true) {
                 // Display username as part of the title for easier feed-readability
+                if ($entry['type'] == 'TRACKBACK' && !empty($entry['ctitle'])) {
+                    $entry['author'] .= ' - ' . $entry['ctitle'];
+                }
                 $entry['title'] = (!empty($entry['author']) ? $entry['author'] : ANONYMOUS) . ': ' . $entry['title'];
             }
 
index 85ea8afeec363317f2d31b89abb6281eb77b39a6..0c0835c1c2715e42435dabf9b894a63d33d93b1f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -278,7 +278,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     $serendipity['view'] = 'feed';
     header('Content-Type: text/html; charset=utf-8');
 
-    if (preg_match('@/(index|atom[0-9]*|rss|comments|opml)\.(rss[0-9]?|rdf|rss|xml|atom)@', $uri, $vmatches)) {
+    if (preg_match('@/(index|atom[0-9]*|rss|comments|trackbacks|comments_and_trackbacks|opml)\.(rss[0-9]?|rdf|rss|xml|atom)@', $uri, $vmatches)) {
         list($_GET['version'], $_GET['type']) = serendipity_discover_rss($vmatches[1], $vmatches[2]);
     }
 
index 3123a6e1aff2641ee54671b8d5d27aa6a04c9255..aa74cc134ca9359859f0efecf21eec39a0e78c69 100644 (file)
@@ -22,7 +22,7 @@ class serendipity_plugin_comments extends serendipity_plugin
         $propbag->add('description',   PLUGIN_COMMENTS_BLAHBLAH);
         $propbag->add('stackable',     true);
         $propbag->add('author',        'Garvin Hicking/Tadashi Jokagi/Judebert');
-        $propbag->add('version',       '1.8');
+        $propbag->add('version',       '1.9');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -191,9 +191,10 @@ class serendipity_plugin_comments extends serendipity_plugin
                                'email'   => $row['comment_email']);
                                
                 // Let's help the BBCOde plugin a bit:
-                #$entry['comment'] = preg_replace('@((\[.*)[\n\r]+(.*\]))+@imsU', '\2\3', $entry['comment']);
-                #$entry['comment'] = preg_replace('@((\[.+\].*)[\r\n]+(.*\[/.+\]))+@imsU', '\2\3', $entry['comment']);
-
+                if (class_exists('serendipity_event_bbcode')) {
+                    $entry['comment'] = preg_replace('@((\[.*)[\n\r]+(.*\]))+@imsU', '\2\3', $entry['comment']);
+                    $entry['comment'] = preg_replace('@((\[.+\].*)[\r\n]+(.*\[/.+\]))+@imsU', '\2\3', $entry['comment']);
+                }
                 serendipity_plugin_api::hook_event('frontend_display', $entry);
 
                 printf(
diff --git a/rss.php b/rss.php
index 1bb96a9cfdd65ce4fedb06f67bb8627db6b03971..842f9a719164011379a8c4b048d805f0ceac8105 100644 (file)
--- a/rss.php
+++ b/rss.php
@@ -29,8 +29,10 @@ if (!isset($_GET['type'])) {
 }
 
 switch ($_GET['type']) {
+    case 'comments_and_trackbacks':
+    case 'trackbacks':
     case 'comments':
-        $latest_entry = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, 1, 'desc');
+        $latest_entry = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, 1, 'desc', false, $_GET['type']);
         break;
     case 'content':
     default:
@@ -76,8 +78,10 @@ if (isset($modified_since) &&
 }
 
 switch ($_GET['type']) {
+case 'comments_and_trackbacks':
+case 'trackbacks':
 case 'comments':
-    $entries     = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, $serendipity['RSSfetchLimit'], 'desc');
+    $entries     = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, $serendipity['RSSfetchLimit'], 'desc', $_GET['type']);
     $description = $title . ' - ' . $description;
     if (isset($_GET['cid'])) {
         $title       = $title . ' - ' . COMMENTS_FROM . ' "' . $latest_entry[0]['title'] . '"';
index 4fdbd9e3029280729b2c5fc2af8ed64ec8046ff3..428dda0a32d53f6786cfba3443901edbaf643720 100644 (file)
@@ -1,5 +1,6 @@
 {foreach from=$trackbacks item=trackback}
     <div class="serendipity_comment">
+        <a id="c{$trackback.id}"></a>
         <div class="serendipity_commentBody">
             <a href="{$trackback.url|@strip_tags}" {'blank'|@xhtml_target}><?= $trackback['title'] ?></a><br />
             {$trackback.body|@strip_tags|@escape:all}
index 2fb0d6ef4085ae999a294ade4fe6d71d3febe994..6419204451770b229f04353a8b5cc1ff1dbcb10a 100644 (file)
@@ -11,7 +11,7 @@
 {foreach from=$entries item="entry"}
 <item>
     <title>{$entry.feed_title}</title>
-    <link>{$entry.feed_entryLink}</link>
+    <link>{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}</link>
 
 {if !empty($entry.body)}
     <description>
index dc5e70b51a7a24c11ca65343d5a9a7fe21d2cf2b..09267a93da7e8817e4c4b5999a08c6c4bfbe0495 100644 (file)
@@ -34,7 +34,7 @@
 {foreach from=$entries item="entry"}
 <item rdf:about="{$entry.feed_guid}">
     <title>{$entry.feed_title}</title>
-    <link>{$entry.feed_entryLink}</link>
+    <link>{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}</link>
 {if !empty($entry.body)}
     <description>
     {$entry.feed_body|@escape} {$entry.feed_ext|@escape}
index 6631b875137aea28dc0e68bad7bd0ad113702b66..a0af1bc19248820c2079be38843f776d6df5f2d7 100644 (file)
@@ -23,7 +23,7 @@
 {foreach from=$entries item="entry"}
 <item>
     <title>{$entry.feed_title}</title>
-    <link>{$entry.feed_entryLink}</link>
+    <link>{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}</link>
     {foreach from=$entry.categories item="cat"}
         <category>{$cat.feed_category_name}</category>
     {/foreach}
index 9c873b5b0c1751deb09aa46bc8c08de5f8d78051..e602d969398c58f589c6e406852b9d6ea3f7c4fe 100644 (file)
@@ -26,7 +26,7 @@
 
 {foreach from=$entries item="entry"}
     <entry>
-        <link href="{$entry.feed_entryLink}" rel="alternate" title="{$entry.feed_title}" type="text/html" />
+        <link href="{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}" rel="alternate" title="{$entry.feed_title}" type="text/html" />
         <author>
             <name>{$entry.feed_author}</name>
             <email>{$entry.feed_email}</email>
index 5106bb8c87193a72bd5ec16af4797fd735fc483f..a917ab3c68a6e814e4e337d22a5e740d8e489631 100644 (file)
@@ -24,7 +24,7 @@
 
 {foreach from=$entries item="entry"}
     <entry>
-        <link href="{$entry.feed_entryLink}" rel="alternate" title="{$entry.feed_title}" />
+        <link href="{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}" rel="alternate" title="{$entry.feed_title}" />
         <author>
             <name>{$entry.feed_author}</name>
             <email>{$entry.feed_email}</email>
index 3d3b2d4cdae632d390421489bed3e34eeaa6481d..ad877ee7685d72221f4f42c74b4a94be7494b82e 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" ?>
-\r
+
 <opml version="{$metadata.version}" {$namespace_display_dat}>
 <head>
     <title>{$metadata.title}</title>
@@ -7,10 +7,10 @@
     <ownerName>Serendipity {$serendipityVersion} - http://www.s9y.org/</ownerName>
 </head>
 <body>
-\r
+
 {foreach from=$entries item="entry"}
-    <outline text="{$entry.feed_title}" type="url" htmlUrl="{$entry.feed_entryLink}" urlHTTP="{$entry.feed_entryLink}" />
-{/foreach}\r
+    <outline text="{$entry.feed_title}" type="url" htmlUrl="{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}" urlHTTP="{$entry.feed_entryLink}{if $is_comments}#c{$entry.commentid}{/if}" />
+{/foreach}
 
-</body>\r
+</body>
 </opml>
\ No newline at end of file
index e8a9cae662b2bc58ceb400864667a31c5c1eb02c..e8b969d3ac323eeebe9b487b7c0cc3e366238965 100644 (file)
@@ -1,5 +1,6 @@
 {foreach from=$trackbacks item=trackback}
     <div class="serendipity_comment">
+        <a id="c{$trackback.id}"></a>
         <div class="serendipity_commentBody">
             <a href="{$trackback.url|@strip_tags}" {'blank'|@xhtml_target}>{$trackback.title}</a><br />
             {$trackback.body|@strip_tags|@escape:all}
index 1585111d46a4a2c9420532fe7dc7eac1af4259e8..85d006c6b7069a7b31c8448f48a58ebb7935803a 100644 (file)
@@ -1,5 +1,6 @@
 {foreach from=$trackbacks item=trackback name="trackbacks"}
     <li class="{if $smarty.foreach.comments.iteration is odd}graybox{/if}">
+        <a id="c{$trackback.id}"></a>
         <cite><a href="{$trackback.url|@strip_tags}" {'blank'|@xhtml_target}>{$trackback.title}</a></cite>
         <p>{$trackback.body|@strip_tags|@escape:all}</p>
         <div class="commentmetadata">