From b04a6a199951f1c5b7cda8df377042a7d9abf02f Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 16 Jan 2013 09:08:13 -0800 Subject: [PATCH] Diffusion / MetaMTA options Summary: Implement Diffusion MetaMTA options. Also make the fake '{{config.option}}' rule work, and use Remarkup to render summaries as well as descriptions. Test Plan: Looked at Diffusion rules, edited some, looked at setup issues, verified '{{config.option}}' linked to the right option. Reviewers: codeblock, btrahan Reviewed By: codeblock CC: aran Maniphest Tasks: T2255 Differential Revision: https://secure.phabricator.com/D4466 --- src/__phutil_library_map__.php | 2 + .../PhabricatorConfigGroupController.php | 10 ++- .../config/option/PhabricatorConfigOption.php | 19 +++++- .../PhabricatorDiffusionConfigOptions.php | 61 +++++++++++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8fecd377ae..eaff501d43 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -756,6 +756,7 @@ phutil_register_library_map(array( 'PhabricatorDeveloperConfigOptions' => 'applications/config/option/PhabricatorDeveloperConfigOptions.php', 'PhabricatorDifferenceEngine' => 'infrastructure/diff/PhabricatorDifferenceEngine.php', 'PhabricatorDifferentialConfigOptions' => 'applications/differential/config/PhabricatorDifferentialConfigOptions.php', + 'PhabricatorDiffusionConfigOptions' => 'applications/diffusion/config/PhabricatorDiffusionConfigOptions.php', 'PhabricatorDirectoryController' => 'applications/directory/controller/PhabricatorDirectoryController.php', 'PhabricatorDirectoryMainController' => 'applications/directory/controller/PhabricatorDirectoryMainController.php', 'PhabricatorDisabledUserController' => 'applications/auth/controller/PhabricatorDisabledUserController.php', @@ -2133,6 +2134,7 @@ phutil_register_library_map(array( 'PhabricatorDefaultSearchEngineSelector' => 'PhabricatorSearchEngineSelector', 'PhabricatorDeveloperConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorDifferentialConfigOptions' => 'PhabricatorApplicationConfigOptions', + 'PhabricatorDiffusionConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorDirectoryController' => 'PhabricatorController', 'PhabricatorDirectoryMainController' => 'PhabricatorDirectoryController', 'PhabricatorDisabledUserController' => 'PhabricatorAuthController', diff --git a/src/applications/config/controller/PhabricatorConfigGroupController.php b/src/applications/config/controller/PhabricatorConfigGroupController.php index 3b5c9159f5..a41bc4efdb 100644 --- a/src/applications/config/controller/PhabricatorConfigGroupController.php +++ b/src/applications/config/controller/PhabricatorConfigGroupController.php @@ -64,13 +64,21 @@ final class PhabricatorConfigGroupController $db_values = mpull($db_values, null, 'getConfigKey'); } + $engine = id(new PhabricatorMarkupEngine()) + ->setViewer($this->getRequest()->getUser()); + foreach ($options as $option) { + $engine->addObject($option, 'summary'); + } + $engine->process(); $list = new PhabricatorObjectItemListView(); foreach ($options as $option) { + $summary = $engine->getOutput($option, 'summary'); + $item = id(new PhabricatorObjectItemView()) ->setHeader($option->getKey()) ->setHref('/config/edit/'.$option->getKey().'/') - ->addAttribute(phutil_escape_html($option->getSummary())); + ->addAttribute($summary); if (!$option->getHidden() && !$option->getMasked()) { $current_value = PhabricatorEnv::getEnvConfig($option->getKey()); diff --git a/src/applications/config/option/PhabricatorConfigOption.php b/src/applications/config/option/PhabricatorConfigOption.php index 076a4f1367..e7f79d9639 100644 --- a/src/applications/config/option/PhabricatorConfigOption.php +++ b/src/applications/config/option/PhabricatorConfigOption.php @@ -151,7 +151,24 @@ final class PhabricatorConfigOption } public function getMarkupText($field) { - return $this->getDescription(); + switch ($field) { + case 'description': + $text = $this->getDescription(); + break; + case 'summary': + $text = $this->getSummary(); + break; + } + + // TODO: We should probably implement this as a real Markup rule, but + // markup rules are a bit of a mess right now and it doesn't hurt us to + // fake this. + $text = preg_replace( + '/{{([^}]+)}}/', + '[[/config/edit/\\1/ | \\1]]', + $text); + + return $text; } public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { diff --git a/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php b/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php new file mode 100644 index 0000000000..4b3805dbb1 --- /dev/null +++ b/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php @@ -0,0 +1,61 @@ +newOption( + 'metamta.diffusion.subject-prefix', + 'string', + '[Diffusion]') + ->setDescription(pht('Subject prefix for Diffusion mail.')), + $this->newOption( + 'metamta.diffusion.reply-handler-domain', + 'string', + null) + ->setDescription( + pht( + 'See {{metamta.maniphest.reply-handler}}. This does the same '. + 'thing, but affects Diffusion.')), + $this->newOption( + 'metamta.diffusion.reply-handler', + 'class', + 'PhabricatorAuditReplyHandler') + ->setBaseClass('PhabricatorMailReplyHandler') + ->setDescription(pht('Override mail reply handler class.')), + $this->newOption( + 'metamta.diffusion.attach-patches', + 'bool', + false) + ->setBoolOptions( + array( + pht("Attach Patches"), + pht("Do Not Attach Patches"), + )) + ->setDescription(pht( + 'Set this to true if you want patches to be attached to commit '. + 'notifications from Diffusion.')), + $this->newOption('metamta.diffusion.inline-patches', 'int', 0) + ->setSummary(pht('Include patches in Diffusion mail as body text.')) + ->setDescription( + pht( + 'To include patches in Diffusion email bodies, set this to a '. + 'positive integer. Patches will be inlined if they are at most '. + 'that many lines. By default, patches are not inlined.')), + $this->newOption('metamta.diffusion.byte-limit', 'int', 1024 * 1024) + ->setDescription(pht('Hard byte limit on including patches in email.')), + $this->newOption('metamta.diffusion.time-limit', 'int', 60) + ->setDescription(pht('Hard time limit on generating patches.')), + ); + } + +}