From 10a9f6501fd225f8f845e1fdfd3796bc38f2a785 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Sat, 2 Nov 2013 16:30:04 -0700 Subject: [PATCH] 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 --- .../ConduitAPI_remarkup_process_Method.php | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/applications/remarkup/conduit/ConduitAPI_remarkup_process_Method.php b/src/applications/remarkup/conduit/ConduitAPI_remarkup_process_Method.php index fd827987fc..8944c6e3c8 100644 --- a/src/applications/remarkup/conduit/ConduitAPI_remarkup_process_Method.php +++ b/src/applications/remarkup/conduit/ConduitAPI_remarkup_process_Method.php @@ -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', ); } 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', ); } } -- 2.51.2