mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-09 06:11:01 +01:00
Move feed off home page to just /feed/
Summary: I haven't actually been using this as much as I thought, and am more interested in the full view than the per-project view. Let's try moving it off /home/ and then maybe adding some filtering options at some point. Test Plan: Looked at "all" and "my projects" in feed. Looked at home page. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1658
This commit is contained in:
parent
5f721004de
commit
1caa812172
3 changed files with 42 additions and 27 deletions
|
@ -32,7 +32,9 @@ class AphrontDefaultApplicationConfiguration
|
||||||
|
|
||||||
public function getURIMap() {
|
public function getURIMap() {
|
||||||
return $this->getResourceURIMapRules() + array(
|
return $this->getResourceURIMapRules() + array(
|
||||||
'/(?:(?P<filter>(?:feed|jump))/)?$' =>
|
'/(?:(?P<filter>jump)/)?$' =>
|
||||||
|
'PhabricatorDirectoryMainController',
|
||||||
|
'/(?:(?P<filter>feed)/)(?:(?P<subfilter>[^/]+)/)?$' =>
|
||||||
'PhabricatorDirectoryMainController',
|
'PhabricatorDirectoryMainController',
|
||||||
'/directory/' => array(
|
'/directory/' => array(
|
||||||
'(?P<id>\d+)/$'
|
'(?P<id>\d+)/$'
|
||||||
|
|
|
@ -20,9 +20,11 @@ class PhabricatorDirectoryMainController
|
||||||
extends PhabricatorDirectoryController {
|
extends PhabricatorDirectoryController {
|
||||||
|
|
||||||
private $filter;
|
private $filter;
|
||||||
|
private $subfilter;
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
public function willProcessRequest(array $data) {
|
||||||
$this->filter = idx($data, 'filter');
|
$this->filter = idx($data, 'filter');
|
||||||
|
$this->subfilter = idx($data, 'subfilter');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldRequireAdmin() {
|
public function shouldRequireAdmin() {
|
||||||
|
@ -73,8 +75,6 @@ class PhabricatorDirectoryMainController
|
||||||
}
|
}
|
||||||
$jump_panel = $this->buildJumpPanel();
|
$jump_panel = $this->buildJumpPanel();
|
||||||
$revision_panel = $this->buildRevisionPanel();
|
$revision_panel = $this->buildRevisionPanel();
|
||||||
$feed_view = $this->buildFeedView($projects, $is_full = false);
|
|
||||||
|
|
||||||
|
|
||||||
$content = array(
|
$content = array(
|
||||||
$unbreak_panel,
|
$unbreak_panel,
|
||||||
|
@ -82,7 +82,6 @@ class PhabricatorDirectoryMainController
|
||||||
$jump_panel,
|
$jump_panel,
|
||||||
$revision_panel,
|
$revision_panel,
|
||||||
$tasks_panel,
|
$tasks_panel,
|
||||||
$feed_view,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$nav->appendChild($content);
|
$nav->appendChild($content);
|
||||||
|
@ -187,8 +186,29 @@ class PhabricatorDirectoryMainController
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildFeedResponse($nav, $projects) {
|
private function buildFeedResponse($nav, $projects) {
|
||||||
$view = $this->buildFeedView($projects, $is_full = true);
|
|
||||||
$nav->appendChild($view);
|
$subnav = new AphrontSideNavFilterView();
|
||||||
|
$subnav->setBaseURI(new PhutilURI('/feed/'));
|
||||||
|
|
||||||
|
$subnav->addFilter('all', 'All Activity', '/feed/');
|
||||||
|
$subnav->addFilter('projects', 'My Projects');
|
||||||
|
|
||||||
|
$filter = $subnav->selectFilter($this->subfilter, 'all');
|
||||||
|
|
||||||
|
switch ($filter) {
|
||||||
|
case 'all':
|
||||||
|
$phids = array();
|
||||||
|
break;
|
||||||
|
case 'projects':
|
||||||
|
$phids = mpull($projects, 'getPHID');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$view = $this->buildFeedView($phids);
|
||||||
|
$subnav->appendChild($view);
|
||||||
|
|
||||||
|
$nav->appendChild($subnav);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$nav,
|
$nav,
|
||||||
array(
|
array(
|
||||||
|
@ -390,16 +410,15 @@ class PhabricatorDirectoryMainController
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildFeedView(array $projects, $is_full) {
|
private function buildFeedView(array $phids) {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
$user_phid = $user->getPHID();
|
$user_phid = $user->getPHID();
|
||||||
|
|
||||||
$feed_query = new PhabricatorFeedQuery();
|
$feed_query = new PhabricatorFeedQuery();
|
||||||
$feed_query->setFilterPHIDs(
|
if ($phids) {
|
||||||
array_merge(
|
$feed_query->setFilterPHIDs($phids);
|
||||||
array($user_phid),
|
}
|
||||||
mpull($projects, 'getPHID')));
|
|
||||||
|
|
||||||
// TODO: All this limit stuff should probably be consolidated into the
|
// TODO: All this limit stuff should probably be consolidated into the
|
||||||
// feed query?
|
// feed query?
|
||||||
|
@ -407,13 +426,9 @@ class PhabricatorDirectoryMainController
|
||||||
$old_link = null;
|
$old_link = null;
|
||||||
$new_link = null;
|
$new_link = null;
|
||||||
|
|
||||||
if ($is_full) {
|
$feed_query->setAfter($request->getStr('after'));
|
||||||
$feed_query->setAfter($request->getStr('after'));
|
$feed_query->setBefore($request->getStr('before'));
|
||||||
$feed_query->setBefore($request->getStr('before'));
|
$limit = 500;
|
||||||
$limit = 500;
|
|
||||||
} else {
|
|
||||||
$limit = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab one more story than we intend to display so we can figure out
|
// Grab one more story than we intend to display so we can figure out
|
||||||
// if we need to render an "Older Posts" link or not (with reasonable
|
// if we need to render an "Older Posts" link or not (with reasonable
|
||||||
|
@ -422,12 +437,8 @@ class PhabricatorDirectoryMainController
|
||||||
$feed = $feed_query->execute();
|
$feed = $feed_query->execute();
|
||||||
$extra_row = (count($feed) == $limit + 1);
|
$extra_row = (count($feed) == $limit + 1);
|
||||||
|
|
||||||
if ($is_full) {
|
$have_new = ($request->getStr('before')) ||
|
||||||
$have_new = ($request->getStr('before')) ||
|
($request->getStr('after') && $extra_row);
|
||||||
($request->getStr('after') && $extra_row);
|
|
||||||
} else {
|
|
||||||
$have_new = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$have_old = ($request->getStr('after')) ||
|
$have_old = ($request->getStr('after')) ||
|
||||||
($request->getStr('before') && $extra_row) ||
|
($request->getStr('before') && $extra_row) ||
|
||||||
|
@ -440,7 +451,7 @@ class PhabricatorDirectoryMainController
|
||||||
$old_link = phutil_render_tag(
|
$old_link = phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => '/feed/?before='.end($feed)->getChronologicalKey(),
|
'href' => '?before='.end($feed)->getChronologicalKey(),
|
||||||
'class' => 'phabricator-feed-older-link',
|
'class' => 'phabricator-feed-older-link',
|
||||||
),
|
),
|
||||||
"Older Stories \xC2\xBB");
|
"Older Stories \xC2\xBB");
|
||||||
|
@ -449,7 +460,7 @@ class PhabricatorDirectoryMainController
|
||||||
$new_link = phutil_render_tag(
|
$new_link = phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => '/feed/?after='.reset($feed)->getChronologicalKey(),
|
'href' => '?after='.reset($feed)->getChronologicalKey(),
|
||||||
'class' => 'phabricator-feed-newer-link',
|
'class' => 'phabricator-feed-newer-link',
|
||||||
),
|
),
|
||||||
"\xC2\xAB Newer Stories");
|
"\xC2\xAB Newer Stories");
|
||||||
|
@ -494,7 +505,7 @@ class PhabricatorDirectoryMainController
|
||||||
array(
|
array(
|
||||||
'href' => $doc_href,
|
'href' => $doc_href,
|
||||||
),
|
),
|
||||||
'Jump Nav Use Guide');
|
'Jump Nav User Guide');
|
||||||
|
|
||||||
$jump_input = phutil_render_tag(
|
$jump_input = phutil_render_tag(
|
||||||
'input',
|
'input',
|
||||||
|
|
|
@ -26,8 +26,10 @@ phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||||
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
|
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
|
||||||
phutil_require_module('phabricator', 'view/layout/minipanel');
|
phutil_require_module('phabricator', 'view/layout/minipanel');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'parser/uri');
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue