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

Provide a concrete class for one-off remarkup blocks

Summary: I want to use some of these for instructional text in Diffusion. Provide a concrete class to make one-offs cacheable and switch Releeph to use it.

Test Plan: {F44175}

Reviewers: btrahan, chad, edward

Reviewed By: btrahan

CC: aran

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

+116 -91
+2 -1
src/__phutil_library_map__.php
··· 1113 1113 'PhabricatorMarkupCache' => 'applications/cache/storage/PhabricatorMarkupCache.php', 1114 1114 'PhabricatorMarkupEngine' => 'infrastructure/markup/PhabricatorMarkupEngine.php', 1115 1115 'PhabricatorMarkupInterface' => 'infrastructure/markup/PhabricatorMarkupInterface.php', 1116 + 'PhabricatorMarkupOneOff' => 'infrastructure/markup/PhabricatorMarkupOneOff.php', 1116 1117 'PhabricatorMenuItemView' => 'view/layout/PhabricatorMenuItemView.php', 1117 1118 'PhabricatorMenuView' => 'view/layout/PhabricatorMenuView.php', 1118 1119 'PhabricatorMenuViewTestCase' => 'view/layout/__tests__/PhabricatorMenuViewTestCase.php', ··· 2890 2891 'PhabricatorManiphestConfigOptions' => 'PhabricatorApplicationConfigOptions', 2891 2892 'PhabricatorManiphestTaskTestDataGenerator' => 'PhabricatorTestDataGenerator', 2892 2893 'PhabricatorMarkupCache' => 'PhabricatorCacheDAO', 2894 + 'PhabricatorMarkupOneOff' => 'PhabricatorMarkupInterface', 2893 2895 'PhabricatorMenuItemView' => 'AphrontTagView', 2894 2896 'PhabricatorMenuView' => 'AphrontTagView', 2895 2897 'PhabricatorMenuViewTestCase' => 'PhabricatorTestCase', ··· 3558 3560 'ReleephBranchEditor' => 'PhabricatorEditor', 3559 3561 'ReleephBranchNamePreviewController' => 'PhabricatorController', 3560 3562 'ReleephBranchPreviewView' => 'AphrontFormControl', 3561 - 'ReleephBranchTemplate' => 'PhabricatorMarkupInterface', 3562 3563 'ReleephBranchViewController' => 'ReleephController', 3563 3564 'ReleephCommitFinderException' => 'Exception', 3564 3565 'ReleephCommitMessageFieldSpecification' => 'ReleephFieldSpecification',
+55 -9
src/applications/releeph/controller/project/ReleephProjectEditController.php
··· 252 252 $commit_author_inset = $this->buildCommitAuthorInset($commit_author); 253 253 254 254 // Build the Template inset 255 - $help_markup = phutil_tag( 256 - 'div', 257 - array( 258 - 'class' => 'phabricator-remarkup', 259 - ), 260 - PhabricatorMarkupEngine::renderOneObject( 261 - new ReleephBranchTemplate(), 262 - 'field', 263 - $request->getUser())); 255 + $help_markup = PhabricatorMarkupEngine::renderOneObject( 256 + id(new PhabricatorMarkupOneOff())->setContent($this->getBranchHelpText()), 257 + 'default', 258 + $request->getUser()); 264 259 265 260 $branch_template_input = id(new AphrontFormTextControl()) 266 261 ->setName('branchTemplate') ··· 382 377 ->setTitle(pht('Authors')) 383 378 ->appendChild($help_markup) 384 379 ->appendChild($control); 380 + } 381 + 382 + private function getBranchHelpText() { 383 + return <<<EOTEXT 384 + 385 + ==== Interpolations ==== 386 + 387 + | Code | Meaning 388 + | ----- | ------- 389 + | `%P` | The name of your project, with spaces changed to "-". 390 + | `%p` | Like %P, but all lowercase. 391 + | `%Y` | The four digit year associated with the branch date. 392 + | `%m` | The two digit month. 393 + | `%d` | The two digit day. 394 + | `%v` | The handle of the commit where the branch was cut ("rXYZa4b3c2d1"). 395 + | `%V` | The abbreviated commit id where the branch was cut ("a4b3c2d1"). 396 + | `%..` | Any other sequence interpreted by `strftime()`. 397 + | `%%` | A literal percent sign. 398 + 399 + 400 + ==== Tips for Branch Templates ==== 401 + 402 + Use a directory to separate your release branches from other branches: 403 + 404 + lang=none 405 + releases/%Y-%M-%d-%v 406 + => releases/2012-30-16-rHERGE32cd512a52b7 407 + 408 + Include a second hierarchy if you share your repository with other projects: 409 + 410 + lang=none 411 + releases/%P/%p-release-%Y%m%d-%V 412 + => releases/Tintin/tintin-release-20121116-32cd512a52b7 413 + 414 + Keep your branch names simple, avoiding strange punctuation, most of which is 415 + forbidden or escaped anyway: 416 + 417 + lang=none, counterexample 418 + releases//..clown-releases..//`date --iso=seconds`-$(sudo halt) 419 + 420 + Include the date early in your template, in an order which sorts properly: 421 + 422 + lang=none 423 + releases/%Y%m%d-%v 424 + => releases/20121116-rHERGE32cd512a52b7 (good!) 425 + 426 + releases/%V-%m.%d.%Y 427 + => releases/32cd512a52b7-11.16.2012 (awful!) 428 + 429 + 430 + EOTEXT; 385 431 } 386 432 387 433 }
+1 -81
src/applications/releeph/view/branch/ReleephBranchTemplate.php
··· 1 1 <?php 2 2 3 - final class ReleephBranchTemplate 4 - implements PhabricatorMarkupInterface { 3 + final class ReleephBranchTemplate { 5 4 6 5 const KEY = 'releeph.default-branch-template'; 7 6 ··· 186 185 187 186 return $errors; 188 187 } 189 - 190 - /* -( Help Text and Markup Interface )------------------------------------- */ 191 - 192 - public function getMarkupFieldKey($field) { 193 - $text = $this->getMarkupText($field); 194 - return sprintf( 195 - '%s:%s', 196 - get_class($this), 197 - PhabricatorHash::digest($text)); 198 - } 199 - 200 - public function newMarkupEngine($field) { 201 - return PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 202 - } 203 - 204 - public function didMarkupText( 205 - $field, 206 - $output, 207 - PhutilMarkupEngine $engine) { 208 - 209 - return $output; 210 - } 211 - 212 - public function shouldUseMarkupCache($field) { 213 - return true; 214 - } 215 - 216 - public function getMarkupText($field) { 217 - return <<<EOTEXT 218 - 219 - ==== Interpolations ==== 220 - 221 - | Code | Meaning 222 - | ----- | ------- 223 - | `%P` | The name of your project, with spaces changed to "-". 224 - | `%p` | Like %P, but all lowercase. 225 - | `%Y` | The four digit year associated with the branch date. 226 - | `%m` | The two digit month. 227 - | `%d` | The two digit day. 228 - | `%v` | The handle of the commit where the branch was cut ("rXYZa4b3c2d1"). 229 - | `%V` | The abbreviated commit id where the branch was cut ("a4b3c2d1"). 230 - | `%..` | Any other sequence interpreted by `strftime()`. 231 - | `%%` | A literal percent sign. 232 - 233 - 234 - ==== Tips for Branch Templates ==== 235 - 236 - Use a directory to separate your release branches from other branches: 237 - 238 - lang=none 239 - releases/%Y-%M-%d-%v 240 - => releases/2012-30-16-rHERGE32cd512a52b7 241 - 242 - Include a second hierarchy if you share your repository with other projects: 243 - 244 - lang=none 245 - releases/%P/%p-release-%Y%m%d-%V 246 - => releases/Tintin/tintin-release-20121116-32cd512a52b7 247 - 248 - Keep your branch names simple, avoiding strange punctuation, most of which is 249 - forbidden or escaped anyway: 250 - 251 - lang=none, counterexample 252 - releases//..clown-releases..//`date --iso=seconds`-$(sudo halt) 253 - 254 - Include the date early in your template, in an order which sorts properly: 255 - 256 - lang=none 257 - releases/%Y%m%d-%v 258 - => releases/20121116-rHERGE32cd512a52b7 (good!) 259 - 260 - releases/%V-%m.%d.%Y 261 - => releases/32cd512a52b7-11.16.2012 (awful!) 262 - 263 - 264 - EOTEXT 265 - ; 266 - } 267 - 268 188 }
+58
src/infrastructure/markup/PhabricatorMarkupOneOff.php
··· 1 + <?php 2 + 3 + /** 4 + * Concrete object for accessing the markup engine with arbitrary blobs of 5 + * text, like form instructions. Usage: 6 + * 7 + * $output = PhabricatorMarkupEngine::renderOneObject( 8 + * id(new PhabricatorMarkupOneOff())->setContent($some_content), 9 + * 'default', 10 + * $viewer); 11 + * 12 + * This is less efficient than batching rendering, but appropriate for small 13 + * amounts of one-off text in form instructions. 14 + */ 15 + final class PhabricatorMarkupOneOff implements PhabricatorMarkupInterface { 16 + 17 + private $content; 18 + 19 + public function setContent($content) { 20 + $this->content = $content; 21 + return $this; 22 + } 23 + 24 + public function getContent() { 25 + return $this->content; 26 + } 27 + 28 + public function getMarkupFieldKey($field) { 29 + return PhabricatorHash::digestForIndex($this->getContent()).':oneoff'; 30 + } 31 + 32 + public function newMarkupEngine($field) { 33 + return PhabricatorMarkupEngine::newMarkupEngine(array()); 34 + } 35 + 36 + public function getMarkupText($field) { 37 + return $this->getContent(); 38 + } 39 + 40 + public function didMarkupText( 41 + $field, 42 + $output, 43 + PhutilMarkupEngine $engine) { 44 + 45 + require_celerity_resource('phabricator-remarkup-css'); 46 + return phutil_tag( 47 + 'div', 48 + array( 49 + 'class' => 'phabricator-remarkup', 50 + ), 51 + $output); 52 + } 53 + 54 + public function shouldUseMarkupCache($field) { 55 + return true; 56 + } 57 + 58 + }