From f447e5d7094650e95a1063f58ab7140c1b8bcc5a Mon Sep 17 00:00:00 2001 From: Emir Habul Date: Thu, 20 Oct 2011 09:41:38 -0700 Subject: [PATCH] Allow custom hyperlinks; Pass differential.diff-id into remarkup engine config Summary: This allows extensions to have more options for generating custom hyperlinks. Test Plan: custom-inline rules are moved before default rules. Test existing products which implement custom rules. Make sure you use "$this->getEngine()->storeText()" in rules. Reviewers: epriestley, jungejason Reviewed By: jungejason CC: aran, epriestley, emiraga, jungejason Differential Revision: 1024 --- .../DifferentialRevisionCommentListView.php | 4 +++- .../markup/engine/PhabricatorMarkupEngine.php | 22 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php index 7ccbcb66f0..d03486e94f 100644 --- a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php +++ b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php @@ -58,7 +58,9 @@ final class DifferentialRevisionCommentListView extends AphrontView { require_celerity_resource('differential-revision-comment-list-css'); - $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); + $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(array( + 'differential.diff' => $this->target + )); $inlines = mgroup($this->inlines, 'getCommentID'); diff --git a/src/applications/markup/engine/PhabricatorMarkupEngine.php b/src/applications/markup/engine/PhabricatorMarkupEngine.php index 788774bd6b..5a4624653f 100644 --- a/src/applications/markup/engine/PhabricatorMarkupEngine.php +++ b/src/applications/markup/engine/PhabricatorMarkupEngine.php @@ -48,12 +48,13 @@ class PhabricatorMarkupEngine { )); } - public static function newDifferentialMarkupEngine() { + public static function newDifferentialMarkupEngine(array $options = array()) { return self::newMarkupEngine(array( 'custom-inline' => PhabricatorEnv::getEnvConfig( 'differential.custom-remarkup-rules'), 'custom-block' => PhabricatorEnv::getEnvConfig( 'differential.custom-remarkup-block-rules'), + 'differential.diff' => idx($options, 'differential.diff'), )); } @@ -75,6 +76,7 @@ class PhabricatorMarkupEngine { 'remarkup.enable-embedded-youtube'), 'custom-inline' => array(), 'custom-block' => array(), + 'differential.diff' => null, 'macros' => true, 'uri.allowed-protocols' => PhabricatorEnv::getEnvConfig( 'uri.allowed-protocols'), @@ -92,9 +94,19 @@ class PhabricatorMarkupEngine { $engine->setConfig( 'uri.allowed-protocols', $options['uri.allowed-protocols']); + $engine->setConfig('differential.diff', $options['differential.diff']); $rules = array(); $rules[] = new PhutilRemarkupRuleEscapeRemarkup(); + + $custom_rule_classes = $options['custom-inline']; + if ($custom_rule_classes) { + foreach ($custom_rule_classes as $custom_rule_class) { + PhutilSymbolLoader::loadClass($custom_rule_class); + $rules[] = newv($custom_rule_class, array()); + } + } + if ($options['fileproxy']) { $rules[] = new PhabricatorRemarkupRuleProxyImage(); } @@ -122,14 +134,6 @@ class PhabricatorMarkupEngine { $rules[] = new PhabricatorRemarkupRuleMention(); - $custom_rule_classes = $options['custom-inline']; - if ($custom_rule_classes) { - foreach ($custom_rule_classes as $custom_rule_class) { - PhutilSymbolLoader::loadClass($custom_rule_class); - $rules[] = newv($custom_rule_class, array()); - } - } - $rules[] = new PhutilRemarkupRuleEscapeHTML(); $rules[] = new PhutilRemarkupRuleMonospace(); $rules[] = new PhutilRemarkupRuleBold();