1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 15:00:58 +01:00

Generalize the markup engine factory

Summary:
This thing services every app but it lives inside Differential right now. Pull
it out, and separate the factory interfaces per-application.

This will let us accommodate changes we need to make for Phriction to support
wiki linking.

Test Plan: Tested remarkup in differential, diffusion, maniphest, people,
slowvote.
Reviewed By: hsb
Reviewers: hsb, codeblock, jungejason, tuomaspelkonen, aran
CC: aran, hsb
Differential Revision: 646
This commit is contained in:
epriestley 2011-07-11 15:58:32 -07:00
parent 6bdbf3c8c2
commit a49138defd
31 changed files with 81 additions and 56 deletions

View file

@ -159,7 +159,6 @@ phutil_register_library_map(array(
'DifferentialInlineCommentView' => 'applications/differential/view/inlinecomment', 'DifferentialInlineCommentView' => 'applications/differential/view/inlinecomment',
'DifferentialLintStatus' => 'applications/differential/constants/lintstatus', 'DifferentialLintStatus' => 'applications/differential/constants/lintstatus',
'DifferentialMail' => 'applications/differential/mail/base', 'DifferentialMail' => 'applications/differential/mail/base',
'DifferentialMarkupEngineFactory' => 'applications/differential/parser/markup',
'DifferentialNewDiffMail' => 'applications/differential/mail/newdiff', 'DifferentialNewDiffMail' => 'applications/differential/mail/newdiff',
'DifferentialPrimaryPaneView' => 'applications/differential/view/primarypane', 'DifferentialPrimaryPaneView' => 'applications/differential/view/primarypane',
'DifferentialReplyHandler' => 'applications/differential/replyhandler', 'DifferentialReplyHandler' => 'applications/differential/replyhandler',
@ -392,6 +391,7 @@ phutil_register_library_map(array(
'PhabricatorMailImplementationSendGridAdapter' => 'applications/metamta/adapter/sendgrid', 'PhabricatorMailImplementationSendGridAdapter' => 'applications/metamta/adapter/sendgrid',
'PhabricatorMailImplementationTestAdapter' => 'applications/metamta/adapter/test', 'PhabricatorMailImplementationTestAdapter' => 'applications/metamta/adapter/test',
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/base', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/base',
'PhabricatorMarkupEngine' => 'applications/markup/engine',
'PhabricatorMetaMTAController' => 'applications/metamta/controller/base', 'PhabricatorMetaMTAController' => 'applications/metamta/controller/base',
'PhabricatorMetaMTADAO' => 'applications/metamta/storage/base', 'PhabricatorMetaMTADAO' => 'applications/metamta/storage/base',
'PhabricatorMetaMTADaemon' => 'applications/metamta/daemon/mta', 'PhabricatorMetaMTADaemon' => 'applications/metamta/daemon/mta',

View file

@ -179,8 +179,7 @@ class DifferentialChangesetViewController extends DifferentialController {
->loadHandles(); ->loadHandles();
$parser->setHandles($handles); $parser->setHandles($handles);
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$parser->setMarkupEngine($engine); $parser->setMarkupEngine($engine);
if ($request->isAjax()) { if ($request->isAjax()) {

View file

@ -14,12 +14,12 @@ phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'aphront/response/file'); phutil_require_module('phabricator', 'aphront/response/file');
phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/parser/changeset'); phutil_require_module('phabricator', 'applications/differential/parser/changeset');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/storage/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/changeset');
phutil_require_module('phabricator', 'applications/differential/storage/diff'); phutil_require_module('phabricator', 'applications/differential/storage/diff');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phabricator', 'applications/differential/view/changesetdetailview'); phutil_require_module('phabricator', 'applications/differential/view/changesetdetailview');
phutil_require_module('phabricator', 'applications/differential/view/primarypane'); phutil_require_module('phabricator', 'applications/differential/view/primarypane');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api');

View file

@ -33,8 +33,7 @@ class DifferentialCommentPreviewController extends DifferentialController {
$handles = id(new PhabricatorObjectHandleData(array($author_phid))) $handles = id(new PhabricatorObjectHandleData(array($author_phid)))
->loadHandles(); ->loadHandles();
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$comment = new DifferentialComment(); $comment = new DifferentialComment();
$comment->setContent($request->getStr('content')); $comment->setContent($request->getStr('content'));

View file

@ -8,10 +8,10 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/view/revisioncomment'); phutil_require_module('phabricator', 'applications/differential/view/revisioncomment');
phutil_require_module('phabricator', 'applications/draft/storage/draft'); phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -152,8 +152,7 @@ class DifferentialInlineCommentEditController extends DifferentialController {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$phids = array($user->getPHID()); $phids = array($user->getPHID());

View file

@ -9,11 +9,11 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'aphront/response/dialog'); phutil_require_module('phabricator', 'aphront/response/dialog');
phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/storage/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/changeset');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phabricator', 'applications/differential/storage/revision'); phutil_require_module('phabricator', 'applications/differential/storage/revision');
phutil_require_module('phabricator', 'applications/differential/view/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/view/inlinecomment');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'view/dialog'); phutil_require_module('phabricator', 'view/dialog');

View file

@ -39,8 +39,7 @@ class DifferentialInlineCommentPreviewController
$user->getPHID(), $user->getPHID(),
$this->revisionID); $this->revisionID);
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$phids = array($user->getPHID()); $phids = array($user->getPHID());
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))

View file

@ -8,9 +8,9 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phabricator', 'applications/differential/view/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/view/inlinecomment');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -343,7 +343,7 @@ class DifferentialCommentEditor {
foreach ($inline_comments as $inline) { foreach ($inline_comments as $inline) {
$content_blocks[] = $inline->getContent(); $content_blocks[] = $inline->getContent();
} }
$mention_ccs = DifferentialMarkupEngineFactory::extractPHIDsFromMentions( $mention_ccs = PhabricatorMarkupEngine::extractPHIDsFromMentions(
$content_blocks); $content_blocks);
if ($mention_ccs) { if ($mention_ccs) {
$current_ccs = $revision->getCCPHIDs(); $current_ccs = $revision->getCCPHIDs();

View file

@ -10,13 +10,13 @@ phutil_require_module('phabricator', 'applications/differential/constants/action
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/editor/revision'); phutil_require_module('phabricator', 'applications/differential/editor/revision');
phutil_require_module('phabricator', 'applications/differential/mail/comment'); phutil_require_module('phabricator', 'applications/differential/mail/comment');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/storage/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/changeset');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment');
phutil_require_module('phabricator', 'applications/feed/constants/story'); phutil_require_module('phabricator', 'applications/feed/constants/story');
phutil_require_module('phabricator', 'applications/feed/publisher'); phutil_require_module('phabricator', 'applications/feed/publisher');
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base'); phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/search/index/indexer/differential'); phutil_require_module('phabricator', 'applications/search/index/indexer/differential');
phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event'); phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event');

View file

@ -58,8 +58,7 @@ final class DifferentialRevisionCommentListView extends AphrontView {
require_celerity_resource('differential-revision-comment-list-css'); require_celerity_resource('differential-revision-comment-list-css');
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$inlines = mgroup($this->inlines, 'getCommentID'); $inlines = mgroup($this->inlines, 'getCommentID');

View file

@ -6,8 +6,8 @@
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/view/revisioncomment'); phutil_require_module('phabricator', 'applications/differential/view/revisioncomment');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'infrastructure/javelin/markup');

View file

@ -44,8 +44,7 @@ class DiffusionCommitController extends DiffusionController {
$commit_data = $drequest->loadCommitData(); $commit_data = $drequest->loadCommitData();
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
require_celerity_resource('diffusion-commit-view-css'); require_celerity_resource('diffusion-commit-view-css');
require_celerity_resource('phabricator-remarkup-css'); require_celerity_resource('phabricator-remarkup-css');

View file

@ -7,12 +7,12 @@
phutil_require_module('phabricator', 'applications/differential/constants/changetype'); phutil_require_module('phabricator', 'applications/differential/constants/changetype');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview'); phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');
phutil_require_module('phabricator', 'applications/diffusion/controller/base'); phutil_require_module('phabricator', 'applications/diffusion/controller/base');
phutil_require_module('phabricator', 'applications/diffusion/data/pathchange'); phutil_require_module('phabricator', 'applications/diffusion/data/pathchange');
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base'); phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable'); phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
phutil_require_module('phabricator', 'applications/repository/storage/repository'); phutil_require_module('phabricator', 'applications/repository/storage/repository');

View file

@ -47,8 +47,7 @@ class ManiphestTaskDescriptionChangeController extends ManiphestController {
} }
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newManiphestMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$view = new ManiphestTransactionDetailView(); $view = new ManiphestTransactionDetailView();
$view->setTransactionGroup($transactions); $view->setTransactionGroup($transactions);

View file

@ -8,10 +8,10 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/maniphest/controller/base'); phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/maniphest/view/transactiondetail'); phutil_require_module('phabricator', 'applications/maniphest/view/transactiondetail');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -73,8 +73,7 @@ class ManiphestTaskDetailController extends ManiphestController {
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles(); ->loadHandles();
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newManiphestMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$dict = array(); $dict = array();
$dict['Status'] = $dict['Status'] =

View file

@ -7,7 +7,6 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/draft/storage/draft'); phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
@ -17,6 +16,7 @@ phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist'); phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');

View file

@ -80,8 +80,7 @@ class ManiphestTransactionPreviewController extends ManiphestController {
$transactions = array(); $transactions = array();
$transactions[] = $transaction; $transactions[] = $transaction;
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newManiphestMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$transaction_view = new ManiphestTransactionListView(); $transaction_view = new ManiphestTransactionListView();
$transaction_view->setTransactions($transactions); $transaction_view->setTransactions($transactions);

View file

@ -8,13 +8,13 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/draft/storage/draft'); phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
phutil_require_module('phabricator', 'applications/maniphest/controller/base'); phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist'); phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -87,7 +87,7 @@ class ManiphestTransactionSaveController extends ManiphestController {
// Compute new CCs added by @mentions. We're going to try to add them to // Compute new CCs added by @mentions. We're going to try to add them to
// another CC transaction if we can. If there aren't any CC transactions, // another CC transaction if we can. If there aren't any CC transactions,
// we'll create a new CC transaction after we handle everything else. // we'll create a new CC transaction after we handle everything else.
$mention_ccs = DifferentialMarkupEngineFactory::extractPHIDsFromMentions( $mention_ccs = PhabricatorMarkupEngine::extractPHIDsFromMentions(
array( array(
$request->getStr('comments'), $request->getStr('comments'),
)); ));

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/draft/storage/draft'); phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/status');
@ -17,6 +16,7 @@ phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/editor/transaction'); phutil_require_module('phabricator', 'applications/maniphest/editor/transaction');
phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -16,13 +16,12 @@
* limitations under the License. * limitations under the License.
*/ */
class DifferentialMarkupEngineFactory { class PhabricatorMarkupEngine {
public static function extractPHIDsFromMentions(array $content_blocks) { public static function extractPHIDsFromMentions(array $content_blocks) {
$mentions = array(); $mentions = array();
$factory = new DifferentialMarkupEngineFactory(); $engine = self::newDifferentialMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
foreach ($content_blocks as $content_block) { foreach ($content_blocks as $content_block) {
$engine->markupText($content_block); $engine->markupText($content_block);
@ -35,21 +34,62 @@ class DifferentialMarkupEngineFactory {
return $mentions; return $mentions;
} }
public function newDifferentialCommentMarkupEngine() { public static function newManiphestMarkupEngine() {
return self::newMarkupEngine(array(
));
}
public static function newPhrictionMarkupEngine() {
return self::newMarkupEngine(array(
));
}
public static function newDifferentialMarkupEngine() {
return self::newMarkupEngine(array(
'custom-inline' => PhabricatorEnv::getEnvConfig(
'differential.custom-remarkup-rules'),
'custom-block' => PhabricatorEnv::getEnvConfig(
'differential.custom-remarkup-block-rules'),
));
}
public static function newProfileMarkupEngine() {
return self::newMarkupEngine(array(
));
}
public static function newSlowvoteMarkupEngine() {
return self::newMarkupEngine(array(
));
}
private static function getMarkupEngineDefaultConfiguration() {
return array(
'pygments' => PhabricatorEnv::getEnvConfig('pygments.enabled'),
'fileproxy' => PhabricatorEnv::getEnvConfig('files.enable-proxy'),
'youtube' => PhabricatorEnv::getEnvConfig(
'remarkup.enable-embedded-youtube'),
'custom-inline' => array(),
'custom-block' => array(),
);
}
private static function newMarkupEngine(array $options) {
$options += self::getMarkupEngineDefaultConfiguration();
$engine = new PhutilRemarkupEngine(); $engine = new PhutilRemarkupEngine();
$engine->setConfig('preserve-linebreaks', true); $engine->setConfig('preserve-linebreaks', true);
$engine->setConfig( $engine->setConfig('pygments.enabled', $options['pygments']);
'pygments.enabled',
PhabricatorEnv::getEnvConfig('pygments.enabled'));
$rules = array(); $rules = array();
$rules[] = new PhutilRemarkupRuleEscapeRemarkup(); $rules[] = new PhutilRemarkupRuleEscapeRemarkup();
if (PhabricatorEnv::getEnvConfig('files.enable-proxy')) { if ($options['fileproxy']) {
$rules[] = new PhabricatorRemarkupRuleProxyImage(); $rules[] = new PhabricatorRemarkupRuleProxyImage();
} }
if (PhabricatorEnv::getEnvConfig('remarkup.enable-embedded-youtube')) { if ($options['youtube']) {
$rules[] = new PhabricatorRemarkupRuleYoutube(); $rules[] = new PhabricatorRemarkupRuleYoutube();
} }
@ -62,8 +102,7 @@ class DifferentialMarkupEngineFactory {
$rules[] = new PhabricatorRemarkupRuleImageMacro(); $rules[] = new PhabricatorRemarkupRuleImageMacro();
$rules[] = new PhabricatorRemarkupRuleMention(); $rules[] = new PhabricatorRemarkupRuleMention();
$custom_rule_classes = $custom_rule_classes = $options['custom-inline'];
PhabricatorEnv::getEnvConfig('differential.custom-remarkup-rules');
if ($custom_rule_classes) { if ($custom_rule_classes) {
foreach ($custom_rule_classes as $custom_rule_class) { foreach ($custom_rule_classes as $custom_rule_class) {
PhutilSymbolLoader::loadClass($custom_rule_class); PhutilSymbolLoader::loadClass($custom_rule_class);
@ -76,7 +115,6 @@ class DifferentialMarkupEngineFactory {
$rules[] = new PhutilRemarkupRuleBold(); $rules[] = new PhutilRemarkupRuleBold();
$rules[] = new PhutilRemarkupRuleItalic(); $rules[] = new PhutilRemarkupRuleItalic();
$blocks = array(); $blocks = array();
$blocks[] = new PhutilRemarkupEngineRemarkupQuotesBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupQuotesBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupHeaderBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupHeaderBlockRule();
@ -84,8 +122,7 @@ class DifferentialMarkupEngineFactory {
$blocks[] = new PhutilRemarkupEngineRemarkupCodeBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupCodeBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule();
$custom_block_rule_classes = $custom_block_rule_classes = $options['custom-block'];
PhabricatorEnv::getEnvConfig('differential.custom-remarkup-block-rules');
if ($custom_block_rule_classes) { if ($custom_block_rule_classes) {
foreach ($custom_block_rule_classes as $custom_block_rule_class) { foreach ($custom_block_rule_classes as $custom_block_rule_class) {
PhutilSymbolLoader::loadClass($custom_block_rule_class); PhutilSymbolLoader::loadClass($custom_block_rule_class);

View file

@ -32,4 +32,4 @@ phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');
phutil_require_source('DifferentialMarkupEngineFactory.php'); phutil_require_source('PhabricatorMarkupEngine.php');

View file

@ -139,8 +139,7 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
$profile->getBlurb(), $profile->getBlurb(),
'//Nothing is known about this rare specimen.//'); '//Nothing is known about this rare specimen.//');
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$blurb = $engine->markupText($blurb); $blurb = $engine->markupText($blurb);
$content = $content =

View file

@ -8,8 +8,8 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/auth/oauth/provider/base'); phutil_require_module('phabricator', 'applications/auth/oauth/provider/base');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/people/controller/base'); phutil_require_module('phabricator', 'applications/people/controller/base');
phutil_require_module('phabricator', 'applications/people/storage/profile'); phutil_require_module('phabricator', 'applications/people/storage/profile');
phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/people/storage/user');

View file

@ -111,8 +111,7 @@ class PhabricatorProjectProfileController
$profile->getBlurb(), $profile->getBlurb(),
'//Nothing is known about this elusive project.//'); '//Nothing is known about this elusive project.//');
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$blurb = $engine->markupText($blurb); $blurb = $engine->markupText($blurb);
$affiliations = $project->loadAffiliations(); $affiliations = $project->loadAffiliations();

View file

@ -7,10 +7,10 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/maniphest/query'); phutil_require_module('phabricator', 'applications/maniphest/query');
phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary'); phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/project/constants/status'); phutil_require_module('phabricator', 'applications/project/constants/status');
phutil_require_module('phabricator', 'applications/project/controller/base'); phutil_require_module('phabricator', 'applications/project/controller/base');

View file

@ -207,8 +207,7 @@ class PhabricatorSlowvotePollController
private function renderComments(array $comments, array $handles) { private function renderComments(array $comments, array $handles) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
$factory = new DifferentialMarkupEngineFactory(); $engine = PhabricatorMarkupEngine::newSlowvoteMarkupEngine();
$engine = $factory->newDifferentialCommentMarkupEngine();
$comment_markup = array(); $comment_markup = array();
foreach ($comments as $comment) { foreach ($comments as $comment) {

View file

@ -8,8 +8,8 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/slowvote/controller/base'); phutil_require_module('phabricator', 'applications/slowvote/controller/base');
phutil_require_module('phabricator', 'applications/slowvote/storage/choice'); phutil_require_module('phabricator', 'applications/slowvote/storage/choice');