NOW MANAGED ON CODEBERG
Applied required changes in BookStack.
Nilesh Deepak947c58f2274f
diff --git a/app/Book.php b/app/Book.phpindex 06c00945d..67bd4f5b2 100644--- a/app/Book.php+++ b/app/Book.php@@ -3,7 +3,7 @@class Book extends Entity{- protected $fillable = ['name', 'description'];+ protected $fillable = ['name', 'description', 'image'];/*** Get the url for this book.diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.phpindex 086929558..9c1154281 100644--- a/app/Http/Controllers/BookController.php+++ b/app/Http/Controllers/BookController.php@@ -36,11 +36,12 @@ class BookController extends Controller*/public function index(){- $books = $this->entityRepo->getAllPaginated('book', 10);+ $books = $this->entityRepo->getAllPaginated('book', 16);$recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false;- $popular = $this->entityRepo->getPopular('book', 4, 0);+ $popular = $this->entityRepo->getPopular('book', 3, 0);+ $books_display = $this->currentUser->books_display;$this->setPageTitle('Books');- return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'display' => $display]); //added displaly to access user display+ return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'books_display' => $books_display]);}/**@@ -68,10 +69,7 @@ class BookController extends Controller'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;+ $path = $this->getBookCoverURL($image);$book = $this->entityRepo->createFromInput('book', $request->all());$book->image = $path;$book->save();@@ -121,12 +119,8 @@ class BookController extends Controller'name' => 'required|string|max:255','description' => 'string|max:1000']);-- $input = $request->file('image')->getClientOriginalName();- echo $input;- $destinationPath = public_path('uploads/book/');- $request->file('image')->move($destinationPath, $input);- $path = baseUrl('/uploads/book/').'/'.$input;+ $image = $request->file('image');+ $path = $this->getBookCoverURL($image);$book = $this->entityRepo->updateFromInput('book', $book, $request->all());$book->image = $path;$book->save();@@ -134,6 +128,20 @@ class BookController extends Controllerreturn redirect($book->getUrl());}+ /**+ * Generate URL for book cover image+ * @param $image+ * @return $path+ */+ public function getBookCoverURL($image)+ {+ $input = time().'-'.$image->getClientOriginalName();+ $destinationPath = public_path('uploads/book/');+ $image->move($destinationPath, $input);+ $path = baseUrl('/uploads/book/').'/'.$input;+ return $path;+ }+/*** Shows the page to confirm deletion* @param $bookSlugdiff --git a/app/User.php b/app/User.phpindex 3d77cd8ee..24eca12f3 100644--- a/app/User.php+++ b/app/User.php@@ -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', 'display']; //to write in user database+ protected $fillable = ['name', 'email', 'image_id', 'books_display'];/*** The attributes excluded from the model's JSON form.diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.phpindex 17e71de5f..62ac94b60 100644--- a/database/migrations/2014_10_12_000000_create_users_table.php+++ b/database/migrations/2014_10_12_000000_create_users_table.php@@ -18,6 +18,7 @@ class CreateUsersTable extends Migration$table->string('email')->unique();$table->string('password', 60);$table->rememberToken();+ $table->string('books_display')->default('grid');$table->nullableTimestamps();});@@ -26,6 +27,7 @@ class CreateUsersTable extends Migration'name' => 'Admin','email' => '[email protected]','password' => bcrypt('password'),+ 'books_display' => 'grid','created_at' => \Carbon\Carbon::now()->toDateTimeString(),'updated_at' => \Carbon\Carbon::now()->toDateTimeString()]);diff --git a/database/migrations/2015_07_12_114933_create_books_table.php b/database/migrations/2015_07_12_114933_create_books_table.phpindex 4220809d5..b8a6c9829 100644--- a/database/migrations/2015_07_12_114933_create_books_table.php+++ b/database/migrations/2015_07_12_114933_create_books_table.php@@ -24,6 +24,7 @@ class CreateBooksTable extends Migration$table->string('slug')->indexed();$table->text('description');$table->nullableTimestamps();+ $table->string('image');});}diff --git a/resources/assets/sass/styles.scss b/resources/assets/sass/styles.scssindex afb9d531b..bfa95fc1e 100644--- a/resources/assets/sass/styles.scss+++ b/resources/assets/sass/styles.scss@@ -276,3 +276,28 @@ $btt-size: 40px;+.galleryItem {+ width: 22%;+ padding: 5px;+ float: left;+ height: 330px;+ margin: 2% 1% 2% 1%;+ overflow: hidden;+ border: 1px solid #9e9e9e;+ h3 {+ font-size: 1.2em;+ text-align: center;+ }+ p {+ font-size: 0.8em;+ text-align: center;+ }+ img {+ height: 192px;+ width: 120px;+ margin-top: 5%;+ }+ &.collapse {+ height: 130px;+ }+}\ No newline at end of filediff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.phpindex 693c909aa..de13ab5cd 100644--- a/resources/views/books/index.blade.php+++ b/resources/views/books/index.blade.php@@ -24,7 +24,7 @@<h1>{{ trans('entities.books') }}</h1>{!! $books->render() !!}@if(count($books) > 0)- @if($display=='grid')+ @if($books_display=='grid')@foreach($books as $book)@include('books/grid-item', ['book' => $book])@endforeachdiff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.phpindex 3cacff645..152567d6c 100644--- a/resources/views/users/edit.blade.php+++ b/resources/views/users/edit.blade.php@@ -49,15 +49,13 @@@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>+ <label for="books_display">Type of view</label>+ <select name="books_display" id="books_display">+ <option @if($user->books_display === 'grid') selected @endif value="grid">Grid</option>+ <option @if($user->books_display === 'list') selected @endif value="list">List</option></select></div>- <!----></div></div><div class="form-group">