From: Dan Brown Date: Sat, 31 Mar 2018 11:41:40 +0000 (+0100) Subject: Added configurable robots.txt file. X-Git-Tag: v0.21.0~1^2~18 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/1a72208d27e1b27034fd9eb5f657d6f3cd0c5ad7?ds=sidebyside;hp=--cc Added configurable robots.txt file. 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 --- 1a72208d27e1b27034fd9eb5f657d6f3cd0c5ad7 diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 3a5fd2cb5..bbe1a8679 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -118,4 +118,20 @@ class HomeController extends Controller { 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'); + } } diff --git a/config/app.php b/config/app.php index fad0c20f2..ca30ee2a0 100755 --- a/config/app.php +++ b/config/app.php @@ -4,12 +4,28 @@ return [ '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