1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 00:10:57 +01:00

Diviner: improve links, book index, and atom view

Summary: Ref T988. Minor improvements to diviner: link stuff to a valid endpoint which actually works; fix group names on the book index; improve the topics index for atom views.

Test Plan: Clicked links in an article, viewed book index, viewed an article with long headers.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D6598
This commit is contained in:
epriestley 2013-07-28 13:07:30 -07:00
parent 69daebc2da
commit 8834b318dd
8 changed files with 90 additions and 9 deletions

View file

@ -3857,7 +3857,7 @@ celerity_register_resource_map(array(
),
'phui-list-view-css' =>
array(
'uri' => '/res/09f24365/rsrc/css/phui/phui-list.css',
'uri' => '/res/3235e888/rsrc/css/phui/phui-list.css',
'type' => 'css',
'requires' =>
array(

View file

@ -526,6 +526,7 @@ phutil_register_library_map(array(
'DivinerDefaultRenderer' => 'applications/diviner/renderer/DivinerDefaultRenderer.php',
'DivinerDiskCache' => 'applications/diviner/cache/DivinerDiskCache.php',
'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',
@ -2519,6 +2520,7 @@ phutil_register_library_map(array(
'DivinerDAO' => 'PhabricatorLiskDAO',
'DivinerDefaultRenderer' => 'DivinerRenderer',
'DivinerFileAtomizer' => 'DivinerAtomizer',
'DivinerFindController' => 'DivinerController',
'DivinerGenerateWorkflow' => 'DivinerWorkflow',
'DivinerLegacyController' => 'DivinerController',
'DivinerLiveAtom' => 'DivinerDAO',

View file

@ -23,6 +23,7 @@ final class PhabricatorApplicationDiviner extends PhabricatorApplication {
'/diviner/' => array(
'' => 'DivinerLegacyController',
'query/((?<key>[^/]+)/)?' => 'DivinerAtomListController',
'find/' => 'DivinerFindController',
),
'/docs/(?P<keyword>[^/]+)/' => 'DivinerJumpController',
'/book/(?P<book>[^/]+)/' => 'DivinerBookController',

View file

@ -0,0 +1,72 @@
<?php
final class DivinerFindController extends DivinerController {
public function shouldAllowPublic() {
return true;
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$book_name = $request->getStr('book');
$book = null;
if ($book_name) {
$book = id(new DivinerBookQuery())
->setViewer($viewer)
->withNames(array($book_name))
->executeOne();
if (!$book) {
return new Aphront404Response();
}
}
$query = id(new DivinerAtomQuery())
->setViewer($viewer)
->withNames(
array(
$request->getStr('name'),
// TODO: This could probably be more smartly normalized in the DB,
// but just fake it for now.
phutil_utf8_strtolower($request->getStr('name')),
));
if ($book) {
$query->withBookPHIDs(array($book->getPHID()));
}
$context = $request->getStr('context');
if (strlen($context)) {
$query->withContexts(array($context));
}
$type = $request->getStr('type');
if (strlen($type)) {
$query->withTypes(array($type));
}
$atoms = $query->execute();
if (!$atoms) {
return new Aphront404Response();
}
if (count($atoms) == 1 && $request->getBool('jump')) {
$atom_uri = head($atoms)->getURI();
return id(new AphrontRedirectResponse())->setURI($atom_uri);
}
$list = $this->renderAtomList($atoms);
return $this->buildApplicationPage(
$list,
array(
'title' => 'derp',
'dust' => true,
'device' => true,
));
}
}

View file

@ -57,7 +57,7 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
$ref['name'] = $name;
}
$ref['title'] = $title;
$ref['title'] = nonempty($title, $name);
foreach ($ref as $key => $value) {
if ($value === '') {
@ -86,7 +86,7 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
foreach ($data as $token => $ref_dict) {
$ref = DivinerAtomRef::newFromDictionary($ref_dict);
$title = nonempty($ref->getTitle(), $ref->getName());
$title = $ref->getTitle();
$href = null;
if ($renderer) {
@ -104,7 +104,14 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
// link to Diviner and let it sort things out.
$href = id(new PhutilURI('/diviner/find/'))
->setQueryParams($ref_dict + array('jump' => true));
->setQueryParams(
array(
'book' => $ref->getBook(),
'name' => $ref->getName(),
'type' => $ref->getType(),
'context' => $ref->getContext(),
'jump' => true,
));
}
if ($this->getEngine()->isTextMode()) {

View file

@ -42,7 +42,7 @@ final class DivinerLiveBook extends DivinerDAO
public function getGroupName($group) {
$groups = $this->getConfig('groups');
$spec = idx($groups, $group, array());
return idx($spec, 'name', pht('Free Radicals'));
return idx($spec, 'name', $group);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -160,7 +160,7 @@ final class DivinerLiveSymbol extends DivinerDAO
public function shouldUseMarkupCache($field) {
return true;
return false;
}
}

View file

@ -58,11 +58,10 @@
.phui-list-sidenav .phui-list-item-href {
display: block;
padding: 2px 16px;
padding: 4px 16px;
clear: both;
line-height: 20px;
color: #333333;
white-space: nowrap;
line-height: 18px;
}
.phui-list-sidenav .phui-list-item-has-icon .phui-list-item-href {