From 50bc33fc1c8893bce394242625d5a9ac0b1bfe8b Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 24 May 2013 12:38:44 -0700 Subject: [PATCH] Change repository description from plain text to remarkup Summary: At one point this was sort of a one-line summary but it isn't really anymore (and doesn't appear on the list view). We could add a summary in the future if we wanted. - Change the control from a text area to a remarkup area. - Change the display to remarkup. Test Plan: {F44183} {F44184} Reviewers: chad, btrahan Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D6034 --- .../DiffusionRepositoryController.php | 8 +++- ...DiffusionRepositoryEditBasicController.php | 2 +- .../DiffusionRepositoryEditController.php | 15 ++++++-- .../storage/PhabricatorRepository.php | 38 ++++++++++++++++++- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index 089ecb6415..9b9bf41c2c 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -135,11 +135,13 @@ final class DiffusionRepositoryController extends DiffusionController { } private function buildPropertiesTable(PhabricatorRepository $repository) { + $user = $this->getRequest()->getUser(); $header = id(new PhabricatorHeaderView()) ->setHeader($repository->getName()); - $view = new PhabricatorPropertyListView(); + $view = id(new PhabricatorPropertyListView()) + ->setUser($user); $view->addProperty(pht('Callsign'), $repository->getCallsign()); switch ($repository->getVersionControlSystem()) { @@ -158,6 +160,10 @@ final class DiffusionRepositoryController extends DiffusionController { $description = $repository->getDetail('description'); if (strlen($description)) { + $description = PhabricatorMarkupEngine::renderOneObject( + $repository, + 'description', + $user); $view->addTextContent($description); } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php index 9ff999911e..c5ac2e8449 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php @@ -91,7 +91,7 @@ final class DiffusionRepositoryEditBasicController extends DiffusionController { ->setValue($v_name) ->setError($e_name)) ->appendChild( - id(new AphrontFormTextAreaControl()) + id(new PhabricatorRemarkupControl()) ->setName('description') ->setLabel(pht('Description')) ->setValue($v_desc)) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditController.php index 81d3344030..eead89d4d2 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditController.php @@ -83,8 +83,10 @@ final class DiffusionRepositoryEditController extends DiffusionController { } private function buildBasicProperties(PhabricatorRepository $repository) { + $user = $this->getRequest()->getUser(); + $view = id(new PhabricatorPropertyListView()) - ->setUser($this->getRequest()->getUser()) + ->setUser($user) ->setObject($repository); $view->addProperty(pht('Name'), $repository->getName()); @@ -98,11 +100,16 @@ final class DiffusionRepositoryEditController extends DiffusionController { $view->addProperty(pht('Callsign'), $repository->getCallsign()); $description = $repository->getDetail('description'); + $view->addSectionHeader(pht('Description')); if (!strlen($description)) { - $description = phutil_tag('em', array(), pht('None')); + $description = phutil_tag('em', array(), pht('No description provided.')); + } else { + $description = PhabricatorMarkupEngine::renderOneObject( + $repository, + 'description', + $user); } - $view->addProperty(pht('Description'), $description); - + $view->addTextContent($description); return $view; } diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index 51195b9518..eeb6f18a8e 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -4,7 +4,9 @@ * @task uri Repository URI Management */ final class PhabricatorRepository extends PhabricatorRepositoryDAO - implements PhabricatorPolicyInterface { + implements + PhabricatorPolicyInterface, + PhabricatorMarkupInterface { /** * Shortest hash we'll recognize in raw "a829f32" form. @@ -742,4 +744,38 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO return false; } + +/* -( PhabricatorMarkupInterface )----------------------------------------- */ + + + public function getMarkupFieldKey($field) { + $hash = PhabricatorHash::digestForIndex($this->getMarkupText($field)); + return "repo:{$hash}"; + } + + public function newMarkupEngine($field) { + return PhabricatorMarkupEngine::newMarkupEngine(array()); + } + + public function getMarkupText($field) { + return $this->getDetail('description'); + } + + public function didMarkupText( + $field, + $output, + PhutilMarkupEngine $engine) { + require_celerity_resource('phabricator-remarkup-css'); + return phutil_tag( + 'div', + array( + 'class' => 'phabricator-remarkup', + ), + $output); + } + + public function shouldUseMarkupCache($field) { + return true; + } + }