@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Introduce PHUIRemarkupView, a sane way to work with Remarkup

Summary:
Fixes T9273. Remarkup has reasonably good fundamentals but the API is a giant pain to work with.

Provide a `PHUIRemarkupView` to make it easier. This object is way simpler to use by default.

It's not currently as powerful, but we can expand the power level later by adding more setters.

Eventually I'd expect to replace `PhabricatorRemarkupInterface` and `PhabricatorMarkupOneOff` with this, but no rush on those.

I converted a few callsites as a sanity check that it works OK.

Test Plan:
- Viewed remarkup in Passphrase.
- Viewed remarkup in Badges.
- Viewed a Conduit method.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9273

Differential Revision: https://secure.phabricator.com/D14289

+40 -28
+2
src/__phutil_library_map__.php
··· 1459 1459 'PHUIPropertyListExample' => 'applications/uiexample/examples/PHUIPropertyListExample.php', 1460 1460 'PHUIPropertyListView' => 'view/phui/PHUIPropertyListView.php', 1461 1461 'PHUIRemarkupPreviewPanel' => 'view/phui/PHUIRemarkupPreviewPanel.php', 1462 + 'PHUIRemarkupView' => 'infrastructure/markup/view/PHUIRemarkupView.php', 1462 1463 'PHUISpacesNamespaceContextView' => 'applications/spaces/view/PHUISpacesNamespaceContextView.php', 1463 1464 'PHUIStatusItemView' => 'view/phui/PHUIStatusItemView.php', 1464 1465 'PHUIStatusListView' => 'view/phui/PHUIStatusListView.php', ··· 5352 5353 'PHUIPropertyListExample' => 'PhabricatorUIExample', 5353 5354 'PHUIPropertyListView' => 'AphrontView', 5354 5355 'PHUIRemarkupPreviewPanel' => 'AphrontTagView', 5356 + 'PHUIRemarkupView' => 'AphrontView', 5355 5357 'PHUISpacesNamespaceContextView' => 'AphrontView', 5356 5358 'PHUIStatusItemView' => 'AphrontTagView', 5357 5359 'PHUIStatusListView' => 'AphrontTagView',
+2 -6
src/applications/badges/controller/PhabricatorBadgesViewController.php
··· 104 104 105 105 $description = $badge->getDescription(); 106 106 if (strlen($description)) { 107 - $description = PhabricatorMarkupEngine::renderOneObject( 108 - id(new PhabricatorMarkupOneOff())->setContent($description), 109 - 'default', 110 - $viewer); 111 - 112 107 $view->addSectionHeader( 113 108 pht('Description'), PHUIPropertyListView::ICON_SUMMARY); 114 - $view->addTextContent($description); 109 + $view->addTextContent( 110 + new PHUIRemarkupView($viewer, $description)); 115 111 } 116 112 117 113 $badge = id(new PHUIBadgeView())
+2 -7
src/applications/conduit/controller/PhabricatorConduitConsoleController.php
··· 195 195 pht('Errors'), 196 196 $error_description); 197 197 198 - 199 - $description = $method->getMethodDescription(); 200 - $description = PhabricatorMarkupEngine::renderOneObject( 201 - id(new PhabricatorMarkupOneOff())->setContent($description), 202 - 'default', 203 - $viewer); 204 198 $view->addSectionHeader( 205 199 pht('Description'), PHUIPropertyListView::ICON_SUMMARY); 206 - $view->addTextContent($description); 200 + $view->addTextContent( 201 + new PHUIRemarkupView($viewer, $method->getMethodDescription())); 207 202 208 203 return $view; 209 204 }
+1 -5
src/applications/passphrase/controller/PassphraseCredentialViewController.php
··· 201 201 pht('Description'), 202 202 PHUIPropertyListView::ICON_SUMMARY); 203 203 $properties->addTextContent( 204 - PhabricatorMarkupEngine::renderOneObject( 205 - id(new PhabricatorMarkupOneOff()) 206 - ->setContent($description), 207 - 'default', 208 - $viewer)); 204 + new PHUIRemarkupView($viewer, $description)); 209 205 } 210 206 211 207 return $properties;
+1 -10
src/infrastructure/markup/PhabricatorMarkupOneOff.php
··· 1 1 <?php 2 2 3 3 /** 4 - * Concrete object for accessing the markup engine with arbitrary blobs of 5 - * text, like form instructions. Usage: 6 - * 7 - * $output = PhabricatorMarkupEngine::renderOneObject( 8 - * id(new PhabricatorMarkupOneOff())->setContent($some_content), 9 - * 'default', 10 - * $viewer); 11 - * 12 - * This is less efficient than batching rendering, but appropriate for small 13 - * amounts of one-off text in form instructions. 4 + * DEPRECATED. Use @{class:PHUIRemarkupView}. 14 5 */ 15 6 final class PhabricatorMarkupOneOff 16 7 extends Phobject
+32
src/infrastructure/markup/view/PHUIRemarkupView.php
··· 1 + <?php 2 + 3 + /** 4 + * Simple API for rendering blocks of Remarkup. 5 + * 6 + * Example usage: 7 + * 8 + * $fancy_text = new PHUIRemarkupView($viewer, $raw_remarkup); 9 + * $view->appendChild($fancy_text); 10 + * 11 + */ 12 + final class PHUIRemarkupView extends AphrontView { 13 + 14 + private $corpus; 15 + 16 + public function __construct(PhabricatorUser $viewer, $corpus) { 17 + $this->setUser($viewer); 18 + $this->corpus = $corpus; 19 + } 20 + 21 + public function render() { 22 + $viewer = $this->getUser(); 23 + $corpus = $this->corpus; 24 + 25 + return PhabricatorMarkupEngine::renderOneObject( 26 + id(new PhabricatorMarkupOneOff()) 27 + ->setContent($corpus), 28 + 'default', 29 + $viewer); 30 + } 31 + 32 + }