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

Minor improvements to Diviner layout

Summary:
  - Render functions as `func()` for consistency/clarity.
  - Sort articles first.
  - Sort case insensitively.
  - Label the "no group" symbols.

Test Plan: Regenerated and examined docs.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D8480
This commit is contained in:
epriestley 2014-03-10 17:59:13 -07:00
parent 8e41315238
commit a0f534b87c
3 changed files with 22 additions and 3 deletions

View file

@ -46,6 +46,7 @@ final class DivinerBookController extends DivinerController {
->setViewer($viewer) ->setViewer($viewer)
->withBookPHIDs(array($book->getPHID())) ->withBookPHIDs(array($book->getPHID()))
->execute(); ->execute();
$atoms = msort($atoms, 'getSortKey'); $atoms = msort($atoms, 'getSortKey');
$group_spec = $book->getConfig('groups'); $group_spec = $book->getConfig('groups');
@ -64,8 +65,11 @@ final class DivinerBookController extends DivinerController {
$out = array(); $out = array();
foreach ($groups as $group => $atoms) { foreach ($groups as $group => $atoms) {
$group_name = $book->getGroupName($group); $group_name = $book->getGroupName($group);
if (!strlen($group_name)) {
$group_name = pht('Free Radicals');
}
$section = id(new DivinerSectionView()) $section = id(new DivinerSectionView())
->setHeader($group_name); ->setHeader($group_name);
$section->addContent($this->renderAtomList($atoms)); $section->addContent($this->renderAtomList($atoms));
$out[] = $section; $out[] = $section;
} }

View file

@ -29,8 +29,18 @@ abstract class DivinerController extends PhabricatorController {
$list = array(); $list = array();
foreach ($symbols as $symbol) { foreach ($symbols as $symbol) {
switch ($symbol->getType()) {
case DivinerAtom::TYPE_FUNCTION:
$title = $symbol->getTitle().'()';
break;
default:
$title = $symbol->getTitle();
break;
}
$item = id(new DivinerBookItemView()) $item = id(new DivinerBookItemView())
->setTitle($symbol->getTitle()) ->setTitle($title)
->setHref($symbol->getURI()) ->setHref($symbol->getURI())
->setSubtitle($symbol->getSummary()) ->setSubtitle($symbol->getSummary())
->setType(DivinerAtom::getAtomTypeNameString( ->setType(DivinerAtom::getAtomTypeNameString(

View file

@ -74,7 +74,12 @@ final class DivinerLiveSymbol extends DivinerDAO
} }
public function getSortKey() { public function getSortKey() {
return $this->getTitle(); // Sort articles before other types of content. Then, sort atoms in a
// case-insensitive way.
return sprintf(
'%c:%s',
($this->getType() == DivinerAtom::TYPE_ARTICLE ? '0' : '1'),
phutil_utf8_strtolower($this->getTitle()));
} }
public function save() { public function save() {