]> BookStack Code Mirror - bookstack/commitdiff
Bookstack grid view.
authorNilesh Deepak <redacted>
Thu, 29 Jun 2017 13:24:04 +0000 (18:54 +0530)
committerNilesh Deepak <redacted>
Thu, 29 Jun 2017 13:24:04 +0000 (18:54 +0530)
app/Http/Controllers/BookController.php
app/User.php
resources/lang/en/common.php
resources/views/books/create.blade.php
resources/views/books/edit.blade.php
resources/views/books/form.blade.php
resources/views/books/grid-item.blade.php [new file with mode: 0644]
resources/views/books/index.blade.php
resources/views/users/edit.blade.php

index 8996ae64aec248d3dc61a2d0307a982d4b496e10..086929558ff55c08412369c8cd48a753c67c5d42 100644 (file)
@@ -40,7 +40,7 @@ class BookController extends Controller
         $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false;
         $popular = $this->entityRepo->getPopular('book', 4, 0);
         $this->setPageTitle('Books');
-        return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular]);
+        return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'display' => $display]);  //added displaly to access user display
     }
 
     /**
@@ -67,7 +67,14 @@ class BookController extends Controller
             'name' => 'required|string|max:255',
             'description' => 'string|max:1000'
         ]);
+        $image = $request->file('image');
+        $input = time().'-'.$image->getClientOriginalName();
+        $destinationPath = public_path('uploads/book/');
+        $image->move($destinationPath, $input);
+        $path = baseUrl('/uploads/book/').'/'.$input;
         $book = $this->entityRepo->createFromInput('book', $request->all());
+        $book->image = $path; 
+        $book->save();
         Activity::add($book, 'book_create', $book->id);
         return redirect($book->getUrl());
     }
@@ -114,9 +121,17 @@ class BookController extends Controller
             'name' => 'required|string|max:255',
             'description' => 'string|max:1000'
         ]);
-        $book = $this->entityRepo->updateFromInput('book', $book, $request->all());
-        Activity::add($book, 'book_update', $book->id);
-        return redirect($book->getUrl());
+            
+            $input = $request->file('image')->getClientOriginalName();
+            echo $input;
+         $destinationPath = public_path('uploads/book/');
+         $request->file('image')->move($destinationPath, $input);
+         $path = baseUrl('/uploads/book/').'/'.$input;
+         $book = $this->entityRepo->updateFromInput('book', $book, $request->all());
+         $book->image = $path; 
+         $book->save();
+         Activity::add($book, 'book_update', $book->id);
+         return redirect($book->getUrl());
     }
 
     /**
index 8033557e4cb9a0a048c1d7112c90f84dc4e4bf70..3d77cd8ee009cfe0f4a57d27779f3b52fa4b4b75 100644 (file)
@@ -22,7 +22,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
      * The attributes that are mass assignable.
      * @var array
      */
-    protected $fillable = ['name', 'email', 'image_id'];
+    protected $fillable = ['name', 'email', 'image_id', 'display']; //to write in user database 
 
     /**
      * The attributes excluded from the model's JSON form.
index e1d74c95e0e0718f0be435c5f40fdbb3da9f8e40..dae6d0509e660004890cf16bda3fdc846a54063f 100644 (file)
@@ -44,6 +44,7 @@ return [
     'no_items' => 'No items available',
     'back_to_top' => 'Back to top',
     'toggle_details' => 'Toggle Details',
+    'toggle_thumbnails' => 'Toggle Thumbnails',
 
     /**
      * Header
index 2c629e699622053940849dc207121cb4a201b21d..36c94af62d00a4762abf41b092eec8fdb7203dc6 100644 (file)
@@ -4,7 +4,7 @@
 
 <div class="container small" ng-non-bindable>
     <h1>{{ trans('entities.books_create') }}</h1>
-    <form action="{{ baseUrl("/books") }}" method="POST">
+    <form action="{{ baseUrl("/books") }}" method="POST" enctype="multipart/form-data">
         @include('books/form')
     </form>
 </div>
index 2419b68da807ab1a346293ee38ec694e67c1c25a..02768b3014bd8083b7ea1f634837edce4eb4e179 100644 (file)
@@ -14,7 +14,7 @@
 
     <div class="container small" ng-non-bindable>
         <h1>{{ trans('entities.books_edit') }}</h1>
-        <form action="{{ $book->getUrl() }}" method="POST">
+        <form action="{{ $book->getUrl() }}" method="POST" enctype="multipart/form-data">
             <input type="hidden" name="_method" value="PUT">
             @include('books/form', ['model' => $book])
         </form>
index b1484d1296f3cf84ef6f2e59bf11d6af8a5c3c2d..e5ee47a82a485cfb2f5b25fe6d3cefec2c887351 100644 (file)
     @include('form/textarea', ['name' => 'description'])
 </div>
 
+<div class="form-group">
+    <label for="image">Choose image</label>
+    <input type="file" name="image">
+</div>
 <div class="form-group">
     <a href="{{ isset($book) ? $book->getUrl() : baseUrl('/books') }}" class="button muted">{{ trans('common.cancel') }}</a>
     <button type="submit" class="button pos">{{ trans('entities.books_save') }}</button>
diff --git a/resources/views/books/grid-item.blade.php b/resources/views/books/grid-item.blade.php
new file mode 100644 (file)
index 0000000..a37458e
--- /dev/null
@@ -0,0 +1,15 @@
+<div class="galleryContainer"  data-entity-type="book" data-entity-id="{{$book->id}}">
+<div class="col-sm-3 galleryItem">
+    <h3>
+        <a class="text-book entity-list-item-link" href="{{$book->getUrl()}}"><i class="zmdi zmdi-book"></i><span class="entity-list-item-name">{{$book->name}}</span>
+        <br>
+        <img @if($book->image === NULL) src="{{baseUrl('/default.jpg')}}" @else src="{{$book->image}}" @endif alt="{{$book->name}}">
+        </a>
+    </h3>
+    @if(isset($book->searchSnippet))
+        <p class="text-muted">{!! $book->searchSnippet !!}</p>
+    @else
+        <p class="text-muted">{{ $book->getExcerpt() }}</p>
+    @endif
+    </div>
+</div>
\ No newline at end of file
index c090a127e1dee9076020d9397ce46f7eaaf39804..76e521633465c044f893636171b3ac0ceb297661 100644 (file)
@@ -5,12 +5,12 @@
     <div class="faded-small toolbar">
         <div class="container">
             <div class="row">
-                <div class="col-xs-1"></div>
                 <div class="col-xs-11 faded">
-                    <div class="action-buttons">
+                    <div class="action-buttons text-left">
                         @if($currentUser->can('book-create-all'))
                             <a href="{{ baseUrl("/books/create") }}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>{{ trans('entities.books_create') }}</a>
                         @endif
+                        <a data-action="expand-thumbnail" class="text-primary text-button"><i class="zmdi zmdi-wrap-text"></i>{{ trans('common.toggle_thumbnails') }}</a>
                     </div>
                 </div>
             </div>
 
     <div class="container" ng-non-bindable>
         <div class="row">
-            <div class="col-sm-7">
+            <div class="col-sm-9">
                 <h1>{{ trans('entities.books') }}</h1>
+                {!! $books->render() !!}
                 @if(count($books) > 0)
+                    @if($display=='grid')
+                        @foreach($books as $book)
+                            @include('books/grid-item', ['book' => $book])
+                        @endforeach
+                    @else
                     @foreach($books as $book)
-                        @include('books/list-item', ['book' => $book])
-                        <hr>
-                    @endforeach
-                    {!! $books->render() !!}
+                            @include('books/list-item', ['book' => $book])
+                        @endforeach
+                    @endif
                 @else
                     <p class="text-muted">{{ trans('entities.books_empty') }}</p>
                     @if(userCan('books-create-all'))
@@ -35,7 +40,7 @@
                     @endif
                 @endif
             </div>
-            <div class="col-sm-4 col-sm-offset-1">
+            <div class="col-sm-3">
                 <div id="recents">
                     @if($recents)
                         <div class="margin-top">&nbsp;</div>
@@ -53,6 +58,7 @@
                     @endif
                 </div>
             </div>
+            {!! $books->render() !!}
         </div>
     </div>
 
index ff3475194bdfacd7705d74cf17e8d81061a8048b..3cacff645f378f1879654ab12db02864602188ea 100644 (file)
                             @endforeach
                         </select>
                     </div>
+                    <!--Select display type -->
+                    <div class="form-group">
+                        <label for="display">Type of view</label>
+                        <select name="display" id="display">
+                            <option @if($user->display === 'grid') selected @endif value="grid">Grid</option>
+                            <option @if($user->display === 'list') selected @endif value="list">List</option>
+                        </select>
+                    </div>
+                    <!---->
                 </div>
             </div>
             <div class="form-group">
Morty Proxy This is a proxified and sanitized view of the page, visit original site.