mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Give Phame blogs an explicit 404 controller
Summary: Ref T11076. Ref T9897. Bad links on Phame blogs are currently made worse because we try to prompt you to login on a non-cookie domain. Instead, just 404 in a vanilla way. Do so cleanly on external domains. Test Plan: {F1672399} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9897, T11076 Differential Revision: https://secure.phabricator.com/D16010
This commit is contained in:
parent
24acac117b
commit
03e54afc14
8 changed files with 106 additions and 10 deletions
|
@ -81,7 +81,7 @@ return array(
|
|||
'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b',
|
||||
'rsrc/css/application/paste/paste.css' => '1898e534',
|
||||
'rsrc/css/application/people/people-profile.css' => '2473d929',
|
||||
'rsrc/css/application/phame/phame.css' => '737792d6',
|
||||
'rsrc/css/application/phame/phame.css' => '7448a969',
|
||||
'rsrc/css/application/pholio/pholio-edit.css' => 'b15fec4a',
|
||||
'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49',
|
||||
'rsrc/css/application/pholio/pholio.css' => 'ca89d380',
|
||||
|
@ -806,7 +806,7 @@ return array(
|
|||
'phabricator-uiexample-reactor-sendclass' => '1def2711',
|
||||
'phabricator-uiexample-reactor-sendproperties' => 'b1f0ccee',
|
||||
'phabricator-zindex-css' => '5b6fcf3f',
|
||||
'phame-css' => '737792d6',
|
||||
'phame-css' => '7448a969',
|
||||
'pholio-css' => 'ca89d380',
|
||||
'pholio-edit-css' => 'b15fec4a',
|
||||
'pholio-inline-comments-css' => '8e545e49',
|
||||
|
|
|
@ -3708,7 +3708,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php',
|
||||
'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php',
|
||||
'PhabricatorYoutubeRemarkupRule' => 'infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php',
|
||||
'Phame404Response' => 'applications/phame/site/Phame404Response.php',
|
||||
'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
|
||||
'PhameBlog404Controller' => 'applications/phame/controller/blog/PhameBlog404Controller.php',
|
||||
'PhameBlogArchiveController' => 'applications/phame/controller/blog/PhameBlogArchiveController.php',
|
||||
'PhameBlogController' => 'applications/phame/controller/blog/PhameBlogController.php',
|
||||
'PhameBlogCreateCapability' => 'applications/phame/capability/PhameBlogCreateCapability.php',
|
||||
|
@ -8508,6 +8510,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO',
|
||||
'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController',
|
||||
'PhabricatorYoutubeRemarkupRule' => 'PhutilRemarkupRule',
|
||||
'Phame404Response' => 'AphrontHTMLResponse',
|
||||
'PhameBlog' => array(
|
||||
'PhameDAO',
|
||||
'PhabricatorPolicyInterface',
|
||||
|
@ -8519,6 +8522,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorConduitResultInterface',
|
||||
),
|
||||
'PhameBlog404Controller' => 'PhameLiveController',
|
||||
'PhameBlogArchiveController' => 'PhameBlogController',
|
||||
'PhameBlogController' => 'PhameController',
|
||||
'PhameBlogCreateCapability' => 'PhabricatorPolicyCapability',
|
||||
|
|
|
@ -93,7 +93,9 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
|
|||
'/' => array(
|
||||
'' => 'PhameBlogViewController',
|
||||
'post/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController',
|
||||
'.*' => 'PhameBlog404Controller',
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ abstract class PhameLiveController extends PhameController {
|
|||
|
||||
$blog = $blog_query->executeOne();
|
||||
if (!$blog) {
|
||||
$this->isExternal = $is_external;
|
||||
$this->isLive = $is_live;
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
|
@ -81,6 +83,9 @@ abstract class PhameLiveController extends PhameController {
|
|||
$blog = null;
|
||||
}
|
||||
|
||||
$this->isExternal = $is_external;
|
||||
$this->isLive = $is_live;
|
||||
|
||||
if ($post_id) {
|
||||
$post_query = id(new PhamePostQuery())
|
||||
->setViewer($viewer)
|
||||
|
@ -109,8 +114,6 @@ abstract class PhameLiveController extends PhameController {
|
|||
$post = null;
|
||||
}
|
||||
|
||||
$this->isExternal = $is_external;
|
||||
$this->isLive = $is_live;
|
||||
$this->blog = $blog;
|
||||
$this->post = $post;
|
||||
|
||||
|
@ -188,4 +191,30 @@ abstract class PhameLiveController extends PhameController {
|
|||
return $crumbs;
|
||||
}
|
||||
|
||||
public function willSendResponse(AphrontResponse $response) {
|
||||
if ($this->getIsExternal()) {
|
||||
if ($response instanceof Aphront404Response) {
|
||||
$page = $this->newPage()
|
||||
->setCrumbs($this->buildApplicationCrumbs());
|
||||
|
||||
$response = id(new Phame404Response())
|
||||
->setPage($page);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::willSendResponse($response);
|
||||
}
|
||||
|
||||
public function newPage() {
|
||||
$page = parent::newPage();
|
||||
|
||||
if ($this->getIsLive()) {
|
||||
$page
|
||||
->setShowChrome(false)
|
||||
->setShowFooter(false);
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlog404Controller extends PhameLiveController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$response = $this->setupLiveEnvironment();
|
||||
if ($response) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
}
|
|
@ -108,12 +108,6 @@ final class PhameBlogViewController extends PhameLiveController {
|
|||
$about,
|
||||
));
|
||||
|
||||
if ($is_live) {
|
||||
$page
|
||||
->setShowChrome(false)
|
||||
->setShowFooter(false);
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
|
43
src/applications/phame/site/Phame404Response.php
Normal file
43
src/applications/phame/site/Phame404Response.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
final class Phame404Response extends AphrontHTMLResponse {
|
||||
|
||||
private $page;
|
||||
|
||||
public function setPage(AphrontPageView $page) {
|
||||
$this->page = $page;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPage() {
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
public function getHTTPResponseCode() {
|
||||
return 404;
|
||||
}
|
||||
|
||||
public function buildResponseString() {
|
||||
require_celerity_resource('phame-css');
|
||||
|
||||
$not_found = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phame-404',
|
||||
),
|
||||
array(
|
||||
phutil_tag('strong', array(), pht('404 Not Found')),
|
||||
phutil_tag('br'),
|
||||
pht('Wherever you go, there you are.'),
|
||||
phutil_tag('br'),
|
||||
pht('But the page you seek is elsewhere.'),
|
||||
));
|
||||
|
||||
$page = $this->getPage()
|
||||
->setTitle(pht('404 Not Found'))
|
||||
->appendChild($not_found);
|
||||
|
||||
return $page->render();
|
||||
}
|
||||
|
||||
}
|
|
@ -243,3 +243,13 @@
|
|||
left: 50px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.phame-404 {
|
||||
margin: 48px auto;
|
||||
padding: 12px 24px;
|
||||
border-radius: 6px;
|
||||
min-width: 240px;
|
||||
width: 50%;
|
||||
color: {$darkgreytext};
|
||||
background: {$greybackground};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue