Skip to content

Commit 303ad93

Browse files
author
epriestley
committedSep 11, 2012
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
1 parent 1b7f049 commit 303ad93

11 files changed

+103
-94
lines changed
 

‎scripts/celerity/generate_sprites.php

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function gly($y) {
140140
'feed' => array(3, 11),
141141
'paste' => array(9, 2),
142142
'audit' => array(8, 19),
143+
'uiexample' => array(7, 28),
143144
);
144145

145146
$xadj = -1;

‎src/__celerity_resource_map__.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
),
6666
'/rsrc/image/autosprite.png' =>
6767
array(
68-
'hash' => 'bd70ca6308d6f80a87a10068a04867f8',
69-
'uri' => '/res/bd70ca63/rsrc/image/autosprite.png',
68+
'hash' => '0b78a23fb4cec90e3a35ba1b9ce20f0c',
69+
'uri' => '/res/0b78a23f/rsrc/image/autosprite.png',
7070
'disk' => '/rsrc/image/autosprite.png',
7171
'type' => 'png',
7272
),
@@ -671,7 +671,7 @@
671671
),
672672
'autosprite-css' =>
673673
array(
674-
'uri' => '/res/114f6e40/rsrc/css/autosprite.css',
674+
'uri' => '/res/cb9c82fd/rsrc/css/autosprite.css',
675675
'type' => 'css',
676676
'requires' =>
677677
array(

‎src/__phutil_library_map__.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@
570570
'PhabricatorApplicationProject' => 'applications/project/application/PhabricatorApplicationProject.php',
571571
'PhabricatorApplicationSettings' => 'applications/settings/application/PhabricatorApplicationSettings.php',
572572
'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php',
573+
'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php',
573574
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
574575
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
575576
'PhabricatorAuditAddCommentController' => 'applications/audit/controller/PhabricatorAuditAddCommentController.php',
@@ -1076,7 +1077,6 @@
10761077
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadDatasourceController.php',
10771078
'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php',
10781079
'PhabricatorUIExample' => 'applications/uiexample/examples/PhabricatorUIExample.php',
1079-
'PhabricatorUIExampleController' => 'applications/uiexample/controller/PhabricatorUIExampleController.php',
10801080
'PhabricatorUIExampleRenderController' => 'applications/uiexample/controller/PhabricatorUIExampleRenderController.php',
10811081
'PhabricatorUIListFilterExample' => 'applications/uiexample/examples/PhabricatorUIListFilterExample.php',
10821082
'PhabricatorUINotificationExample' => 'applications/uiexample/examples/PhabricatorUINotificationExample.php',
@@ -1710,6 +1710,7 @@
17101710
'PhabricatorApplicationProject' => 'PhabricatorApplication',
17111711
'PhabricatorApplicationSettings' => 'PhabricatorApplication',
17121712
'PhabricatorApplicationStatusView' => 'AphrontView',
1713+
'PhabricatorApplicationUIExamples' => 'PhabricatorApplication',
17131714
'PhabricatorApplicationsListController' => 'PhabricatorController',
17141715
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
17151716
'PhabricatorAuditComment' => 'PhabricatorAuditDAO',
@@ -2155,8 +2156,7 @@
21552156
'PhabricatorTrivialTestCase' => 'PhabricatorTestCase',
21562157
'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
21572158
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
2158-
'PhabricatorUIExampleController' => 'PhabricatorController',
2159-
'PhabricatorUIExampleRenderController' => 'PhabricatorUIExampleController',
2159+
'PhabricatorUIExampleRenderController' => 'PhabricatorController',
21602160
'PhabricatorUIListFilterExample' => 'PhabricatorUIExample',
21612161
'PhabricatorUINotificationExample' => 'PhabricatorUIExample',
21622162
'PhabricatorUIPagerExample' => 'PhabricatorUIExample',

‎src/aphront/configuration/AphrontDefaultApplicationConfiguration.php

-5
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ public function getURIMap() {
166166
=> 'HeraldTranscriptController',
167167
),
168168

169-
'/uiexample/' => array(
170-
'' => 'PhabricatorUIExampleRenderController',
171-
'view/(?P<class>[^/]+)/' => 'PhabricatorUIExampleRenderController',
172-
),
173-
174169
'/owners/' => array(
175170
'' => 'PhabricatorOwnersListController',
176171
'view/(?P<view>[^/]+)/' => 'PhabricatorOwnersListController',

‎src/applications/base/PhabricatorApplication.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,26 @@ public function buildMainMenuItems(
138138

139139

140140
public static function getAllInstalledApplications() {
141-
$classes = id(new PhutilSymbolLoader())
142-
->setAncestorClass(__CLASS__)
143-
->setConcreteOnly(true)
144-
->selectAndLoadSymbols();
145-
146-
$apps = array();
147-
foreach ($classes as $class) {
148-
$app = newv($class['name'], array());
149-
if (!$app->isEnabled()) {
150-
continue;
141+
static $applications;
142+
143+
if (empty($applications)) {
144+
$classes = id(new PhutilSymbolLoader())
145+
->setAncestorClass(__CLASS__)
146+
->setConcreteOnly(true)
147+
->selectAndLoadSymbols();
148+
149+
$apps = array();
150+
foreach ($classes as $class) {
151+
$app = newv($class['name'], array());
152+
if (!$app->isEnabled()) {
153+
continue;
154+
}
155+
$apps[] = $app;
151156
}
152-
$apps[] = $app;
157+
$applications = $apps;
153158
}
154159

155-
return $apps;
160+
return $applications;
156161
}
157162

158163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2012 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
final class PhabricatorApplicationUIExamples extends PhabricatorApplication {
20+
21+
public function getBaseURI() {
22+
return '/uiexample/';
23+
}
24+
25+
public function getShortDescription() {
26+
return 'Developer UI Examples';
27+
}
28+
29+
public function getAutospriteName() {
30+
return 'uiexample';
31+
}
32+
33+
public function getTitleGlyph() {
34+
return "\xE2\x8F\x9A";
35+
}
36+
37+
public function getRoutes() {
38+
return array(
39+
'/uiexample/' => array(
40+
'' => 'PhabricatorUIExampleRenderController',
41+
'view/(?P<class>[^/]+)/' => 'PhabricatorUIExampleRenderController',
42+
),
43+
);
44+
}
45+
46+
}

‎src/applications/uiexample/controller/PhabricatorUIExampleController.php

-34
This file was deleted.

‎src/applications/uiexample/controller/PhabricatorUIExampleRenderController.php

+11-24
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
final class PhabricatorUIExampleRenderController
20-
extends PhabricatorUIExampleController {
19+
final class PhabricatorUIExampleRenderController extends PhabricatorController {
2120

2221
private $class;
2322

@@ -29,44 +28,31 @@ public function processRequest() {
2928

3029
$classes = id(new PhutilSymbolLoader())
3130
->setAncestorClass('PhabricatorUIExample')
31+
->setConcreteOnly(true)
3232
->selectAndLoadSymbols();
3333
$classes = ipull($classes, 'name', 'name');
3434

35-
$selected = null;
3635
foreach ($classes as $class => $ignored) {
3736
$classes[$class] = newv($class, array());
38-
if ($this->class == $classes[$class]->getName()) {
39-
$selected = $class;
40-
}
4137
}
4238

43-
if (!$selected) {
44-
$selected = head_key($classes);
45-
}
39+
$classes = msort($classes, 'getName');
4640

47-
$nav = new AphrontSideNavView();
41+
$nav = new AphrontSideNavFilterView();
42+
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
4843

4944
foreach ($classes as $class => $obj) {
5045
$name = $obj->getName();
51-
52-
$nav->addNavItem(
53-
phutil_render_tag(
54-
'a',
55-
array(
56-
'href' => '/uiexample/view/'.$name.'/',
57-
'class' => ($selected == $class)
58-
? 'aphront-side-nav-selected'
59-
: null,
60-
),
61-
phutil_escape_html($obj->getName())));
46+
$nav->addFilter($class, $name);
6247
}
6348

49+
$selected = $nav->selectFilter($this->class, head_key($classes));
50+
6451
require_celerity_resource('phabricator-ui-example-css');
6552

6653
$example = $classes[$selected];
6754
$example->setRequest($this->getRequest());
6855

69-
7056
$nav->appendChild(
7157
'<div class="phabricator-ui-example-header">'.
7258
'<h1 class="phabricator-ui-example-name">'.
@@ -80,10 +66,11 @@ public function processRequest() {
8066

8167
$nav->appendChild($example->renderExample());
8268

83-
return $this->buildStandardPageResponse(
69+
return $this->buildApplicationPage(
8470
$nav,
8571
array(
86-
'title' => 'UI Example',
72+
'title' => 'UI Example',
73+
'device' => true,
8774
));
8875
}
8976

‎src/applications/uiexample/examples/JavelinReactorExample.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
*/
1818

1919
final class JavelinReactorExample extends PhabricatorUIExample {
20+
2021
public function getName() {
21-
return 'Javelin Reactor Examples';
22+
return 'Javelin Reactor';
2223
}
2324

2425
public function getDescription() {

‎webroot/rsrc/css/autosprite.css

+20-12
Original file line numberDiff line numberDiff line change
@@ -251,50 +251,58 @@
251251
background-position: 0px -2490px;
252252
}
253253

254-
.action-file {
254+
.app-uiexample-full {
255255
background-position: 0px -2521px;
256256
}
257257

258+
.app-uiexample {
259+
background-position: 0px -2582px;
260+
}
261+
262+
.action-file {
263+
background-position: 0px -2613px;
264+
}
265+
258266
.action-fork {
259-
background-position: 0px -2538px;
267+
background-position: 0px -2630px;
260268
}
261269

262270
.action-edit {
263-
background-position: 0px -2555px;
271+
background-position: 0px -2647px;
264272
}
265273

266274
.action-flag-0 {
267-
background-position: 0px -2572px;
275+
background-position: 0px -2664px;
268276
}
269277

270278
.action-flag-1 {
271-
background-position: 0px -2589px;
279+
background-position: 0px -2681px;
272280
}
273281

274282
.action-flag-2 {
275-
background-position: 0px -2606px;
283+
background-position: 0px -2698px;
276284
}
277285

278286
.action-flag-3 {
279-
background-position: 0px -2623px;
287+
background-position: 0px -2715px;
280288
}
281289

282290
.action-flag-4 {
283-
background-position: 0px -2640px;
291+
background-position: 0px -2732px;
284292
}
285293

286294
.action-flag-5 {
287-
background-position: 0px -2657px;
295+
background-position: 0px -2749px;
288296
}
289297

290298
.action-flag-6 {
291-
background-position: 0px -2674px;
299+
background-position: 0px -2766px;
292300
}
293301

294302
.action-flag-7 {
295-
background-position: 0px -2691px;
303+
background-position: 0px -2783px;
296304
}
297305

298306
.action-flag-ghost {
299-
background-position: 0px -2708px;
307+
background-position: 0px -2800px;
300308
}

‎webroot/rsrc/image/autosprite.png

2.84 KB
Loading

0 commit comments

Comments
 (0)
Failed to load comments.