1
0
Fork 0

Merge pull request #7100 from nupplaphil/task/mod_robots_txt

Move mod/robots_txt to src/Module/RobotsTxt
This commit is contained in:
Hypolite Petovan 2019-05-05 14:23:10 -04:00 committed by GitHub
commit 12b6ab9943
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 30 deletions

View file

@ -1,30 +0,0 @@
<?php
/**
* @file mod/robots_text.php
* @brief Module which returns the default robots.txt
* @version 0.1.2
*/
use Friendica\App;
/**
* @brief Return default robots.txt when init
* @param App $a
* @return void
*/
function robots_txt_init(App $a)
{
$allDisalloweds = [
'/settings/',
'/admin/',
'/message/',
];
header('Content-Type: text/plain');
echo 'User-agent: *' . PHP_EOL;
foreach ($allDisalloweds as $disallowed) {
echo 'Disallow: ' . $disallowed . PHP_EOL;
}
exit();
}

View file

@ -166,6 +166,7 @@ class Router
$collector->addRoute(['GET'], '/{sub1}/{sub2}/{url}' , Module\Proxy::class); $collector->addRoute(['GET'], '/{sub1}/{sub2}/{url}' , Module\Proxy::class);
}); });
$this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class); $this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class);
$this->routeCollector->addRoute(['GET'], '/robots.txt', Module\RobotsTxt::class);
$this->routeCollector->addRoute(['GET'], '/rsd.xml', Module\ReallySimpleDiscovery::class); $this->routeCollector->addRoute(['GET'], '/rsd.xml', Module\ReallySimpleDiscovery::class);
$this->routeCollector->addRoute(['GET'], '/statistics.json', Module\Statistics::class); $this->routeCollector->addRoute(['GET'], '/statistics.json', Module\Statistics::class);
$this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class); $this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class);

27
src/Module/RobotsTxt.php Normal file
View file

@ -0,0 +1,27 @@
<?php
namespace Friendica\Module;
use Friendica\BaseModule;
/**
* Return the default robots.txt
*/
class RobotsTxt extends BaseModule
{
public static function rawContent()
{
$allDisalloweds = [
'/settings/',
'/admin/',
'/message/',
];
header('Content-Type: text/plain');
echo 'User-agent: *' . PHP_EOL;
foreach ($allDisalloweds as $disallowed) {
echo 'Disallow: ' . $disallowed . PHP_EOL;
}
exit();
}
}