mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-12 14:58:33 +01:00
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
47 lines
1 KiB
PHP
47 lines
1 KiB
PHP
<?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;
|
|
}
|
|
|
|
}
|