mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-04 20:01:00 +01:00
Implement text mode for Phabricator Remarkup rules
Test Plan: lang=remarkup D1 {D1} {C1} {F1} [[ Test ]] iiam {meme, src=iiam, above="I\'m not always", below="But I am"} @{function:pht} @vrana Reviewers: epriestley, edward Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2617 Differential Revision: https://secure.phabricator.com/D5392
This commit is contained in:
parent
c81592bf5c
commit
efe0c135fe
9 changed files with 73 additions and 15 deletions
|
@ -19,9 +19,19 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
|
||||||
if (!$countdown) {
|
if (!$countdown) {
|
||||||
return $matches[0];
|
return $matches[0];
|
||||||
}
|
}
|
||||||
$id = celerity_generate_unique_node_id();
|
|
||||||
|
|
||||||
$engine = $this->getEngine();
|
$engine = $this->getEngine();
|
||||||
|
|
||||||
|
if ($engine->isTextMode()) {
|
||||||
|
$date = $countdown->getDatepoint();
|
||||||
|
$viewer = $engine->getConfig('viewer');
|
||||||
|
if ($viewer) {
|
||||||
|
$date = phabricator_datetime($date, $viewer);
|
||||||
|
}
|
||||||
|
return $engine->storeText($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = celerity_generate_unique_node_id();
|
||||||
$token = $engine->storeText('');
|
$token = $engine->storeText('');
|
||||||
|
|
||||||
$metadata_key = self::KEY_RULE_COUNTDOWN;
|
$metadata_key = self::KEY_RULE_COUNTDOWN;
|
||||||
|
|
|
@ -100,14 +100,20 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
|
||||||
$href = $renderer->getHrefForAtomRef($ref);
|
$href = $renderer->getHrefForAtomRef($ref);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Here, we're generating commment text or something like that. Just
|
// Here, we're generating comment text or something like that. Just
|
||||||
// link to Diviner and let it sort things out.
|
// link to Diviner and let it sort things out.
|
||||||
|
|
||||||
$href = id(new PhutilURI('/diviner/find/'))
|
$href = id(new PhutilURI('/diviner/find/'))
|
||||||
->setQueryParams($ref_dict + array('jump' => true));
|
->setQueryParams($ref_dict + array('jump' => true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($href) {
|
if ($this->getEngine()->isTextMode()) {
|
||||||
|
if ($href) {
|
||||||
|
$link = $title.' <'.PhabricatorEnv::getProductionURI($href).'>';
|
||||||
|
} else {
|
||||||
|
$link = $title;
|
||||||
|
}
|
||||||
|
} else if ($href) {
|
||||||
$link = phutil_tag(
|
$link = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -27,9 +27,15 @@ final class PhabricatorRemarkupRuleEmbedFile
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return $matches[0];
|
return $matches[0];
|
||||||
}
|
}
|
||||||
$phid = $file->getPHID();
|
|
||||||
|
|
||||||
$engine = $this->getEngine();
|
$engine = $this->getEngine();
|
||||||
|
|
||||||
|
if ($engine->isTextMode()) {
|
||||||
|
return $engine->storeText($file->getBestURI());
|
||||||
|
}
|
||||||
|
|
||||||
|
$phid = $file->getPHID();
|
||||||
|
|
||||||
$token = $engine->storeText('');
|
$token = $engine->storeText('');
|
||||||
$metadata_key = self::KEY_RULE_EMBED_FILE;
|
$metadata_key = self::KEY_RULE_EMBED_FILE;
|
||||||
$metadata = $engine->getTextMetadata($metadata_key, array());
|
$metadata = $engine->getTextMetadata($metadata_key, array());
|
||||||
|
|
|
@ -35,6 +35,14 @@ final class PhabricatorRemarkupRuleImageMacro
|
||||||
$phid = $this->images[$name];
|
$phid = $this->images[$name];
|
||||||
|
|
||||||
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid);
|
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid);
|
||||||
|
|
||||||
|
if ($this->getEngine()->isTextMode()) {
|
||||||
|
if ($file) {
|
||||||
|
$name .= ' <'.$file->getBestURI().'>';
|
||||||
|
}
|
||||||
|
return $this->getEngine()->storeText($name);
|
||||||
|
}
|
||||||
|
|
||||||
$style = null;
|
$style = null;
|
||||||
$src_uri = null;
|
$src_uri = null;
|
||||||
if ($file) {
|
if ($file) {
|
||||||
|
|
|
@ -30,11 +30,18 @@ final class PhabricatorRemarkupRuleMeme
|
||||||
->alter('uppertext', $options['above'])
|
->alter('uppertext', $options['above'])
|
||||||
->alter('lowertext', $options['below']);
|
->alter('lowertext', $options['below']);
|
||||||
|
|
||||||
$img = phutil_tag(
|
if ($this->getEngine()->isTextMode()) {
|
||||||
'img',
|
$img =
|
||||||
array(
|
($options['above'] != '' ? "\"{$options['above']}\"\n" : '').
|
||||||
'src' => (string)$uri,
|
$options['src'].' <'.PhabricatorEnv::getProductionURI($uri).'>'.
|
||||||
));
|
($options['below'] != '' ? "\n\"{$options['below']}\"" : '');
|
||||||
|
} else {
|
||||||
|
$img = phutil_tag(
|
||||||
|
'img',
|
||||||
|
array(
|
||||||
|
'src' => (string)$uri,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getEngine()->storeText($img);
|
return $this->getEngine()->storeText($img);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,11 @@ final class PhabricatorRemarkupRuleMention
|
||||||
|
|
||||||
protected function markupMention($matches) {
|
protected function markupMention($matches) {
|
||||||
$engine = $this->getEngine();
|
$engine = $this->getEngine();
|
||||||
|
|
||||||
|
if ($engine->isTextMode()) {
|
||||||
|
return $engine->storeText($matches[0]);
|
||||||
|
}
|
||||||
|
|
||||||
$token = $engine->storeText('');
|
$token = $engine->storeText('');
|
||||||
|
|
||||||
// Store the original text exactly so we can preserve casing if it doesn't
|
// Store the original text exactly so we can preserve casing if it doesn't
|
||||||
|
|
|
@ -29,14 +29,16 @@ final class PhrictionRemarkupRule
|
||||||
|
|
||||||
if ($this->getEngine()->getState('toc')) {
|
if ($this->getEngine()->getState('toc')) {
|
||||||
$text = $name;
|
$text = $name;
|
||||||
|
} else if ($this->getEngine()->isTextMode()) {
|
||||||
|
return PhabricatorEnv::getProductionURI($href);
|
||||||
} else {
|
} else {
|
||||||
$text = phutil_tag(
|
$text = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $href,
|
'href' => $href,
|
||||||
'class' => 'phriction-link',
|
'class' => 'phriction-link',
|
||||||
),
|
),
|
||||||
$name);
|
$name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getEngine()->storeText($text);
|
return $this->getEngine()->storeText($text);
|
||||||
|
|
|
@ -50,6 +50,10 @@ abstract class PhabricatorRemarkupRuleObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->getEngine()->isTextMode()) {
|
||||||
|
return PhabricatorEnv::getProductionURI($href);
|
||||||
|
}
|
||||||
|
|
||||||
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
|
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
|
||||||
|
|
||||||
$attr = array(
|
$attr = array(
|
||||||
|
@ -63,6 +67,11 @@ abstract class PhabricatorRemarkupRuleObject
|
||||||
protected function renderObjectEmbed($object, $handle, $options) {
|
protected function renderObjectEmbed($object, $handle, $options) {
|
||||||
$name = $handle->getFullName();
|
$name = $handle->getFullName();
|
||||||
$href = $handle->getURI();
|
$href = $handle->getURI();
|
||||||
|
|
||||||
|
if ($this->getEngine()->isTextMode()) {
|
||||||
|
return $name.' <'.PhabricatorEnv::getProductionURI($href).'>';
|
||||||
|
}
|
||||||
|
|
||||||
$attr = array(
|
$attr = array(
|
||||||
'phid' => $handle->getPHID(),
|
'phid' => $handle->getPHID(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -20,6 +20,11 @@ final class PhabricatorRemarkupRuleYoutube
|
||||||
|
|
||||||
public function markupYoutubeLink() {
|
public function markupYoutubeLink() {
|
||||||
$v = idx($this->uri->getQueryParams(), 'v');
|
$v = idx($this->uri->getQueryParams(), 'v');
|
||||||
|
|
||||||
|
if ($this->getEngine()->isTextMode()) {
|
||||||
|
return $this->getEngine()->storeText('http://youtu.be/'.$v);
|
||||||
|
}
|
||||||
|
|
||||||
$youtube_src = 'https://www.youtube.com/embed/'.$v;
|
$youtube_src = 'https://www.youtube.com/embed/'.$v;
|
||||||
$iframe = hsprintf(
|
$iframe = hsprintf(
|
||||||
'<div class="embedded-youtube-video">%s</div>',
|
'<div class="embedded-youtube-video">%s</div>',
|
||||||
|
|
Loading…
Reference in a new issue