Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14000650
D10340.id24893.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D10340.id24893.diff
View Options
diff --git a/src/applications/diffusion/conduit/DiffusionReadmeQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionReadmeQueryConduitAPIMethod.php
--- a/src/applications/diffusion/conduit/DiffusionReadmeQueryConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionReadmeQueryConduitAPIMethod.php
@@ -34,6 +34,7 @@
$best = -1;
$readme = '';
+ $best_render_type = 'plain';
foreach ($paths as $result_path) {
$file_type = $result_path->getFileType();
if (($file_type != ArcanistDiffChangeType::FILE_NORMAL) &&
@@ -45,7 +46,7 @@
$path = strtolower($result_path->getPath());
if ($path === 'readme') {
- $path .= '.txt';
+ $path .= '.remarkup';
}
if (strncmp($path, 'readme.', 7) !== 0) {
@@ -56,21 +57,30 @@
switch (substr($path, 7)) {
case 'remarkup':
$priority = 100;
+ $render_type = 'remarkup';
break;
case 'rainbow':
$priority = 90;
+ $render_type = 'rainbow';
break;
case 'md':
$priority = 50;
+ $render_type = 'remarkup';
break;
case 'txt':
$priority = 10;
+ $render_type = 'plain';
+ break;
+ default:
+ $priority = 0;
+ $render_type = 'plain';
break;
}
if ($priority > $best) {
$best = $priority;
$readme = $result_path;
+ $best_render_type = $render_type;
}
}
@@ -98,47 +108,50 @@
)));
$readme_content = $file_content->getCorpus();
- if (preg_match('/\\.txt$/', $readme->getPath())) {
- $readme_content = phutil_escape_html_newlines($readme_content);
-
- $class = null;
- } else if (preg_match('/\\.rainbow$/', $readme->getPath())) {
- $highlighter = new PhutilRainbowSyntaxHighlighter();
- $readme_content = $highlighter
- ->getHighlightFuture($readme_content)
- ->resolve();
- $readme_content = phutil_escape_html_newlines($readme_content);
-
- require_celerity_resource('syntax-highlighting-css');
- $class = 'remarkup-code';
- } else {
- // TODO: This is sketchy, but make sure we hit the markup cache.
- $markup_object = id(new PhabricatorMarkupOneOff())
- ->setEngineRuleset('diffusion-readme')
- ->setContent($readme_content);
- $markup_field = 'default';
-
- $readme_content = id(new PhabricatorMarkupEngine())
- ->setViewer($request->getUser())
- ->addObject($markup_object, $markup_field)
- ->process()
- ->getOutput($markup_object, $markup_field);
-
- $engine = $markup_object->newMarkupEngine($markup_field);
- $toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine);
- if ($toc) {
- $toc = phutil_tag_div(
- 'phabricator-remarkup-toc',
- array(
- phutil_tag_div(
- 'phabricator-remarkup-toc-header',
- pht('Table of Contents')),
- $toc,
- ));
- $readme_content = array($toc, $readme_content);
- }
-
- $class = 'phabricator-remarkup';
+ switch ($best_render_type) {
+ case 'plain':
+ $readme_content = phutil_escape_html_newlines($readme_content);
+ $class = null;
+ break;
+ case 'rainbow':
+ $highlighter = new PhutilRainbowSyntaxHighlighter();
+ $readme_content = $highlighter
+ ->getHighlightFuture($readme_content)
+ ->resolve();
+ $readme_content = phutil_escape_html_newlines($readme_content);
+
+ require_celerity_resource('syntax-highlighting-css');
+ $class = 'remarkup-code';
+ break;
+ case 'remarkup':
+ // TODO: This is sketchy, but make sure we hit the markup cache.
+ $markup_object = id(new PhabricatorMarkupOneOff())
+ ->setEngineRuleset('diffusion-readme')
+ ->setContent($readme_content);
+ $markup_field = 'default';
+
+ $readme_content = id(new PhabricatorMarkupEngine())
+ ->setViewer($request->getUser())
+ ->addObject($markup_object, $markup_field)
+ ->process()
+ ->getOutput($markup_object, $markup_field);
+
+ $engine = $markup_object->newMarkupEngine($markup_field);
+ $toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine);
+ if ($toc) {
+ $toc = phutil_tag_div(
+ 'phabricator-remarkup-toc',
+ array(
+ phutil_tag_div(
+ 'phabricator-remarkup-toc-header',
+ pht('Table of Contents')),
+ $toc,
+ ));
+ $readme_content = array($toc, $readme_content);
+ }
+
+ $class = 'phabricator-remarkup';
+ break;
}
$readme_content = phutil_tag(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 25, 11:25 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6726395
Default Alt Text
D10340.id24893.diff (4 KB)
Attached To
Mode
D10340: Diffusion - re-jigger how README files get rendered
Attached
Detach File
Event Timeline
Log In to Comment