From a0f534b87c1b1a2fed27198e7f5407b7315901f3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 10 Mar 2014 17:59:13 -0700 Subject: [PATCH] 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 --- .../diviner/controller/DivinerBookController.php | 6 +++++- .../diviner/controller/DivinerController.php | 12 +++++++++++- .../diviner/storage/DivinerLiveSymbol.php | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/applications/diviner/controller/DivinerBookController.php b/src/applications/diviner/controller/DivinerBookController.php index ea67efb39b..1065fd39d1 100644 --- a/src/applications/diviner/controller/DivinerBookController.php +++ b/src/applications/diviner/controller/DivinerBookController.php @@ -46,6 +46,7 @@ final class DivinerBookController extends DivinerController { ->setViewer($viewer) ->withBookPHIDs(array($book->getPHID())) ->execute(); + $atoms = msort($atoms, 'getSortKey'); $group_spec = $book->getConfig('groups'); @@ -64,8 +65,11 @@ final class DivinerBookController extends DivinerController { $out = array(); foreach ($groups as $group => $atoms) { $group_name = $book->getGroupName($group); + if (!strlen($group_name)) { + $group_name = pht('Free Radicals'); + } $section = id(new DivinerSectionView()) - ->setHeader($group_name); + ->setHeader($group_name); $section->addContent($this->renderAtomList($atoms)); $out[] = $section; } diff --git a/src/applications/diviner/controller/DivinerController.php b/src/applications/diviner/controller/DivinerController.php index d501e2e950..691581ff42 100644 --- a/src/applications/diviner/controller/DivinerController.php +++ b/src/applications/diviner/controller/DivinerController.php @@ -29,8 +29,18 @@ abstract class DivinerController extends PhabricatorController { $list = array(); foreach ($symbols as $symbol) { + + switch ($symbol->getType()) { + case DivinerAtom::TYPE_FUNCTION: + $title = $symbol->getTitle().'()'; + break; + default: + $title = $symbol->getTitle(); + break; + } + $item = id(new DivinerBookItemView()) - ->setTitle($symbol->getTitle()) + ->setTitle($title) ->setHref($symbol->getURI()) ->setSubtitle($symbol->getSummary()) ->setType(DivinerAtom::getAtomTypeNameString( diff --git a/src/applications/diviner/storage/DivinerLiveSymbol.php b/src/applications/diviner/storage/DivinerLiveSymbol.php index 41a52c4dd8..5ed524a582 100644 --- a/src/applications/diviner/storage/DivinerLiveSymbol.php +++ b/src/applications/diviner/storage/DivinerLiveSymbol.php @@ -74,7 +74,12 @@ final class DivinerLiveSymbol extends DivinerDAO } 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() {