1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-12 14:58:33 +01:00
phorge-phorge/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
epriestley 8b658706a8 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
2018-03-23 07:07:50 -07:00

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;
}
}