]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Added RSS for personal tags
authorRobin Millette <millette@controlyourself.ca>
Mon, 18 May 2009 22:18:08 +0000 (18:18 -0400)
committerRobin Millette <millette@controlyourself.ca>
Mon, 18 May 2009 22:18:08 +0000 (18:18 -0400)
actions/showstream.php
actions/userrss.php
lib/router.php
lib/rssaction.php

index 1654f589c64ea4267a8a16e6f57e275a5bec17f9..678a3174c151800a482b35c41bfdb71f6245a691 100644 (file)
@@ -113,6 +113,15 @@ class ShowstreamAction extends ProfileAction
 
     function getFeeds()
     {
+        if (!empty($this->tag)) {
+            return array(new Feed(Feed::RSS1,
+                common_local_url('userrss',
+                    array('nickname' => $this->user->nickname,
+                        'tag' => $this->tag)),
+                sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
+                    $this->user->nickname, $this->tag)));
+        }
+
         return array(new Feed(Feed::RSS1,
                               common_local_url('userrss',
                                                array('nickname' => $this->user->nickname)),
index 5861d9ee3687bd7a4e79e6088ea30a059c690a2b..2280509b22942c372be42745684cfbbe9b292c4b 100644 (file)
@@ -25,14 +25,15 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
 
 class UserrssAction extends Rss10Action
 {
-
     var $user = null;
+    var $tag  = null;
 
     function prepare($args)
     {
         parent::prepare($args);
-        $nickname = $this->trimmed('nickname');
+        $nickname   = $this->trimmed('nickname');
         $this->user = User::staticGet('nickname', $nickname);
+        $this->tag  = $this->trimmed('tag');
 
         if (!$this->user) {
             $this->clientError(_('No such user.'));
@@ -42,6 +43,25 @@ class UserrssAction extends Rss10Action
         }
     }
 
+    function getTaggedNotices($tag = null, $limit=0)
+    {
+        $user = $this->user;
+
+        if (is_null($user)) {
+            return null;
+        }
+
+        $notice = $user->getTaggedNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit, 0, 0, null, $tag);
+
+        $notices = array();
+        while ($notice->fetch()) {
+            $notices[] = clone($notice);
+        }
+
+        return $notices;
+    }
+
+
     function getNotices($limit=0)
     {
 
index f07e5937342cdf09dc9f780ff8db2c359f74389b..70ee0f3fb05d6302b66994f863ccacde82ee096c 100644 (file)
@@ -426,6 +426,11 @@ class Router
                     array('size' => '(original|96|48|24)',
                           'nickname' => '[a-zA-Z0-9]{1,64}'));
 
+        $m->connect(':nickname/tag/:tag/rss',
+            array('action' => 'userrss'),
+            array('nickname' => '[a-zA-Z0-9]{1,64}'),
+            array('tag' => '[a-zA-Z0-9]+'));
+
         $m->connect(':nickname/tag/:tag',
                     array('action' => 'showstream'),
                     array('nickname' => '[a-zA-Z0-9]{1,64}'),
index ddba862dcf9b22113d74787215f3a15f094e6b5a..2f25ed7e47d14150094efaa57b5322d1c56b862b 100644 (file)
@@ -97,7 +97,11 @@ class Rss10Action extends Action
         // Parent handling, including cache check
         parent::handle($args);
         // Get the list of notices
-        $this->notices = $this->getNotices($this->limit);
+        if (empty($this->tag)) {
+            $this->notices = $this->getNotices($this->limit);
+        } else {
+            $this->notices = $this->getTaggedNotices($this->tag, $this->limit);
+        }
         $this->showRss();
     }