mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 23:31:03 +01:00
Diffusion - add ToC for readme files
Summary: see title. Fixes T4549. Test Plan: made a readme that had some headers and observed a nice ToC Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: aran, epriestley, Korvin Maniphest Tasks: T4549 Differential Revision: https://secure.phabricator.com/D8490
This commit is contained in:
parent
a1faac0a21
commit
740757fd9b
2 changed files with 14 additions and 2 deletions
|
@ -8,8 +8,8 @@ final class ConduitAPI_diffusion_readmequery_Method
|
||||||
|
|
||||||
public function getMethodDescription() {
|
public function getMethodDescription() {
|
||||||
return
|
return
|
||||||
'Retrieve any "readme" that can be found for a set of paths in '.
|
pht('Retrieve any "readme" that can be found for a set of paths in '.
|
||||||
'repository.';
|
'repository.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function defineReturnType() {
|
public function defineReturnType() {
|
||||||
|
@ -89,6 +89,17 @@ final class ConduitAPI_diffusion_readmequery_Method
|
||||||
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
||||||
$engine->setConfig('viewer', $request->getUser());
|
$engine->setConfig('viewer', $request->getUser());
|
||||||
$readme_content = $engine->markupText($readme_content);
|
$readme_content = $engine->markupText($readme_content);
|
||||||
|
$toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::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';
|
$class = 'phabricator-remarkup';
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,6 +352,7 @@ final class PhabricatorMarkupEngine {
|
||||||
*/
|
*/
|
||||||
public static function newDiffusionMarkupEngine(array $options = array()) {
|
public static function newDiffusionMarkupEngine(array $options = array()) {
|
||||||
return self::newMarkupEngine(array(
|
return self::newMarkupEngine(array(
|
||||||
|
'header.generate-toc' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue