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.
This commit is contained in:
Evan Prodromou 2011-09-29 12:29:12 -04:00
parent 797e187acb
commit 32845a1051
10 changed files with 116 additions and 26 deletions

View File

@ -71,7 +71,11 @@ class EditpeopletagAction extends Action
} }
$id = $this->arg('id'); $id = $this->arg('id');
if (common_config('singleuser', 'enabled')) {
$tagger_arg = User::singleUserNickname();
} else {
$tagger_arg = $this->arg('tagger'); $tagger_arg = $this->arg('tagger');
}
$tag_arg = $this->arg('tag'); $tag_arg = $this->arg('tag');
$tagger = common_canonical_nickname($tagger_arg); $tagger = common_canonical_nickname($tagger_arg);

View File

@ -58,7 +58,12 @@ class PeopletaggedAction extends Action
parent::prepare($args); parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
if (common_config('singleuser', 'enabled')) {
$tagger_arg = User::singleUserNickname();
} else {
$tagger_arg = $this->arg('tagger'); $tagger_arg = $this->arg('tagger');
}
$tag_arg = $this->arg('tag'); $tag_arg = $this->arg('tag');
$tagger = common_canonical_nickname($tagger_arg); $tagger = common_canonical_nickname($tagger_arg);
$tag = common_canonical_tag($tag_arg); $tag = common_canonical_tag($tag_arg);

View File

@ -76,7 +76,12 @@ class PeopletagsbyuserAction extends Action
$this->args['public'] = $this->args['private'] = false; $this->args['public'] = $this->args['private'] = false;
} }
if (common_config('singleuser', 'enabled')) {
$nickname_arg = User::singleUserNickname();
} else {
$nickname_arg = $this->arg('nickname'); $nickname_arg = $this->arg('nickname');
}
$nickname = common_canonical_nickname($nickname_arg); $nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname // Permanent redirect on non-canonical nickname

View File

@ -58,7 +58,12 @@ class PeopletagsforuserAction extends Action
{ {
parent::prepare($args); parent::prepare($args);
if (common_config('singleuser', 'enabled')) {
$nickname_arg = User::singleUserNickname();
} else {
$nickname_arg = $this->arg('nickname'); $nickname_arg = $this->arg('nickname');
}
$nickname = common_canonical_nickname($nickname_arg); $nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname // Permanent redirect on non-canonical nickname

View File

@ -58,7 +58,12 @@ class PeopletagsubscribersAction extends Action
parent::prepare($args); parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
if (common_config('singleuser', 'enabled')) {
$tagger_arg = User::singleUserNickname();
} else {
$tagger_arg = $this->arg('tagger'); $tagger_arg = $this->arg('tagger');
}
$tag_arg = $this->arg('tag'); $tag_arg = $this->arg('tag');
$tagger = common_canonical_nickname($tagger_arg); $tagger = common_canonical_nickname($tagger_arg);
$tag = common_canonical_tag($tag_arg); $tag = common_canonical_tag($tag_arg);

View File

@ -60,7 +60,12 @@ class PeopletagsubscriptionsAction extends Action
{ {
parent::prepare($args); parent::prepare($args);
if (common_config('singleuser', 'enabled')) {
$nickname_arg = User::singleUserNickname();
} else {
$nickname_arg = $this->arg('nickname'); $nickname_arg = $this->arg('nickname');
}
$nickname = common_canonical_nickname($nickname_arg); $nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname // Permanent redirect on non-canonical nickname

View File

@ -44,7 +44,11 @@ class ShowprofiletagAction extends Action
{ {
parent::prepare($args); parent::prepare($args);
if (common_config('singleuser', 'enabled')) {
$tagger_arg = User::singleUserNickname();
} else {
$tagger_arg = $this->arg('tagger'); $tagger_arg = $this->arg('tagger');
}
$tag_arg = $this->arg('tag'); $tag_arg = $this->arg('tag');
$tagger = common_canonical_nickname($tagger_arg); $tagger = common_canonical_nickname($tagger_arg);
$tag = common_canonical_tag($tag_arg); $tag = common_canonical_tag($tag_arg);

View File

@ -328,10 +328,8 @@ class Action extends HTMLOutputter // lawsuit
} }
// This route isn't available in single-user mode. // This route isn't available in single-user mode.
// Not sure why, but it causes errors here. // Not sure why, but it causes errors here.
if (!common_config('singleuser', 'enabled')) {
$this->inlineScript('var _peopletagAC = "' . $this->inlineScript('var _peopletagAC = "' .
common_local_url('peopletagautocomplete') . '";'); common_local_url('peopletagautocomplete') . '";');
}
$this->showScriptMessages(); $this->showScriptMessages();
// Anti-framing code to avoid clickjacking attacks in older browsers. // Anti-framing code to avoid clickjacking attacks in older browsers.
// This will show a blank page if the page is being framed, which is // This will show a blank page if the page is being framed, which is

View File

@ -79,7 +79,13 @@ class PeopletagGroupNav extends Widget
// FIXME: we should probably pass this in // FIXME: we should probably pass this in
$action = $this->action->trimmed('action'); $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'); $tag = $this->action->trimmed('tag');
if ($nickname) { if ($nickname) {

View File

@ -817,6 +817,22 @@ class Router
array('action' => 'getfile'), array('action' => 'getfile'),
array('filename' => '[A-Za-z0-9._-]+')); 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" // In the "root"
if (common_config('singleuser', 'enabled')) { if (common_config('singleuser', 'enabled')) {
@ -880,6 +896,57 @@ class Router
$m->connect('', $m->connect('',
array('action' => 'showstream', array('action' => 'showstream',
'nickname' => $nickname)); '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 { } else {
$m->connect('', array('action' => 'public')); $m->connect('', array('action' => 'public'));
$m->connect('rss', array('action' => 'publicrss')); $m->connect('rss', array('action' => 'publicrss'));
@ -904,20 +971,6 @@ class Router
// people tags // 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', $m->connect(':nickname/peopletags',
array('action' => 'peopletagsbyuser', array('action' => 'peopletagsbyuser',
'nickname' => Nickname::DISPLAY_FMT)); 'nickname' => Nickname::DISPLAY_FMT));