]> BookStack Code Mirror - bookstack/commitdiff
Updated custom homepage views
authorDan Brown <redacted>
Sat, 6 Apr 2019 16:31:59 +0000 (17:31 +0100)
committerDan Brown <redacted>
Sat, 6 Apr 2019 16:31:59 +0000 (17:31 +0100)
app/Http/Controllers/HomeController.php
resources/assets/sass/_grid.scss
resources/assets/sass/_lists.scss
resources/views/common/home-book.blade.php
resources/views/common/home-custom.blade.php
resources/views/common/home-shelves.blade.php
resources/views/common/home-sidebar.blade.php
resources/views/components/entity-selector.blade.php

index 5a5f34e4a5ce0d61e37bc797cfe1350bb49a5ef0..fb2620bf47e81eb662b2b1159effedb6b69965f9 100644 (file)
@@ -19,7 +19,6 @@ class HomeController extends Controller
         parent::__construct();
     }
 
-
     /**
      * Display the homepage.
      * @return Response
@@ -45,17 +44,36 @@ class HomeController extends Controller
             'draftPages' => $draftPages,
         ];
 
+        // Add required list ordering & sorting for books & shelves views.
+        if ($homepageOption === 'bookshelves' || $homepageOption === 'books') {
+            $key = $homepageOption;
+            $view = setting()->getUser($this->currentUser, $key . '_view_type', config('app.views.' . $key));
+            $sort = setting()->getUser($this->currentUser, $key . '_sort', 'name');
+            $order = setting()->getUser($this->currentUser, $key . '_sort_order', 'asc');
+
+            $sortOptions = [
+                'name' => trans('common.sort_name'),
+                'created_at' => trans('common.sort_created_at'),
+                'updated_at' => trans('common.sort_updated_at'),
+            ];
+
+            $commonData = array_merge($commonData, [
+                'view' => $view,
+                'sort' => $sort,
+                'order' => $order,
+                'sortOptions' => $sortOptions,
+            ]);
+        }
+
         if ($homepageOption === 'bookshelves') {
-            $shelves = $this->entityRepo->getAllPaginated('bookshelf', 18);
-            $shelvesViewType = setting()->getUser($this->currentUser, 'bookshelves_view_type', config('app.views.bookshelves', 'grid'));
-            $data = array_merge($commonData, ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType]);
+            $shelves = $this->entityRepo->getAllPaginated('bookshelf', 18, $commonData['sort'], $commonData['order']);
+            $data = array_merge($commonData, ['shelves' => $shelves]);
             return view('common.home-shelves', $data);
         }
 
         if ($homepageOption === 'books') {
-            $books = $this->entityRepo->getAllPaginated('book', 18);
-            $booksViewType = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books', 'list'));
-            $data = array_merge($commonData, ['books' => $books, 'booksViewType' => $booksViewType]);
+            $books = $this->entityRepo->getAllPaginated('book', 18, $commonData['sort'], $commonData['order']);
+            $data = array_merge($commonData, ['books' => $books]);
             return view('common.home-book', $data);
         }
 
index 8c93b12d582f9acd07d079ed93fe0e3bf9e766e0..b8bd2cc046dcae79a57cb92df1f52d348fff9511 100644 (file)
@@ -231,7 +231,7 @@ div[class^="col-"] img {
     grid-template-columns: 2fr 1fr;
   }
   &.right-focus {
-    grid-template-columns: 1fr 2fr;
+    grid-template-columns: 1fr 3fr;
   }
   &.gap-xl {
     grid-column-gap: $-xl;
index 3b3afad9dbe7c57241a27d84fd9ec3acdced0766..43ec13cf698e6be1bc94232dadc348106cda533d 100644 (file)
@@ -371,6 +371,7 @@ ul.pagination {
   border: 0;
   width: 100%;
   position: relative;
+  word-break: break-word;
   h4 a {
     color: #666;
   }
index 2849d5ecdb427cc5a3631145eb17d35633d7486e..139c77c07e1bd4234f0e135101d0c827c8beed2f 100644 (file)
@@ -1,18 +1,26 @@
-@extends('sidebar-layout')
+@extends('simple-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>
-            @include('books/view-toggle', ['booksViewType' => $booksViewType])
-        </div>
-    </div>
-@stop
+@section('body')
+    <div class="container mt-m">
+        <div class="grid right-focus gap-xl">
+            <div>
 
-@section('sidebar')
-    @include('common/home-sidebar')
-@stop
+                <div class="actions mb-xl">
+                    <h5>{{ trans('common.actions') }}</h5>
+                    <div class="icon-list text-primary">
+                        @include('partials.view-toggle', ['view' => $view, 'type' => 'book'])
+                        <a expand-toggle=".entity-list.compact .entity-item-snippet" class="icon-list-item">
+                            <span>@icon('expand-text')</span>
+                            <span>{{ trans('common.toggle_details') }}</span>
+                        </a>
+                    </div>
+                </div>
 
-@section('body')
-    @include('books/list', ['books' => $books, 'bookViewType' => $booksViewType])
+                @include('common.home-sidebar')
+            </div>
+            <div>
+                @include('books.list', ['books' => $books, 'view' => $view])
+            </div>
+        </div>
+    </div>
 @stop
\ No newline at end of file
index 89154ee13ea4a87518d4981c73957d5bd8880f54..0ef3c2e25848d6f1d5f5ff04925038302d959bdc 100644 (file)
@@ -1,19 +1,29 @@
-@extends('sidebar-layout')
+@extends('simple-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('body')
+    <div class="container mt-l">
+        <div class="grid right-focus gap-xl">
+            <div>
 
-@section('sidebar')
-    @include('common/home-sidebar')
-@stop
+                <div class="actions mb-xl">
+                    <h5>{{ trans('common.actions') }}</h5>
+                    <div class="icon-list text-primary">
+                        <a expand-toggle=".entity-list.compact .entity-item-snippet" class="icon-list-item">
+                            <span>@icon('expand-text')</span>
+                            <span>{{ trans('common.toggle_details') }}</span>
+                        </a>
+                    </div>
+                </div>
 
-@section('body')
-    <div class="page-content" page-display="{{ $customHomepage->id }}">
-        @include('pages/page-display', ['page' => $customHomepage])
+                @include('common.home-sidebar')
+            </div>
+            <div>
+                <div class="content-wrap card">
+                    <div class="page-content" page-display="{{ $customHomepage->id }}">
+                        @include('pages.page-display', ['page' => $customHomepage])
+                    </div>
+                </div>
+            </div>
+        </div>
     </div>
-@stop
+@stop
\ No newline at end of file
index 3ae055b33a6314260a1d639f0963105606b55649..8cb99b9078fcf967bb5c9622a7d2e98a3c12a7f7 100644 (file)
@@ -1,18 +1,26 @@
-@extends('sidebar-layout')
+@extends('simple-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>
-            @include('shelves/view-toggle', ['shelvesViewType' => $shelvesViewType])
-        </div>
-    </div>
-@stop
+@section('body')
+    <div class="container mt-m">
+        <div class="grid right-focus gap-xl">
+            <div>
 
-@section('sidebar')
-    @include('common/home-sidebar')
-@stop
+                <div class="actions mb-xl">
+                    <h5>{{ trans('common.actions') }}</h5>
+                    <div class="icon-list text-primary">
+                        @include('partials.view-toggle', ['view' => $view, 'type' => 'shelf'])
+                        <a expand-toggle=".entity-list.compact .entity-item-snippet" class="icon-list-item">
+                            <span>@icon('expand-text')</span>
+                            <span>{{ trans('common.toggle_details') }}</span>
+                        </a>
+                    </div>
+                </div>
 
-@section('body')
-    @include('shelves/list', ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType])
+                @include('common.home-sidebar')
+            </div>
+            <div>
+                @include('shelves.list', ['shelves' => $shelves, 'view' => $view])
+            </div>
+        </div>
+    </div>
 @stop
\ No newline at end of file
index 2210294814c0ac4ef859dd5ab488c7f2cfdd83b4..07eda2cff997ac848a1c7f63b1720d8ce6226212 100644 (file)
@@ -1,23 +1,23 @@
 @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 id="recent-drafts" class="mb-xl">
+        <h5>{{ trans('entities.my_recent_drafts') }}</h5>
+        @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', [
+<div class="mb-xl">
+    <h5>{{ trans('entities.' . ($signedIn ? 'my_recently_viewed' : 'books_recent')) }}</h5>
+    @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 class="mb-xl">
+    <h5><a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h5>
     <div id="recently-updated-pages">
-        @include('partials/entity-list', [
+        @include('partials.entity-list', [
         'entities' => $recentlyUpdatedPages,
         'style' => 'compact',
         'emptyText' => trans('entities.no_pages_recently_updated')
@@ -25,7 +25,7 @@
     </div>
 </div>
 
-<div id="recent-activity" class="card">
-    <h3>@icon('time') {{ trans('entities.recent_activity') }}</h3>
-    @include('partials/activity-list', ['activity' => $activity])
+<div id="recent-activity" class="mb-xl">
+    <h5>{{ trans('entities.recent_activity') }}</h5>
+    @include('partials.activity-list', ['activity' => $activity])
 </div>
\ No newline at end of file
index f115054734c5fde3851c95c2e5ffaee13f04bf1d..6f8d046964f2c7904e2d7ec333af17db3c5b694c 100644 (file)
@@ -1,10 +1,10 @@
 <div class="form-group">
-    <div entity-selector class="entity-selector {{$selectorSize or ''}}" entity-types="{{ $entityTypes or 'book,chapter,page' }}" entity-permission="{{ $entityPermission or 'view' }}">
+    <div entity-selector class="entity-selector {{$selectorSize ?? ''}}" entity-types="{{ $entityTypes ?? 'book,chapter,page' }}" entity-permission="{{ $entityPermission ?? 'view' }}">
         <input type="hidden" entity-selector-input name="{{$name}}" value="">
         <input type="text" placeholder="{{ trans('common.search') }}" entity-selector-search>
         <div class="text-center loading" entity-selector-loading>@include('partials.loading-icon')</div>
         <div entity-selector-results></div>
-        @if($showAdd)
+        @if($showAdd ?? false)
             <div class="entity-selector-add">
                 <button entity-selector-add-button type="button"
                         class="button outline">@icon('add'){{ trans('common.add') }}</button>