Deleted old static file.
Default output depends on app-public setting.
Otherwise can be overidden in `.env` file via `ALLOW_ROBOTS`
Otherwise view file can be customized.
Fixes #779
{
return view('partials/custom-head-content');
}
+
+ /**
+ * Show the view for /robots.txt
+ * @return $this
+ */
+ public function getRobots()
+ {
+ $sitePublic = setting('app-public', false);
+ $allowRobots = config('app.allow_robots');
+ if ($allowRobots === null) {
+ $allowRobots = $sitePublic;
+ }
+ return response()
+ ->view('robots', ['allowRobots' => $allowRobots])
+ ->header('Content-Type', 'text/plain');
+ }
}
'env' => env('APP_ENV', 'production'),
+ /**
+ * Set the default view type for various lists. Can be overridden by user preferences.
+ * This will be used for public viewers and users that have not set a preference.
+ */
'views' => [
'books' => env('APP_VIEWS_BOOKS', 'list')
],
+ /**
+ * Allow <script> tags to entered within page content.
+ * <script> tags are escaped by default.
+ * Even when overridden the WYSIWYG editor may still escape script content.
+ */
'allow_content_scripts' => env('ALLOW_CONTENT_SCRIPTS', false),
+ /**
+ * Override the default behaviour for allowing crawlers to crawl the instance.
+ * May be ignored if view has be overridden or modified.
+ * Defaults to null since, if not set, 'app-public' status used instead.
+ */
+ 'allow_robots' => env('ALLOW_ROBOTS', null),
+
/*
|--------------------------------------------------------------------------
| Application Debug Mode
+++ /dev/null
-User-agent: *
-Disallow:
--- /dev/null
+User-agent: *
+@if($allowRobots)
+Disallow:
+@else
+Disallow: /
+@endif
\ No newline at end of file
Route::get('/translations', 'HomeController@getTranslations');
Route::get('/icon/{iconName}.svg', 'HomeController@getIcon');
+Route::get('/robots.txt', 'HomeController@getRobots');
// Authenticated routes...
Route::group(['middleware' => 'auth'], function () {
$this->dontSee($page->name);
}
+ public function test_robots_effected_by_public_status()
+ {
+ $this->visit('/robots.txt');
+ $this->seeText("User-agent: *\nDisallow: /");
+
+ $this->setSettings(['app-public' => 'true']);
+ $this->visit('/robots.txt');
+
+ $this->seeText("User-agent: *\nDisallow:");
+ $this->dontSeeText("Disallow: /");
+ }
+
+ public function test_robots_effected_by_setting()
+ {
+ $this->visit('/robots.txt');
+ $this->seeText("User-agent: *\nDisallow: /");
+
+ config()->set('app.allow_robots', true);
+ $this->visit('/robots.txt');
+
+ $this->seeText("User-agent: *\nDisallow:");
+ $this->dontSeeText("Disallow: /");
+
+ // Check config overrides app-public setting
+ config()->set('app.allow_robots', false);
+ $this->setSettings(['app-public' => 'true']);
+ $this->visit('/robots.txt');
+
+ $this->seeText("User-agent: *\nDisallow: /");
+ }
+
}
\ No newline at end of file