@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 comments to internal Phame Posts

Summary: Adds commenting to Phame Posts, also testing a new "document comment style". Unsure about it but Phame is a prototype so good place to explore.

Test Plan: Leave some comments, see some comments, test show/hide.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9746

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

+198 -2
+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' => '414406b5', 129 - 'rsrc/css/phui/phui-document-pro.css' => '4f2b42e3', 129 + 'rsrc/css/phui/phui-document-pro.css' => '7f3009ce', 130 130 'rsrc/css/phui/phui-document.css' => 'f841ad0a', 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' => '414406b5', 783 783 'phui-document-view-css' => 'f841ad0a', 784 - 'phui-document-view-pro-css' => '4f2b42e3', 784 + 'phui-document-view-pro-css' => '7f3009ce', 785 785 'phui-feed-story-css' => 'b7b26d23', 786 786 'phui-font-icon-base-css' => 'ecbbb4c2', 787 787 'phui-fontkit-css' => 'c9d63950',
+18
resources/sql/autopatches/20151109.phame.post.comments.1.sql
··· 1 + CREATE TABLE {$NAMESPACE}_phame.phame_posttransaction_comment ( 2 + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 3 + phid VARCHAR(64) NOT NULL, 4 + transactionPHID VARCHAR(64), 5 + authorPHID VARCHAR(64) NOT NULL, 6 + viewPolicy VARCHAR(64) NOT NULL, 7 + editPolicy VARCHAR(64) NOT NULL, 8 + commentVersion INT UNSIGNED NOT NULL, 9 + content LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, 10 + contentSource LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, 11 + isDeleted BOOL NOT NULL, 12 + dateCreated INT UNSIGNED NOT NULL, 13 + dateModified INT UNSIGNED NOT NULL, 14 + 15 + UNIQUE KEY `key_phid` (phid), 16 + UNIQUE KEY `key_version` (transactionPHID, commentVersion) 17 + 18 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+4
src/__phutil_library_map__.php
··· 3273 3273 'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php', 3274 3274 'PhameDAO' => 'applications/phame/storage/PhameDAO.php', 3275 3275 'PhamePost' => 'applications/phame/storage/PhamePost.php', 3276 + 'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php', 3276 3277 'PhamePostController' => 'applications/phame/controller/post/PhamePostController.php', 3277 3278 'PhamePostDeleteController' => 'applications/phame/controller/post/PhamePostDeleteController.php', 3278 3279 'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php', ··· 3287 3288 'PhamePostReplyHandler' => 'applications/phame/mail/PhamePostReplyHandler.php', 3288 3289 'PhamePostSearchEngine' => 'applications/phame/query/PhamePostSearchEngine.php', 3289 3290 'PhamePostTransaction' => 'applications/phame/storage/PhamePostTransaction.php', 3291 + 'PhamePostTransactionComment' => 'applications/phame/storage/PhamePostTransactionComment.php', 3290 3292 'PhamePostTransactionQuery' => 'applications/phame/query/PhamePostTransactionQuery.php', 3291 3293 'PhamePostUnpublishController' => 'applications/phame/controller/post/PhamePostUnpublishController.php', 3292 3294 'PhamePostView' => 'applications/phame/view/PhamePostView.php', ··· 7552 7554 'PhabricatorSubscribableInterface', 7553 7555 'PhabricatorTokenReceiverInterface', 7554 7556 ), 7557 + 'PhamePostCommentController' => 'PhamePostController', 7555 7558 'PhamePostController' => 'PhameController', 7556 7559 'PhamePostDeleteController' => 'PhamePostController', 7557 7560 'PhamePostEditController' => 'PhamePostController', ··· 7566 7569 'PhamePostReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 7567 7570 'PhamePostSearchEngine' => 'PhabricatorApplicationSearchEngine', 7568 7571 'PhamePostTransaction' => 'PhabricatorApplicationTransaction', 7572 + 'PhamePostTransactionComment' => 'PhabricatorApplicationTransactionComment', 7569 7573 'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7570 7574 'PhamePostUnpublishController' => 'PhamePostController', 7571 7575 'PhamePostView' => 'AphrontView',
+1
src/applications/phame/application/PhabricatorPhameApplication.php
··· 54 54 'framed/(?P<id>\d+)/' => 'PhamePostFramedController', 55 55 'new/' => 'PhamePostNewController', 56 56 'move/(?P<id>\d+)/' => 'PhamePostNewController', 57 + 'comment/(?P<id>[1-9]\d*)/' => 'PhamePostCommentController', 57 58 ), 58 59 'blog/' => array( 59 60 '(?:(?P<filter>user|all)/)?' => 'PhameBlogListController',
+63
src/applications/phame/controller/post/PhamePostCommentController.php
··· 1 + <?php 2 + 3 + final class PhamePostCommentController 4 + extends PhamePostController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 9 + 10 + if (!$request->isFormPost()) { 11 + return new Aphront400Response(); 12 + } 13 + 14 + $post = id(new PhamePostQuery()) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 17 + ->executeOne(); 18 + if (!$post) { 19 + return new Aphront404Response(); 20 + } 21 + 22 + $is_preview = $request->isPreviewRequest(); 23 + $draft = PhabricatorDraft::buildFromRequest($request); 24 + 25 + $view_uri = $this->getApplicationURI('post/view/'.$post->getID().'/'); 26 + 27 + $xactions = array(); 28 + $xactions[] = id(new PhamePostTransaction()) 29 + ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 30 + ->attachComment( 31 + id(new PhamePostTransactionComment()) 32 + ->setContent($request->getStr('comment'))); 33 + 34 + $editor = id(new PhamePostEditor()) 35 + ->setActor($viewer) 36 + ->setContinueOnNoEffect($request->isContinueRequest()) 37 + ->setContentSourceFromRequest($request) 38 + ->setIsPreview($is_preview); 39 + 40 + try { 41 + $xactions = $editor->applyTransactions($post, $xactions); 42 + } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 43 + return id(new PhabricatorApplicationTransactionNoEffectResponse()) 44 + ->setCancelURI($view_uri) 45 + ->setException($ex); 46 + } 47 + 48 + if ($draft) { 49 + $draft->replaceOrDelete(); 50 + } 51 + 52 + if ($request->isAjax() && $is_preview) { 53 + return id(new PhabricatorApplicationTransactionResponse()) 54 + ->setViewer($viewer) 55 + ->setTransactions($xactions) 56 + ->setIsPreview($is_preview); 57 + } else { 58 + return id(new AphrontRedirectResponse()) 59 + ->setURI($view_uri); 60 + } 61 + } 62 + 63 + }
+34
src/applications/phame/controller/post/PhamePostViewController.php
··· 81 81 ), 82 82 $engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY))); 83 83 84 + $timeline = $this->buildTransactionTimeline( 85 + $post, 86 + id(new PhamePostTransactionQuery()) 87 + ->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); 88 + $timeline = phutil_tag_div('phui-document-view-pro-box', $timeline); 89 + 90 + $add_comment = $this->buildCommentForm($post); 91 + 84 92 return $this->newPage() 85 93 ->setTitle($post->getTitle()) 86 94 ->addClass('pro-white-background') 95 + ->setPageObjectPHIDs(array($post->getPHID())) 87 96 ->setCrumbs($crumbs) 88 97 ->appendChild( 89 98 array( 90 99 $document, 100 + $timeline, 101 + $add_comment, 91 102 )); 92 103 } 93 104 ··· 195 206 $properties->invokeWillRenderEvent(); 196 207 197 208 return $properties; 209 + } 210 + 211 + private function buildCommentForm(PhamePost $post) { 212 + $viewer = $this->getViewer(); 213 + 214 + $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 215 + 216 + $add_comment_header = $is_serious 217 + ? pht('Add Comment') 218 + : pht('Derp Text'); 219 + 220 + $draft = PhabricatorDraft::newFromUserAndKey( 221 + $viewer, $post->getPHID()); 222 + 223 + $box = id(new PhabricatorApplicationTransactionCommentView()) 224 + ->setUser($viewer) 225 + ->setObjectPHID($post->getPHID()) 226 + ->setDraft($draft) 227 + ->setHeaderText($add_comment_header) 228 + ->setAction($this->getApplicationURI('post/comment/'.$post->getID().'/')) 229 + ->setSubmitButtonName(pht('Add Comment')); 230 + 231 + return phutil_tag_div('phui-document-view-pro-box', $box); 198 232 } 199 233 200 234 }
+1
src/applications/phame/editor/PhamePostEditor.php
··· 18 18 $types[] = PhamePostTransaction::TYPE_PHAME_TITLE; 19 19 $types[] = PhamePostTransaction::TYPE_BODY; 20 20 $types[] = PhamePostTransaction::TYPE_VISIBILITY; 21 + $types[] = PhabricatorTransactions::TYPE_COMMENT; 21 22 22 23 return $types; 23 24 }
+4
src/applications/phame/storage/PhamePostTransaction.php
··· 20 20 return PhabricatorPhamePostPHIDType::TYPECONST; 21 21 } 22 22 23 + public function getApplicationTransactionCommentObject() { 24 + return new PhamePostTransactionComment(); 25 + } 26 + 23 27 public function getRemarkupBlocks() { 24 28 $blocks = parent::getRemarkupBlocks(); 25 29
+10
src/applications/phame/storage/PhamePostTransactionComment.php
··· 1 + <?php 2 + 3 + final class PhamePostTransactionComment 4 + extends PhabricatorApplicationTransactionComment { 5 + 6 + public function getApplicationTransactionObject() { 7 + return new PhamePostTransaction(); 8 + } 9 + 10 + }
+61
webroot/rsrc/css/phui/phui-document-pro.css
··· 112 112 .phui-document-view-pro .phui-info-view { 113 113 margin: 16px 0 0 0; 114 114 } 115 + 116 + 117 + 118 + 119 + .phui-document-view-pro-box .phui-timeline-view { 120 + padding: 0; 121 + background: none; 122 + } 123 + 124 + .phui-document-view-pro-box .phui-timeline-image { 125 + border-radius: 25px; 126 + } 127 + 128 + .phui-document-view-pro-box .phui-timeline-wedge { 129 + display: none; 130 + } 131 + 132 + .phui-document-view-pro-box .phui-timeline-major-event .phui-timeline-group { 133 + border: none; 134 + } 135 + 136 + .phui-document-view-pro-box .phui-timeline-major-event .phui-timeline-content { 137 + border: none; 138 + } 139 + 140 + .device-desktop .phui-document-view-pro-box 141 + .phui-timeline-event-view.phui-timeline-minor-event { 142 + margin-left: 62px; 143 + } 144 + 145 + .phui-document-view-pro-box .phui-timeline-title { 146 + border-radius: 3px; 147 + background-color: {$lightgreybackground}; 148 + } 149 + 150 + .phui-document-view-pro-box .phui-timeline-title-with-icon { 151 + padding-left: 12px; 152 + } 153 + 154 + .phui-document-view-pro-box .phui-timeline-icon-fill { 155 + display: none; 156 + } 157 + 158 + .phui-document-view-pro-box .phui-timeline-major-event .phui-timeline-content 159 + .phui-timeline-core-content { 160 + padding-bottom: 24px; 161 + } 162 + 163 + .phui-document-view-pro-box .phui-object-box { 164 + background-color: {$lightgreybackground}; 165 + border: none; 166 + margin: 0; 167 + } 168 + 169 + .phui-document-view-pro-box .phui-object-box .phui-form-view { 170 + padding-bottom: 0; 171 + } 172 + 173 + .phui-document-view-pro-box .phui-object-box .remarkup-assist-textarea { 174 + height: 9em; 175 + }