mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-25 19:56:05 +00:00
Implemented displaying of the books list on home page.
This commit is contained in:
parent
2e4863edb1
commit
86b2ddbd28
@ -33,22 +33,41 @@ class HomeController extends Controller
|
|||||||
$recents = $this->signedIn ? Views::getUserRecentlyViewed(12*$recentFactor, 0) : $this->entityRepo->getRecentlyCreated('book', 12*$recentFactor);
|
$recents = $this->signedIn ? Views::getUserRecentlyViewed(12*$recentFactor, 0) : $this->entityRepo->getRecentlyCreated('book', 12*$recentFactor);
|
||||||
$recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdated('page', 12);
|
$recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdated('page', 12);
|
||||||
|
|
||||||
// Custom homepage
|
|
||||||
$customHomepage = false;
|
$customHomepage = false;
|
||||||
$homepageSetting = setting('app-homepage');
|
$books = false;
|
||||||
if ($homepageSetting) {
|
$booksViewType = false;
|
||||||
$id = intval(explode(':', $homepageSetting)[0]);
|
|
||||||
$customHomepage = $this->entityRepo->getById('page', $id, false, true);
|
// Check book homepage
|
||||||
$this->entityRepo->renderPage($customHomepage, true);
|
$bookHomepageSetting = setting('app-book-homepage');
|
||||||
|
if ($bookHomepageSetting) {
|
||||||
|
$books = $this->entityRepo->getAllPaginated('book', 18);
|
||||||
|
$booksViewType = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books', 'list'));
|
||||||
|
} else {
|
||||||
|
// Check custom homepage
|
||||||
|
$homepageSetting = setting('app-homepage');
|
||||||
|
if ($homepageSetting) {
|
||||||
|
$id = intval(explode(':', $homepageSetting)[0]);
|
||||||
|
$customHomepage = $this->entityRepo->getById('page', $id, false, true);
|
||||||
|
$this->entityRepo->renderPage($customHomepage, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$view = 'home';
|
||||||
|
if ($bookHomepageSetting) {
|
||||||
|
$view = 'home-book';
|
||||||
|
} else if ($customHomepage) {
|
||||||
|
$view = 'home-custom';
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = $customHomepage ? 'home-custom' : 'home';
|
|
||||||
return view($view, [
|
return view($view, [
|
||||||
'activity' => $activity,
|
'activity' => $activity,
|
||||||
'recents' => $recents,
|
'recents' => $recents,
|
||||||
'recentlyUpdatedPages' => $recentlyUpdatedPages,
|
'recentlyUpdatedPages' => $recentlyUpdatedPages,
|
||||||
'draftPages' => $draftPages,
|
'draftPages' => $draftPages,
|
||||||
'customHomepage' => $customHomepage
|
'customHomepage' => $customHomepage,
|
||||||
|
'books' => $books,
|
||||||
|
'booksViewType' => $booksViewType
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,34 +52,5 @@
|
|||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
@if($booksViewType === 'list')
|
@include('books/list', ['books' => $books, 'bookViewType' => $booksViewType])
|
||||||
<div class="container small" ng-non-bindable>
|
|
||||||
@else
|
|
||||||
<div class="container" ng-non-bindable>
|
|
||||||
@endif
|
|
||||||
<h1>{{ trans('entities.books') }}</h1>
|
|
||||||
@if(count($books) > 0)
|
|
||||||
@if($booksViewType === 'list')
|
|
||||||
@foreach($books as $book)
|
|
||||||
@include('books/list-item', ['book' => $book])
|
|
||||||
<hr>
|
|
||||||
@endforeach
|
|
||||||
{!! $books->render() !!}
|
|
||||||
@else
|
|
||||||
<div class="grid third">
|
|
||||||
@foreach($books as $key => $book)
|
|
||||||
@include('books/grid-item', ['book' => $book])
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{!! $books->render() !!}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@else
|
|
||||||
<p class="text-muted">{{ trans('entities.books_empty') }}</p>
|
|
||||||
@if(userCan('books-create-all'))
|
|
||||||
<a href="{{ baseUrl("/create-book") }}" class="text-pos">@icon('edit'){{ trans('entities.create_one_now') }}</a>
|
|
||||||
@endif
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
@stop
|
@stop
|
31
resources/views/books/list.blade.php
Normal file
31
resources/views/books/list.blade.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
@if($booksViewType === 'list')
|
||||||
|
<div class="container small">
|
||||||
|
@else
|
||||||
|
<div class="container">
|
||||||
|
@endif
|
||||||
|
<h1>{{ trans('entities.books') }}</h1>
|
||||||
|
@if(count($books) > 0)
|
||||||
|
@if($booksViewType === 'list')
|
||||||
|
@foreach($books as $book)
|
||||||
|
@include('books/list-item', ['book' => $book])
|
||||||
|
<hr>
|
||||||
|
@endforeach
|
||||||
|
{!! $books->render() !!}
|
||||||
|
@else
|
||||||
|
<div class="grid third">
|
||||||
|
@foreach($books as $key => $book)
|
||||||
|
@include('books/grid-item', ['book' => $book])
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{!! $books->render() !!}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<p class="text-muted">{{ trans('entities.books_empty') }}</p>
|
||||||
|
@if(userCan('books-create-all'))
|
||||||
|
<a href="{{ baseUrl("/create-book") }}" class="text-pos">@icon('edit'){{ trans('entities.create_one_now') }}</a>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</div>
|
47
resources/views/home-book.blade.php
Normal file
47
resources/views/home-book.blade.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
@extends('sidebar-layout')
|
||||||
|
|
||||||
|
@section('toolbar')
|
||||||
|
<div class="col-sm-6 faded">
|
||||||
|
<div class="action-buttons text-left">
|
||||||
|
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="text-primary text-button">@icon('expand-text'){{ trans('common.toggle_details') }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('sidebar')
|
||||||
|
@if(count($draftPages) > 0)
|
||||||
|
<div id="recent-drafts" class="card">
|
||||||
|
<h3>@icon('edit') {{ trans('entities.my_recent_drafts') }}</h3>
|
||||||
|
@include('partials/entity-list', ['entities' => $draftPages, 'style' => 'compact'])
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h3>@icon($signedIn ? 'view' : 'star-circle') {{ trans('entities.' . ($signedIn ? 'my_recently_viewed' : 'books_recent')) }}</h3>
|
||||||
|
@include('partials/entity-list', [
|
||||||
|
'entities' => $recents,
|
||||||
|
'style' => 'compact',
|
||||||
|
'emptyText' => $signedIn ? trans('entities.no_pages_viewed') : trans('entities.books_empty')
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h3>@icon('file') <a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h3>
|
||||||
|
<div id="recently-updated-pages">
|
||||||
|
@include('partials/entity-list', [
|
||||||
|
'entities' => $recentlyUpdatedPages,
|
||||||
|
'style' => 'compact',
|
||||||
|
'emptyText' => trans('entities.no_pages_recently_updated')
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="recent-activity" class="card">
|
||||||
|
<h3>@icon('time') {{ trans('entities.recent_activity') }}</h3>
|
||||||
|
@include('partials/activity-list', ['activity' => $activity])
|
||||||
|
</div>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('body')
|
||||||
|
@include('books/list', ['books' => $books, 'bookViewType' => $booksViewType])
|
||||||
|
@stop
|
Loading…
Reference in New Issue
Block a user