1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00

Give Diviner a non-legacy root controller

Summary: Ref T988. Instead of hard-coding the application landing page, make the Diviner root show books if any have been generated. Otherwise, show a helpful message about how to generate documentation locally.

Test Plan:
{F122723}

{F122724}

Reviewers: chad, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D8416
This commit is contained in:
epriestley 2014-03-05 13:07:50 -08:00
parent d07fc70bbe
commit 81d381f69d
4 changed files with 88 additions and 69 deletions

View file

@ -642,11 +642,11 @@ phutil_register_library_map(array(
'DivinerFileAtomizer' => 'applications/diviner/atomizer/DivinerFileAtomizer.php',
'DivinerFindController' => 'applications/diviner/controller/DivinerFindController.php',
'DivinerGenerateWorkflow' => 'applications/diviner/workflow/DivinerGenerateWorkflow.php',
'DivinerLegacyController' => 'applications/diviner/controller/DivinerLegacyController.php',
'DivinerLiveAtom' => 'applications/diviner/storage/DivinerLiveAtom.php',
'DivinerLiveBook' => 'applications/diviner/storage/DivinerLiveBook.php',
'DivinerLivePublisher' => 'applications/diviner/publisher/DivinerLivePublisher.php',
'DivinerLiveSymbol' => 'applications/diviner/storage/DivinerLiveSymbol.php',
'DivinerMainController' => 'applications/diviner/controller/DivinerMainController.php',
'DivinerPHIDTypeAtom' => 'applications/diviner/phid/DivinerPHIDTypeAtom.php',
'DivinerPHIDTypeBook' => 'applications/diviner/phid/DivinerPHIDTypeBook.php',
'DivinerPHPAtomizer' => 'applications/diviner/atomizer/DivinerPHPAtomizer.php',
@ -3207,7 +3207,6 @@ phutil_register_library_map(array(
'DivinerFileAtomizer' => 'DivinerAtomizer',
'DivinerFindController' => 'DivinerController',
'DivinerGenerateWorkflow' => 'DivinerWorkflow',
'DivinerLegacyController' => 'DivinerController',
'DivinerLiveAtom' => 'DivinerDAO',
'DivinerLiveBook' =>
array(
@ -3221,6 +3220,7 @@ phutil_register_library_map(array(
1 => 'PhabricatorPolicyInterface',
2 => 'PhabricatorMarkupInterface',
),
'DivinerMainController' => 'DivinerController',
'DivinerPHIDTypeAtom' => 'PhabricatorPHIDType',
'DivinerPHIDTypeBook' => 'PhabricatorPHIDType',
'DivinerPHPAtomizer' => 'DivinerAtomizer',

View file

@ -21,11 +21,10 @@ final class PhabricatorApplicationDiviner extends PhabricatorApplication {
public function getRoutes() {
return array(
'/diviner/' => array(
'' => 'DivinerLegacyController',
'' => 'DivinerMainController',
'query/((?<key>[^/]+)/)?' => 'DivinerAtomListController',
'find/' => 'DivinerFindController',
),
'/docs/(?P<keyword>[^/]+)/' => 'DivinerJumpController',
'/book/(?P<book>[^/]+)/' => 'DivinerBookController',
'/book/'.
'(?P<book>[^/]+)/'.

View file

@ -1,65 +0,0 @@
<?php
final class DivinerLegacyController extends DivinerController {
public function processRequest() {
// TODO: Temporary implementation until Diviner is up and running inside
// Phabricator.
$links = array(
'http://www.phabricator.com/docs/phabricator/' => array(
'name' => 'Phabricator Ducks',
'flavor' => 'Oops, that should say "Docs".',
),
'http://www.phabricator.com/docs/arcanist/' => array(
'name' => 'Arcanist Docs',
'flavor' => 'Words have never been so finely crafted.',
),
'http://www.phabricator.com/docs/libphutil/' => array(
'name' => 'libphutil Docs',
'flavor' => 'Soothing prose; seductive poetry.',
),
'http://www.phabricator.com/docs/javelin/' => array(
'name' => 'Javelin Docs',
'flavor' => 'O, what noble scribe hath penned these words?',
),
);
$request = $this->getRequest();
$viewer = $request->getUser();
$list = id(new PHUIObjectItemListView())
->setUser($viewer)
->setPlain(true);
foreach ($links as $href => $link) {
$item = id(new PHUIObjectItemView())
->setHref($href)
->setHeader($link['name'])
->addAttribute($link['flavor']);
$list->addItem($item);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Documentation'));
$header = id(new PHUIHeaderView())
->setHeader(pht('Documentation'));
$document = new PHUIDocumentView();
$document->setHeader($header);
$document->appendChild($list);
return $this->buildApplicationPage(
array(
$crumbs,
$document,
),
array(
'title' => pht('Documentation'),
'device' => true,
));
}
}

View file

@ -0,0 +1,85 @@
<?php
final class DivinerMainController extends DivinerController {
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$books = id(new DivinerBookQuery())
->setViewer($viewer)
->execute();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Books'));
$search_icon = id(new PHUIIconView())
->setSpriteIcon('search')
->setSpriteSheet(PHUIIconView::SPRITE_ICONS);
$query_button = id(new PHUIButtonView())
->setTag('a')
->setHref($this->getApplicationURI('query/'))
->setText(pht('Advanced Search'))
->setIcon($search_icon);
$header = id(new PHUIHeaderView())
->setHeader(pht('Documentation Books'))
->addActionLink($query_button);
$document = new PHUIDocumentView();
$document->setHeader($header);
if ($books) {
$list = id(new PHUIObjectItemListView())
->setUser($viewer)
->setPlain(true);
$books = msort($books, 'getTitle');
foreach ($books as $book) {
$item = id(new PHUIObjectItemView())
->setHref('/book/'.$book->getName().'/')
->setHeader($book->getTitle())
->addAttribute($book->getPreface());
$list->addItem($item);
}
$document->appendChild($list);
} else {
$text = pht(
"(NOTE) **Looking for Phabricator documentation?** If you're looking ".
"for help and information about Phabricator, you can ".
"[[ https://secure.phabricator.com/diviner/ | browse the public ".
"Phabricator documentation ]] on the live site.\n\n".
"Diviner is the documentation generator used to build the Phabricator ".
"documentation.\n\n".
"You haven't generated any Diviner documentation books yet, so ".
"there's nothing to show here. If you'd like to generate your own ".
"local copy of the Phabricator documentation and have it appear ".
"here, run this command:\n\n".
" phabricator/ $ ./bin/diviner generate\n\n".
"Right now, Diviner isn't very useful for generating documentation ".
"for projects other than Phabricator. If you're interested in using ".
"it in your own projects, leave feedback for us on ".
"[[ https://secure.phabricator.com/T4558 | T4558 ]].");
$text = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($text),
'default',
$viewer);
$document->appendChild($text);
}
return $this->buildApplicationPage(
array(
$crumbs,
$document,
),
array(
'title' => pht('Documentation Books'),
'device' => true,
));
}
}