Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15437570
D14618.id35364.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D14618.id35364.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3312,6 +3312,7 @@
'PhameController' => 'applications/phame/controller/PhameController.php',
'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php',
'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
+ 'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php',
'PhamePost' => 'applications/phame/storage/PhamePost.php',
'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php',
'PhamePostController' => 'applications/phame/controller/post/PhamePostController.php',
@@ -3319,6 +3320,7 @@
'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php',
'PhamePostFramedController' => 'applications/phame/controller/post/PhamePostFramedController.php',
'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php',
+ 'PhamePostListView' => 'applications/phame/view/PhamePostListView.php',
'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php',
'PhamePostNewController' => 'applications/phame/controller/post/PhamePostNewController.php',
'PhamePostNotLiveController' => 'applications/phame/controller/post/PhamePostNotLiveController.php',
@@ -7632,6 +7634,7 @@
'PhameController' => 'PhabricatorController',
'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod',
'PhameDAO' => 'PhabricatorLiskDAO',
+ 'PhameHomeController' => 'PhamePostController',
'PhamePost' => array(
'PhameDAO',
'PhabricatorPolicyInterface',
@@ -7649,6 +7652,7 @@
'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor',
'PhamePostFramedController' => 'PhamePostController',
'PhamePostListController' => 'PhamePostController',
+ 'PhamePostListView' => 'AphrontTagView',
'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhamePostNewController' => 'PhamePostController',
'PhamePostNotLiveController' => 'PhamePostController',
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
@@ -38,7 +38,7 @@
public function getRoutes() {
return array(
'/phame/' => array(
- '' => 'PhamePostListController',
+ '' => 'PhameHomeController',
'live/(?P<id>[^/]+)/(?P<more>.*)' => 'PhameBlogLiveController',
'post/' => array(
'(?:(?P<filter>draft|all)/)?' => 'PhamePostListController',
diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/controller/PhameHomeController.php
@@ -0,0 +1,98 @@
+<?php
+
+final class PhameHomeController extends PhamePostController {
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+
+ $pager = id(new AphrontCursorPagerView())
+ ->readFromRequest($request);
+
+ $posts = id(new PhamePostQuery())
+ ->setViewer($viewer)
+ ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED)
+ ->executeWithCursorPager($pager);
+
+ $actions = $this->renderActions($viewer);
+ $action_button = id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText(pht('Search'))
+ ->setHref('#')
+ ->setIconFont('fa-search')
+ ->addClass('phui-mobile-menu')
+ ->setDropdownMenu($actions);
+
+ $title = pht('Recent Posts');
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader($title)
+ ->addActionLink($action_button);
+
+ $post_list = id(new PhamePostListView())
+ ->setPosts($posts)
+ ->setViewer($viewer)
+ ->showBlog(true)
+ ->setNodata(pht('No Recent Visible Posts.'));
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->setBorder(true);
+ $crumbs->addTextCrumb(
+ pht('Recent Posts'),
+ $this->getApplicationURI('post/'));
+
+ $page = id(new PHUIDocumentViewPro())
+ ->setHeader($header)
+ ->appendChild($post_list);
+
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild(
+ array(
+ $page,
+ ));
+
+
+ }
+
+ private function renderActions($viewer) {
+ $actions = id(new PhabricatorActionListView())
+ ->setUser($viewer);
+
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('fa-pencil-square-o')
+ ->setHref($this->getApplicationURI('post/'))
+ ->setName(pht('Find Posts')));
+
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('fa-star')
+ ->setHref($this->getApplicationURI('blog/'))
+ ->setName(pht('Find Blogs')));
+
+ return $actions;
+ }
+
+ 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/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php
--- a/src/applications/phame/controller/blog/PhameBlogViewController.php
+++ b/src/applications/phame/controller/blog/PhameBlogViewController.php
@@ -52,10 +52,10 @@
->setStatus($header_icon, $header_color, $header_name)
->addActionLink($action_button);
- $post_list = $this->renderPostList(
- $posts,
- $viewer,
- pht('This blog has no visible posts.'));
+ $post_list = id(new PhamePostListView())
+ ->setPosts($posts)
+ ->setViewer($viewer)
+ ->setNodata(pht('This blog has no visible posts.'));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
@@ -128,63 +128,6 @@
return $view;
}
- protected function renderPostList(
- array $posts,
- PhabricatorUser $viewer,
- $nodata) {
- assert_instances_of($posts, 'PhamePost');
-
- $handle_phids = array();
- foreach ($posts as $post) {
- $handle_phids[] = $post->getBloggerPHID();
- if ($post->getBlog()) {
- $handle_phids[] = $post->getBlog()->getPHID();
- }
- }
- $handles = $viewer->loadHandles($handle_phids);
-
- $list = array();
- foreach ($posts as $post) {
- $blogger = $handles[$post->getBloggerPHID()]->renderLink();
- $blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
- $blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
-
- $phame_post = null;
- if ($post->getBody()) {
- $phame_post = PhabricatorMarkupEngine::summarize($post->getBody());
- $phame_post = new PHUIRemarkupView($viewer, $phame_post);
- } else {
- $phame_post = phutil_tag('em', array(), pht('Empty Post'));
- }
-
- $blogger = phutil_tag('strong', array(), $blogger);
- $date = phabricator_datetime($post->getDatePublished(), $viewer);
- if ($post->isDraft()) {
- $subtitle = pht('Unpublished draft by %s.', $blogger);
- } else {
- $subtitle = pht('Written by %s on %s.', $blogger, $date);
- }
-
- $item = id(new PHUIDocumentSummaryView())
- ->setTitle($post->getTitle())
- ->setHref($this->getApplicationURI('/post/view/'.$post->getID().'/'))
- ->setSubtitle($subtitle)
- ->setImage($blogger_image)
- ->setImageHref($blogger_uri)
- ->setSummary($phame_post)
- ->setDraft($post->isDraft());
-
- $list[] = $item;
- }
-
- if (empty($list)) {
- $list = id(new PHUIInfoView())
- ->appendChild($nodata);
- }
-
- return $list;
- }
-
private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) {
$actions = id(new PhabricatorActionListView())
->setObject($blog)
diff --git a/src/applications/phame/view/PhamePostListView.php b/src/applications/phame/view/PhamePostListView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/view/PhamePostListView.php
@@ -0,0 +1,110 @@
+<?php
+
+final class PhamePostListView extends AphrontTagView {
+
+ private $posts;
+ private $nodata;
+ private $viewer;
+ private $showBlog = false;
+
+ public function setPosts($posts) {
+ assert_instances_of($posts, 'PhamePost');
+ $this->posts = $posts;
+ return $this;
+ }
+
+ public function setNodata($nodata) {
+ $this->nodata = $nodata;
+ return $this;
+ }
+
+ public function showBlog($show) {
+ $this->showBlog = $show;
+ return $this;
+ }
+
+ public function setViewer($viewer) {
+ $this->viewer = $viewer;
+ return $this;
+ }
+
+ protected function getTagAttributes() {
+ return array();
+ }
+
+ protected function getTagContent() {
+ $viewer = $this->viewer;
+ $posts = $this->posts;
+ $nodata = $this->nodata;
+
+ $handle_phids = array();
+ foreach ($posts as $post) {
+ $handle_phids[] = $post->getBloggerPHID();
+ if ($post->getBlog()) {
+ $handle_phids[] = $post->getBlog()->getPHID();
+ }
+ }
+ $handles = $viewer->loadHandles($handle_phids);
+
+ $list = array();
+ foreach ($posts as $post) {
+ $blogger = $handles[$post->getBloggerPHID()]->renderLink();
+ $blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
+ $blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
+
+ $phame_post = null;
+ if ($post->getBody()) {
+ $phame_post = PhabricatorMarkupEngine::summarize($post->getBody());
+ $phame_post = new PHUIRemarkupView($viewer, $phame_post);
+ } else {
+ $phame_post = phutil_tag('em', array(), pht('Empty Post'));
+ }
+
+ $blogger = phutil_tag('strong', array(), $blogger);
+ $date = phabricator_datetime($post->getDatePublished(), $viewer);
+
+ $blog = null;
+ if ($post->getBlog()) {
+ $blog = phutil_tag(
+ 'a',
+ array(
+ 'href' => '/phame/blog/view/'.$post->getBlog()->getID().'/',
+ ),
+ $post->getBlog()->getName());
+ }
+
+ if ($this->showBlog && $blog) {
+ if ($post->isDraft()) {
+ $subtitle = pht('Unpublished draft by %s in %s.', $blogger, $blog);
+ } else {
+ $subtitle = pht('By %s on %s in %s.', $blogger, $date, $blog);
+ }
+ } else {
+ if ($post->isDraft()) {
+ $subtitle = pht('Unpublished draft by %s.', $blogger);
+ } else {
+ $subtitle = pht('Written by %s on %s.', $blogger, $date);
+ }
+ }
+
+ $item = id(new PHUIDocumentSummaryView())
+ ->setTitle($post->getTitle())
+ ->setHref('/phame/post/view/'.$post->getID().'/')
+ ->setSubtitle($subtitle)
+ ->setImage($blogger_image)
+ ->setImageHref($blogger_uri)
+ ->setSummary($phame_post)
+ ->setDraft($post->isDraft());
+
+ $list[] = $item;
+ }
+
+ if (empty($list)) {
+ $list = id(new PHUIInfoView())
+ ->appendChild($nodata);
+ }
+
+ return $list;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 26, 8:28 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7723966
Default Alt Text
D14618.id35364.diff (11 KB)
Attached To
Mode
D14618: Add a homepage for Phame
Attached
Detach File
Event Timeline
Log In to Comment