@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a homepage for Phame

Summary: Sends `/phame/` to PhameHomeController, which is all published posts. Still some rough edges to work out for new posts, new blogs, but I think this is the right direction.

Test Plan:
go to Phame, see most recent posts, no drafts. click on find posts, see post list, click on find blogs, see blogs.

{F1008800}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9742

Differential Revision: https://secure.phabricator.com/D14618

authored by

Chad Little and committed by
chad
4e6cd90e 2fba7e66

+217 -62
+4
src/__phutil_library_map__.php
··· 3312 3312 'PhameController' => 'applications/phame/controller/PhameController.php', 3313 3313 'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php', 3314 3314 'PhameDAO' => 'applications/phame/storage/PhameDAO.php', 3315 + 'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php', 3315 3316 'PhamePost' => 'applications/phame/storage/PhamePost.php', 3316 3317 'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php', 3317 3318 'PhamePostController' => 'applications/phame/controller/post/PhamePostController.php', ··· 3319 3320 'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php', 3320 3321 'PhamePostFramedController' => 'applications/phame/controller/post/PhamePostFramedController.php', 3321 3322 'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php', 3323 + 'PhamePostListView' => 'applications/phame/view/PhamePostListView.php', 3322 3324 'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php', 3323 3325 'PhamePostNewController' => 'applications/phame/controller/post/PhamePostNewController.php', 3324 3326 'PhamePostNotLiveController' => 'applications/phame/controller/post/PhamePostNotLiveController.php', ··· 7632 7634 'PhameController' => 'PhabricatorController', 7633 7635 'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod', 7634 7636 'PhameDAO' => 'PhabricatorLiskDAO', 7637 + 'PhameHomeController' => 'PhamePostController', 7635 7638 'PhamePost' => array( 7636 7639 'PhameDAO', 7637 7640 'PhabricatorPolicyInterface', ··· 7649 7652 'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor', 7650 7653 'PhamePostFramedController' => 'PhamePostController', 7651 7654 'PhamePostListController' => 'PhamePostController', 7655 + 'PhamePostListView' => 'AphrontTagView', 7652 7656 'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver', 7653 7657 'PhamePostNewController' => 'PhamePostController', 7654 7658 'PhamePostNotLiveController' => 'PhamePostController',
+1 -1
src/applications/phame/application/PhabricatorPhameApplication.php
··· 38 38 public function getRoutes() { 39 39 return array( 40 40 '/phame/' => array( 41 - '' => 'PhamePostListController', 41 + '' => 'PhameHomeController', 42 42 'live/(?P<id>[^/]+)/(?P<more>.*)' => 'PhameBlogLiveController', 43 43 'post/' => array( 44 44 '(?:(?P<filter>draft|all)/)?' => 'PhamePostListController',
+98
src/applications/phame/controller/PhameHomeController.php
··· 1 + <?php 2 + 3 + final class PhameHomeController extends PhamePostController { 4 + 5 + public function shouldAllowPublic() { 6 + return true; 7 + } 8 + 9 + public function handleRequest(AphrontRequest $request) { 10 + $viewer = $request->getViewer(); 11 + 12 + $pager = id(new AphrontCursorPagerView()) 13 + ->readFromRequest($request); 14 + 15 + $posts = id(new PhamePostQuery()) 16 + ->setViewer($viewer) 17 + ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED) 18 + ->executeWithCursorPager($pager); 19 + 20 + $actions = $this->renderActions($viewer); 21 + $action_button = id(new PHUIButtonView()) 22 + ->setTag('a') 23 + ->setText(pht('Search')) 24 + ->setHref('#') 25 + ->setIconFont('fa-search') 26 + ->addClass('phui-mobile-menu') 27 + ->setDropdownMenu($actions); 28 + 29 + $title = pht('Recent Posts'); 30 + 31 + $header = id(new PHUIHeaderView()) 32 + ->setHeader($title) 33 + ->addActionLink($action_button); 34 + 35 + $post_list = id(new PhamePostListView()) 36 + ->setPosts($posts) 37 + ->setViewer($viewer) 38 + ->showBlog(true) 39 + ->setNodata(pht('No Recent Visible Posts.')); 40 + 41 + $crumbs = $this->buildApplicationCrumbs(); 42 + $crumbs->setBorder(true); 43 + $crumbs->addTextCrumb( 44 + pht('Recent Posts'), 45 + $this->getApplicationURI('post/')); 46 + 47 + $page = id(new PHUIDocumentViewPro()) 48 + ->setHeader($header) 49 + ->appendChild($post_list); 50 + 51 + return $this->newPage() 52 + ->setTitle($title) 53 + ->setCrumbs($crumbs) 54 + ->appendChild( 55 + array( 56 + $page, 57 + )); 58 + 59 + 60 + } 61 + 62 + private function renderActions($viewer) { 63 + $actions = id(new PhabricatorActionListView()) 64 + ->setUser($viewer); 65 + 66 + $actions->addAction( 67 + id(new PhabricatorActionView()) 68 + ->setIcon('fa-pencil-square-o') 69 + ->setHref($this->getApplicationURI('post/')) 70 + ->setName(pht('Find Posts'))); 71 + 72 + $actions->addAction( 73 + id(new PhabricatorActionView()) 74 + ->setIcon('fa-star') 75 + ->setHref($this->getApplicationURI('blog/')) 76 + ->setName(pht('Find Blogs'))); 77 + 78 + return $actions; 79 + } 80 + 81 + protected function buildApplicationCrumbs() { 82 + $crumbs = parent::buildApplicationCrumbs(); 83 + 84 + $can_create = $this->hasApplicationCapability( 85 + PhameBlogCreateCapability::CAPABILITY); 86 + 87 + $crumbs->addAction( 88 + id(new PHUIListItemView()) 89 + ->setName(pht('New Blog')) 90 + ->setHref($this->getApplicationURI('/blog/new/')) 91 + ->setIcon('fa-plus-square') 92 + ->setDisabled(!$can_create) 93 + ->setWorkflow(!$can_create)); 94 + 95 + return $crumbs; 96 + } 97 + 98 + }
+4 -61
src/applications/phame/controller/blog/PhameBlogViewController.php
··· 52 52 ->setStatus($header_icon, $header_color, $header_name) 53 53 ->addActionLink($action_button); 54 54 55 - $post_list = $this->renderPostList( 56 - $posts, 57 - $viewer, 58 - pht('This blog has no visible posts.')); 55 + $post_list = id(new PhamePostListView()) 56 + ->setPosts($posts) 57 + ->setViewer($viewer) 58 + ->setNodata(pht('This blog has no visible posts.')); 59 59 60 60 $crumbs = $this->buildApplicationCrumbs(); 61 61 $crumbs->setBorder(true); ··· 126 126 )); 127 127 128 128 return $view; 129 - } 130 - 131 - protected function renderPostList( 132 - array $posts, 133 - PhabricatorUser $viewer, 134 - $nodata) { 135 - assert_instances_of($posts, 'PhamePost'); 136 - 137 - $handle_phids = array(); 138 - foreach ($posts as $post) { 139 - $handle_phids[] = $post->getBloggerPHID(); 140 - if ($post->getBlog()) { 141 - $handle_phids[] = $post->getBlog()->getPHID(); 142 - } 143 - } 144 - $handles = $viewer->loadHandles($handle_phids); 145 - 146 - $list = array(); 147 - foreach ($posts as $post) { 148 - $blogger = $handles[$post->getBloggerPHID()]->renderLink(); 149 - $blogger_uri = $handles[$post->getBloggerPHID()]->getURI(); 150 - $blogger_image = $handles[$post->getBloggerPHID()]->getImageURI(); 151 - 152 - $phame_post = null; 153 - if ($post->getBody()) { 154 - $phame_post = PhabricatorMarkupEngine::summarize($post->getBody()); 155 - $phame_post = new PHUIRemarkupView($viewer, $phame_post); 156 - } else { 157 - $phame_post = phutil_tag('em', array(), pht('Empty Post')); 158 - } 159 - 160 - $blogger = phutil_tag('strong', array(), $blogger); 161 - $date = phabricator_datetime($post->getDatePublished(), $viewer); 162 - if ($post->isDraft()) { 163 - $subtitle = pht('Unpublished draft by %s.', $blogger); 164 - } else { 165 - $subtitle = pht('Written by %s on %s.', $blogger, $date); 166 - } 167 - 168 - $item = id(new PHUIDocumentSummaryView()) 169 - ->setTitle($post->getTitle()) 170 - ->setHref($this->getApplicationURI('/post/view/'.$post->getID().'/')) 171 - ->setSubtitle($subtitle) 172 - ->setImage($blogger_image) 173 - ->setImageHref($blogger_uri) 174 - ->setSummary($phame_post) 175 - ->setDraft($post->isDraft()); 176 - 177 - $list[] = $item; 178 - } 179 - 180 - if (empty($list)) { 181 - $list = id(new PHUIInfoView()) 182 - ->appendChild($nodata); 183 - } 184 - 185 - return $list; 186 129 } 187 130 188 131 private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) {
+110
src/applications/phame/view/PhamePostListView.php
··· 1 + <?php 2 + 3 + final class PhamePostListView extends AphrontTagView { 4 + 5 + private $posts; 6 + private $nodata; 7 + private $viewer; 8 + private $showBlog = false; 9 + 10 + public function setPosts($posts) { 11 + assert_instances_of($posts, 'PhamePost'); 12 + $this->posts = $posts; 13 + return $this; 14 + } 15 + 16 + public function setNodata($nodata) { 17 + $this->nodata = $nodata; 18 + return $this; 19 + } 20 + 21 + public function showBlog($show) { 22 + $this->showBlog = $show; 23 + return $this; 24 + } 25 + 26 + public function setViewer($viewer) { 27 + $this->viewer = $viewer; 28 + return $this; 29 + } 30 + 31 + protected function getTagAttributes() { 32 + return array(); 33 + } 34 + 35 + protected function getTagContent() { 36 + $viewer = $this->viewer; 37 + $posts = $this->posts; 38 + $nodata = $this->nodata; 39 + 40 + $handle_phids = array(); 41 + foreach ($posts as $post) { 42 + $handle_phids[] = $post->getBloggerPHID(); 43 + if ($post->getBlog()) { 44 + $handle_phids[] = $post->getBlog()->getPHID(); 45 + } 46 + } 47 + $handles = $viewer->loadHandles($handle_phids); 48 + 49 + $list = array(); 50 + foreach ($posts as $post) { 51 + $blogger = $handles[$post->getBloggerPHID()]->renderLink(); 52 + $blogger_uri = $handles[$post->getBloggerPHID()]->getURI(); 53 + $blogger_image = $handles[$post->getBloggerPHID()]->getImageURI(); 54 + 55 + $phame_post = null; 56 + if ($post->getBody()) { 57 + $phame_post = PhabricatorMarkupEngine::summarize($post->getBody()); 58 + $phame_post = new PHUIRemarkupView($viewer, $phame_post); 59 + } else { 60 + $phame_post = phutil_tag('em', array(), pht('Empty Post')); 61 + } 62 + 63 + $blogger = phutil_tag('strong', array(), $blogger); 64 + $date = phabricator_datetime($post->getDatePublished(), $viewer); 65 + 66 + $blog = null; 67 + if ($post->getBlog()) { 68 + $blog = phutil_tag( 69 + 'a', 70 + array( 71 + 'href' => '/phame/blog/view/'.$post->getBlog()->getID().'/', 72 + ), 73 + $post->getBlog()->getName()); 74 + } 75 + 76 + if ($this->showBlog && $blog) { 77 + if ($post->isDraft()) { 78 + $subtitle = pht('Unpublished draft by %s in %s.', $blogger, $blog); 79 + } else { 80 + $subtitle = pht('By %s on %s in %s.', $blogger, $date, $blog); 81 + } 82 + } else { 83 + if ($post->isDraft()) { 84 + $subtitle = pht('Unpublished draft by %s.', $blogger); 85 + } else { 86 + $subtitle = pht('Written by %s on %s.', $blogger, $date); 87 + } 88 + } 89 + 90 + $item = id(new PHUIDocumentSummaryView()) 91 + ->setTitle($post->getTitle()) 92 + ->setHref('/phame/post/view/'.$post->getID().'/') 93 + ->setSubtitle($subtitle) 94 + ->setImage($blogger_image) 95 + ->setImageHref($blogger_uri) 96 + ->setSummary($phame_post) 97 + ->setDraft($post->isDraft()); 98 + 99 + $list[] = $item; 100 + } 101 + 102 + if (empty($list)) { 103 + $list = id(new PHUIInfoView()) 104 + ->appendChild($nodata); 105 + } 106 + 107 + return $list; 108 + } 109 + 110 + }