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

Cache the Releeph project edit page's help remarkup

Summary: I wrote some of the Releeph-project edit-page's help in remarkup. This renders the remarkup using the `PhabricatorMarkupEngine` pipeline.

Test Plan:
* Edit a Releeph project.
* Feel the cool base of a laptop whose CPU is no longer being thrashed by onerous remarkup rendering duties.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3098

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

+84 -60
+4 -7
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 - $markup_engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 256 - 257 - // From DifferentialUnitFieldSpecification... 258 - $markup_engine->setConfig('viewer', $request->getUser()); 259 - 260 255 $help_markup = phutil_tag( 261 256 'div', 262 257 array( 263 258 'class' => 'phabricator-remarkup', 264 259 ), 265 - phutil_safe_html( 266 - $markup_engine->markupText(ReleephBranchTemplate::getHelpRemarkup()))); 260 + PhabricatorMarkupEngine::renderOneObject( 261 + new ReleephBranchTemplate(), 262 + 'field', 263 + $request->getUser())); 267 264 268 265 $branch_template_input = id(new AphrontFormTextControl()) 269 266 ->setName('branchTemplate')
+80 -53
src/applications/releeph/view/branch/ReleephBranchTemplate.php
··· 1 1 <?php 2 2 3 - final class ReleephBranchTemplate { 3 + final class ReleephBranchTemplate 4 + implements PhabricatorMarkupInterface { 4 5 5 6 const KEY = 'releeph.default-branch-template'; 6 7 ··· 75 76 } 76 77 } 77 78 78 - public static function getHelpRemarkup() { 79 - return <<<EOTEXT 80 - 81 - ==== Interpolations ==== 82 - 83 - | Code | Meaning 84 - | ----- | ------- 85 - | `%P` | The name of your project, with spaces changed to "-". 86 - | `%p` | Like %P, but all lowercase. 87 - | `%Y` | The four digit year associated with the branch date. 88 - | `%m` | The two digit month. 89 - | `%d` | The two digit day. 90 - | `%v` | The handle of the commit where the branch was cut ("rXYZa4b3c2d1"). 91 - | `%V` | The abbreviated commit id where the branch was cut ("a4b3c2d1"). 92 - | `%..` | Any other sequence interpreted by `strftime()`. 93 - | `%%` | A literal percent sign. 94 - 95 - 96 - ==== Tips for Branch Templates ==== 97 - 98 - Use a directory to separate your release branches from other branches: 99 - 100 - lang=none 101 - releases/%Y-%M-%d-%v 102 - => releases/2012-30-16-rHERGE32cd512a52b7 103 - 104 - Include a second hierarchy if you share your repository with other projects: 105 - 106 - lang=none 107 - releases/%P/%p-release-%Y%m%d-%V 108 - => releases/Tintin/tintin-release-20121116-32cd512a52b7 109 - 110 - Keep your branch names simple, avoiding strange punctuation, most of which is 111 - forbidden or escaped anyway: 112 - 113 - lang=none, counterexample 114 - releases//..clown-releases..//`date --iso=seconds`-$(sudo halt) 115 - 116 - Include the date early in your template, in an order which sorts properly: 117 - 118 - lang=none 119 - releases/%Y%m%d-%v 120 - => releases/20121116-rHERGE32cd512a52b7 (good!) 121 - 122 - releases/%V-%m.%d.%Y 123 - => releases/32cd512a52b7-11.16.2012 (awful!) 124 - 125 - 126 - EOTEXT 127 - ; 128 - } 129 - 130 79 /* 131 80 * xsprintf() would be useful here, but that's for formatting concrete lists 132 81 * of things in a certain way... ··· 236 185 } 237 186 238 187 return $errors; 188 + } 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 + ; 239 266 } 240 267 241 268 }