Added RSS for personal tags

This commit is contained in:
Robin Millette 2009-05-18 18:18:08 -04:00
parent 57860b4d8a
commit f5606b6aa3
4 changed files with 41 additions and 3 deletions

View File

@ -113,6 +113,15 @@ class ShowstreamAction extends ProfileAction
function getFeeds() 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, return array(new Feed(Feed::RSS1,
common_local_url('userrss', common_local_url('userrss',
array('nickname' => $this->user->nickname)), array('nickname' => $this->user->nickname)),

View File

@ -25,14 +25,15 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class UserrssAction extends Rss10Action class UserrssAction extends Rss10Action
{ {
var $user = null; var $user = null;
var $tag = null;
function prepare($args) function prepare($args)
{ {
parent::prepare($args); parent::prepare($args);
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
$this->tag = $this->trimmed('tag');
if (!$this->user) { if (!$this->user) {
$this->clientError(_('No such 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) function getNotices($limit=0)
{ {

View File

@ -426,6 +426,11 @@ class Router
array('size' => '(original|96|48|24)', array('size' => '(original|96|48|24)',
'nickname' => '[a-zA-Z0-9]{1,64}')); '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', $m->connect(':nickname/tag/:tag',
array('action' => 'showstream'), array('action' => 'showstream'),
array('nickname' => '[a-zA-Z0-9]{1,64}'), array('nickname' => '[a-zA-Z0-9]{1,64}'),

View File

@ -97,7 +97,11 @@ class Rss10Action extends Action
// Parent handling, including cache check // Parent handling, including cache check
parent::handle($args); parent::handle($args);
// Get the list of notices // 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(); $this->showRss();
} }