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 @@ -60,11 +60,11 @@ 'blog/' => array( '(?:query/(?P[^/]+)/)?' => 'PhameBlogListController', 'archive/(?P[^/]+)/' => 'PhameBlogArchiveController', - 'edit/(?P[^/]+)/' => 'PhameBlogEditController', + $this->getEditRoutePattern('edit/') + => 'PhameBlogEditController', 'view/(?P\d+)/' => 'PhameBlogViewController', 'manage/(?P[^/]+)/' => 'PhameBlogManageController', 'feed/(?P[^/]+)/' => 'PhameBlogFeedController', - 'new/' => 'PhameBlogEditController', 'picture/(?P[1-9]\d*)/' => 'PhameBlogProfilePictureController', ), ) + $this->getResourceSubroutes(), diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php --- a/src/applications/phame/controller/PhameHomeController.php +++ b/src/applications/phame/controller/PhameHomeController.php @@ -6,6 +6,16 @@ return true; } + protected function buildApplicationCrumbs() { + $crumbs = parent::buildApplicationCrumbs(); + + id(new PhameBlogEditEngine()) + ->setViewer($this->getViewer()) + ->addActionToCrumbs($crumbs); + + return $crumbs; + } + public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); @@ -44,7 +54,7 @@ $create_button = id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Create a Blog')) - ->setHref('/phame/blog/new/') + ->setHref('/phame/blog/edit/') ->setColor(PHUIButtonView::GREEN); $post_list = id(new PHUIBigInfoView()) @@ -116,27 +126,6 @@ array( $phame_home, )); - - - } - - private function renderBlogs($viewer, $blogs) {} - - protected function buildApplicationCrumbs() { - $crumbs = parent::buildApplicationCrumbs(); - - $can_create = $this->hasApplicationCapability( - PhameBlogCreateCapability::CAPABILITY); - - $crumbs->addAction( - id(new PHUIListItemView()) - ->setName(pht('New Blog')) - ->setHref($this->getApplicationURI('/blog/new/')) - ->setIcon('fa-plus-square') - ->setDisabled(!$can_create) - ->setWorkflow(!$can_create)); - - return $crumbs; } } 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 @@ -7,43 +7,18 @@ } 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->delegateToController($controller); + return id(new PhameBlogSearchEngine()) + ->setController($this) + ->buildResponse(); } - public function buildSideNavView() { - $viewer = $this->getRequest()->getUser(); - - $nav = new AphrontSideNavFilterView(); - $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - - id(new PhameBlogSearchEngine()) - ->setViewer($viewer) - ->addNavigationItems($nav->getMenu()); - - $nav->selectFilter(null); - - return $nav; - } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); - $can_create = $this->hasApplicationCapability( - PhameBlogCreateCapability::CAPABILITY); - - $crumbs->addAction( - id(new PHUIListItemView()) - ->setName(pht('New Blog')) - ->setHref($this->getApplicationURI('/blog/new/')) - ->setIcon('fa-plus-square') - ->setDisabled(!$can_create) - ->setWorkflow(!$can_create)); + id(new PhameBlogEditEngine()) + ->setViewer($this->getViewer()) + ->addActionToCrumbs($crumbs); return $crumbs; } diff --git a/src/applications/phame/editor/PhameBlogEditEngine.php b/src/applications/phame/editor/PhameBlogEditEngine.php --- a/src/applications/phame/editor/PhameBlogEditEngine.php +++ b/src/applications/phame/editor/PhameBlogEditEngine.php @@ -46,12 +46,24 @@ return pht('Create Blog'); } + protected function getObjectCreateCancelURI($object) { + return $this->getApplication()->getApplicationURI('blog/'); + } + + protected function getEditorURI() { + return $this->getApplication()->getApplicationURI('blog/edit/'); + } + protected function getObjectViewURI($object) { return $object->getManageURI(); } - protected function buildCustomEditFields($object) { + protected function getCreateNewObjectPolicy() { + return $this->getApplication()->getPolicy( + PhameBlogCreateCapability::CAPABILITY); + } + protected function buildCustomEditFields($object) { return array( id(new PhabricatorTextEditField()) ->setKey('name') diff --git a/src/applications/phame/view/PhameBlogListView.php b/src/applications/phame/view/PhameBlogListView.php --- a/src/applications/phame/view/PhameBlogListView.php +++ b/src/applications/phame/view/PhameBlogListView.php @@ -72,7 +72,7 @@ $list = phutil_tag( 'a', array( - 'href' => '/phame/blog/new/', + 'href' => '/phame/blog/edit/', ), pht('Create a Blog')); }