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

Clean up Phame Preview

Summary: This adds a separate Publish/Unpublish step aside from Preview in Phame Posts. This allows easier access to publishing without previewing, though I left publish in tact on the preview page. Also cleaned up some minor transaction issues with mail.

Test Plan: New Post, Publish Post, Preview Post. Check mail logs. Get mail upon publish.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+127 -51
+2
src/__phutil_library_map__.php
··· 3331 3331 'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php', 3332 3332 'PhamePostNewController' => 'applications/phame/controller/post/PhamePostNewController.php', 3333 3333 'PhamePostNotLiveController' => 'applications/phame/controller/post/PhamePostNotLiveController.php', 3334 + 'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php', 3334 3335 'PhamePostPublishController' => 'applications/phame/controller/post/PhamePostPublishController.php', 3335 3336 'PhamePostQuery' => 'applications/phame/query/PhamePostQuery.php', 3336 3337 'PhamePostReplyHandler' => 'applications/phame/mail/PhamePostReplyHandler.php', ··· 7670 7671 'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver', 7671 7672 'PhamePostNewController' => 'PhamePostController', 7672 7673 'PhamePostNotLiveController' => 'PhamePostController', 7674 + 'PhamePostPreviewController' => 'PhamePostController', 7673 7675 'PhamePostPublishController' => 'PhamePostController', 7674 7676 'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 7675 7677 'PhamePostReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
+1
src/applications/phame/application/PhabricatorPhameApplication.php
··· 47 47 'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController', 48 48 'view/(?P<id>\d+)/' => 'PhamePostViewController', 49 49 'publish/(?P<id>\d+)/' => 'PhamePostPublishController', 50 + 'preview/(?P<id>\d+)/' => 'PhamePostPreviewController', 50 51 'unpublish/(?P<id>\d+)/' => 'PhamePostUnpublishController', 51 52 'notlive/(?P<id>\d+)/' => 'PhamePostNotLiveController', 52 53 'preview/' => 'PhabricatorMarkupPreviewController',
+89
src/applications/phame/controller/post/PhamePostPreviewController.php
··· 1 + <?php 2 + 3 + final class PhamePostPreviewController extends PhamePostController { 4 + 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $id = $request->getURIData('id'); 8 + 9 + $post = id(new PhamePostQuery()) 10 + ->setViewer($viewer) 11 + ->withIDs(array($id)) 12 + ->requireCapabilities( 13 + array( 14 + PhabricatorPolicyCapability::CAN_EDIT, 15 + )) 16 + ->executeOne(); 17 + if (!$post) { 18 + return new Aphront404Response(); 19 + } 20 + 21 + $view_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); 22 + 23 + if ($request->isFormPost()) { 24 + $xactions = array(); 25 + $xactions[] = id(new PhamePostTransaction()) 26 + ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) 27 + ->setNewValue(PhameConstants::VISIBILITY_PUBLISHED); 28 + 29 + id(new PhamePostEditor()) 30 + ->setActor($viewer) 31 + ->setContentSourceFromRequest($request) 32 + ->setContinueOnNoEffect(true) 33 + ->setContinueOnMissingFields(true) 34 + ->applyTransactions($post, $xactions); 35 + 36 + return id(new AphrontRedirectResponse())->setURI($view_uri); 37 + } 38 + 39 + $form = id(new AphrontFormView()) 40 + ->setUser($viewer) 41 + ->appendChild( 42 + id(new AphrontFormSubmitControl()) 43 + ->setValue(pht('Publish Post')) 44 + ->addCancelButton($view_uri)); 45 + 46 + $frame = $this->renderPreviewFrame($post); 47 + 48 + $form_box = id(new PHUIObjectBoxView()) 49 + ->setHeaderText(pht('Preview Post')) 50 + ->setForm($form); 51 + 52 + $blog = $post->getBlog(); 53 + 54 + $crumbs = $this->buildApplicationCrumbs(); 55 + $crumbs->addTextCrumb( 56 + $blog->getName(), 57 + $this->getApplicationURI('blog/view/'.$blog->getID().'/')); 58 + $crumbs->addTextCrumb(pht('Preview Post'), $view_uri); 59 + 60 + return $this->newPage() 61 + ->setTitle(pht('Preview Post')) 62 + ->setCrumbs($crumbs) 63 + ->appendChild( 64 + array( 65 + $form_box, 66 + $frame, 67 + )); 68 + } 69 + 70 + private function renderPreviewFrame(PhamePost $post) { 71 + 72 + return phutil_tag( 73 + 'div', 74 + array( 75 + 'style' => 'text-align: center; padding: 16px;', 76 + ), 77 + phutil_tag( 78 + 'iframe', 79 + array( 80 + 'style' => 'width: 100%; height: 800px; '. 81 + 'border: 1px solid #BFCFDA; '. 82 + 'background-color: #fff; '. 83 + 'border-radius: 3px; ', 84 + 'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), 85 + ), 86 + '')); 87 + } 88 + 89 + }
+11 -43
src/applications/phame/controller/post/PhamePostPublishController.php
··· 18 18 return new Aphront404Response(); 19 19 } 20 20 21 - $view_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); 22 - 23 21 if ($request->isFormPost()) { 24 22 $xactions = array(); 25 23 $xactions[] = id(new PhamePostTransaction()) ··· 33 31 ->setContinueOnMissingFields(true) 34 32 ->applyTransactions($post, $xactions); 35 33 36 - return id(new AphrontRedirectResponse())->setURI($view_uri); 34 + return id(new AphrontRedirectResponse()) 35 + ->setURI($this->getApplicationURI('/post/view/'.$post->getID().'/')); 37 36 } 38 37 39 - $form = id(new AphrontFormView()) 40 - ->setUser($viewer) 41 - ->appendChild( 42 - id(new AphrontFormSubmitControl()) 43 - ->setValue(pht('Publish Post')) 44 - ->addCancelButton($view_uri)); 38 + $cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); 45 39 46 - $frame = $this->renderPreviewFrame($post); 47 - 48 - $form_box = id(new PHUIObjectBoxView()) 49 - ->setHeaderText(pht('Preview Post')) 50 - ->setForm($form); 51 - 52 - $crumbs = $this->buildApplicationCrumbs(); 53 - $crumbs->addTextCrumb(pht('Preview'), $view_uri); 54 - 55 - return $this->newPage() 56 - ->setTitle(pht('Preview Post')) 57 - ->setCrumbs($crumbs) 40 + $dialog = $this->newDialog() 41 + ->setTitle(pht('Publish Post?')) 58 42 ->appendChild( 59 - array( 60 - $form_box, 61 - $frame, 62 - )); 63 - } 64 - 65 - private function renderPreviewFrame(PhamePost $post) { 43 + pht( 44 + 'The post "%s" will go live once you publish it.', 45 + $post->getTitle())) 46 + ->addSubmitButton(pht('Publish')) 47 + ->addCancelButton($cancel_uri); 66 48 67 - return phutil_tag( 68 - 'div', 69 - array( 70 - 'style' => 'text-align: center; padding: 16px;', 71 - ), 72 - phutil_tag( 73 - 'iframe', 74 - array( 75 - 'style' => 'width: 100%; height: 600px; '. 76 - 'border: 1px solid #BFCFDA; '. 77 - 'background-color: #fff; '. 78 - 'border-radius: 3px; ', 79 - 'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), 80 - ), 81 - '')); 49 + return id(new AphrontDialogResponse())->setDialog($dialog); 82 50 } 83 51 84 52 }
+1 -2
src/applications/phame/controller/post/PhamePostUnpublishController.php
··· 37 37 38 38 $cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); 39 39 40 - $dialog = id(new AphrontDialogView()) 41 - ->setUser($viewer) 40 + $dialog = $this->newDialog() 42 41 ->setTitle(pht('Unpublish Post?')) 43 42 ->appendChild( 44 43 pht(
+9 -2
src/applications/phame/controller/post/PhamePostViewController.php
··· 63 63 ->appendChild( 64 64 pht( 65 65 'Only you can see this draft until you publish it. '. 66 - 'Use "Preview / Publish" to publish this post.'))); 66 + 'Use "Preview or Publish" to publish this post.'))); 67 67 } 68 68 69 69 if (!$post->getBlog()) { ··· 150 150 ->setIcon('fa-eye') 151 151 ->setHref($this->getApplicationURI('post/publish/'.$id.'/')) 152 152 ->setDisabled(!$can_edit) 153 - ->setName(pht('Preview / Publish'))); 153 + ->setName(pht('Publish')) 154 + ->setWorkflow(true)); 155 + $actions->addAction( 156 + id(new PhabricatorActionView()) 157 + ->setIcon('fa-eye') 158 + ->setHref($this->getApplicationURI('post/preview/'.$id.'/')) 159 + ->setDisabled(!$can_edit) 160 + ->setName(pht('Preview in Skin'))); 154 161 } else { 155 162 $actions->addAction( 156 163 id(new PhabricatorActionView())
+13
src/applications/phame/editor/PhamePostEditor.php
··· 209 209 210 210 $body = parent::buildMailBody($object, $xactions); 211 211 212 + // We don't send mail if the object is a draft, and we only want 213 + // to include the full body of the post on the either the 214 + // first creation or if it was created as a draft, once it goes live. 212 215 if ($this->getIsNewObject()) { 213 216 $body->addRemarkupSection(null, $object->getBody()); 217 + } else { 218 + foreach ($xactions as $xaction) { 219 + switch ($xaction->getTransactionType()) { 220 + case PhamePostTransaction::TYPE_VISIBILITY: 221 + if (!$object->isDraft()) { 222 + $body->addRemarkupSection(null, $object->getBody()); 223 + } 224 + break; 225 + } 226 + } 214 227 } 215 228 216 229 $body->addLinkSection(
+1 -4
src/applications/phame/storage/PhamePostTransaction.php
··· 206 206 } 207 207 208 208 if (strlen($text)) { 209 - return phutil_escape_html_newlines( 210 - id(new PhutilUTF8StringTruncator()) 211 - ->setMaximumGlyphs(128) 212 - ->truncateString($text)); 209 + return PhabricatorMarkupEngine::summarize($text); 213 210 } 214 211 215 212 return parent::getBodyForFeed($story);