mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 17:30:59 +01:00
Link "DNNNN" and "TNNNN" in Phabricator remarkup.
Summary: Autolink Differential and Maniphest objects. Test Plan: Typed "D12345" and "T12345" into the Differential comment preview, got links. Typed "http://www.elsewhere.com/D12345" and got a single link to that URI, not a mess where the D12345 part linked incorrectly. Reviewers: aran CC: Differential Revision: 35
This commit is contained in:
parent
1bb055d163
commit
8784b5bd3b
8 changed files with 110 additions and 0 deletions
|
@ -220,6 +220,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleEditController' => 'applications/people/controller/edit',
|
||||
'PhabricatorPeopleListController' => 'applications/people/controller/list',
|
||||
'PhabricatorPeopleProfileController' => 'applications/people/controller/profile',
|
||||
'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/remarkup/markuprule/differential',
|
||||
'PhabricatorRemarkupRuleManiphest' => 'infrastructure/markup/remarkup/markuprule/maniphest',
|
||||
'PhabricatorStandardPageView' => 'view/page/standard',
|
||||
'PhabricatorTypeaheadCommonDatasourceController' => 'applications/typeahead/controller/common',
|
||||
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/base',
|
||||
|
@ -417,6 +419,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleEditController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorPeopleListController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorRemarkupRuleDifferential' => 'PhutilRemarkupRule',
|
||||
'PhabricatorRemarkupRuleManiphest' => 'PhutilRemarkupRule',
|
||||
'PhabricatorStandardPageView' => 'AphrontPageView',
|
||||
'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
|
||||
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/console/plugin/base');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
|
|
@ -24,6 +24,10 @@ class DifferentialMarkupEngineFactory {
|
|||
$rules = array();
|
||||
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
|
||||
$rules[] = new PhutilRemarkupRuleHyperlink();
|
||||
|
||||
$rules[] = new PhabricatorRemarkupRuleDifferential();
|
||||
$rules[] = new PhabricatorRemarkupRuleManiphest();
|
||||
|
||||
$rules[] = new PhutilRemarkupRuleEscapeHTML();
|
||||
$rules[] = new PhutilRemarkupRuleMonospace();
|
||||
$rules[] = new PhutilRemarkupRuleBold();
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/differential');
|
||||
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/maniphest');
|
||||
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupcode');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupdefault');
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group markup
|
||||
*/
|
||||
class PhabricatorRemarkupRuleDifferential
|
||||
extends PhutilRemarkupRule {
|
||||
|
||||
public function apply($text) {
|
||||
return preg_replace_callback(
|
||||
'@\bD(\d+)\b@',
|
||||
array($this, 'markupDifferentialLink'),
|
||||
$text);
|
||||
}
|
||||
|
||||
public function markupDifferentialLink($matches) {
|
||||
return $this->getEngine()->storeText(
|
||||
'<a href="/D'.$matches[1].'">D'.$matches[1].'</a>');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRemarkupRuleDifferential.php');
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group markup
|
||||
*/
|
||||
class PhabricatorRemarkupRuleManiphest
|
||||
extends PhutilRemarkupRule {
|
||||
|
||||
public function apply($text) {
|
||||
return preg_replace_callback(
|
||||
'@\bT(\d+)\b@',
|
||||
array($this, 'markupManiphestLink'),
|
||||
$text);
|
||||
}
|
||||
|
||||
public function markupManiphestLink($matches) {
|
||||
return $this->getEngine()->storeText(
|
||||
'<a href="/T'.$matches[1].'">T'.$matches[1].'</a>');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRemarkupRuleManiphest.php');
|
Loading…
Reference in a new issue