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

Differential comment previews.

+241 -23
+34 -15
src/__celerity_resource_map__.php
··· 27 27 ), 28 28 'aphront-panel-view-css' => 29 29 array( 30 - 'uri' => '/res/fe62e634/rsrc/css/aphront/panel-view.css', 30 + 'uri' => '/res/63672373/rsrc/css/aphront/panel-view.css', 31 31 'type' => 'css', 32 32 'requires' => 33 33 array( ··· 36 36 ), 37 37 'aphront-request-failure-view-css' => 38 38 array( 39 - 'uri' => '/res/d7df3b42/rsrc/css/aphront/request-failure-view.css', 39 + 'uri' => '/res/97b8337a/rsrc/css/aphront/request-failure-view.css', 40 40 'type' => 'css', 41 41 'requires' => 42 42 array( ··· 88 88 array( 89 89 ), 90 90 'disk' => '/rsrc/css/application/base/standard-page-view.css', 91 + ), 92 + 'differential-revision-add-comment-css' => 93 + array( 94 + 'uri' => '/res/623fef21/rsrc/css/application/differential/add-comment.css', 95 + 'type' => 'css', 96 + 'requires' => 97 + array( 98 + ), 99 + 'disk' => '/rsrc/css/application/differential/add-comment.css', 91 100 ), 92 101 'differential-changeset-view-css' => 93 102 array( ··· 207 216 ), 208 217 'disk' => '/rsrc/js/application/core/behavior-tokenizer.js', 209 218 ), 219 + 'javelin-behavior-differential-feedback-preview' => 220 + array( 221 + 'uri' => '/res/34fbb670/rsrc/js/application/differential/behavior-comment-preview.js', 222 + 'type' => 'js', 223 + 'requires' => 224 + array( 225 + 0 => 'javelin-lib-dev', 226 + ), 227 + 'disk' => '/rsrc/js/application/differential/behavior-comment-preview.js', 228 + ), 210 229 'javelin-behavior-differential-populate' => 211 230 array( 212 231 'uri' => '/res/9982573c/rsrc/js/application/differential/behavior-populate.js', ··· 274 293 ), array ( 275 294 'packages' => 276 295 array ( 277 - '364a306c' => 296 + 'd348c79d' => 278 297 array ( 279 298 'name' => 'core.pkg.css', 280 299 'symbols' => ··· 291 310 9 => 'aphront-typeahead-control-css', 292 311 10 => 'phabricator-directory-css', 293 312 ), 294 - 'uri' => '/res/pkg/364a306c/core.pkg.css', 313 + 'uri' => '/res/pkg/d348c79d/core.pkg.css', 295 314 'type' => 'css', 296 315 ), 297 316 '69b11588' => ··· 311 330 ), 312 331 'reverse' => 313 332 array ( 314 - 'phabricator-core-css' => '364a306c', 315 - 'phabricator-core-buttons-css' => '364a306c', 316 - 'phabricator-standard-page-view' => '364a306c', 317 - 'aphront-dialog-view-css' => '364a306c', 318 - 'aphront-form-view-css' => '364a306c', 319 - 'aphront-panel-view-css' => '364a306c', 320 - 'aphront-side-nav-view-css' => '364a306c', 321 - 'aphront-table-view-css' => '364a306c', 322 - 'aphront-tokenizer-control-css' => '364a306c', 323 - 'aphront-typeahead-control-css' => '364a306c', 324 - 'phabricator-directory-css' => '364a306c', 333 + 'phabricator-core-css' => 'd348c79d', 334 + 'phabricator-core-buttons-css' => 'd348c79d', 335 + 'phabricator-standard-page-view' => 'd348c79d', 336 + 'aphront-dialog-view-css' => 'd348c79d', 337 + 'aphront-form-view-css' => 'd348c79d', 338 + 'aphront-panel-view-css' => 'd348c79d', 339 + 'aphront-side-nav-view-css' => 'd348c79d', 340 + 'aphront-table-view-css' => 'd348c79d', 341 + 'aphront-tokenizer-control-css' => 'd348c79d', 342 + 'aphront-typeahead-control-css' => 'd348c79d', 343 + 'phabricator-directory-css' => 'd348c79d', 325 344 'differential-core-view-css' => '69b11588', 326 345 'differential-changeset-view-css' => '69b11588', 327 346 'differential-revision-detail-css' => '69b11588',
+2
src/__phutil_library_map__.php
··· 80 80 'DifferentialComment' => 'applications/differential/storage/comment', 81 81 'DifferentialCommentEditor' => 'applications/differential/editor/comment', 82 82 'DifferentialCommentMail' => 'applications/differential/mail/comment', 83 + 'DifferentialCommentPreviewController' => 'applications/differential/controller/commentpreview', 83 84 'DifferentialCommentSaveController' => 'applications/differential/controller/commentsave', 84 85 'DifferentialController' => 'applications/differential/controller/base', 85 86 'DifferentialDAO' => 'applications/differential/storage/base', ··· 253 254 'DifferentialChangesetViewController' => 'DifferentialController', 254 255 'DifferentialComment' => 'DifferentialDAO', 255 256 'DifferentialCommentMail' => 'DifferentialMail', 257 + 'DifferentialCommentPreviewController' => 'DifferentialController', 256 258 'DifferentialCommentSaveController' => 'DifferentialController', 257 259 'DifferentialController' => 'PhabricatorController', 258 260 'DifferentialDAO' => 'PhabricatorLiskDAO',
+1 -1
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 87 87 'revision/edit/(?:(?<id>\d+)/)?$' 88 88 => 'DifferentialRevisionEditController', 89 89 'comment/' => array( 90 - 'preview/$' => 'DifferentialCommentPreviewController', 90 + 'preview/(?<id>\d+)/$' => 'DifferentialCommentPreviewController', 91 91 'save/$' => 'DifferentialCommentSaveController', 92 92 'inline/' => array( 93 93 'preview/$' => 'DifferentialInlineCommentPreviewController',
+1
src/applications/conduit/method/differential/creatediff/__init__.php
··· 14 14 phutil_require_module('phabricator', 'applications/differential/constants/unitstatus'); 15 15 phutil_require_module('phabricator', 'applications/differential/storage/diff'); 16 16 phutil_require_module('phabricator', 'applications/differential/storage/revision'); 17 + phutil_require_module('phabricator', 'infrastructure/env'); 17 18 18 19 phutil_require_module('phutil', 'utils'); 19 20
+54
src/applications/differential/controller/commentpreview/DifferentialCommentPreviewController.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class DifferentialCommentPreviewController extends DifferentialController { 20 + 21 + private $id; 22 + 23 + public function willProcessRequest(array $data) { 24 + $this->id = $data['id']; 25 + } 26 + 27 + public function processRequest() { 28 + 29 + $request = $this->getRequest(); 30 + 31 + $author_phid = $request->getUser()->getPHID(); 32 + 33 + $handles = id(new PhabricatorObjectHandleData(array($author_phid))) 34 + ->loadHandles(); 35 + 36 + $factory = new DifferentialMarkupEngineFactory(); 37 + $engine = $factory->newDifferentialCommentMarkupEngine(); 38 + 39 + $comment = new DifferentialComment(); 40 + $comment->setContent($request->getStr('content')); 41 + $comment->setAction($request->getStr('action')); 42 + $comment->setAuthorPHID($author_phid); 43 + 44 + $view = new DifferentialRevisionCommentView(); 45 + $view->setComment($comment); 46 + $view->setHandles($handles); 47 + $view->setMarkupEngine($engine); 48 + $view->setPreview(true); 49 + 50 + return id(new AphrontAjaxResponse()) 51 + ->setContent($view->render()); 52 + } 53 + 54 + }
+19
src/applications/differential/controller/commentpreview/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'aphront/response/ajax'); 10 + phutil_require_module('phabricator', 'applications/differential/controller/base'); 11 + phutil_require_module('phabricator', 'applications/differential/parser/markup'); 12 + phutil_require_module('phabricator', 'applications/differential/storage/comment'); 13 + phutil_require_module('phabricator', 'applications/differential/view/revisioncomment'); 14 + phutil_require_module('phabricator', 'applications/phid/handle/data'); 15 + 16 + phutil_require_module('phutil', 'utils'); 17 + 18 + 19 + phutil_require_source('DifferentialCommentPreviewController.php');
+1
src/applications/differential/mail/base/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'applications/metamta/storage/mail'); 10 + phutil_require_module('phabricator', 'infrastructure/env'); 10 11 11 12 12 13 phutil_require_source('DifferentialMail.php');
+26 -3
src/applications/differential/view/addcomment/DifferentialAddCommentView.php
··· 42 42 } 43 43 44 44 public function render() { 45 + 46 + require_celerity_resource('differential-revision-add-comment-css'); 47 + 45 48 $revision = $this->revision; 46 49 47 50 $actions = array(); ··· 58 61 id(new AphrontFormSelectControl()) 59 62 ->setLabel('Action') 60 63 ->setName('action') 64 + ->setID('comment-action') 61 65 ->setOptions($actions)) 62 66 ->appendChild( 63 67 id(new AphrontFormTextAreaControl()) 64 68 ->setName('comment') 69 + ->setID('comment-content') 65 70 ->setLabel('Comment')) 66 71 ->appendChild( 67 72 id(new AphrontFormSubmitControl()) 68 73 ->setValue('Comment')); 69 74 75 + Javelin::initBehavior( 76 + 'differential-feedback-preview', 77 + array( 78 + 'uri' => '/differential/comment/preview/'.$revision->getID().'/', 79 + 'preview' => 'comment-preview', 80 + 'action' => 'comment-action', 81 + 'content' => 'comment-content', 82 + )); 83 + 70 84 return 71 - '<div class="differential-panel">'. 72 - '<h1>Add Comment</h1>'. 73 - $form->render(). 85 + '<div class="differential-add-comment-panel">'. 86 + '<div class="differential-panel">'. 87 + '<h1>Add Comment</h1>'. 88 + $form->render(). 89 + '</div>'. 90 + '<div class="differential-comment-preview">'. 91 + '<div id="comment-preview">'. 92 + '<span class="differential-loading-text">'. 93 + 'Loading comment preview...'. 94 + '</span>'. 95 + '</div>'. 96 + '</div>'. 74 97 '</div>'; 75 98 } 76 99 }
+2
src/applications/differential/view/addcomment/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'applications/differential/constants/action'); 10 + phutil_require_module('phabricator', 'infrastructure/celerity/api'); 11 + phutil_require_module('phabricator', 'infrastructure/javelin/api'); 10 12 phutil_require_module('phabricator', 'view/base'); 11 13 phutil_require_module('phabricator', 'view/form/base'); 12 14 phutil_require_module('phabricator', 'view/form/control/submit');
+13 -3
src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php
··· 21 21 private $comment; 22 22 private $handles; 23 23 private $markupEngine; 24 + private $preview; 24 25 25 26 public function setComment($comment) { 26 27 $this->comment = $comment; ··· 37 38 return $this; 38 39 } 39 40 41 + public function setPreview($preview) { 42 + $this->preview = $preview; 43 + return $this; 44 + } 45 + 40 46 public function render() { 41 47 42 48 require_celerity_resource('phabricator-remarkup-css'); ··· 48 54 49 55 $action_class = 'differential-comment-action-'.phutil_escape_html($action); 50 56 51 - $date = date('F jS, Y g:i:s A', $comment->getDateCreated()); 57 + if ($this->preview) { 58 + $date = 'COMMENT PREVIEW'; 59 + } else { 60 + $date = date('F jS, Y g:i:s A', $comment->getDateCreated()); 61 + } 52 62 53 63 $author = $this->handles[$comment->getAuthorPHID()]; 54 64 $author_link = $author->renderLink(); ··· 70 80 "<p>{$author_link} {$verb} this revision.</p>". 71 81 '</div>'; 72 82 } 73 - 83 + 74 84 $background = null; 75 85 $uri = $author->getImageURI(); 76 86 if ($uri) { 77 87 $background = "background-image: url('{$uri}');"; 78 - } 88 + } 79 89 80 90 return 81 91 '<div class="differential-comment '.$action_class.'">'.
+10
src/view/form/control/base/AphrontFormControl.php
··· 24 24 private $name; 25 25 private $value; 26 26 private $disabled; 27 + private $id; 28 + 29 + public function setID($id) { 30 + $this->id = $id; 31 + return $this; 32 + } 33 + 34 + public function getID() { 35 + return $this->id; 36 + } 27 37 28 38 public function setLabel($label) { 29 39 $this->label = $label;
+1
src/view/form/control/password/AphrontFormPasswordControl.php
··· 30 30 'name' => $this->getName(), 31 31 'value' => $this->getValue(), 32 32 'disabled' => $this->getDisabled() ? 'disabled' : null, 33 + 'id' => $this->getID(), 33 34 )); 34 35 } 35 36
+1
src/view/form/control/select/AphrontFormSelectControl.php
··· 50 50 array( 51 51 'name' => $this->getName(), 52 52 'disabled' => $this->getDisabled() ? 'disabled' : null, 53 + 'id' => $this->getID(), 53 54 ), 54 55 implode("\n", $options)); 55 56 }
+1
src/view/form/control/text/AphrontFormTextControl.php
··· 30 30 'name' => $this->getName(), 31 31 'value' => $this->getValue(), 32 32 'disabled' => $this->getDisabled() ? 'disabled' : null, 33 + 'id' => $this->getID(), 33 34 )); 34 35 } 35 36
+2 -1
src/view/form/control/textarea/AphrontFormTextAreaControl.php
··· 20 20 21 21 const HEIGHT_VERY_SHORT = 'very-short'; 22 22 const HEIGHT_SHORT = 'short'; 23 - 23 + 24 24 private $height; 25 25 26 26 public function setHeight($height) { ··· 48 48 'name' => $this->getName(), 49 49 'disabled' => $this->getDisabled() ? 'disabled' : null, 50 50 'class' => $height_class, 51 + 'id' => $this->getID(), 51 52 ), 52 53 phutil_escape_html($this->getValue())); 53 54 }
+23
webroot/rsrc/css/application/differential/add-comment.css
··· 1 + /** 2 + * @provides differential-revision-add-comment-css 3 + */ 4 + 5 + .differential-add-comment-panel .aphront-form-view { 6 + background: #fffff5; 7 + } 8 + 9 + .differential-add-comment-panel .differential-panel { 10 + margin-bottom: 0; 11 + } 12 + 13 + .differential-comment-preview { 14 + background: #f0f0f0; 15 + border-bottom: 1px solid #aaaaaa; 16 + margin-bottom: 2em; 17 + max-width: 1120px; 18 + padding: 15px 20px; 19 + } 20 + 21 + .differential-comment-preview .differential-loading-text { 22 + color: #aaaaaa; 23 + }
+50
webroot/rsrc/js/application/differential/behavior-comment-preview.js
··· 1 + /** 2 + * @provides javelin-behavior-differential-feedback-preview 3 + * @requires javelin-lib-dev 4 + */ 5 + 6 + JX.behavior('differential-feedback-preview', function(config) { 7 + 8 + var action = JX.$(config.action); 9 + var content = JX.$(config.content); 10 + var preview = JX.$(config.preview); 11 + 12 + var aval = null;//action.value; 13 + var cval = null;//content.value; 14 + var defer = null; 15 + var min = null; 16 + var request = null; 17 + 18 + function check() { 19 + if (request || (min && (new Date().getTime() < min))) { 20 + // Waiting on an async or just got one back, rate-limit. 21 + return; 22 + } 23 + 24 + defer && defer.stop(); 25 + 26 + if (action.value !== aval || content.value !== cval) { 27 + aval = action.value; 28 + cval = content.value; 29 + 30 + request = new JX.Request(config.uri, function(r) { 31 + preview && JX.DOM.setContent(preview, JX.HTML(r)); 32 + min = new Date().getTime() + 500; 33 + defer && defer.stop(); 34 + defer = JX.defer(check, 500); 35 + }); 36 + request.listen('finally', function() { request = null; }); 37 + request.setData({action : aval, content : cval}); 38 + // If we don't get a response back soon, retry on the next action. 39 + request.setTimeout(2000); 40 + request.send(); 41 + } else { 42 + defer = JX.defer(check, 2000); 43 + } 44 + } 45 + 46 + JX.DOM.listen(content, 'keydown', null, check); 47 + JX.DOM.listen(action, 'change', null, check); 48 + 49 + check(); 50 + });