1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Modernize UIExamples

Summary:
  - Get rid of an AphrontSideNavView callsite.
  - Modernize and simplify the application implementation.
  - Doesn't work perfectly on tablet/phone but that's because not all the UI examples work there yet.

Test Plan: Looked at /applications/ and /uiexample/.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3431
This commit is contained in:
epriestley 2012-09-11 09:56:40 -07:00
parent 1b7f04914c
commit 303ad93996
11 changed files with 102 additions and 93 deletions

View file

@ -140,6 +140,7 @@ $app_map = array(
'feed' => array(3, 11),
'paste' => array(9, 2),
'audit' => array(8, 19),
'uiexample' => array(7, 28),
);
$xadj = -1;

View file

@ -65,8 +65,8 @@ celerity_register_resource_map(array(
),
'/rsrc/image/autosprite.png' =>
array(
'hash' => 'bd70ca6308d6f80a87a10068a04867f8',
'uri' => '/res/bd70ca63/rsrc/image/autosprite.png',
'hash' => '0b78a23fb4cec90e3a35ba1b9ce20f0c',
'uri' => '/res/0b78a23f/rsrc/image/autosprite.png',
'disk' => '/rsrc/image/autosprite.png',
'type' => 'png',
),
@ -671,7 +671,7 @@ celerity_register_resource_map(array(
),
'autosprite-css' =>
array(
'uri' => '/res/114f6e40/rsrc/css/autosprite.css',
'uri' => '/res/cb9c82fd/rsrc/css/autosprite.css',
'type' => 'css',
'requires' =>
array(

View file

@ -570,6 +570,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationProject' => 'applications/project/application/PhabricatorApplicationProject.php',
'PhabricatorApplicationSettings' => 'applications/settings/application/PhabricatorApplicationSettings.php',
'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php',
'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php',
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
'PhabricatorAuditAddCommentController' => 'applications/audit/controller/PhabricatorAuditAddCommentController.php',
@ -1076,7 +1077,6 @@ phutil_register_library_map(array(
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadDatasourceController.php',
'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php',
'PhabricatorUIExample' => 'applications/uiexample/examples/PhabricatorUIExample.php',
'PhabricatorUIExampleController' => 'applications/uiexample/controller/PhabricatorUIExampleController.php',
'PhabricatorUIExampleRenderController' => 'applications/uiexample/controller/PhabricatorUIExampleRenderController.php',
'PhabricatorUIListFilterExample' => 'applications/uiexample/examples/PhabricatorUIListFilterExample.php',
'PhabricatorUINotificationExample' => 'applications/uiexample/examples/PhabricatorUINotificationExample.php',
@ -1710,6 +1710,7 @@ phutil_register_library_map(array(
'PhabricatorApplicationProject' => 'PhabricatorApplication',
'PhabricatorApplicationSettings' => 'PhabricatorApplication',
'PhabricatorApplicationStatusView' => 'AphrontView',
'PhabricatorApplicationUIExamples' => 'PhabricatorApplication',
'PhabricatorApplicationsListController' => 'PhabricatorController',
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
'PhabricatorAuditComment' => 'PhabricatorAuditDAO',
@ -2155,8 +2156,7 @@ phutil_register_library_map(array(
'PhabricatorTrivialTestCase' => 'PhabricatorTestCase',
'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
'PhabricatorUIExampleController' => 'PhabricatorController',
'PhabricatorUIExampleRenderController' => 'PhabricatorUIExampleController',
'PhabricatorUIExampleRenderController' => 'PhabricatorController',
'PhabricatorUIListFilterExample' => 'PhabricatorUIExample',
'PhabricatorUINotificationExample' => 'PhabricatorUIExample',
'PhabricatorUIPagerExample' => 'PhabricatorUIExample',

View file

@ -166,11 +166,6 @@ class AphrontDefaultApplicationConfiguration
=> 'HeraldTranscriptController',
),
'/uiexample/' => array(
'' => 'PhabricatorUIExampleRenderController',
'view/(?P<class>[^/]+)/' => 'PhabricatorUIExampleRenderController',
),
'/owners/' => array(
'' => 'PhabricatorOwnersListController',
'view/(?P<view>[^/]+)/' => 'PhabricatorOwnersListController',

View file

@ -138,21 +138,26 @@ abstract class PhabricatorApplication {
public static function getAllInstalledApplications() {
$classes = id(new PhutilSymbolLoader())
->setAncestorClass(__CLASS__)
->setConcreteOnly(true)
->selectAndLoadSymbols();
static $applications;
$apps = array();
foreach ($classes as $class) {
$app = newv($class['name'], array());
if (!$app->isEnabled()) {
continue;
if (empty($applications)) {
$classes = id(new PhutilSymbolLoader())
->setAncestorClass(__CLASS__)
->setConcreteOnly(true)
->selectAndLoadSymbols();
$apps = array();
foreach ($classes as $class) {
$app = newv($class['name'], array());
if (!$app->isEnabled()) {
continue;
}
$apps[] = $app;
}
$apps[] = $app;
$applications = $apps;
}
return $apps;
return $applications;
}

View file

@ -0,0 +1,46 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorApplicationUIExamples extends PhabricatorApplication {
public function getBaseURI() {
return '/uiexample/';
}
public function getShortDescription() {
return 'Developer UI Examples';
}
public function getAutospriteName() {
return 'uiexample';
}
public function getTitleGlyph() {
return "\xE2\x8F\x9A";
}
public function getRoutes() {
return array(
'/uiexample/' => array(
'' => 'PhabricatorUIExampleRenderController',
'view/(?P<class>[^/]+)/' => 'PhabricatorUIExampleRenderController',
),
);
}
}

View file

@ -1,34 +0,0 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
abstract class PhabricatorUIExampleController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
$page->setApplicationName('UI Examples');
$page->setBaseURI('/uiexample/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x8F\x9A");
$page->appendChild($view);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
}

View file

@ -16,8 +16,7 @@
* limitations under the License.
*/
final class PhabricatorUIExampleRenderController
extends PhabricatorUIExampleController {
final class PhabricatorUIExampleRenderController extends PhabricatorController {
private $class;
@ -29,44 +28,31 @@ final class PhabricatorUIExampleRenderController
$classes = id(new PhutilSymbolLoader())
->setAncestorClass('PhabricatorUIExample')
->setConcreteOnly(true)
->selectAndLoadSymbols();
$classes = ipull($classes, 'name', 'name');
$selected = null;
foreach ($classes as $class => $ignored) {
$classes[$class] = newv($class, array());
if ($this->class == $classes[$class]->getName()) {
$selected = $class;
}
}
if (!$selected) {
$selected = head_key($classes);
}
$classes = msort($classes, 'getName');
$nav = new AphrontSideNavView();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
foreach ($classes as $class => $obj) {
$name = $obj->getName();
$nav->addNavItem(
phutil_render_tag(
'a',
array(
'href' => '/uiexample/view/'.$name.'/',
'class' => ($selected == $class)
? 'aphront-side-nav-selected'
: null,
),
phutil_escape_html($obj->getName())));
$nav->addFilter($class, $name);
}
$selected = $nav->selectFilter($this->class, head_key($classes));
require_celerity_resource('phabricator-ui-example-css');
$example = $classes[$selected];
$example->setRequest($this->getRequest());
$nav->appendChild(
'<div class="phabricator-ui-example-header">'.
'<h1 class="phabricator-ui-example-name">'.
@ -80,10 +66,11 @@ final class PhabricatorUIExampleRenderController
$nav->appendChild($example->renderExample());
return $this->buildStandardPageResponse(
return $this->buildApplicationPage(
$nav,
array(
'title' => 'UI Example',
'title' => 'UI Example',
'device' => true,
));
}

View file

@ -17,8 +17,9 @@
*/
final class JavelinReactorExample extends PhabricatorUIExample {
public function getName() {
return 'Javelin Reactor Examples';
return 'Javelin Reactor';
}
public function getDescription() {

View file

@ -251,50 +251,58 @@
background-position: 0px -2490px;
}
.action-file {
.app-uiexample-full {
background-position: 0px -2521px;
}
.app-uiexample {
background-position: 0px -2582px;
}
.action-file {
background-position: 0px -2613px;
}
.action-fork {
background-position: 0px -2538px;
background-position: 0px -2630px;
}
.action-edit {
background-position: 0px -2555px;
background-position: 0px -2647px;
}
.action-flag-0 {
background-position: 0px -2572px;
background-position: 0px -2664px;
}
.action-flag-1 {
background-position: 0px -2589px;
background-position: 0px -2681px;
}
.action-flag-2 {
background-position: 0px -2606px;
background-position: 0px -2698px;
}
.action-flag-3 {
background-position: 0px -2623px;
background-position: 0px -2715px;
}
.action-flag-4 {
background-position: 0px -2640px;
background-position: 0px -2732px;
}
.action-flag-5 {
background-position: 0px -2657px;
background-position: 0px -2749px;
}
.action-flag-6 {
background-position: 0px -2674px;
background-position: 0px -2766px;
}
.action-flag-7 {
background-position: 0px -2691px;
background-position: 0px -2783px;
}
.action-flag-ghost {
background-position: 0px -2708px;
background-position: 0px -2800px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 90 KiB