1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 20:40:56 +01:00

Support processing Remarkup in bulk with remarkup.processbulk Conduit method

Summary: This adds support for a Conduit method to process Remarkup content in bulk.  It also updates the `getEngineContexts` methods to support any missing contexts.

Test Plan: Ran the command and processed a few sets of text.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4046

Differential Revision: https://secure.phabricator.com/D7479
This commit is contained in:
James Rhodes 2013-11-02 16:30:04 -07:00 committed by epriestley
parent 7498aec194
commit 10a9f6501f

View file

@ -27,12 +27,12 @@ final class ConduitAPI_remarkup_process_Method extends ConduitAPIMethod {
return array(
'context' => 'required enum<'.$available_contexts.'>',
'content' => 'required string',
'contents' => 'required list<string>',
);
}
protected function execute(ConduitAPIRequest $request) {
$content = $request->getValue('content');
$contents = $request->getValue('contents');
$context = $request->getValue('context');
$engine_class = idx($this->getEngineContexts(), $context);
@ -43,18 +43,19 @@ final class ConduitAPI_remarkup_process_Method extends ConduitAPIMethod {
$engine = PhabricatorMarkupEngine::$engine_class();
$engine->setConfig('viewer', $request->getUser());
$text = $engine->markupText($content);
if ($text) {
$content = hsprintf('%s', $text)->getHTMLContent();
} else {
$content = '';
$results = array();
foreach ($contents as $content) {
$text = $engine->markupText($content);
if ($text) {
$content = hsprintf('%s', $text)->getHTMLContent();
} else {
$content = '';
}
$results[] = array(
'content' => $content,
);
}
$result = array(
'content' => $content,
);
return $result;
return $results;
}
private function getEngineContexts() {
@ -62,6 +63,9 @@ final class ConduitAPI_remarkup_process_Method extends ConduitAPIMethod {
'phriction' => 'newPhrictionMarkupEngine',
'maniphest' => 'newManiphestMarkupEngine',
'differential' => 'newDifferentialMarkupEngine',
'phame' => 'newPhameMarkupEngine',
'feed' => 'newFeedMarkupEngine',
'diffusion' => 'newDiffusionMarkupEngine',
);
}
}