X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ddb7f33868ea499ab8f48a7062f145e8c0fbe02f..refs/pull/2510/head:/app/Http/Controllers/HomeController.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 260952fd1..3258f4369 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,9 +1,9 @@ isSignedIn()) { - $draftPages = Page::visible()->where('draft', '=', true) + $draftPages = Page::visible() + ->where('draft', '=', true) ->where('created_by', '=', user()->id) - ->orderBy('updated_at', 'desc')->take(6)->get(); + ->orderBy('updated_at', 'desc') + ->with('book') + ->take(6) + ->get(); } $recentFactor = count($draftPages) > 0 ? 0.5 : 1; $recents = $this->isSignedIn() ? - Views::getUserRecentlyViewed(12*$recentFactor, 0) + Views::getUserRecentlyViewed(12*$recentFactor, 1) : Book::visible()->orderBy('created_at', 'desc')->take(12 * $recentFactor)->get(); - $recentlyUpdatedPages = Page::visible()->where('draft', false) - ->orderBy('updated_at', 'desc')->take(12)->get(); + $recentlyUpdatedPages = Page::visible()->with('book') + ->where('draft', false) + ->orderBy('updated_at', 'desc') + ->take(12) + ->get(); $homepageOptions = ['default', 'books', 'bookshelves', 'page']; $homepageOption = setting('app-homepage-type', 'default'); @@ -69,11 +75,7 @@ class HomeController extends Controller } if ($homepageOption === 'bookshelves') { - $shelfRepo = app(BookshelfRepo::class); $shelves = app(BookshelfRepo::class)->getAllPaginated(18, $commonData['sort'], $commonData['order']); - foreach ($shelves as $shelf) { - $shelf->books = $shelf->visibleBooks; - } $data = array_merge($commonData, ['shelves' => $shelves]); return view('common.home-shelves', $data); } @@ -108,15 +110,16 @@ class HomeController extends Controller /** * 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('common.robots', ['allowRobots' => $allowRobots]) ->header('Content-Type', 'text/plain');