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

Simplify and generalize remarkup engine construction

Summary:
Depends on D6395.

- Now that inline rules have explicit priorities, they can just go in applications in all cases.
- We don't need the inline rule conditionals anymore after D6395.

Test Plan: Wrote remarkup with mentions, phriction links, countdowns, etc.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+43 -20
+6
src/applications/countdown/application/PhabricatorApplicationCountdown.php
··· 29 29 return self::GROUP_UTILITIES; 30 30 } 31 31 32 + public function getRemarkupRules() { 33 + return array( 34 + new PhabricatorCountdownRemarkupRule(), 35 + ); 36 + } 37 + 32 38 public function getRoutes() { 33 39 return array( 34 40 '/countdown/' => array(
+6
src/applications/diviner/application/PhabricatorApplicationDiviner.php
··· 39 39 return self::GROUP_COMMUNICATION; 40 40 } 41 41 42 + public function getRemarkupRules() { 43 + return array( 44 + new DivinerRemarkupRuleSymbol(), 45 + ); 46 + } 47 + 42 48 public function buildMainMenuItems( 43 49 PhabricatorUser $user, 44 50 PhabricatorController $controller = null) {
+7
src/applications/files/application/PhabricatorApplicationFiles.php
··· 34 34 return false; 35 35 } 36 36 37 + public function getRemarkupRules() { 38 + return array( 39 + new PhabricatorRemarkupRuleEmbedFile(), 40 + ); 41 + } 42 + 43 + 37 44 public function getRoutes() { 38 45 return array( 39 46 '/F(?P<id>[1-9]\d*)' => 'PhabricatorFileShortcutController',
+6
src/applications/people/application/PhabricatorApplicationPeople.php
··· 54 54 ); 55 55 } 56 56 57 + public function getRemarkupRules() { 58 + return array( 59 + new PhabricatorRemarkupRuleMention(), 60 + ); 61 + } 62 + 57 63 public function buildMainMenuItems( 58 64 PhabricatorUser $user, 59 65 PhabricatorController $controller = null) {
+6
src/applications/phriction/application/PhabricatorApplicationPhriction.php
··· 22 22 return "\xE2\x9A\xA1"; 23 23 } 24 24 25 + public function getRemarkupRules() { 26 + return array( 27 + new PhrictionRemarkupRule(), 28 + ); 29 + } 30 + 25 31 public function getRoutes() { 26 32 return array( 27 33 // Match "/w/" with slug "/".
+9 -3
src/applications/phriction/remarkup/PhrictionRemarkupRule.php
··· 6 6 final class PhrictionRemarkupRule 7 7 extends PhutilRemarkupRule { 8 8 9 + public function getPriority() { 10 + return 350.0; 11 + } 12 + 9 13 public function apply($text) { 10 14 return preg_replace_callback( 11 15 '@\B\\[\\[([^|\\]]+)(?:\\|([^\\]]+))?\\]\\]\B@U', ··· 17 21 18 22 $link = trim($matches[1]); 19 23 $name = trim(idx($matches, 2, $link)); 20 - $name = explode('/', trim($name, '/')); 21 - $name = end($name); 24 + if (empty($matches[2])) { 25 + $name = explode('/', trim($name, '/')); 26 + $name = end($name); 27 + } 22 28 23 29 $uri = new PhutilURI($link); 24 30 $slug = $uri->getPath(); 25 31 $fragment = $uri->getFragment(); 26 32 $slug = PhabricatorSlug::normalize($slug); 27 33 $slug = PhrictionDocument::getSlugURI($slug); 28 - $href = (string) id(new PhutilURI($slug))->setFragment($fragment); 34 + $href = (string)id(new PhutilURI($slug))->setFragment($fragment); 29 35 30 36 if ($this->getEngine()->getState('toc')) { 31 37 $text = $name;
+3 -17
src/infrastructure/markup/PhabricatorMarkupEngine.php
··· 457 457 } 458 458 459 459 $rules[] = new PhutilRemarkupRuleHyperlink(); 460 - $rules[] = new PhrictionRemarkupRule(); 461 - 462 - $rules[] = new PhabricatorRemarkupRuleEmbedFile(); 463 - $rules[] = new PhabricatorCountdownRemarkupRule(); 464 460 465 461 if ($options['macros']) { 466 462 $rules[] = new PhabricatorRemarkupRuleImageMacro(); 467 463 $rules[] = new PhabricatorRemarkupRuleMeme(); 468 464 } 469 465 470 - $rules[] = new DivinerRemarkupRuleSymbol(); 471 - 472 - $rules[] = new PhabricatorRemarkupRuleMention(); 473 - 474 466 $rules[] = new PhutilRemarkupRuleBold(); 475 467 $rules[] = new PhutilRemarkupRuleItalic(); 476 468 $rules[] = new PhutilRemarkupRuleDel(); ··· 485 477 $blocks[] = new PhutilRemarkupEngineRemarkupNoteBlockRule(); 486 478 $blocks[] = new PhutilRemarkupEngineRemarkupTableBlockRule(); 487 479 $blocks[] = new PhutilRemarkupEngineRemarkupSimpleTableBlockRule(); 488 - $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule(); 489 480 490 481 $custom_block_rule_classes = $options['custom-block']; 491 482 if ($custom_block_rule_classes) { ··· 494 485 } 495 486 } 496 487 488 + $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule(); 489 + 497 490 foreach ($blocks as $block) { 498 - if ($block instanceof PhutilRemarkupEngineRemarkupLiteralBlockRule) { 499 - $literal_rules = array(); 500 - $literal_rules[] = new PhutilRemarkupRuleLinebreaks(); 501 - $block->setMarkupRules($literal_rules); 502 - } else if ( 503 - !($block instanceof PhutilRemarkupEngineRemarkupCodeBlockRule)) { 504 - $block->setMarkupRules($rules); 505 - } 491 + $block->setMarkupRules($rules); 506 492 } 507 493 508 494 $engine->setBlockRules($blocks);