Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14413632
D14146.id34185.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D14146.id34185.diff
View Options
diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php
--- a/src/applications/phame/application/PhabricatorPhameApplication.php
+++ b/src/applications/phame/application/PhabricatorPhameApplication.php
@@ -42,6 +42,7 @@
'live/(?P<id>[^/]+)/(?P<more>.*)' => 'PhameBlogLiveController',
'post/' => array(
'(?:(?P<filter>draft|all)/)?' => 'PhamePostListController',
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhamePostListController',
'blogger/(?P<bloggername>[\w\.-_]+)/' => 'PhamePostListController',
'delete/(?P<id>[^/]+)/' => 'PhamePostDeleteController',
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
@@ -56,6 +57,7 @@
),
'blog/' => array(
'(?:(?P<filter>user|all)/)?' => 'PhameBlogListController',
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhameBlogListController',
'delete/(?P<id>[^/]+)/' => 'PhameBlogDeleteController',
'edit/(?P<id>[^/]+)/' => 'PhameBlogEditController',
'view/(?P<id>[^/]+)/' => 'PhameBlogViewController',
diff --git a/src/applications/phame/controller/blog/PhameBlogListController.php b/src/applications/phame/controller/blog/PhameBlogListController.php
--- a/src/applications/phame/controller/blog/PhameBlogListController.php
+++ b/src/applications/phame/controller/blog/PhameBlogListController.php
@@ -2,86 +2,33 @@
final class PhameBlogListController extends PhameController {
- public function handleRequest(AphrontRequest $request) {
- $user = $request->getUser();
-
- $nav = $this->renderSideNavFilterView(null);
- $filter = $request->getURIData('filter');
- $filter = $nav->selectFilter('blog/'.$filter, 'blog/user');
-
- $query = id(new PhameBlogQuery())
- ->setViewer($user);
-
- switch ($filter) {
- case 'blog/all':
- $title = pht('All Blogs');
- $nodata = pht('No blogs have been created.');
- break;
- case 'blog/user':
- $title = pht('Joinable Blogs');
- $nodata = pht('There are no blogs you can contribute to.');
- $query->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_JOIN,
- ));
- break;
- default:
- throw new Exception(pht("Unknown filter '%s'!", $filter));
- }
-
- $pager = id(new PHUIPagerView())
- ->setURI($request->getRequestURI(), 'offset')
- ->setOffset($request->getInt('offset'));
-
- $blogs = $query->executeWithOffsetPager($pager);
-
- $blog_list = $this->renderBlogList($blogs, $user, $nodata);
- $blog_list->setPager($pager);
-
- $box = id(new PHUIObjectBoxView())
- ->setHeaderText($title)
- ->setObjectList($blog_list);
-
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $this->getApplicationURI());
+ public function shouldAllowPublic() {
+ return true;
+ }
- $nav->appendChild(
- array(
- $crumbs,
- $box,
- ));
+ public function handleRequest(AphrontRequest $request) {
+ $query_key = $request->getURIData('queryKey');
+ $controller = id(new PhabricatorApplicationSearchController())
+ ->setQueryKey($query_key)
+ ->setSearchEngine(new PhameBlogSearchEngine())
+ ->setNavigation($this->buildSideNavView());
- return $this->buildApplicationPage(
- $nav,
- array(
- 'title' => $title,
- ));
+ return $this->delegateToController($controller);
}
- private function renderBlogList(
- array $blogs,
- PhabricatorUser $viewer,
- $nodata) {
+ public function buildSideNavView() {
+ $viewer = $this->getRequest()->getUser();
- $view = new PHUIObjectItemListView();
- $view->setNoDataString($nodata);
- $view->setUser($viewer);
- foreach ($blogs as $blog) {
+ $nav = new AphrontSideNavFilterView();
+ $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
- $id = $blog->getID();
- $item = id(new PHUIObjectItemView())
- ->setUser($viewer)
- ->setObject($blog)
- ->setHeader($blog->getName())
- ->setStatusIcon('fa-star')
- ->setHref($this->getApplicationURI("/blog/view/{$id}/"))
- ->addAttribute($blog->getSkin())
- ->addAttribute($blog->getDomain());
+ id(new PhameBlogSearchEngine())
+ ->setViewer($viewer)
+ ->addNavigationItems($nav->getMenu());
- $view->addItem($item);
- }
+ $nav->selectFilter(null);
- return $view;
+ return $nav;
}
}
diff --git a/src/applications/phame/controller/post/PhamePostListController.php b/src/applications/phame/controller/post/PhamePostListController.php
--- a/src/applications/phame/controller/post/PhamePostListController.php
+++ b/src/applications/phame/controller/post/PhamePostListController.php
@@ -2,78 +2,37 @@
final class PhamePostListController extends PhameController {
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getViewer();
- $filter = $request->getURIData('filter');
- $bloggername = $request->getURIData('bloggername');
-
- $query = id(new PhamePostQuery())
- ->setViewer($viewer);
-
- $nav = $this->renderSideNavFilterView();
- $nodata = null;
+ public function shouldAllowPublic() {
+ return true;
+ }
- switch ($filter) {
- case 'draft':
- $query->withBloggerPHIDs(array($viewer->getPHID()));
- $query->withVisibility(PhamePost::VISIBILITY_DRAFT);
- $nodata = pht('You have no unpublished drafts.');
- $title = pht('Unpublished Drafts');
- $nav->selectFilter('post/draft');
- break;
- case 'blogger':
- if ($bloggername) {
- $blogger = id(new PhabricatorUser())->loadOneWhere(
- 'username = %s',
- $bloggername);
- if (!$blogger) {
- return new Aphront404Response();
- }
- } else {
- $blogger = $viewer;
- }
+ public function handleRequest(AphrontRequest $request) {
+ $query_key = $request->getURIData('queryKey');
+ $controller = id(new PhabricatorApplicationSearchController())
+ ->setQueryKey($query_key)
+ ->setSearchEngine(new PhamePostSearchEngine())
+ ->setNavigation($this->buildSideNavView());
- $query->withBloggerPHIDs(array($blogger->getPHID()));
- if ($blogger->getPHID() == $viewer->getPHID()) {
- $nav->selectFilter('post');
- $nodata = pht('You have not written any posts.');
- } else {
- $nodata = pht('%s has not written any posts.', $blogger);
- }
- $title = pht('Posts by %s', $blogger);
- break;
- default:
- case 'all':
- $nodata = pht('There are no visible posts.');
- $title = pht('Posts');
- $nav->selectFilter('post/all');
- break;
- }
+ return $this->delegateToController($controller);
+ }
- $pager = id(new AphrontCursorPagerView())
- ->readFromRequest($request);
+ public function buildSideNavView() {
+ $viewer = $this->getRequest()->getUser();
- $posts = $query->executeWithCursorPager($pager);
+ $nav = new AphrontSideNavFilterView();
+ $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
- $post_list = $this->renderPostList($posts, $viewer, $nodata);
- $post_list = id(new PHUIObjectBoxView())
- ->setHeaderText($title)
- ->appendChild($post_list);
+ id(new PhamePostSearchEngine())
+ ->setViewer($viewer)
+ ->addNavigationItems($nav->getMenu());
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $this->getApplicationURI());
+ $nav->addLabel(pht('Blogs'));
+ $nav->addFilter('blog/', pht('Manage Blogs'));
- $nav->appendChild(
- array(
- $crumbs,
- $post_list,
- ));
+ $nav->selectFilter(null);
- return $this->buildApplicationPage(
- $nav,
- array(
- 'title' => $title,
- ));
+ return $nav;
}
+
}
diff --git a/src/applications/phame/query/PhamePostSearchEngine.php b/src/applications/phame/query/PhamePostSearchEngine.php
--- a/src/applications/phame/query/PhamePostSearchEngine.php
+++ b/src/applications/phame/query/PhamePostSearchEngine.php
@@ -29,6 +29,7 @@
return array(
id(new PhabricatorSearchSelectField())
->setKey('visibility')
+ ->setLabel(pht('Visibility'))
->setOptions(array(
'' => pht('All'),
PhamePost::VISIBILITY_PUBLISHED => pht('Live'),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 2:30 PM (3 h, 35 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6926701
Default Alt Text
D14146.id34185.diff (8 KB)
Attached To
Mode
D14146: Add Application Routes to Phame AppSearch queries
Attached
Detach File
Event Timeline
Log In to Comment