diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8adc589fe6..ace26640ae 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3341,6 +3341,7 @@ phutil_register_library_map(array( 'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php', 'PhameDAO' => 'applications/phame/storage/PhameDAO.php', 'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php', + 'PhameDraftListView' => 'applications/phame/view/PhameDraftListView.php', 'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php', 'PhameLiveController' => 'applications/phame/controller/PhameLiveController.php', 'PhamePost' => 'applications/phame/storage/PhamePost.php', @@ -7691,6 +7692,7 @@ phutil_register_library_map(array( 'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod', 'PhameDAO' => 'PhabricatorLiskDAO', 'PhameDescriptionView' => 'AphrontTagView', + 'PhameDraftListView' => 'AphrontTagView', 'PhameHomeController' => 'PhamePostController', 'PhameLiveController' => 'PhameController', 'PhamePost' => array( diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php index 27fb907f50..6383a65894 100644 --- a/src/applications/phame/controller/PhameHomeController.php +++ b/src/applications/phame/controller/PhameHomeController.php @@ -57,15 +57,34 @@ final class PhameHomeController extends PhamePostController { ->setHeader($header) ->appendChild($post_list); - $sidebar = id(new PhameBlogListView()) + $blog_list = id(new PhameBlogListView()) ->setBlogs($blogs) ->setViewer($viewer); + $draft_list = null; + if ($viewer->isLoggedIn()) { + $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($sidebar) + ->setSideColumn(array( + $blog_list, + $draft_list, + )) ->setDisplay(PHUITwoColumnView::DISPLAY_LEFT) ->addClass('phame-home-view'); diff --git a/src/applications/phame/query/PhamePostQuery.php b/src/applications/phame/query/PhamePostQuery.php index 011314c1bf..44d4f8be8f 100644 --- a/src/applications/phame/query/PhamePostQuery.php +++ b/src/applications/phame/query/PhamePostQuery.php @@ -68,6 +68,7 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery { $blog_phids = mpull($posts, 'getBlogPHID'); $blogs = id(new PhameBlogQuery()) ->setViewer($this->getViewer()) + ->needProfileImage(true) ->withPHIDs($blog_phids) ->execute(); $blogs = mpull($blogs, null, 'getPHID'); diff --git a/src/applications/phame/view/PhameBlogListView.php b/src/applications/phame/view/PhameBlogListView.php index 965954f292..6f42da77fe 100644 --- a/src/applications/phame/view/PhameBlogListView.php +++ b/src/applications/phame/view/PhameBlogListView.php @@ -24,7 +24,6 @@ final class PhameBlogListView extends AphrontTagView { protected function getTagContent() { require_celerity_resource('phame-css'); - Javelin::initBehavior('phabricator-tooltips'); $list = array(); foreach ($this->blogs as $blog) { @@ -54,8 +53,6 @@ final class PhameBlogListView extends AphrontTagView { array( 'href' => '/phame/post/edit/?blog='.$blog->getID(), 'class' => 'phame-blog-list-new-post', - 'sigil' => 'has-tooltip', - 'meta' => array('tip' => pht('New Post')), ), $icon); diff --git a/src/applications/phame/view/PhameDraftListView.php b/src/applications/phame/view/PhameDraftListView.php new file mode 100644 index 0000000000..558bf19b52 --- /dev/null +++ b/src/applications/phame/view/PhameDraftListView.php @@ -0,0 +1,98 @@ +posts = $posts; + return $this; + } + + 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->posts as $post) { + $blog = $post->getBlog(); + $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' => $post->getViewURI(), + ), + $post->getTitle()); + + $icon = id(new PHUIIconView()) + ->setIconFont('fa-pencil-square-o') + ->addClass('phame-blog-list-icon'); + + $edit = phutil_tag( + 'a', + array( + 'href' => '/phame/post/edit/'.$post->getID().'/', + 'class' => 'phame-blog-list-new-post', + ), + $icon); + + $list[] = phutil_tag( + 'div', + array( + 'class' => 'phame-blog-list-item', + ), + array( + $image, + $title, + $edit, + )); + } + + if (empty($list)) { + $list = pht('You have no draft posts.'); + } + + $header = phutil_tag( + 'h4', + array( + 'class' => 'phame-blog-list-header', + ), + phutil_tag( + 'a', + array( + 'href' => '/phame/post/query/draft/', + ), + pht('Drafts'))); + + return array($header, $list); + } + +}