From 0271859c2425daff6fbaeac74aee6d6a9fcdce16 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 18 May 2009 17:18:57 -0400 Subject: Added personal tag page: http://example.com/MY_NICK/tag/A_TAG --- lib/profileaction.php | 13 +++++++------ lib/router.php | 5 +++++ lib/tagcloudsection.php | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/profileaction.php b/lib/profileaction.php index 1f2e30994..a3437ff4d 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -49,16 +49,17 @@ require_once INSTALLDIR.'/lib/groupminilist.php'; class ProfileAction extends Action { - var $user = null; - var $page = null; + var $user = null; + var $page = null; var $profile = null; + var $tag = null; function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); - $nickname = common_canonical_nickname($nickname_arg); + $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname @@ -85,10 +86,9 @@ class ProfileAction extends Action return false; } + $this->tag = $this->trimmed('tag'); $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - common_set_returnto($this->selfUrl()); - return true; } @@ -244,4 +244,5 @@ class ProfileAction extends Action $this->elementEnd('div'); } -} \ No newline at end of file +} + diff --git a/lib/router.php b/lib/router.php index 635e1d77e..f07e59373 100644 --- a/lib/router.php +++ b/lib/router.php @@ -426,6 +426,11 @@ class Router array('size' => '(original|96|48|24)', 'nickname' => '[a-zA-Z0-9]{1,64}')); + $m->connect(':nickname/tag/:tag', + array('action' => 'showstream'), + array('nickname' => '[a-zA-Z0-9]{1,64}'), + array('tag' => '[a-zA-Z0-9]+')); + $m->connect(':nickname', array('action' => 'showstream'), array('nickname' => '[a-zA-Z0-9]{1,64}')); diff --git a/lib/tagcloudsection.php b/lib/tagcloudsection.php index ff2aca6d6..62f7d8961 100644 --- a/lib/tagcloudsection.php +++ b/lib/tagcloudsection.php @@ -114,7 +114,11 @@ class TagCloudSection extends Section function tagUrl($tag) { - return common_local_url('tag', array('tag' => $tag)); + if ('showstream' === $this->out->trimmed('action')) { + return common_local_url('showstream', array('nickname' => $this->out->profile->nickname, 'tag' => $tag)); + } else { + return common_local_url('tag', array('tag' => $tag)); + } } function divId() -- cgit v1.2.3-54-g00ecf From f5606b6aa3868d777c6c697cf1bbc5348cb2ccc3 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 18 May 2009 18:18:08 -0400 Subject: Added RSS for personal tags --- actions/showstream.php | 9 +++++++++ actions/userrss.php | 24 ++++++++++++++++++++++-- lib/router.php | 5 +++++ lib/rssaction.php | 6 +++++- 4 files changed, 41 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/actions/showstream.php b/actions/showstream.php index 1654f589c..678a3174c 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -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)), diff --git a/actions/userrss.php b/actions/userrss.php index 5861d9ee3..2280509b2 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -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) { diff --git a/lib/router.php b/lib/router.php index f07e59373..70ee0f3fb 100644 --- a/lib/router.php +++ b/lib/router.php @@ -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}'), diff --git a/lib/rssaction.php b/lib/rssaction.php index ddba862dc..2f25ed7e4 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -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(); } -- cgit v1.2.3-54-g00ecf From 9261e48ef039869fb3709d374b7e4346d8773a49 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 18 May 2009 19:23:18 -0400 Subject: Removed dead code. --- classes/File_redirection.php | 2 -- lib/noticelist.php | 4 ++-- lib/util.php | 5 ----- 3 files changed, 2 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/classes/File_redirection.php b/classes/File_redirection.php index a71d1c083..0eae68178 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -201,7 +201,6 @@ class File_redirection extends Memcached_DataObject if ($short_url) { $short_url = (string)$short_url; -if(1) { // store it $file = File::staticGet('url', $long_url); if (empty($file)) { @@ -221,7 +220,6 @@ if(1) { $file_redir->file_id = $file_id; $file_redir->insert(); } -} return $short_url; } return $long_url; diff --git a/lib/noticelist.php b/lib/noticelist.php index 55dd902b4..004905056 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -187,7 +187,7 @@ class NoticeListItem extends Widget function showNotice() { -if (0) +if(0) $this->out->elementStart('entry-title'); else @@ -236,7 +236,7 @@ else $clip .= '.png'; $top = '20px'; } -if (0) +if(0) $this->out->elementStart('div', 'entry-attachments'); else $this->out->elementStart('p', array('class' => 'entry-attachments', 'style' => "float: right; width: $width_att; background: url($clip) no-repeat; text-align: right; height: $height;")); diff --git a/lib/util.php b/lib/util.php index 25c0fb0a1..fbef8764a 100644 --- a/lib/util.php +++ b/lib/util.php @@ -496,11 +496,6 @@ function common_linkify($url) { } $attrs = array('href' => $longurl, 'rel' => 'external'); -if(0){ - if ($longurl !== $url) { - $attrs['title'] = $longurl; - } -} return XMLStringer::estring('a', $attrs, $display); } -- cgit v1.2.3-54-g00ecf