@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.

Use PHUIDocumentProView in Phame

Summary: Updates "View Post" to use PHUIDocumentViewPro, updates calls to `newPage` and other minor modernizations. Edit Page updated to show proper document display as well. Ref T9545

Test Plan:
Write a blog post, edit it.

{F945897}

{F945896}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9545

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

+88 -87
+2 -2
resources/celerity/map.php
··· 126 126 'rsrc/css/phui/phui-box.css' => 'a5bb366d', 127 127 'rsrc/css/phui/phui-button.css' => '16020a60', 128 128 'rsrc/css/phui/phui-crumbs-view.css' => 'd842f867', 129 - 'rsrc/css/phui/phui-document-pro.css' => '61d70f8e', 129 + 'rsrc/css/phui/phui-document-pro.css' => '4f2b42e3', 130 130 'rsrc/css/phui/phui-document.css' => '9fa715d2', 131 131 'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23', 132 132 'rsrc/css/phui/phui-fontkit.css' => 'c9d63950', ··· 781 781 'phui-calendar-month-css' => '476be7e0', 782 782 'phui-crumbs-view-css' => 'd842f867', 783 783 'phui-document-view-css' => '9fa715d2', 784 - 'phui-document-view-pro-css' => '61d70f8e', 784 + 'phui-document-view-pro-css' => '4f2b42e3', 785 785 'phui-feed-story-css' => 'b7b26d23', 786 786 'phui-font-icon-base-css' => 'ecbbb4c2', 787 787 'phui-fontkit-css' => 'c9d63950',
+26 -23
src/applications/phame/controller/post/PhamePostEditController.php
··· 3 3 final class PhamePostEditController extends PhameController { 4 4 5 5 public function handleRequest(AphrontRequest $request) { 6 - $user = $request->getUser(); 6 + $viewer = $request->getViewer(); 7 7 $id = $request->getURIData('id'); 8 8 9 9 if ($id) { 10 10 $post = id(new PhamePostQuery()) 11 - ->setViewer($user) 11 + ->setViewer($viewer) 12 12 ->withIDs(array($id)) 13 13 ->requireCapabilities( 14 14 array( ··· 29 29 $v_projects = array_reverse($v_projects); 30 30 } else { 31 31 $blog = id(new PhameBlogQuery()) 32 - ->setViewer($user) 32 + ->setViewer($viewer) 33 33 ->withIDs(array($request->getInt('blog'))) 34 34 ->requireCapabilities( 35 35 array( ··· 42 42 } 43 43 $v_projects = array(); 44 44 45 - $post = PhamePost::initializePost($user, $blog); 45 + $post = PhamePost::initializePost($viewer, $blog); 46 46 $cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/'); 47 47 48 48 $submit_button = pht('Save Draft'); ··· 87 87 ->setNewValue(array('=' => array_fuse($v_projects))); 88 88 89 89 $editor = id(new PhamePostEditor()) 90 - ->setActor($user) 90 + ->setActor($viewer) 91 91 ->setContentSourceFromRequest($request) 92 92 ->setContinueOnNoEffect(true); 93 93 ··· 106 106 } 107 107 108 108 $handle = id(new PhabricatorHandleQuery()) 109 - ->setViewer($user) 109 + ->setViewer($viewer) 110 110 ->withPHIDs(array($post->getBlogPHID())) 111 111 ->executeOne(); 112 112 113 113 $form = id(new AphrontFormView()) 114 - ->setUser($user) 114 + ->setUser($viewer) 115 115 ->addHiddenInput('blog', $request->getInt('blog')) 116 116 ->appendChild( 117 117 id(new AphrontFormMarkupControl()) ··· 141 141 ->setValue($body) 142 142 ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) 143 143 ->setID('post-body') 144 - ->setUser($user) 144 + ->setUser($viewer) 145 145 ->setDisableMacros(true)) 146 146 ->appendControl( 147 147 id(new AphrontFormTokenizerControl()) ··· 160 160 ->addCancelButton($cancel_uri) 161 161 ->setValue($submit_button)); 162 162 163 - $loading = phutil_tag_div( 164 - 'aphront-panel-preview-loading-text', 165 - pht('Loading preview...')); 163 + $header = id(new PHUIHeaderView()) 164 + ->setHeader(pht('%s (Post Preview)', $title)); 165 + 166 + $container = id(new PHUIBoxView()) 167 + ->setID('post-preview'); 168 + 169 + $document = id(new PHUIDocumentViewPro()) 170 + ->setHeader($header) 171 + ->appendChild($container); 166 172 167 - $preview_panel = phutil_tag_div('aphront-panel-preview', array( 168 - phutil_tag_div('phame-post-preview-header', pht('Post Preview')), 169 - phutil_tag('div', array('id' => 'post-preview'), $loading), 170 - )); 173 + $preview_panel = id(new PHUIObjectBoxView()) 174 + ->appendChild($document); 171 175 172 176 Javelin::initBehavior( 173 177 'phame-post-preview', ··· 189 193 $page_title, 190 194 $this->getApplicationURI('/post/view/'.$id.'/')); 191 195 192 - return $this->buildApplicationPage( 193 - array( 194 - $crumbs, 195 - $form_box, 196 - $preview_panel, 197 - ), 198 - array( 199 - 'title' => $page_title, 196 + return $this->newPage() 197 + ->setTitle($page_title) 198 + ->setCrumbs($crumbs) 199 + ->appendChild( 200 + array( 201 + $form_box, 202 + $preview_panel, 200 203 )); 201 204 } 202 205
+4 -5
src/applications/phame/controller/post/PhamePostPreviewController.php
··· 6 6 return null; 7 7 } 8 8 9 - public function processRequest() { 10 - $request = $this->getRequest(); 11 - $user = $request->getUser(); 12 - $body = $request->getStr('body'); 9 + public function handleRequest(AphrontRequest $request) { 10 + $viewer = $request->getViewer(); 11 + $body = $request->getStr('body'); 13 12 14 13 $post = id(new PhamePost()) 15 14 ->setBody($body); ··· 17 16 $content = PhabricatorMarkupEngine::renderOneObject( 18 17 $post, 19 18 PhamePost::MARKUP_FIELD_BODY, 20 - $user); 19 + $viewer); 21 20 22 21 $content = phutil_tag_div('phabricator-remarkup', $content); 23 22
+50 -51
src/applications/phame/controller/post/PhamePostViewController.php
··· 3 3 final class PhamePostViewController extends PhameController { 4 4 5 5 public function handleRequest(AphrontRequest $request) { 6 - $user = $request->getUser(); 6 + $viewer = $request->getViewer(); 7 7 8 8 $post = id(new PhamePostQuery()) 9 - ->setViewer($user) 9 + ->setViewer($viewer) 10 10 ->withIDs(array($request->getURIData('id'))) 11 11 ->executeOne(); 12 12 ··· 14 14 return new Aphront404Response(); 15 15 } 16 16 17 - $nav = $this->renderSideNavFilterView(); 18 - 19 - $actions = $this->renderActions($post, $user); 20 - $properties = $this->renderProperties($post, $user, $actions); 21 - 22 17 $crumbs = $this->buildApplicationCrumbs(); 23 18 $crumbs->addTextCrumb( 24 19 $post->getTitle(), 25 20 $this->getApplicationURI('post/view/'.$post->getID().'/')); 21 + $crumbs->setBorder(true); 26 22 27 - $nav->appendChild($crumbs); 23 + $actions = $this->renderActions($post, $viewer); 24 + $properties = $this->renderProperties($post, $viewer); 25 + 26 + $action_button = id(new PHUIButtonView()) 27 + ->setTag('a') 28 + ->setText(pht('Actions')) 29 + ->setHref('#') 30 + ->setIconFont('fa-bars') 31 + ->addClass('phui-mobile-menu') 32 + ->setDropdownMenu($actions); 28 33 29 34 $header = id(new PHUIHeaderView()) 30 - ->setHeader($post->getTitle()) 31 - ->setUser($user) 32 - ->setPolicyObject($post); 35 + ->setHeader($post->getTitle()) 36 + ->setUser($viewer) 37 + ->setPolicyObject($post) 38 + ->addActionLink($action_button); 33 39 34 - $object_box = id(new PHUIObjectBoxView()) 40 + $document = id(new PHUIDocumentViewPro()) 35 41 ->setHeader($header) 36 - ->addPropertyList($properties); 42 + ->setPropertyList($properties); 37 43 38 44 if ($post->isDraft()) { 39 - $object_box->appendChild( 45 + $document->appendChild( 40 46 id(new PHUIInfoView()) 41 47 ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 42 48 ->setTitle(pht('Draft Post')) ··· 47 53 } 48 54 49 55 if (!$post->getBlog()) { 50 - $object_box->appendChild( 56 + $document->appendChild( 51 57 id(new PHUIInfoView()) 52 58 ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 53 59 ->setTitle(pht('Not On A Blog')) ··· 57 63 'been deleted). Use "Move Post" to move it to a new blog.'))); 58 64 } 59 65 60 - $nav->appendChild( 61 - array( 62 - $object_box, 63 - $this->buildTransactionTimeline( 64 - $post, 65 - new PhamePostTransactionQuery()), 66 - )); 66 + $engine = id(new PhabricatorMarkupEngine()) 67 + ->setViewer($viewer) 68 + ->addObject($post, PhamePost::MARKUP_FIELD_BODY) 69 + ->process(); 70 + 71 + $document->appendChild( 72 + phutil_tag( 73 + 'div', 74 + array( 75 + 'class' => 'phabricator-remarkup', 76 + ), 77 + $engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY))); 67 78 68 - return $this->buildApplicationPage( 69 - $nav, 70 - array( 71 - 'title' => $post->getTitle(), 79 + return $this->newPage() 80 + ->setTitle($post->getTitle()) 81 + ->addClass('pro-white-background') 82 + ->setCrumbs($crumbs) 83 + ->appendChild( 84 + array( 85 + $document, 72 86 )); 73 87 } 74 88 75 89 private function renderActions( 76 90 PhamePost $post, 77 - PhabricatorUser $user) { 91 + PhabricatorUser $viewer) { 78 92 79 93 $actions = id(new PhabricatorActionListView()) 80 94 ->setObject($post) 81 95 ->setObjectURI($this->getRequest()->getRequestURI()) 82 - ->setUser($user); 96 + ->setUser($viewer); 83 97 84 98 $can_edit = PhabricatorPolicyFilter::hasCapability( 85 - $user, 99 + $viewer, 86 100 $post, 87 101 PhabricatorPolicyCapability::CAN_EDIT); 88 102 ··· 139 153 140 154 $actions->addAction( 141 155 id(new PhabricatorActionView()) 142 - ->setUser($user) 156 + ->setUser($viewer) 143 157 ->setIcon('fa-globe') 144 158 ->setHref($live_uri) 145 159 ->setName(pht('View Live')) ··· 151 165 152 166 private function renderProperties( 153 167 PhamePost $post, 154 - PhabricatorUser $user, 155 - PhabricatorActionListView $actions) { 168 + PhabricatorUser $viewer) { 156 169 157 170 $properties = id(new PHUIPropertyListView()) 158 - ->setUser($user) 159 - ->setObject($post) 160 - ->setActionList($actions); 171 + ->setUser($viewer) 172 + ->setObject($post); 161 173 162 174 $properties->addProperty( 163 175 pht('Blog'), 164 - $user->renderHandle($post->getBlogPHID())); 176 + $viewer->renderHandle($post->getBlogPHID())); 165 177 166 178 $properties->addProperty( 167 179 pht('Blogger'), 168 - $user->renderHandle($post->getBloggerPHID())); 180 + $viewer->renderHandle($post->getBloggerPHID())); 169 181 170 182 $properties->addProperty( 171 183 pht('Published'), 172 184 $post->isDraft() 173 185 ? pht('Draft') 174 - : phabricator_datetime($post->getDatePublished(), $user)); 175 - 176 - $engine = id(new PhabricatorMarkupEngine()) 177 - ->setViewer($user) 178 - ->addObject($post, PhamePost::MARKUP_FIELD_BODY) 179 - ->process(); 186 + : phabricator_datetime($post->getDatePublished(), $viewer)); 180 187 181 188 $properties->invokeWillRenderEvent(); 182 - 183 - $properties->addTextContent( 184 - phutil_tag( 185 - 'div', 186 - array( 187 - 'class' => 'phabricator-remarkup', 188 - ), 189 - $engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY))); 190 189 191 190 return $properties; 192 191 }
+6 -6
webroot/rsrc/css/phui/phui-document-pro.css
··· 3 3 */ 4 4 5 5 .phui-document-view.phui-document-view-pro, 6 - .phui-document-view-pro-box { 6 + .phui-document-view-pro-box, 7 + .phui-document-properties { 7 8 max-width: 800px; 8 9 padding: 0 16px; 9 10 position: relative; ··· 11 12 } 12 13 13 14 .phui-document-properties { 14 - max-width: 800px; 15 - padding: 0 16px; 15 + max-width: 768px; 16 16 background-color: {$lightgreybackground}; 17 - margin: 0 auto; 17 + margin: 16px auto; 18 18 border-radius: 3px; 19 19 } 20 20 21 - .device-phone .phui-document-properties { 22 - margin: 0 8px; 21 + .device .phui-document-properties { 22 + margin: 0 8px 16px; 23 23 } 24 24 25 25 .device-phone .phui-document-view.phui-document-view-pro {