mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-28 21:22:30 +00:00
Bookstack grid view.
This commit is contained in:
parent
0528e98d9c
commit
af72f0d490
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -10,6 +10,10 @@
|
||||
@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>
|
||||
|
15
resources/views/books/grid-item.blade.php
Normal file
15
resources/views/books/grid-item.blade.php
Normal file
@ -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>
|
@ -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>
|
||||
@ -20,14 +20,19 @@
|
||||
|
||||
<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"> </div>
|
||||
@ -53,6 +58,7 @@
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
{!! $books->render() !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -49,6 +49,15 @@
|
||||
@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">
|
||||
|
Loading…
Reference in New Issue
Block a user