@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 an abstract "Text" document engine and a "Source" document engine

Summary: Ref T13105. Allow normal text files to be rendered as documents, and add a "source code" rendering engine.

Test Plan: Viewed some source code.

Reviewers: mydeveloperday

Reviewed By: mydeveloperday

Maniphest Tasks: T13105

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

+82 -19
+5 -5
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => 'e68cf1fa', 11 11 'conpherence.pkg.js' => '15191c65', 12 - 'core.pkg.css' => '7daac340', 12 + 'core.pkg.css' => 'da541195', 13 13 'core.pkg.js' => 'b9b4a943', 14 14 'differential.pkg.css' => '113e692c', 15 15 'differential.pkg.js' => 'f6d809c0', ··· 120 120 'rsrc/css/font/font-lato.css' => 'c7ccd872', 121 121 'rsrc/css/font/phui-font-icon-base.css' => '870a7360', 122 122 'rsrc/css/layout/phabricator-filetree-view.css' => 'b912ad97', 123 - 'rsrc/css/layout/phabricator-source-code-view.css' => '926ced2d', 123 + 'rsrc/css/layout/phabricator-source-code-view.css' => '31ee3c83', 124 124 'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494', 125 125 'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68', 126 126 'rsrc/css/phui/button/phui-button.css' => '1863cc6e', ··· 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' => '871f6815', 171 + 'rsrc/css/phui/phui-property-list-view.css' => '54c071ed', 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', ··· 784 784 'phabricator-search-results-css' => '505dd8cf', 785 785 'phabricator-shaped-request' => '7cbe244b', 786 786 'phabricator-slowvote-css' => 'a94b7230', 787 - 'phabricator-source-code-view-css' => '926ced2d', 787 + 'phabricator-source-code-view-css' => '31ee3c83', 788 788 'phabricator-standard-page-view' => '34ee718b', 789 789 'phabricator-textareautils' => '320810c8', 790 790 'phabricator-title' => '485aaa6c', ··· 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' => '871f6815', 853 + 'phui-property-list-view-css' => '54c071ed', 854 854 'phui-remarkup-preview-css' => '54a34863', 855 855 'phui-segment-bar-view-css' => 'b1d1b892', 856 856 'phui-spacing-css' => '042804d6',
+4
src/__phutil_library_map__.php
··· 4222 4222 'PhabricatorSlug' => 'infrastructure/util/PhabricatorSlug.php', 4223 4223 'PhabricatorSlugTestCase' => 'infrastructure/util/__tests__/PhabricatorSlugTestCase.php', 4224 4224 'PhabricatorSourceCodeView' => 'view/layout/PhabricatorSourceCodeView.php', 4225 + 'PhabricatorSourceDocumentEngine' => 'applications/files/document/PhabricatorSourceDocumentEngine.php', 4225 4226 'PhabricatorSpaceEditField' => 'applications/transactions/editfield/PhabricatorSpaceEditField.php', 4226 4227 'PhabricatorSpacesApplication' => 'applications/spaces/application/PhabricatorSpacesApplication.php', 4227 4228 'PhabricatorSpacesArchiveController' => 'applications/spaces/controller/PhabricatorSpacesArchiveController.php', ··· 4363 4364 'PhabricatorTestWorker' => 'infrastructure/daemon/workers/__tests__/PhabricatorTestWorker.php', 4364 4365 'PhabricatorTextAreaEditField' => 'applications/transactions/editfield/PhabricatorTextAreaEditField.php', 4365 4366 'PhabricatorTextConfigType' => 'applications/config/type/PhabricatorTextConfigType.php', 4367 + 'PhabricatorTextDocumentEngine' => 'applications/files/document/PhabricatorTextDocumentEngine.php', 4366 4368 'PhabricatorTextEditField' => 'applications/transactions/editfield/PhabricatorTextEditField.php', 4367 4369 'PhabricatorTextExportFormat' => 'infrastructure/export/format/PhabricatorTextExportFormat.php', 4368 4370 'PhabricatorTextListConfigType' => 'applications/config/type/PhabricatorTextListConfigType.php', ··· 10041 10043 'PhabricatorSlug' => 'Phobject', 10042 10044 'PhabricatorSlugTestCase' => 'PhabricatorTestCase', 10043 10045 'PhabricatorSourceCodeView' => 'AphrontView', 10046 + 'PhabricatorSourceDocumentEngine' => 'PhabricatorTextDocumentEngine', 10044 10047 'PhabricatorSpaceEditField' => 'PhabricatorEditField', 10045 10048 'PhabricatorSpacesApplication' => 'PhabricatorApplication', 10046 10049 'PhabricatorSpacesArchiveController' => 'PhabricatorSpacesController', ··· 10188 10191 'PhabricatorTestWorker' => 'PhabricatorWorker', 10189 10192 'PhabricatorTextAreaEditField' => 'PhabricatorEditField', 10190 10193 'PhabricatorTextConfigType' => 'PhabricatorConfigType', 10194 + 'PhabricatorTextDocumentEngine' => 'PhabricatorDocumentEngine', 10191 10195 'PhabricatorTextEditField' => 'PhabricatorEditField', 10192 10196 'PhabricatorTextExportFormat' => 'PhabricatorExportFormat', 10193 10197 'PhabricatorTextListConfigType' => 'PhabricatorTextConfigType',
+30
src/applications/files/document/PhabricatorSourceDocumentEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorSourceDocumentEngine 4 + extends PhabricatorTextDocumentEngine { 5 + 6 + const ENGINEKEY = 'source'; 7 + 8 + public function getViewAsLabel(PhabricatorDocumentRef $ref) { 9 + return pht('View as Source'); 10 + } 11 + 12 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 13 + return 'fa-code'; 14 + } 15 + 16 + protected function getContentScore(PhabricatorDocumentRef $ref) { 17 + return 1500; 18 + } 19 + 20 + protected function newDocumentContent(PhabricatorDocumentRef $ref) { 21 + $content = $this->loadTextData($ref); 22 + 23 + $content = PhabricatorSyntaxHighlighter::highlightWithFilename( 24 + $ref->getName(), 25 + $content); 26 + 27 + return $this->newTextDocumentContent($content); 28 + } 29 + 30 + }
+33
src/applications/files/document/PhabricatorTextDocumentEngine.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorTextDocumentEngine 4 + extends PhabricatorDocumentEngine { 5 + 6 + protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 7 + return $ref->isProbablyText(); 8 + } 9 + 10 + protected function newTextDocumentContent($content) { 11 + $lines = phutil_split_lines($content); 12 + 13 + $view = id(new PhabricatorSourceCodeView()) 14 + ->setLines($lines) 15 + ->disableHighlightOnClick(); 16 + 17 + $container = phutil_tag( 18 + 'div', 19 + array( 20 + 'class' => 'document-engine-text', 21 + ), 22 + $view); 23 + 24 + return $container; 25 + } 26 + 27 + protected function loadTextData(PhabricatorDocumentRef $ref) { 28 + $content = $ref->loadData(); 29 + $content = phutil_utf8ize($content); 30 + return $content; 31 + } 32 + 33 + }
+6 -14
webroot/rsrc/css/layout/phabricator-source-code-view.css
··· 14 14 margin-left: 8px; 15 15 } 16 16 17 - .phabricator-source-code-view tr:first-child * { 18 - padding-top: 8px; 19 - } 20 - 21 - .phabricator-source-code-view tr:last-child * { 22 - padding-bottom: 8px; 23 - } 24 - 25 17 .phabricator-source-code { 26 18 white-space: pre-wrap; 27 19 padding: 2px 8px 1px; ··· 45 37 white-space: nowrap; 46 38 } 47 39 48 - th.phabricator-source-line a { 49 - color: {$darkbluetext}; 40 + th.phabricator-source-line a, 41 + th.phabricator-source-line span { 50 42 display: block; 51 43 padding: 2px 6px 1px 12px; 44 + } 45 + 46 + th.phabricator-source-line a { 47 + color: {$darkbluetext}; 52 48 } 53 49 54 50 th.phabricator-source-line a:hover { ··· 58 54 59 55 .phabricator-source-highlight { 60 56 background: {$paste.highlight}; 61 - } 62 - 63 - .phabricator-source-highlight th.phabricator-source-line { 64 - background: {$paste.border}; 65 57 } 66 58 67 59 .phabricator-source-code-summary {
+4
webroot/rsrc/css/phui/phui-property-list-view.css
··· 258 258 text-align: left; 259 259 } 260 260 261 + .document-engine-text .phabricator-source-code-container { 262 + border: none; 263 + } 264 + 261 265 .document-engine-jupyter { 262 266 overflow: hidden; 263 267 margin: 20px;