mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-22 22:59:58 +08:00
Applied required changes in BookStack.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
class Book extends Entity
|
||||
{
|
||||
|
||||
protected $fillable = ['name', 'description'];
|
||||
protected $fillable = ['name', 'description', 'image'];
|
||||
|
||||
/**
|
||||
* Get the url for this book.
|
||||
|
@ -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 Controller
|
||||
return 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 $bookSlug
|
||||
|
@ -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.
|
||||
|
@ -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' => 'admin@admin.com',
|
||||
'password' => bcrypt('password'),
|
||||
'books_display' => 'grid',
|
||||
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
|
||||
]);
|
||||
|
@ -24,6 +24,7 @@ class CreateBooksTable extends Migration
|
||||
$table->string('slug')->indexed();
|
||||
$table->text('description');
|
||||
$table->nullableTimestamps();
|
||||
$table->string('image');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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])
|
||||
@endforeach
|
||||
|
@ -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">
|
||||
|
Reference in New Issue
Block a user