@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.

Add a basic Remarkup document rendering engine

Summary:
Ref T13105. Although Markdown is trickier to deal with, we can handle Remarkup easily.

This may need some support for encoding options.

Test Plan: Viewed `.remarkup` files, got remarkup document presentation by default. Viewed other text files, got an option to render as remarkup.

Reviewers: avivey

Reviewed By: avivey

Subscribers: mydeveloperday, avivey

Maniphest Tasks: T13105

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

+70 -3
+3 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => 'e68cf1fa', 11 11 'conpherence.pkg.js' => '15191c65', 12 - 'core.pkg.css' => '6da3c0e5', 12 + 'core.pkg.css' => 'afe29a6c', 13 13 'core.pkg.js' => 'b9b4a943', 14 14 'differential.pkg.css' => '113e692c', 15 15 'differential.pkg.js' => 'f6d809c0', ··· 168 168 'rsrc/css/phui/phui-object-box.css' => '9cff003c', 169 169 'rsrc/css/phui/phui-pager.css' => 'edcbc226', 170 170 'rsrc/css/phui/phui-pinboard-view.css' => '2495140e', 171 - 'rsrc/css/phui/phui-property-list-view.css' => '6ef560df', 171 + 'rsrc/css/phui/phui-property-list-view.css' => '94a14381', 172 172 'rsrc/css/phui/phui-remarkup-preview.css' => '54a34863', 173 173 'rsrc/css/phui/phui-segment-bar-view.css' => 'b1d1b892', 174 174 'rsrc/css/phui/phui-spacing.css' => '042804d6', ··· 850 850 'phui-oi-simple-ui-css' => 'a8beebea', 851 851 'phui-pager-css' => 'edcbc226', 852 852 'phui-pinboard-view-css' => '2495140e', 853 - 'phui-property-list-view-css' => '6ef560df', 853 + 'phui-property-list-view-css' => '94a14381', 854 854 'phui-remarkup-preview-css' => '54a34863', 855 855 'phui-segment-bar-view-css' => 'b1d1b892', 856 856 'phui-spacing-css' => '042804d6',
+2
src/__phutil_library_map__.php
··· 3967 3967 'PhabricatorRemarkupCowsayBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php', 3968 3968 'PhabricatorRemarkupCustomBlockRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php', 3969 3969 'PhabricatorRemarkupCustomInlineRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomInlineRule.php', 3970 + 'PhabricatorRemarkupDocumentEngine' => 'applications/files/document/PhabricatorRemarkupDocumentEngine.php', 3970 3971 'PhabricatorRemarkupEditField' => 'applications/transactions/editfield/PhabricatorRemarkupEditField.php', 3971 3972 'PhabricatorRemarkupFigletBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php', 3972 3973 'PhabricatorRemarkupUIExample' => 'applications/uiexample/examples/PhabricatorRemarkupUIExample.php', ··· 9710 9711 'PhabricatorRemarkupCowsayBlockInterpreter' => 'PhutilRemarkupBlockInterpreter', 9711 9712 'PhabricatorRemarkupCustomBlockRule' => 'PhutilRemarkupBlockRule', 9712 9713 'PhabricatorRemarkupCustomInlineRule' => 'PhutilRemarkupRule', 9714 + 'PhabricatorRemarkupDocumentEngine' => 'PhabricatorDocumentEngine', 9713 9715 'PhabricatorRemarkupEditField' => 'PhabricatorEditField', 9714 9716 'PhabricatorRemarkupFigletBlockInterpreter' => 'PhutilRemarkupBlockInterpreter', 9715 9717 'PhabricatorRemarkupUIExample' => 'PhabricatorUIExample',
+14
src/applications/files/document/PhabricatorDocumentRef.php
··· 7 7 private $mimeType; 8 8 private $file; 9 9 private $byteLength; 10 + private $snippet; 10 11 11 12 public function setFile(PhabricatorFile $file) { 12 13 $this->file = $file; ··· 102 103 $mime_type = trim($mime_type); 103 104 $mime_type = phutil_utf8_strtolower($mime_type); 104 105 return $mime_type; 106 + } 107 + 108 + public function isProbablyText() { 109 + $snippet = $this->getSnippet(); 110 + return (strpos($snippet, "\0") === false); 111 + } 112 + 113 + public function getSnippet() { 114 + if ($this->snippet === null) { 115 + $this->snippet = $this->loadData(null, (1024 * 1024 * 1)); 116 + } 117 + 118 + return $this->snippet; 105 119 } 106 120 107 121 }
+47
src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorRemarkupDocumentEngine 4 + extends PhabricatorDocumentEngine { 5 + 6 + const ENGINEKEY = 'remarkup'; 7 + 8 + public function getViewAsLabel(PhabricatorDocumentRef $ref) { 9 + return pht('View as Remarkup'); 10 + } 11 + 12 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 13 + return 'fa-file-text-o'; 14 + } 15 + 16 + protected function getContentScore(PhabricatorDocumentRef $ref) { 17 + $name = $ref->getName(); 18 + if (preg_match('/\\.remarkup\z/i', $name)) { 19 + return 2000; 20 + } 21 + 22 + return 500; 23 + } 24 + 25 + protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 26 + return $ref->isProbablyText(); 27 + } 28 + 29 + protected function newDocumentContent(PhabricatorDocumentRef $ref) { 30 + $viewer = $this->getViewer(); 31 + 32 + $content = $ref->loadData(); 33 + $content = phutil_utf8ize($content); 34 + 35 + $remarkup = new PHUIRemarkupView($viewer, $content); 36 + 37 + $container = phutil_tag( 38 + 'div', 39 + array( 40 + 'class' => 'document-engine-remarkup', 41 + ), 42 + $remarkup); 43 + 44 + return $container; 45 + } 46 + 47 + }
+4
webroot/rsrc/css/phui/phui-property-list-view.css
··· 244 244 margin: 20px; 245 245 white-space: pre; 246 246 } 247 + 248 + .document-engine-remarkup { 249 + margin: 20px; 250 + }