1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Improve routing of "/robots.txt", "/favicon.ico", and "/status/" on Short and Blog sites

Summary: Ref T13636. Add routing for "/robots.txt", "favicon.ico", and "/status/" on the ShortSite and BlogSite.

Test Plan: Visted all resources (and 404 pages) on Short and Blog sites, and Platform site.

Maniphest Tasks: T13636

Differential Revision: https://secure.phabricator.com/D21607
This commit is contained in:
epriestley 2021-03-11 13:47:23 -08:00
parent 36c6eb9663
commit 31c9d4094f
8 changed files with 59 additions and 11 deletions

View file

@ -4689,9 +4689,11 @@ phutil_register_library_map(array(
'PhabricatorRequestExceptionHandler' => 'aphront/handler/PhabricatorRequestExceptionHandler.php',
'PhabricatorResetPasswordUserLogType' => 'applications/people/userlog/PhabricatorResetPasswordUserLogType.php',
'PhabricatorResourceSite' => 'aphront/site/PhabricatorResourceSite.php',
'PhabricatorRobotsController' => 'applications/system/controller/PhabricatorRobotsController.php',
'PhabricatorRobotsPlatformController' => 'applications/system/controller/PhabricatorRobotsPlatformController.php',
'PhabricatorRobotsResourceController' => 'applications/system/controller/PhabricatorRobotsResourceController.php',
'PhabricatorRobotsBlogController' => 'applications/system/controller/robots/PhabricatorRobotsBlogController.php',
'PhabricatorRobotsController' => 'applications/system/controller/robots/PhabricatorRobotsController.php',
'PhabricatorRobotsPlatformController' => 'applications/system/controller/robots/PhabricatorRobotsPlatformController.php',
'PhabricatorRobotsResourceController' => 'applications/system/controller/robots/PhabricatorRobotsResourceController.php',
'PhabricatorRobotsShortController' => 'applications/system/controller/robots/PhabricatorRobotsShortController.php',
'PhabricatorS3FileStorageEngine' => 'applications/files/engine/PhabricatorS3FileStorageEngine.php',
'PhabricatorSMSAuthFactor' => 'applications/auth/factor/PhabricatorSMSAuthFactor.php',
'PhabricatorSQLPatchList' => 'infrastructure/storage/patch/PhabricatorSQLPatchList.php',
@ -11474,9 +11476,11 @@ phutil_register_library_map(array(
'PhabricatorRequestExceptionHandler' => 'AphrontRequestExceptionHandler',
'PhabricatorResetPasswordUserLogType' => 'PhabricatorUserLogType',
'PhabricatorResourceSite' => 'PhabricatorSite',
'PhabricatorRobotsBlogController' => 'PhabricatorRobotsController',
'PhabricatorRobotsController' => 'PhabricatorController',
'PhabricatorRobotsPlatformController' => 'PhabricatorRobotsController',
'PhabricatorRobotsResourceController' => 'PhabricatorRobotsController',
'PhabricatorRobotsShortController' => 'PhabricatorRobotsController',
'PhabricatorS3FileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorSMSAuthFactor' => 'PhabricatorAuthFactor',
'PhabricatorSQLPatchList' => 'Phobject',

View file

@ -70,7 +70,11 @@ final class PhabricatorPhameApplication extends PhabricatorApplication {
}
public function getBlogRoutes() {
return $this->getLiveRoutes();
return $this->getLiveRoutes() + array(
'/status/' => 'PhabricatorStatusController',
'/favicon.ico' => 'PhabricatorFaviconController',
'/robots.txt' => 'PhabricatorRobotsBlogController',
);
}
private function getLiveRoutes() {

View file

@ -55,6 +55,10 @@ final class PhabricatorPhurlApplication extends PhabricatorApplication {
public function getShortRoutes() {
return array(
'/status/' => 'PhabricatorStatusController',
'/favicon.ico' => 'PhabricatorFaviconController',
'/robots.txt' => 'PhabricatorRobotsShortController',
'/u/(?P<append>[^/]+)' => 'PhabricatorPhurlShortURLController',
'.*' => 'PhabricatorPhurlShortURLDefaultController',
);

View file

@ -0,0 +1,17 @@
<?php
final class PhabricatorRobotsBlogController
extends PhabricatorRobotsController {
protected function newRobotsRules() {
$out = array();
// Allow everything on blog domains to be indexed.
$out[] = 'User-Agent: *';
$out[] = 'Crawl-delay: 1';
return $out;
}
}

View file

@ -9,13 +9,6 @@ abstract class PhabricatorRobotsController extends PhabricatorController {
final public function processRequest() {
$out = $this->newRobotsRules();
// Add a small crawl delay (number of seconds between requests) for spiders
// which respect it. The intent here is to prevent spiders from affecting
// performance for users. The possible cost is slower indexing, but that
// seems like a reasonable tradeoff, since most Phabricator installs are
// probably not hugely concerned about cutting-edge SEO.
$out[] = 'Crawl-delay: 1';
$content = implode("\n", $out)."\n";
return id(new AphrontPlainTextResponse())

View file

@ -19,6 +19,13 @@ final class PhabricatorRobotsPlatformController
$out[] = 'Disallow: /diffusion/';
$out[] = 'Disallow: /source/';
// Add a small crawl delay (number of seconds between requests) for spiders
// which respect it. The intent here is to prevent spiders from affecting
// performance for users. The possible cost is slower indexing, but that
// seems like a reasonable tradeoff, since most Phabricator installs are
// probably not hugely concerned about cutting-edge SEO.
$out[] = 'Crawl-delay: 1';
return $out;
}

View file

@ -10,6 +10,7 @@ final class PhabricatorRobotsResourceController
$out[] = 'User-Agent: *';
$out[] = 'Disallow: /';
$out[] = 'Crawl-delay: 1';
return $out;
}

View file

@ -0,0 +1,18 @@
<?php
final class PhabricatorRobotsShortController
extends PhabricatorRobotsController {
protected function newRobotsRules() {
$out = array();
// See T13636. Prevent indexing of any content on short domains.
$out[] = 'User-Agent: *';
$out[] = 'Disallow: /';
$out[] = 'Crawl-delay: 1';
return $out;
}
}