@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+106 -10
+2 -2
resources/celerity/map.php
··· 81 81 'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b', 82 82 'rsrc/css/application/paste/paste.css' => '1898e534', 83 83 'rsrc/css/application/people/people-profile.css' => '2473d929', 84 - 'rsrc/css/application/phame/phame.css' => '737792d6', 84 + 'rsrc/css/application/phame/phame.css' => '7448a969', 85 85 'rsrc/css/application/pholio/pholio-edit.css' => 'b15fec4a', 86 86 'rsrc/css/application/pholio/pholio-inline-comments.css' => '8e545e49', 87 87 'rsrc/css/application/pholio/pholio.css' => 'ca89d380', ··· 806 806 'phabricator-uiexample-reactor-sendclass' => '1def2711', 807 807 'phabricator-uiexample-reactor-sendproperties' => 'b1f0ccee', 808 808 'phabricator-zindex-css' => '5b6fcf3f', 809 - 'phame-css' => '737792d6', 809 + 'phame-css' => '7448a969', 810 810 'pholio-css' => 'ca89d380', 811 811 'pholio-edit-css' => 'b15fec4a', 812 812 'pholio-inline-comments-css' => '8e545e49',
+4
src/__phutil_library_map__.php
··· 3708 3708 'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php', 3709 3709 'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php', 3710 3710 'PhabricatorYoutubeRemarkupRule' => 'infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php', 3711 + 'Phame404Response' => 'applications/phame/site/Phame404Response.php', 3711 3712 'PhameBlog' => 'applications/phame/storage/PhameBlog.php', 3713 + 'PhameBlog404Controller' => 'applications/phame/controller/blog/PhameBlog404Controller.php', 3712 3714 'PhameBlogArchiveController' => 'applications/phame/controller/blog/PhameBlogArchiveController.php', 3713 3715 'PhameBlogController' => 'applications/phame/controller/blog/PhameBlogController.php', 3714 3716 'PhameBlogCreateCapability' => 'applications/phame/capability/PhameBlogCreateCapability.php', ··· 8508 8510 'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO', 8509 8511 'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController', 8510 8512 'PhabricatorYoutubeRemarkupRule' => 'PhutilRemarkupRule', 8513 + 'Phame404Response' => 'AphrontHTMLResponse', 8511 8514 'PhameBlog' => array( 8512 8515 'PhameDAO', 8513 8516 'PhabricatorPolicyInterface', ··· 8519 8522 'PhabricatorApplicationTransactionInterface', 8520 8523 'PhabricatorConduitResultInterface', 8521 8524 ), 8525 + 'PhameBlog404Controller' => 'PhameLiveController', 8522 8526 'PhameBlogArchiveController' => 'PhameBlogController', 8523 8527 'PhameBlogController' => 'PhameController', 8524 8528 'PhameBlogCreateCapability' => 'PhabricatorPolicyCapability',
+2
src/applications/phame/application/PhabricatorPhameApplication.php
··· 93 93 '/' => array( 94 94 '' => 'PhameBlogViewController', 95 95 'post/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController', 96 + '.*' => 'PhameBlog404Controller', 96 97 ), 98 + 97 99 ); 98 100 } 99 101
+31 -2
src/applications/phame/controller/PhameLiveController.php
··· 70 70 71 71 $blog = $blog_query->executeOne(); 72 72 if (!$blog) { 73 + $this->isExternal = $is_external; 74 + $this->isLive = $is_live; 73 75 return new Aphront404Response(); 74 76 } 75 77 ··· 80 82 $is_live = false; 81 83 $blog = null; 82 84 } 85 + 86 + $this->isExternal = $is_external; 87 + $this->isLive = $is_live; 83 88 84 89 if ($post_id) { 85 90 $post_query = id(new PhamePostQuery()) ··· 109 114 $post = null; 110 115 } 111 116 112 - $this->isExternal = $is_external; 113 - $this->isLive = $is_live; 114 117 $this->blog = $blog; 115 118 $this->post = $post; 116 119 ··· 186 189 } 187 190 188 191 return $crumbs; 192 + } 193 + 194 + public function willSendResponse(AphrontResponse $response) { 195 + if ($this->getIsExternal()) { 196 + if ($response instanceof Aphront404Response) { 197 + $page = $this->newPage() 198 + ->setCrumbs($this->buildApplicationCrumbs()); 199 + 200 + $response = id(new Phame404Response()) 201 + ->setPage($page); 202 + } 203 + } 204 + 205 + return parent::willSendResponse($response); 206 + } 207 + 208 + public function newPage() { 209 + $page = parent::newPage(); 210 + 211 + if ($this->getIsLive()) { 212 + $page 213 + ->setShowChrome(false) 214 + ->setShowFooter(false); 215 + } 216 + 217 + return $page; 189 218 } 190 219 191 220 }
+14
src/applications/phame/controller/blog/PhameBlog404Controller.php
··· 1 + <?php 2 + 3 + final class PhameBlog404Controller extends PhameLiveController { 4 + 5 + public function handleRequest(AphrontRequest $request) { 6 + $response = $this->setupLiveEnvironment(); 7 + if ($response) { 8 + return $response; 9 + } 10 + 11 + return new Aphront404Response(); 12 + } 13 + 14 + }
-6
src/applications/phame/controller/blog/PhameBlogViewController.php
··· 108 108 $about, 109 109 )); 110 110 111 - if ($is_live) { 112 - $page 113 - ->setShowChrome(false) 114 - ->setShowFooter(false); 115 - } 116 - 117 111 return $page; 118 112 } 119 113
+43
src/applications/phame/site/Phame404Response.php
··· 1 + <?php 2 + 3 + final class Phame404Response extends AphrontHTMLResponse { 4 + 5 + private $page; 6 + 7 + public function setPage(AphrontPageView $page) { 8 + $this->page = $page; 9 + return $this; 10 + } 11 + 12 + public function getPage() { 13 + return $this->page; 14 + } 15 + 16 + public function getHTTPResponseCode() { 17 + return 404; 18 + } 19 + 20 + public function buildResponseString() { 21 + require_celerity_resource('phame-css'); 22 + 23 + $not_found = phutil_tag( 24 + 'div', 25 + array( 26 + 'class' => 'phame-404', 27 + ), 28 + array( 29 + phutil_tag('strong', array(), pht('404 Not Found')), 30 + phutil_tag('br'), 31 + pht('Wherever you go, there you are.'), 32 + phutil_tag('br'), 33 + pht('But the page you seek is elsewhere.'), 34 + )); 35 + 36 + $page = $this->getPage() 37 + ->setTitle(pht('404 Not Found')) 38 + ->appendChild($not_found); 39 + 40 + return $page->render(); 41 + } 42 + 43 + }
+10
webroot/rsrc/css/application/phame/phame.css
··· 243 243 left: 50px; 244 244 position: absolute; 245 245 } 246 + 247 + .phame-404 { 248 + margin: 48px auto; 249 + padding: 12px 24px; 250 + border-radius: 6px; 251 + min-width: 240px; 252 + width: 50%; 253 + color: {$darkgreytext}; 254 + background: {$greybackground}; 255 + }