Page MenuHomePhabricator

D19251.diff
No OneTemporary

D19251.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -9,7 +9,7 @@
'names' => array(
'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65',
- 'core.pkg.css' => '6da3c0e5',
+ 'core.pkg.css' => 'afe29a6c',
'core.pkg.js' => 'b9b4a943',
'differential.pkg.css' => '113e692c',
'differential.pkg.js' => 'f6d809c0',
@@ -168,7 +168,7 @@
'rsrc/css/phui/phui-object-box.css' => '9cff003c',
'rsrc/css/phui/phui-pager.css' => 'edcbc226',
'rsrc/css/phui/phui-pinboard-view.css' => '2495140e',
- 'rsrc/css/phui/phui-property-list-view.css' => '6ef560df',
+ 'rsrc/css/phui/phui-property-list-view.css' => '94a14381',
'rsrc/css/phui/phui-remarkup-preview.css' => '54a34863',
'rsrc/css/phui/phui-segment-bar-view.css' => 'b1d1b892',
'rsrc/css/phui/phui-spacing.css' => '042804d6',
@@ -850,7 +850,7 @@
'phui-oi-simple-ui-css' => 'a8beebea',
'phui-pager-css' => 'edcbc226',
'phui-pinboard-view-css' => '2495140e',
- 'phui-property-list-view-css' => '6ef560df',
+ 'phui-property-list-view-css' => '94a14381',
'phui-remarkup-preview-css' => '54a34863',
'phui-segment-bar-view-css' => 'b1d1b892',
'phui-spacing-css' => '042804d6',
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3967,6 +3967,7 @@
'PhabricatorRemarkupCowsayBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php',
'PhabricatorRemarkupCustomBlockRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php',
'PhabricatorRemarkupCustomInlineRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomInlineRule.php',
+ 'PhabricatorRemarkupDocumentEngine' => 'applications/files/document/PhabricatorRemarkupDocumentEngine.php',
'PhabricatorRemarkupEditField' => 'applications/transactions/editfield/PhabricatorRemarkupEditField.php',
'PhabricatorRemarkupFigletBlockInterpreter' => 'infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php',
'PhabricatorRemarkupUIExample' => 'applications/uiexample/examples/PhabricatorRemarkupUIExample.php',
@@ -9710,6 +9711,7 @@
'PhabricatorRemarkupCowsayBlockInterpreter' => 'PhutilRemarkupBlockInterpreter',
'PhabricatorRemarkupCustomBlockRule' => 'PhutilRemarkupBlockRule',
'PhabricatorRemarkupCustomInlineRule' => 'PhutilRemarkupRule',
+ 'PhabricatorRemarkupDocumentEngine' => 'PhabricatorDocumentEngine',
'PhabricatorRemarkupEditField' => 'PhabricatorEditField',
'PhabricatorRemarkupFigletBlockInterpreter' => 'PhutilRemarkupBlockInterpreter',
'PhabricatorRemarkupUIExample' => 'PhabricatorUIExample',
diff --git a/src/applications/files/document/PhabricatorDocumentRef.php b/src/applications/files/document/PhabricatorDocumentRef.php
--- a/src/applications/files/document/PhabricatorDocumentRef.php
+++ b/src/applications/files/document/PhabricatorDocumentRef.php
@@ -7,6 +7,7 @@
private $mimeType;
private $file;
private $byteLength;
+ private $snippet;
public function setFile(PhabricatorFile $file) {
$this->file = $file;
@@ -104,4 +105,17 @@
return $mime_type;
}
+ public function isProbablyText() {
+ $snippet = $this->getSnippet();
+ return (strpos($snippet, "\0") === false);
+ }
+
+ public function getSnippet() {
+ if ($this->snippet === null) {
+ $this->snippet = $this->loadData(null, (1024 * 1024 * 1));
+ }
+
+ return $this->snippet;
+ }
+
}
diff --git a/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php b/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
@@ -0,0 +1,47 @@
+<?php
+
+final class PhabricatorRemarkupDocumentEngine
+ extends PhabricatorDocumentEngine {
+
+ const ENGINEKEY = 'remarkup';
+
+ public function getViewAsLabel(PhabricatorDocumentRef $ref) {
+ return pht('View as Remarkup');
+ }
+
+ protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
+ return 'fa-file-text-o';
+ }
+
+ protected function getContentScore(PhabricatorDocumentRef $ref) {
+ $name = $ref->getName();
+ if (preg_match('/\\.remarkup\z/i', $name)) {
+ return 2000;
+ }
+
+ return 500;
+ }
+
+ protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
+ return $ref->isProbablyText();
+ }
+
+ protected function newDocumentContent(PhabricatorDocumentRef $ref) {
+ $viewer = $this->getViewer();
+
+ $content = $ref->loadData();
+ $content = phutil_utf8ize($content);
+
+ $remarkup = new PHUIRemarkupView($viewer, $content);
+
+ $container = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'document-engine-remarkup',
+ ),
+ $remarkup);
+
+ return $container;
+ }
+
+}
diff --git a/webroot/rsrc/css/phui/phui-property-list-view.css b/webroot/rsrc/css/phui/phui-property-list-view.css
--- a/webroot/rsrc/css/phui/phui-property-list-view.css
+++ b/webroot/rsrc/css/phui/phui-property-list-view.css
@@ -244,3 +244,7 @@
margin: 20px;
white-space: pre;
}
+
+.document-engine-remarkup {
+ margin: 20px;
+}

File Metadata

Mime Type
text/plain
Expires
Oct 19 2024, 8:55 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6716222
Default Alt Text
D19251.diff (5 KB)

Event Timeline