1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 20:40:56 +01:00

Support /differential/filter/<filter>/<username>/

Summary: NOTE: I didn't add BC for ?phid=.

Test Plan:
/differential/
/differential/filter/active/
/differential/filter/active/epriestley/
/differential/filter/active/x/ - 404
/differential/filter/revisions/?status=open - search for epriestley
/differential/filter/revisions/epriestley/?status=open
/p/jakubv/

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, epriestley

Maniphest Tasks: T900

Differential Revision: https://secure.phabricator.com/D1797
This commit is contained in:
vrana 2012-03-06 13:57:31 -08:00
parent f0396b2f06
commit ad58491c6c
4 changed files with 37 additions and 15 deletions

View file

@ -100,7 +100,8 @@ class AphrontDefaultApplicationConfiguration
'/D(?P<id>\d+)' => 'DifferentialRevisionViewController',
'/differential/' => array(
'' => 'DifferentialRevisionListController',
'filter/(?P<filter>\w+)/' => 'DifferentialRevisionListController',
'filter/(?P<filter>\w+)/(?:(?P<username>\w+)/)?' =>
'DifferentialRevisionListController',
'stats/(?P<filter>\w+)/' => 'DifferentialRevisionStatsController',
'diff/' => array(
'(?P<id>\d+)/' => 'DifferentialDiffViewController',

View file

@ -19,6 +19,7 @@
class DifferentialRevisionListController extends DifferentialController {
private $filter;
private $username;
public function shouldRequireLogin() {
return !$this->allowsAnonymousAccess();
@ -26,6 +27,7 @@ class DifferentialRevisionListController extends DifferentialController {
public function willProcessRequest(array $data) {
$this->filter = idx($data, 'filter');
$this->username = idx($data, 'username');
}
public function processRequest() {
@ -33,18 +35,8 @@ class DifferentialRevisionListController extends DifferentialController {
$user = $request->getUser();
$viewer_is_anonymous = !$user->isLoggedIn();
$phid_arr = $request->getArr('view_user');
if ($phid_arr) {
$view_target = head($phid_arr);
return id(new AphrontRedirectResponse())
->setURI($request->getRequestURI()
->alter('phid', $view_target)
->setQueryParam('view_user', null));
}
$params = array_filter(
array(
'phid' => $request->getStr('phid'),
'status' => $request->getStr('status'),
'order' => $request->getStr('order'),
));
@ -56,9 +48,35 @@ class DifferentialRevisionListController extends DifferentialController {
$this->filter,
$default_filter);
// Redirect from search to canonical URL.
$phid_arr = $request->getArr('view_user');
if ($phid_arr) {
$view_user = id(new PhabricatorUser())
->loadOneWhere('phid = %s', head($phid_arr));
if (!$view_user) {
return new Aphront404Response();
}
$uri = id(new PhutilURI('/differential/filter/'.$this->filter.'/'.
phutil_escape_uri($view_user->getUserName()).'/'))
->setQueryParams($params);
return id(new AphrontRedirectResponse())->setURI($uri);
}
$uri = new PhutilURI('/differential/filter/'.$this->filter.'/');
$uri->setQueryParams($params);
$username = '';
if ($this->username) {
$view_user = id(new PhabricatorUser())
->loadOneWhere('userName = %s', $this->username);
if (!$view_user) {
return new Aphront404Response();
}
$username = phutil_escape_uri($this->username).'/';
$uri->setPath('/differential/filter/'.$this->filter.'/'.$username);
$params['phid'] = $view_user->getPHID();
}
// Fill in the defaults we'll actually use for calculations if any
// parameters are missing.
$params += array(
@ -72,7 +90,7 @@ class DifferentialRevisionListController extends DifferentialController {
list($filter_name, $display_name) = $filter;
if ($filter_name) {
$href = clone $uri;
$href->setPath('/differential/filter/'.$filter_name.'/');
$href->setPath('/differential/filter/'.$filter_name.'/'.$username);
if ($filter_name == $this->filter) {
$class = 'aphront-side-nav-selected';
} else {

View file

@ -6,10 +6,12 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/query/revision');
phutil_require_module('phabricator', 'applications/differential/view/revisionlist');
phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/form/base');

View file

@ -45,9 +45,10 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
if (!$profile) {
$profile = new PhabricatorUserProfile();
}
$username = phutil_escape_uri($user->getUserName());
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/p/'.$user->getUserName().'/'));
$nav->setBaseURI(new PhutilURI('/p/'.$username.'/'));
$nav->addFilter('feed', 'Feed');
$nav->addFilter('about', 'About');
@ -58,7 +59,7 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
$nav->addFilter(
null,
"Revisions {$external_arrow}",
'/differential/filter/revisions/?phid='.$user->getPHID());
'/differential/filter/revisions/'.$username.'/');
$nav->addFilter(
null,
@ -68,7 +69,7 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
$nav->addFilter(
null,
"Commits {$external_arrow}",
'/audit/view/author/'.phutil_escape_uri($user->getUserName()).'/');
'/audit/view/author/'.$username.'/');
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
'userID = %d',