mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
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
This commit is contained in:
parent
cbd3c0b7ac
commit
48b7539d7d
2 changed files with 84 additions and 60 deletions
|
@ -252,18 +252,15 @@ final class ReleephProjectEditController extends ReleephController {
|
|||
$commit_author_inset = $this->buildCommitAuthorInset($commit_author);
|
||||
|
||||
// Build the Template inset
|
||||
$markup_engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
|
||||
|
||||
// From DifferentialUnitFieldSpecification...
|
||||
$markup_engine->setConfig('viewer', $request->getUser());
|
||||
|
||||
$help_markup = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-remarkup',
|
||||
),
|
||||
phutil_safe_html(
|
||||
$markup_engine->markupText(ReleephBranchTemplate::getHelpRemarkup())));
|
||||
PhabricatorMarkupEngine::renderOneObject(
|
||||
new ReleephBranchTemplate(),
|
||||
'field',
|
||||
$request->getUser()));
|
||||
|
||||
$branch_template_input = id(new AphrontFormTextControl())
|
||||
->setName('branchTemplate')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class ReleephBranchTemplate {
|
||||
final class ReleephBranchTemplate
|
||||
implements PhabricatorMarkupInterface {
|
||||
|
||||
const KEY = 'releeph.default-branch-template';
|
||||
|
||||
|
@ -75,58 +76,6 @@ final class ReleephBranchTemplate {
|
|||
}
|
||||
}
|
||||
|
||||
public static function getHelpRemarkup() {
|
||||
return <<<EOTEXT
|
||||
|
||||
==== Interpolations ====
|
||||
|
||||
| Code | Meaning
|
||||
| ----- | -------
|
||||
| `%P` | The name of your project, with spaces changed to "-".
|
||||
| `%p` | Like %P, but all lowercase.
|
||||
| `%Y` | The four digit year associated with the branch date.
|
||||
| `%m` | The two digit month.
|
||||
| `%d` | The two digit day.
|
||||
| `%v` | The handle of the commit where the branch was cut ("rXYZa4b3c2d1").
|
||||
| `%V` | The abbreviated commit id where the branch was cut ("a4b3c2d1").
|
||||
| `%..` | Any other sequence interpreted by `strftime()`.
|
||||
| `%%` | A literal percent sign.
|
||||
|
||||
|
||||
==== Tips for Branch Templates ====
|
||||
|
||||
Use a directory to separate your release branches from other branches:
|
||||
|
||||
lang=none
|
||||
releases/%Y-%M-%d-%v
|
||||
=> releases/2012-30-16-rHERGE32cd512a52b7
|
||||
|
||||
Include a second hierarchy if you share your repository with other projects:
|
||||
|
||||
lang=none
|
||||
releases/%P/%p-release-%Y%m%d-%V
|
||||
=> releases/Tintin/tintin-release-20121116-32cd512a52b7
|
||||
|
||||
Keep your branch names simple, avoiding strange punctuation, most of which is
|
||||
forbidden or escaped anyway:
|
||||
|
||||
lang=none, counterexample
|
||||
releases//..clown-releases..//`date --iso=seconds`-$(sudo halt)
|
||||
|
||||
Include the date early in your template, in an order which sorts properly:
|
||||
|
||||
lang=none
|
||||
releases/%Y%m%d-%v
|
||||
=> releases/20121116-rHERGE32cd512a52b7 (good!)
|
||||
|
||||
releases/%V-%m.%d.%Y
|
||||
=> releases/32cd512a52b7-11.16.2012 (awful!)
|
||||
|
||||
|
||||
EOTEXT
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
* xsprintf() would be useful here, but that's for formatting concrete lists
|
||||
* of things in a certain way...
|
||||
|
@ -238,4 +187,82 @@ EOTEXT
|
|||
return $errors;
|
||||
}
|
||||
|
||||
/* -( Help Text and Markup Interface )------------------------------------- */
|
||||
|
||||
public function getMarkupFieldKey($field) {
|
||||
$text = $this->getMarkupText($field);
|
||||
return sprintf(
|
||||
'%s:%s',
|
||||
get_class($this),
|
||||
PhabricatorHash::digest($text));
|
||||
}
|
||||
|
||||
public function newMarkupEngine($field) {
|
||||
return PhabricatorMarkupEngine::newDifferentialMarkupEngine();
|
||||
}
|
||||
|
||||
public function didMarkupText(
|
||||
$field,
|
||||
$output,
|
||||
PhutilMarkupEngine $engine) {
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function shouldUseMarkupCache($field) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMarkupText($field) {
|
||||
return <<<EOTEXT
|
||||
|
||||
==== Interpolations ====
|
||||
|
||||
| Code | Meaning
|
||||
| ----- | -------
|
||||
| `%P` | The name of your project, with spaces changed to "-".
|
||||
| `%p` | Like %P, but all lowercase.
|
||||
| `%Y` | The four digit year associated with the branch date.
|
||||
| `%m` | The two digit month.
|
||||
| `%d` | The two digit day.
|
||||
| `%v` | The handle of the commit where the branch was cut ("rXYZa4b3c2d1").
|
||||
| `%V` | The abbreviated commit id where the branch was cut ("a4b3c2d1").
|
||||
| `%..` | Any other sequence interpreted by `strftime()`.
|
||||
| `%%` | A literal percent sign.
|
||||
|
||||
|
||||
==== Tips for Branch Templates ====
|
||||
|
||||
Use a directory to separate your release branches from other branches:
|
||||
|
||||
lang=none
|
||||
releases/%Y-%M-%d-%v
|
||||
=> releases/2012-30-16-rHERGE32cd512a52b7
|
||||
|
||||
Include a second hierarchy if you share your repository with other projects:
|
||||
|
||||
lang=none
|
||||
releases/%P/%p-release-%Y%m%d-%V
|
||||
=> releases/Tintin/tintin-release-20121116-32cd512a52b7
|
||||
|
||||
Keep your branch names simple, avoiding strange punctuation, most of which is
|
||||
forbidden or escaped anyway:
|
||||
|
||||
lang=none, counterexample
|
||||
releases//..clown-releases..//`date --iso=seconds`-$(sudo halt)
|
||||
|
||||
Include the date early in your template, in an order which sorts properly:
|
||||
|
||||
lang=none
|
||||
releases/%Y%m%d-%v
|
||||
=> releases/20121116-rHERGE32cd512a52b7 (good!)
|
||||
|
||||
releases/%V-%m.%d.%Y
|
||||
=> releases/32cd512a52b7-11.16.2012 (awful!)
|
||||
|
||||
|
||||
EOTEXT
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue