mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Separate "PhabricatorBarePageView" out of "PhabricatorStandardPageView"
Summary: For Phame, we really want more than a chromeless page -- it shouldn't have Javelin or Phabricator styles on it. Pull the bare infrastructure out of StandardPageView and make it available as BarePageView. Test Plan: Viewed bare page in UIExamples, various non-bare pages. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D3711
This commit is contained in:
parent
c02a588b4e
commit
9fa4c2d406
6 changed files with 204 additions and 73 deletions
|
@ -601,6 +601,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuditReplyHandler' => 'applications/audit/PhabricatorAuditReplyHandler.php',
|
||||
'PhabricatorAuditStatusConstants' => 'applications/audit/constants/PhabricatorAuditStatusConstants.php',
|
||||
'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php',
|
||||
'PhabricatorBarePageExample' => 'applications/uiexample/examples/PhabricatorBarePageExample.php',
|
||||
'PhabricatorBarePageView' => 'view/page/PhabricatorBarePageView.php',
|
||||
'PhabricatorBaseEnglishTranslation' => 'infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php',
|
||||
'PhabricatorBlogSkin' => 'applications/phame/view/skins/PhabricatorBlogSkin.php',
|
||||
'PhabricatorBuiltinPatchList' => 'infrastructure/storage/patch/PhabricatorBuiltinPatchList.php',
|
||||
|
@ -1785,6 +1787,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuditPreviewController' => 'PhabricatorAuditController',
|
||||
'PhabricatorAuditReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'PhabricatorAuthController' => 'PhabricatorController',
|
||||
'PhabricatorBarePageExample' => 'PhabricatorUIExample',
|
||||
'PhabricatorBarePageView' => 'AphrontPageView',
|
||||
'PhabricatorBaseEnglishTranslation' => 'PhabricatorTranslation',
|
||||
'PhabricatorBlogSkin' => 'PhameBlogSkin',
|
||||
'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList',
|
||||
|
@ -2203,7 +2207,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSlugTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorSortTableExample' => 'PhabricatorUIExample',
|
||||
'PhabricatorSourceCodeView' => 'AphrontView',
|
||||
'PhabricatorStandardPageView' => 'AphrontPageView',
|
||||
'PhabricatorStandardPageView' => 'PhabricatorBarePageView',
|
||||
'PhabricatorStatusController' => 'PhabricatorController',
|
||||
'PhabricatorStorageManagementDatabasesWorkflow' => 'PhabricatorStorageManagementWorkflow',
|
||||
'PhabricatorStorageManagementDestroyWorkflow' => 'PhabricatorStorageManagementWorkflow',
|
||||
|
|
|
@ -48,8 +48,6 @@ final class PhabricatorUIExampleRenderController extends PhabricatorController {
|
|||
|
||||
$selected = $nav->selectFilter($this->class, head_key($classes));
|
||||
|
||||
require_celerity_resource('phabricator-ui-example-css');
|
||||
|
||||
$example = $classes[$selected];
|
||||
$example->setRequest($this->getRequest());
|
||||
|
||||
|
@ -59,6 +57,8 @@ final class PhabricatorUIExampleRenderController extends PhabricatorController {
|
|||
return $result;
|
||||
}
|
||||
|
||||
require_celerity_resource('phabricator-ui-example-css');
|
||||
|
||||
$nav->appendChild(
|
||||
'<div class="phabricator-ui-example-header">'.
|
||||
'<h1 class="phabricator-ui-example-name">'.
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?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 PhabricatorBarePageExample extends PhabricatorUIExample {
|
||||
|
||||
public function getName() {
|
||||
return 'Bare Page';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return 'This is a bare page.';
|
||||
}
|
||||
|
||||
public function renderExample() {
|
||||
$view = new PhabricatorBarePageView();
|
||||
$view->appendChild(
|
||||
phutil_render_tag(
|
||||
'h1',
|
||||
array(),
|
||||
phutil_escape_html($this->getDescription())));
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
$response->setContent($view->render());
|
||||
return $response;
|
||||
}
|
||||
}
|
|
@ -68,6 +68,13 @@ abstract class AphrontPageView extends AphrontView {
|
|||
|
||||
$body_classes = $this->getBodyClasses();
|
||||
|
||||
$body = phutil_render_tag(
|
||||
'body',
|
||||
array(
|
||||
'class' => nonempty($body_classes, null),
|
||||
),
|
||||
$body.$tail);
|
||||
|
||||
$response = <<<EOHTML
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -76,10 +83,7 @@ abstract class AphrontPageView extends AphrontView {
|
|||
<title>{$title}</title>
|
||||
{$head}
|
||||
</head>
|
||||
<body class="{$body_classes}">
|
||||
{$body}
|
||||
{$tail}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
EOHTML;
|
||||
|
|
121
src/view/page/PhabricatorBarePageView.php
Normal file
121
src/view/page/PhabricatorBarePageView.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a bare HTML page view which has access to Phabricator page
|
||||
* infrastructure like Celerity, but no content or builtin static resources.
|
||||
* You basically get a valid HMTL5 document and an empty body tag.
|
||||
*
|
||||
* @concrete-extensible
|
||||
*/
|
||||
class PhabricatorBarePageView extends AphrontPageView {
|
||||
|
||||
private $request;
|
||||
private $controller;
|
||||
private $frameable;
|
||||
private $deviceReady;
|
||||
|
||||
private $bodyContent;
|
||||
|
||||
public function setController(AphrontController $controller) {
|
||||
$this->controller = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getController() {
|
||||
return $this->controller;
|
||||
}
|
||||
|
||||
public function setRequest(AphrontRequest $request) {
|
||||
$this->request = $request;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function setFrameable($frameable) {
|
||||
$this->frameable = $frameable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFrameable() {
|
||||
return $this->frameable;
|
||||
}
|
||||
|
||||
public function setDeviceReady($device_ready) {
|
||||
$this->deviceReady = $device_ready;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeviceReady() {
|
||||
return $this->deviceReady;
|
||||
}
|
||||
|
||||
protected function willRenderPage() {
|
||||
// We render this now to resolve static resources so they can appear in the
|
||||
// document head.
|
||||
$this->bodyContent = $this->renderChildren();
|
||||
}
|
||||
|
||||
protected function getHead() {
|
||||
$framebust = null;
|
||||
if (!$this->getFrameable()) {
|
||||
$framebust = '(top != self) && top.location.replace(self.location.href);';
|
||||
}
|
||||
|
||||
$viewport_tag = null;
|
||||
if (PhabricatorEnv::getEnvConfig('preview.viewport-meta-tag') ||
|
||||
$this->getDeviceReady()) {
|
||||
$viewport_tag = phutil_render_tag(
|
||||
'meta',
|
||||
array(
|
||||
'name' => 'viewport',
|
||||
'content' => 'width=device-width, '.
|
||||
'initial-scale=1, '.
|
||||
'maximum-scale=1',
|
||||
));
|
||||
}
|
||||
|
||||
$response = CelerityAPI::getStaticResourceResponse();
|
||||
|
||||
$head = array(
|
||||
$viewport_tag,
|
||||
|
||||
'<script type="text/javascript">'.
|
||||
$framebust.
|
||||
'window.__DEV__=1;'.
|
||||
'</script>',
|
||||
|
||||
$response->renderResourcesOfType('css'),
|
||||
);
|
||||
|
||||
return implode("\n", $head);
|
||||
}
|
||||
|
||||
protected function getBody() {
|
||||
return $this->bodyContent;
|
||||
}
|
||||
|
||||
protected function getTail() {
|
||||
$response = CelerityAPI::getStaticResourceResponse();
|
||||
return $response->renderResourcesOfType('js');
|
||||
}
|
||||
|
||||
}
|
|
@ -16,50 +16,27 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorStandardPageView extends AphrontPageView {
|
||||
/**
|
||||
* This is a standard Phabricator page with menus, Javelin, DarkConsole, and
|
||||
* basic styles.
|
||||
*
|
||||
*/
|
||||
final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
||||
|
||||
private $baseURI;
|
||||
private $applicationName;
|
||||
private $glyph;
|
||||
private $bodyContent;
|
||||
private $menuContent;
|
||||
private $request;
|
||||
private $showChrome = true;
|
||||
private $isFrameable = false;
|
||||
private $disableConsole;
|
||||
private $searchDefaultScope;
|
||||
private $pageObjects = array();
|
||||
private $controller;
|
||||
|
||||
|
||||
public function setController(AphrontController $controller) {
|
||||
$this->controller = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getController() {
|
||||
return $this->controller;
|
||||
}
|
||||
|
||||
public function setRequest($request) {
|
||||
$this->request = $request;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function setApplicationName($application_name) {
|
||||
$this->applicationName = $application_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFrameable($frameable) {
|
||||
$this->isFrameable = $frameable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDisableConsole($disable) {
|
||||
$this->disableConsole = $disable;
|
||||
return $this;
|
||||
|
@ -120,6 +97,7 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
|
||||
|
||||
protected function willRenderPage() {
|
||||
parent::willRenderPage();
|
||||
|
||||
if (!$this->getRequest()) {
|
||||
throw new Exception(
|
||||
|
@ -168,19 +146,10 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
}
|
||||
|
||||
$this->menuContent = $this->renderMainMenu();
|
||||
$this->bodyContent = $this->renderChildren();
|
||||
}
|
||||
|
||||
|
||||
protected function getHead() {
|
||||
|
||||
$framebust = null;
|
||||
if (!$this->isFrameable) {
|
||||
$framebust = '(top != self) && top.location.replace(self.location.href);';
|
||||
}
|
||||
|
||||
$response = CelerityAPI::getStaticResourceResponse();
|
||||
|
||||
$monospaced = PhabricatorEnv::getEnvConfig('style.monospace');
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
@ -194,32 +163,17 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
}
|
||||
}
|
||||
|
||||
$viewport_tag = null;
|
||||
if (PhabricatorEnv::getEnvConfig('preview.viewport-meta-tag') ||
|
||||
$this->deviceReady) {
|
||||
$viewport_tag = phutil_render_tag(
|
||||
'meta',
|
||||
array(
|
||||
'name' => 'viewport',
|
||||
'content' => 'width=device-width, '.
|
||||
'initial-scale=1, '.
|
||||
'maximum-scale=1',
|
||||
));
|
||||
}
|
||||
$response = CelerityAPI::getStaticResourceResponse();
|
||||
|
||||
$head =
|
||||
$viewport_tag.
|
||||
'<script type="text/javascript">'.
|
||||
$framebust.
|
||||
'window.__DEV__=1;'.
|
||||
'</script>'.
|
||||
$response->renderResourcesOfType('css').
|
||||
$head = array(
|
||||
parent::getHead(),
|
||||
'<style type="text/css">'.
|
||||
'.PhabricatorMonospaced { font: '.$monospaced.'; }'.
|
||||
'</style>'.
|
||||
$response->renderSingleResource('javelin-magical-init');
|
||||
'</style>',
|
||||
$response->renderSingleResource('javelin-magical-init'),
|
||||
);
|
||||
|
||||
return $head;
|
||||
return implode("\n", $head);
|
||||
}
|
||||
|
||||
public function setGlyph($glyph) {
|
||||
|
@ -232,6 +186,8 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
}
|
||||
|
||||
protected function willSendResponse($response) {
|
||||
$response = parent::willSendResponse($response);
|
||||
|
||||
$console = $this->getRequest()->getApplicationConfiguration()->getConsole();
|
||||
if ($console) {
|
||||
$response = str_replace(
|
||||
|
@ -239,6 +195,7 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
$console->render($this->getRequest()),
|
||||
$response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
@ -293,7 +250,7 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
if ($this->getShowChrome()) {
|
||||
$header_chrome = $this->menuContent;
|
||||
|
||||
if (!$this->deviceReady) {
|
||||
if (!$this->getDeviceReady()) {
|
||||
$footer_chrome = $this->renderFooter();
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +293,7 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
'<div class="phabricator-standard-page-body">'.
|
||||
($console ? '<darkconsole />' : null).
|
||||
$developer_warning.
|
||||
$this->bodyContent.
|
||||
parent::getBody().
|
||||
'<div style="clear: both;"></div>'.
|
||||
'</div>').
|
||||
$footer_chrome;
|
||||
|
@ -382,10 +339,14 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
}
|
||||
|
||||
$response = CelerityAPI::getStaticResourceResponse();
|
||||
return
|
||||
$response->renderResourcesOfType('js').
|
||||
$container.
|
||||
$response->renderHTMLFooter();
|
||||
|
||||
$tail = array(
|
||||
parent::getTail(),
|
||||
$container,
|
||||
$response->renderHTMLFooter(),
|
||||
);
|
||||
|
||||
return implode("\n", $tail);
|
||||
}
|
||||
|
||||
protected function getBodyClasses() {
|
||||
|
|
Loading…
Reference in a new issue