Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php
index 637b51a66c..30d1b9cb3d 100644
--- a/src/applications/phame/application/PhabricatorPhameApplication.php
+++ b/src/applications/phame/application/PhabricatorPhameApplication.php
@@ -1,115 +1,115 @@
<?php
final class PhabricatorPhameApplication extends PhabricatorApplication {
public function getName() {
return pht('Phame');
}
public function getBaseURI() {
return '/phame/';
}
public function getIcon() {
return 'fa-star';
}
public function getShortDescription() {
return pht('Blog');
}
public function getTitleGlyph() {
return "\xe2\x9c\xa9";
}
public function getHelpDocumentationArticles(PhabricatorUser $viewer) {
return array(
array(
'name' => pht('Phame User Guide'),
'href' => PhabricatorEnv::getDoclink('Phame User Guide'),
),
);
}
public function isPrototype() {
return true;
}
public function getRoutes() {
return array(
'/phame/' => array(
'' => 'PhameHomeController',
// NOTE: The live routes include an initial "/", so leave it off
// this route.
'(?P<live>live)/(?P<blogID>\d+)' => $this->getLiveRoutes(),
'post/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhamePostListController',
'blogger/(?P<bloggername>[\w\.-_]+)/' => 'PhamePostListController',
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
'history/(?P<id>\d+)/' => 'PhamePostHistoryController',
'view/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController',
'(?P<action>publish|unpublish)/(?P<id>\d+)/'
=> 'PhamePostPublishController',
'preview/(?P<id>\d+)/' => 'PhamePostPreviewController',
'preview/' => 'PhabricatorMarkupPreviewController',
'framed/(?P<id>\d+)/' => 'PhamePostFramedController',
'move/(?P<id>\d+)/' => 'PhamePostMoveController',
'comment/(?P<id>[1-9]\d*)/' => 'PhamePostCommentController',
),
'blog/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhameBlogListController',
'archive/(?P<id>[^/]+)/' => 'PhameBlogArchiveController',
- 'edit/(?P<id>[^/]+)/' => 'PhameBlogEditController',
+ $this->getEditRoutePattern('edit/')
+ => 'PhameBlogEditController',
'view/(?P<blogID>\d+)/' => 'PhameBlogViewController',
'manage/(?P<id>[^/]+)/' => 'PhameBlogManageController',
'feed/(?P<id>[^/]+)/' => 'PhameBlogFeedController',
- 'new/' => 'PhameBlogEditController',
'picture/(?P<id>[1-9]\d*)/' => 'PhameBlogProfilePictureController',
),
) + $this->getResourceSubroutes(),
);
}
public function getResourceRoutes() {
return array(
'/phame/' => $this->getResourceSubroutes(),
);
}
private function getResourceSubroutes() {
return array(
'r/(?P<id>\d+)/(?P<hash>[^/]+)/(?P<name>.*)' =>
'PhameResourceController',
);
}
public function getBlogRoutes() {
return $this->getLiveRoutes();
}
private function getLiveRoutes() {
return array(
'/' => array(
'' => 'PhameBlogViewController',
'post/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController',
),
);
}
public function getQuicksandURIPatternBlacklist() {
return array(
'/phame/live/.*',
);
}
protected function getCustomCapabilities() {
return array(
PhameBlogCreateCapability::CAPABILITY => array(
'default' => PhabricatorPolicies::POLICY_USER,
'caption' => pht('Default create policy for blogs.'),
),
);
}
}
diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php
index cea86735b5..95d1544abe 100644
--- a/src/applications/phame/controller/PhameHomeController.php
+++ b/src/applications/phame/controller/PhameHomeController.php
@@ -1,142 +1,131 @@
<?php
final class PhameHomeController extends PhamePostController {
public function shouldAllowPublic() {
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();
$blogs = id(new PhameBlogQuery())
->setViewer($viewer)
->withStatuses(array(PhameBlog::STATUS_ACTIVE))
->needProfileImage(true)
->execute();
$post_list = null;
if ($blogs) {
$blog_phids = mpull($blogs, 'getPHID');
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$posts = id(new PhamePostQuery())
->setViewer($viewer)
->withBlogPHIDs($blog_phids)
->withVisibility(PhameConstants::VISIBILITY_PUBLISHED)
->executeWithCursorPager($pager);
if ($posts) {
$post_list = id(new PhamePostListView())
->setPosts($posts)
->setViewer($viewer)
->showBlog(true);
} else {
$post_list = id(new PHUIBigInfoView())
->setIcon('fa-star')
->setTitle('No Visible Posts')
->setDescription(
pht('There aren\'t any visible blog posts.'));
}
} else {
$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())
->setIcon('fa-star')
->setTitle('Welcome to Phame')
->setDescription(
pht('There aren\'t any visible blog posts.'))
->addAction($create_button);
}
$view_all = id(new PHUIButtonView())
->setTag('a')
->setText(pht('View All'))
->setHref($this->getApplicationURI('post/'))
->setIcon('fa-list-ul');
$title = pht('Recent Posts');
$header = id(new PHUIHeaderView())
->setHeader($title)
->addActionLink($view_all);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$crumbs->addTextCrumb(
pht('Recent Posts'),
$this->getApplicationURI('post/'));
$page = id(new PHUIDocumentViewPro())
->setHeader($header)
->appendChild($post_list);
$blog_list = id(new PhameBlogListView())
->setBlogs($blogs)
->setViewer($viewer);
$draft_list = null;
if ($viewer->isLoggedIn() && $blogs) {
$drafts = id(new PhamePostQuery())
->setViewer($viewer)
->withBloggerPHIDs(array($viewer->getPHID()))
->withBlogPHIDs(mpull($blogs, 'getPHID'))
->withVisibility(PhameConstants::VISIBILITY_DRAFT)
->setLimit(5)
->execute();
$draft_list = id(new PhameDraftListView())
->setPosts($drafts)
->setBlogs($blogs)
->setViewer($viewer);
}
$phame_view = id(new PHUITwoColumnView())
->setMainColumn(array(
$page,
))
->setSideColumn(array(
$blog_list,
$draft_list,
))
->addClass('phame-home-container');
$phame_home = phutil_tag_div('phame-home-view', $phame_view);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
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
index 9bef5c1cf9..ff14178087 100644
--- a/src/applications/phame/controller/blog/PhameBlogListController.php
+++ b/src/applications/phame/controller/blog/PhameBlogListController.php
@@ -1,51 +1,26 @@
<?php
final class PhameBlogListController extends PhameBlogController {
public function shouldAllowPublic() {
return true;
}
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
index 92e267096d..503a6bbd27 100644
--- a/src/applications/phame/editor/PhameBlogEditEngine.php
+++ b/src/applications/phame/editor/PhameBlogEditEngine.php
@@ -1,93 +1,105 @@
<?php
final class PhameBlogEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'phame.blog';
public function getEngineName() {
return pht('Blogs');
}
public function getEngineApplicationClass() {
return 'PhabricatorPhameApplication';
}
public function getSummaryHeader() {
return pht('Configure Phame Blog Forms');
}
public function getSummaryText() {
return pht('Configure how blogs in Phame are created and edited.');
}
protected function newEditableObject() {
return PhameBlog::initializeNewBlog($this->getViewer());
}
protected function newObjectQuery() {
return id(new PhameBlogQuery())
->needProfileImage(true);
}
protected function getObjectCreateTitleText($object) {
return pht('Create New Blog');
}
protected function getObjectEditTitleText($object) {
return pht('Edit %s', $object->getName());
}
protected function getObjectEditShortText($object) {
return $object->getName();
}
protected function getObjectCreateShortText() {
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')
->setLabel(pht('Name'))
->setDescription(pht('Blog name.'))
->setConduitDescription(pht('Retitle the blog.'))
->setConduitTypeDescription(pht('New blog title.'))
->setTransactionType(PhameBlogTransaction::TYPE_NAME)
->setValue($object->getName()),
id(new PhabricatorRemarkupEditField())
->setKey('description')
->setLabel(pht('Description'))
->setDescription(pht('Blog description.'))
->setConduitDescription(pht('Change the blog description.'))
->setConduitTypeDescription(pht('New blog description.'))
->setTransactionType(PhameBlogTransaction::TYPE_DESCRIPTION)
->setValue($object->getDescription()),
id(new PhabricatorTextEditField())
->setKey('domain')
->setLabel(pht('Custom Domain'))
->setDescription(pht('Blog domain name.'))
->setConduitDescription(pht('Change the blog domain.'))
->setConduitTypeDescription(pht('New blog domain.'))
->setValue($object->getDomain())
->setTransactionType(PhameBlogTransaction::TYPE_DOMAIN),
id(new PhabricatorSelectEditField())
->setKey('status')
->setLabel(pht('Status'))
->setTransactionType(PhameBlogTransaction::TYPE_STATUS)
->setIsConduitOnly(true)
->setOptions(PhameBlog::getStatusNameMap())
->setDescription(pht('Active or archived status.'))
->setConduitDescription(pht('Active or archive the blog.'))
->setConduitTypeDescription(pht('New blog status constant.'))
->setValue($object->getStatus()),
);
}
}
diff --git a/src/applications/phame/view/PhameBlogListView.php b/src/applications/phame/view/PhameBlogListView.php
index f2149b8cfb..0d897b730a 100644
--- a/src/applications/phame/view/PhameBlogListView.php
+++ b/src/applications/phame/view/PhameBlogListView.php
@@ -1,100 +1,100 @@
<?php
final class PhameBlogListView extends AphrontTagView {
private $blogs;
private $viewer;
public function setBlogs($blogs) {
assert_instances_of($blogs, 'PhameBlog');
$this->blogs = $blogs;
return $this;
}
public function setViewer($viewer) {
$this->viewer = $viewer;
return $this;
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'phame-blog-list';
return array('class' => implode(' ', $classes));
}
protected function getTagContent() {
require_celerity_resource('phame-css');
$list = array();
foreach ($this->blogs as $blog) {
$image_uri = $blog->getProfileImageURI();
$image = phutil_tag(
'a',
array(
'class' => 'phame-blog-list-image',
'style' => 'background-image: url('.$image_uri.');',
'href' => $blog->getViewURI(),
));
$title = phutil_tag(
'a',
array(
'class' => 'phame-blog-list-title',
'href' => $blog->getViewURI(),
),
$blog->getName());
$icon = id(new PHUIIconView())
->setIcon('fa-plus-square')
->addClass('phame-blog-list-icon');
$add_new = phutil_tag(
'a',
array(
'href' => '/phame/post/edit/?blog='.$blog->getID(),
'class' => 'phame-blog-list-new-post',
),
$icon);
$list[] = phutil_tag(
'div',
array(
'class' => 'phame-blog-list-item',
),
array(
$image,
$title,
$add_new,
));
}
if (empty($list)) {
$list = phutil_tag(
'a',
array(
- 'href' => '/phame/blog/new/',
+ 'href' => '/phame/blog/edit/',
),
pht('Create a Blog'));
}
$header = phutil_tag(
'h4',
array(
'class' => 'phame-blog-list-header',
),
phutil_tag(
'a',
array(
'href' => '/phame/blog/',
),
pht('Blogs')));
return id(new PHUIBoxView())
->appendChild($header)
->appendChild($list)
->addClass('pl')
->setColor(PHUIBoxView::BLUE);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 16:35 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126530
Default Alt Text
(16 KB)

Event Timeline