]> git.mxchange.org Git - friendica.git/commitdiff
Move mod/robots_txt to src/Module/RobotsTxt
authorPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 17:06:51 +0000 (19:06 +0200)
committerPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 17:06:51 +0000 (19:06 +0200)
mod/robots_txt.php [deleted file]
src/App/Router.php
src/Module/RobotsTxt.php [new file with mode: 0644]

diff --git a/mod/robots_txt.php b/mod/robots_txt.php
deleted file mode 100644 (file)
index 0575742..0000000
+++ /dev/null
@@ -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();
-}
index 1dffb6b406f0d3b22bd75880710bd56a5eee8437..68330c7e688730632aef74e05620ff89c1a19a79 100644 (file)
@@ -164,6 +164,7 @@ class Router
                        $collector->addRoute(['GET'], '/{sub1}/{sub2}/{url}'               , Module\Proxy::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'],         '/statistics.json',     Module\Statistics::class);
                $this->routeCollector->addRoute(['GET'],         '/tos',                 Module\Tos::class);
diff --git a/src/Module/RobotsTxt.php b/src/Module/RobotsTxt.php
new file mode 100644 (file)
index 0000000..3648f6f
--- /dev/null
@@ -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();
+       }
+}