diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -81,7 +81,7 @@ '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 @@ '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', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3708,7 +3708,9 @@ '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 @@ 'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO', 'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController', 'PhabricatorYoutubeRemarkupRule' => 'PhutilRemarkupRule', + 'Phame404Response' => 'AphrontHTMLResponse', 'PhameBlog' => array( 'PhameDAO', 'PhabricatorPolicyInterface', @@ -8519,6 +8522,7 @@ 'PhabricatorApplicationTransactionInterface', 'PhabricatorConduitResultInterface', ), + 'PhameBlog404Controller' => 'PhameLiveController', 'PhameBlogArchiveController' => 'PhameBlogController', 'PhameBlogController' => 'PhameController', 'PhameBlogCreateCapability' => 'PhabricatorPolicyCapability', diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php --- a/src/applications/phame/application/PhabricatorPhameApplication.php +++ b/src/applications/phame/application/PhabricatorPhameApplication.php @@ -93,7 +93,9 @@ '/' => array( '' => 'PhameBlogViewController', 'post/(?P\d+)/(?:(?P[^/]+)/)?' => 'PhamePostViewController', + '.*' => 'PhameBlog404Controller', ), + ); } diff --git a/src/applications/phame/controller/PhameLiveController.php b/src/applications/phame/controller/PhameLiveController.php --- a/src/applications/phame/controller/PhameLiveController.php +++ b/src/applications/phame/controller/PhameLiveController.php @@ -70,6 +70,8 @@ $blog = $blog_query->executeOne(); if (!$blog) { + $this->isExternal = $is_external; + $this->isLive = $is_live; return new Aphront404Response(); } @@ -81,6 +83,9 @@ $blog = null; } + $this->isExternal = $is_external; + $this->isLive = $is_live; + if ($post_id) { $post_query = id(new PhamePostQuery()) ->setViewer($viewer) @@ -109,8 +114,6 @@ $post = null; } - $this->isExternal = $is_external; - $this->isLive = $is_live; $this->blog = $blog; $this->post = $post; @@ -188,4 +191,30 @@ 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; + } + } diff --git a/src/applications/phame/controller/blog/PhameBlog404Controller.php b/src/applications/phame/controller/blog/PhameBlog404Controller.php new file mode 100644 --- /dev/null +++ b/src/applications/phame/controller/blog/PhameBlog404Controller.php @@ -0,0 +1,14 @@ +setupLiveEnvironment(); + if ($response) { + return $response; + } + + return new Aphront404Response(); + } + +} diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -108,12 +108,6 @@ $about, )); - if ($is_live) { - $page - ->setShowChrome(false) - ->setShowFooter(false); - } - return $page; } diff --git a/src/applications/phame/site/Phame404Response.php b/src/applications/phame/site/Phame404Response.php new file mode 100644 --- /dev/null +++ b/src/applications/phame/site/Phame404Response.php @@ -0,0 +1,43 @@ +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(); + } + +} diff --git a/webroot/rsrc/css/application/phame/phame.css b/webroot/rsrc/css/application/phame/phame.css --- a/webroot/rsrc/css/application/phame/phame.css +++ b/webroot/rsrc/css/application/phame/phame.css @@ -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}; +}