@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 the markup pipeline in Releeph

Summary: Use a single `PhabricatorMarkupEngine` to render any markup in Releeph's fields, rather than rendering everything from scratch every time.

Test Plan: Check out the "Services" tab in the dark console when rendering a page on a branch page with 500x RQs!

Reviewers: wez, epriestley

Reviewed By: epriestley

CC: epriestley, aran

Maniphest Tasks: T3098

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

+110 -22
+16 -10
src/applications/releeph/field/specification/ReleephDiffMessageFieldSpecification.php
··· 12 12 } 13 13 14 14 public function renderValueForHeaderView() { 15 - $commit_data = $this 16 - ->getReleephRequest() 17 - ->loadPhabricatorRepositoryCommitData(); 18 - if (!$commit_data) { 19 - return ''; 20 - } 21 - 22 - $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 23 - $engine->setConfig('viewer', $this->getUser()); 24 15 $markup = phutil_tag( 25 16 'div', 26 17 array( 27 18 'class' => 'phabricator-remarkup', 28 19 ), 29 - $engine->markupText($commit_data->getCommitMessage())); 20 + $this->getMarkupEngineOutput()); 30 21 31 22 return id(new AphrontNoteView()) 32 23 ->setTitle('Commit Message') 33 24 ->appendChild($markup) 34 25 ->render(); 26 + } 27 + 28 + public function shouldMarkup() { 29 + return true; 30 + } 31 + 32 + public function getMarkupText($field) { 33 + $commit_data = $this 34 + ->getReleephRequest() 35 + ->loadPhabricatorRepositoryCommitData(); 36 + if ($commit_data) { 37 + return $commit_data->getCommitMessage(); 38 + } else { 39 + return ''; 40 + } 35 41 } 36 42 37 43 }
+60 -1
src/applications/releeph/field/specification/ReleephFieldSpecification.php
··· 1 1 <?php 2 2 3 - abstract class ReleephFieldSpecification { 3 + abstract class ReleephFieldSpecification 4 + implements PhabricatorMarkupInterface { 4 5 5 6 abstract public function getName(); 6 7 ··· 236 237 237 238 public function renderValueForRevertMessage() { 238 239 return $this->renderValueForCommitMessage(); 240 + } 241 + 242 + 243 + /* -( Markup Interface )--------------------------------------------------- */ 244 + 245 + const MARKUP_FIELD_GENERIC = 'releeph:generic-markup-field'; 246 + 247 + private $engine; 248 + 249 + /** 250 + * ReleephFieldSpecification implements much of PhabricatorMarkupInterface 251 + * for you. If you return true from `shouldMarkup()`, and implement 252 + * `getMarkupText()` then your text will be rendered through the Phabricator 253 + * markup pipeline. 254 + * 255 + * Output is retrievable with `getMarkupEngineOutput()`. 256 + */ 257 + public function shouldMarkup() { 258 + return false; 259 + } 260 + 261 + public function getMarkupText($field) { 262 + throw new ReleephFieldSpecificationIncompleteException($this); 263 + } 264 + 265 + final public function getMarkupEngineOutput() { 266 + return $this->engine->getOutput($this, self::MARKUP_FIELD_GENERIC); 267 + } 268 + 269 + final public function setMarkupEngine(PhabricatorMarkupEngine $engine) { 270 + $this->engine = $engine; 271 + $engine->addObject($this, self::MARKUP_FIELD_GENERIC); 272 + return $this; 273 + } 274 + 275 + final public function getMarkupFieldKey($field) { 276 + return sprintf( 277 + '%s:%s:%s:%s', 278 + $this->getReleephRequest()->getPHID(), 279 + $this->getStorageKey(), 280 + $field, 281 + PhabricatorHash::digest($this->getMarkupText($field))); 282 + } 283 + 284 + final public function newMarkupEngine($field) { 285 + return PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 286 + } 287 + 288 + final public function didMarkupText( 289 + $field, 290 + $output, 291 + PhutilMarkupEngine $engine) { 292 + 293 + return $output; 294 + } 295 + 296 + final public function shouldUseMarkupCache($field) { 297 + return true; 239 298 } 240 299 241 300
+14 -8
src/applications/releeph/field/specification/ReleephReasonFieldSpecification.php
··· 16 16 } 17 17 18 18 public function renderValueForHeaderView() { 19 - $reason = $this->getValue(); 20 - if (!$reason) { 21 - return ''; 22 - } 23 - 24 - $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 25 - $engine->setConfig('viewer', $this->getUser()); 26 19 $markup = phutil_tag( 27 20 'div', 28 21 array( 29 22 'class' => 'phabricator-remarkup', 30 23 ), 31 - $engine->markupText($reason)); 24 + $this->getMarkupEngineOutput()); 32 25 33 26 return id(new AphrontNoteView()) 34 27 ->setTitle('Reason') ··· 73 66 74 67 public function renderValueForCommitMessage() { 75 68 return $this->getValue(); 69 + } 70 + 71 + public function shouldMarkup() { 72 + return true; 73 + } 74 + 75 + public function getMarkupText($field) { 76 + $reason = $this->getValue(); 77 + if ($reason) { 78 + return $reason; 79 + } else { 80 + return ''; 81 + } 76 82 } 77 83 78 84 }
+20 -3
src/applications/releeph/view/request/header/ReleephRequestHeaderListView.php
··· 90 90 } 91 91 } 92 92 93 - $field_groups = $selector->arrangeFieldsForHeaderView($fields); 93 + $engine = id(new PhabricatorMarkupEngine()) 94 + ->setViewer($this->getUser()); 94 95 95 96 $views = array(); 96 97 foreach ($this->releephRequests as $releeph_request) { 98 + $our_fields = array(); 99 + foreach ($fields as $key => $field) { 100 + $our_fields[$key] = clone $field; 101 + } 102 + 103 + foreach ($our_fields as $field) { 104 + if ($field->shouldMarkup()) { 105 + $field 106 + ->setReleephRequest($releeph_request) 107 + ->setMarkupEngine($engine); 108 + } 109 + } 110 + 111 + $our_field_groups = $selector->arrangeFieldsForHeaderView($our_fields); 112 + 97 113 $views[] = id(new ReleephRequestHeaderView()) 98 114 ->setUser($this->user) 99 115 ->setAphrontRequest($this->aphrontRequest) ··· 101 117 ->setReleephProject($this->releephProject) 102 118 ->setReleephBranch($this->releephBranch) 103 119 ->setReleephRequest($releeph_request) 104 - ->setReleephFieldGroups($field_groups) 105 - ->render(); 120 + ->setReleephFieldGroups($our_field_groups); 106 121 } 122 + 123 + $engine->process(); 107 124 108 125 return $views; 109 126 }