From 32845a1051356b56053a768ca3e9df68d7d5523a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 29 Sep 2011 12:29:12 -0400 Subject: [PATCH] Make lists work in single-user mode Added routes to the router for list pages in single-user mode. For each of the actions in those routes, use the global single-user nickname rather than a nickname URL argument to determine the tagger ID. In nav, and for Ajax, provide the right nicknames. --- actions/editpeopletag.php | 6 ++- actions/peopletagged.php | 7 ++- actions/peopletagsbyuser.php | 7 ++- actions/peopletagsforuser.php | 7 ++- actions/peopletagsubscribers.php | 7 ++- actions/peopletagsubscriptions.php | 7 ++- actions/showprofiletag.php | 6 ++- lib/action.php | 6 +-- lib/peopletaggroupnav.php | 8 ++- lib/router.php | 81 ++++++++++++++++++++++++------ 10 files changed, 116 insertions(+), 26 deletions(-) diff --git a/actions/editpeopletag.php b/actions/editpeopletag.php index b2dedc890f..546d9910ba 100644 --- a/actions/editpeopletag.php +++ b/actions/editpeopletag.php @@ -71,7 +71,11 @@ class EditpeopletagAction extends Action } $id = $this->arg('id'); - $tagger_arg = $this->arg('tagger'); + if (common_config('singleuser', 'enabled')) { + $tagger_arg = User::singleUserNickname(); + } else { + $tagger_arg = $this->arg('tagger'); + } $tag_arg = $this->arg('tag'); $tagger = common_canonical_nickname($tagger_arg); diff --git a/actions/peopletagged.php b/actions/peopletagged.php index 424bf2dcbe..6f9748c234 100644 --- a/actions/peopletagged.php +++ b/actions/peopletagged.php @@ -58,7 +58,12 @@ class PeopletaggedAction extends Action parent::prepare($args); $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $tagger_arg = $this->arg('tagger'); + if (common_config('singleuser', 'enabled')) { + $tagger_arg = User::singleUserNickname(); + } else { + $tagger_arg = $this->arg('tagger'); + } + $tag_arg = $this->arg('tag'); $tagger = common_canonical_nickname($tagger_arg); $tag = common_canonical_tag($tag_arg); diff --git a/actions/peopletagsbyuser.php b/actions/peopletagsbyuser.php index dc3e50b9f2..8ef1a56ee1 100644 --- a/actions/peopletagsbyuser.php +++ b/actions/peopletagsbyuser.php @@ -76,7 +76,12 @@ class PeopletagsbyuserAction extends Action $this->args['public'] = $this->args['private'] = false; } - $nickname_arg = $this->arg('nickname'); + if (common_config('singleuser', 'enabled')) { + $nickname_arg = User::singleUserNickname(); + } else { + $nickname_arg = $this->arg('nickname'); + } + $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname diff --git a/actions/peopletagsforuser.php b/actions/peopletagsforuser.php index 321dbe19a1..d30f7321c1 100644 --- a/actions/peopletagsforuser.php +++ b/actions/peopletagsforuser.php @@ -58,7 +58,12 @@ class PeopletagsforuserAction extends Action { parent::prepare($args); - $nickname_arg = $this->arg('nickname'); + if (common_config('singleuser', 'enabled')) { + $nickname_arg = User::singleUserNickname(); + } else { + $nickname_arg = $this->arg('nickname'); + } + $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname diff --git a/actions/peopletagsubscribers.php b/actions/peopletagsubscribers.php index e371799efb..1834a7e4ad 100644 --- a/actions/peopletagsubscribers.php +++ b/actions/peopletagsubscribers.php @@ -58,7 +58,12 @@ class PeopletagsubscribersAction extends Action parent::prepare($args); $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $tagger_arg = $this->arg('tagger'); + if (common_config('singleuser', 'enabled')) { + $tagger_arg = User::singleUserNickname(); + } else { + $tagger_arg = $this->arg('tagger'); + } + $tag_arg = $this->arg('tag'); $tagger = common_canonical_nickname($tagger_arg); $tag = common_canonical_tag($tag_arg); diff --git a/actions/peopletagsubscriptions.php b/actions/peopletagsubscriptions.php index d857fb2356..c497842969 100644 --- a/actions/peopletagsubscriptions.php +++ b/actions/peopletagsubscriptions.php @@ -60,7 +60,12 @@ class PeopletagsubscriptionsAction extends Action { parent::prepare($args); - $nickname_arg = $this->arg('nickname'); + if (common_config('singleuser', 'enabled')) { + $nickname_arg = User::singleUserNickname(); + } else { + $nickname_arg = $this->arg('nickname'); + } + $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname diff --git a/actions/showprofiletag.php b/actions/showprofiletag.php index 278246c894..ec1837f835 100644 --- a/actions/showprofiletag.php +++ b/actions/showprofiletag.php @@ -44,7 +44,11 @@ class ShowprofiletagAction extends Action { parent::prepare($args); - $tagger_arg = $this->arg('tagger'); + if (common_config('singleuser', 'enabled')) { + $tagger_arg = User::singleUserNickname(); + } else { + $tagger_arg = $this->arg('tagger'); + } $tag_arg = $this->arg('tag'); $tagger = common_canonical_nickname($tagger_arg); $tag = common_canonical_tag($tag_arg); diff --git a/lib/action.php b/lib/action.php index 18ffb5e920..d85ee25fb6 100644 --- a/lib/action.php +++ b/lib/action.php @@ -328,10 +328,8 @@ class Action extends HTMLOutputter // lawsuit } // This route isn't available in single-user mode. // Not sure why, but it causes errors here. - if (!common_config('singleuser', 'enabled')) { - $this->inlineScript('var _peopletagAC = "' . - common_local_url('peopletagautocomplete') . '";'); - } + $this->inlineScript('var _peopletagAC = "' . + common_local_url('peopletagautocomplete') . '";'); $this->showScriptMessages(); // Anti-framing code to avoid clickjacking attacks in older browsers. // This will show a blank page if the page is being framed, which is diff --git a/lib/peopletaggroupnav.php b/lib/peopletaggroupnav.php index 3cfcb3cff3..70f7f5a425 100644 --- a/lib/peopletaggroupnav.php +++ b/lib/peopletaggroupnav.php @@ -79,7 +79,13 @@ class PeopletagGroupNav extends Widget // FIXME: we should probably pass this in $action = $this->action->trimmed('action'); - $nickname = $this->action->trimmed('tagger'); + + if (common_config('singleuser', 'enabled')) { + $nickname = User::singleUserNickname(); + } else { + $nickname = $this->action->arg('tagger'); + } + $tag = $this->action->trimmed('tag'); if ($nickname) { diff --git a/lib/router.php b/lib/router.php index c9b12ac8e7..09121c561c 100644 --- a/lib/router.php +++ b/lib/router.php @@ -817,6 +817,22 @@ class Router array('action' => 'getfile'), array('filename' => '[A-Za-z0-9._-]+')); + // Common people-tag stuff + + $m->connect('peopletag/:tag', array('action' => 'peopletag', + 'tag' => self::REGEX_TAG)); + + $m->connect('selftag/:tag', array('action' => 'selftag', + 'tag' => self::REGEX_TAG)); + + $m->connect('main/addpeopletag', array('action' => 'addpeopletag')); + + $m->connect('main/removepeopletag', array('action' => 'removepeopletag')); + + $m->connect('main/profilecompletion', array('action' => 'profilecompletion')); + + $m->connect('main/peopletagautocomplete', array('action' => 'peopletagautocomplete')); + // In the "root" if (common_config('singleuser', 'enabled')) { @@ -880,6 +896,57 @@ class Router $m->connect('', array('action' => 'showstream', 'nickname' => $nickname)); + + // peopletags + + $m->connect('peopletags', + array('action' => 'peopletagsbyuser')); + + $m->connect('peopletags/private', + array('action' => 'peopletagsbyuser', + 'private' => 1)); + + $m->connect('peopletags/public', + array('action' => 'peopletagsbyuser', + 'public' => 1)); + + $m->connect('othertags', + array('action' => 'peopletagsforuser')); + + $m->connect('peopletagsubscriptions', + array('action' => 'peopletagsubscriptions')); + + $m->connect('all/:tag/subscribers', + array('action' => 'peopletagsubscribers', + 'tag' => self::REGEX_TAG)); + + $m->connect('all/:tag/tagged', + array('action' => 'peopletagged', + 'tag' => self::REGEX_TAG)); + + $m->connect('all/:tag/edit', + array('action' => 'editpeopletag', + 'tag' => self::REGEX_TAG)); + + foreach(array('subscribe', 'unsubscribe') as $v) { + $m->connect('peopletag/:id/'.$v, + array('action' => $v.'peopletag', + 'id' => '[0-9]{1,64}')); + } + $m->connect('user/:tagger_id/profiletag/:id/id', + array('action' => 'profiletagbyid', + 'tagger_id' => '[0-9]+', + 'id' => '[0-9]+')); + + $m->connect('all/:tag', + array('action' => 'showprofiletag', + 'tag' => self::REGEX_TAG)); + + foreach (array('subscriptions', 'subscribers') as $a) { + $m->connect($a.'/:tag', + array('action' => $a), + array('tag' => self::REGEX_TAG)); + } } else { $m->connect('', array('action' => 'public')); $m->connect('rss', array('action' => 'publicrss')); @@ -904,20 +971,6 @@ class Router // people tags - $m->connect('peopletag/:tag', array('action' => 'peopletag', - 'tag' => self::REGEX_TAG)); - - $m->connect('selftag/:tag', array('action' => 'selftag', - 'tag' => self::REGEX_TAG)); - - $m->connect('main/addpeopletag', array('action' => 'addpeopletag')); - - $m->connect('main/removepeopletag', array('action' => 'removepeopletag')); - - $m->connect('main/profilecompletion', array('action' => 'profilecompletion')); - - $m->connect('main/peopletagautocomplete', array('action' => 'peopletagautocomplete')); - $m->connect(':nickname/peopletags', array('action' => 'peopletagsbyuser', 'nickname' => Nickname::DISPLAY_FMT));