Revize 1bcdcb05
Přidáno uživatelem Adam Mištera před téměř 5 roky(ů)
app/Http/Controllers/ArtefactController.php | ||
---|---|---|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
/** |
73 |
* Likes metadata given by its id.
|
|
73 |
* Likes artefact given by its id.
|
|
74 | 74 |
* |
75 | 75 |
* @param $id int id of metadata |
76 | 76 |
* @return \Illuminate\Http\RedirectResponse |
... | ... | |
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
/** |
89 |
* Unlikes metadata given by its id.
|
|
89 |
* Unlikes artefact given by its id.
|
|
90 | 90 |
* |
91 | 91 |
* @param $id int id of metadata |
92 | 92 |
* @return \Illuminate\Http\RedirectResponse |
app/Http/Controllers/DetailsController.php | ||
---|---|---|
3 | 3 |
namespace App\Http\Controllers; |
4 | 4 |
|
5 | 5 |
use App\ArtefactUser; |
6 |
use App\User; |
|
6 | 7 |
use Illuminate\Http\Request; |
7 | 8 |
use App\Metadata; |
8 | 9 |
use App\Artefact; |
10 |
use Illuminate\Support\Facades\Auth; |
|
9 | 11 |
|
10 | 12 |
class DetailsController extends Controller |
11 | 13 |
{ |
14 |
const ORDER_COLUMN = 'page'; |
|
15 |
|
|
12 | 16 |
public function __construct() |
13 | 17 |
{ |
14 | 18 |
$this->middleware('auth'); |
... | ... | |
32 | 36 |
* Display the specified resource. |
33 | 37 |
* |
34 | 38 |
* @param int $id |
35 |
* @return \Illuminate\Http\Response
|
|
39 |
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
36 | 40 |
*/ |
37 | 41 |
public function show($id) |
38 | 42 |
{ |
39 |
$data = array( |
|
40 |
'id' => $id, |
|
41 |
'arrArtefact' => Artefact::find($id), |
|
42 |
'likes' => Artefact::find($id)->users()->count(), |
|
43 |
'metadata' => Metadata::where('artefact_id', $id)->get() |
|
44 |
); |
|
45 |
return view('detail.index') -> with($data); |
|
43 |
if (is_null(Artefact::find($id))) |
|
44 |
{ |
|
45 |
return view('detail.index', ['metadata' => []]); |
|
46 |
} |
|
47 |
|
|
48 |
$metadata = Artefact::find($id)->metadata()->orderBy(self::ORDER_COLUMN)->get(); |
|
49 |
foreach($metadata as $item) |
|
50 |
{ |
|
51 |
$item['favourite'] = is_null(User::find(Auth::id())->likesMetadata()->find($item->id)) ? false : true; |
|
52 |
} |
|
53 |
|
|
54 |
return view('detail.index', ['metadata' => $metadata]); |
|
46 | 55 |
} |
47 | 56 |
|
57 |
/** |
|
58 |
* Likes metadata given by its id. |
|
59 |
* |
|
60 |
* @param $id int id of metadata |
|
61 |
* @return \Illuminate\Http\RedirectResponse |
|
62 |
*/ |
|
63 |
public function like($id) |
|
64 |
{ |
|
65 |
$user = User::find(Auth::id()); |
|
66 |
$metadata = Metadata::find($id); |
|
67 |
|
|
68 |
$user->likesMetadata()->attach($metadata); |
|
69 |
|
|
70 |
return back()->withInput(); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Unlikes metadata given by its id. |
|
75 |
* |
|
76 |
* @param $id int id of metadata |
|
77 |
* @return \Illuminate\Http\RedirectResponse |
|
78 |
*/ |
|
79 |
public function unlike($id) |
|
80 |
{ |
|
81 |
$user = User::find(Auth::id()); |
|
82 |
$metadata = Metadata::find($id); |
|
83 |
|
|
84 |
$user->likesMetadata()->detach($metadata); |
|
85 |
|
|
86 |
return back()->withInput(); |
|
87 |
} |
|
48 | 88 |
} |
public/css/app.css | ||
---|---|---|
10969 | 10969 |
background-color: rgba(239, 218, 179, 0.5); |
10970 | 10970 |
} |
10971 | 10971 |
|
10972 |
body .container { |
|
10973 |
margin-top: 4.99055rem; |
|
10974 |
} |
|
10975 |
|
|
10972 | 10976 |
body .text { |
10973 | 10977 |
font-weight: 400; |
10974 | 10978 |
font-size: 8pt; |
... | ... | |
11040 | 11044 |
border-radius: 0; |
11041 | 11045 |
} |
11042 | 11046 |
|
11047 |
body .auth .form-control:focus { |
|
11048 |
border-color: #ffffff; |
|
11049 |
box-shadow: none; |
|
11050 |
} |
|
11051 |
|
|
11052 |
body .auth .card-body { |
|
11053 |
padding-bottom: 0px; |
|
11054 |
padding-top: calc(28vh - 4.99055rem); |
|
11055 |
} |
|
11056 |
|
|
11043 | 11057 |
body input:-webkit-autofill { |
11044 |
-webkit-box-shadow: 0 0 0 50px #272727 inset; |
|
11058 |
-webkit-box-shadow: 0 0 0 50px #272727 inset !important;
|
|
11045 | 11059 |
-webkit-text-fill-color: #ffffff; |
11060 |
background-color: #272727 !important; |
|
11046 | 11061 |
} |
11047 | 11062 |
|
11048 | 11063 |
body input:-webkit-autofill:active, |
11049 | 11064 |
body input:-webkit-autofill:focus, |
11050 | 11065 |
body input:-webkit-autofill:visited, |
11051 | 11066 |
body input:-webkit-autofill:hover { |
11052 |
-webkit-box-shadow: 0 0 0 50px #272727 inset; |
|
11067 |
-webkit-box-shadow: 0 0 0 50px #272727 inset !important;
|
|
11053 | 11068 |
-webkit-text-fill-color: #ffffff; |
11069 |
background-color: #272727 !important; |
|
11054 | 11070 |
} |
11055 | 11071 |
|
11056 | 11072 |
body .card-body { |
... | ... | |
11069 | 11085 |
color: #ffffff; |
11070 | 11086 |
box-shadow: none; |
11071 | 11087 |
font-size: 8pt; |
11088 |
outline: none; |
|
11072 | 11089 |
} |
11073 | 11090 |
|
11074 | 11091 |
body .form-control:active, |
11075 | 11092 |
body .form-control:focus, |
11076 |
body .form-control:visited { |
|
11093 |
body .form-control:visited, |
|
11094 |
body .form-control:hover { |
|
11095 |
outline: none; |
|
11077 | 11096 |
background-color: #272727; |
11078 | 11097 |
margin-top: -1px; |
11079 | 11098 |
border-top-color: #272727; |
... | ... | |
11138 | 11157 |
display: inline-block; |
11139 | 11158 |
margin: 12rem 50px 0px -5rem; |
11140 | 11159 |
position: fixed; |
11141 |
top: 0;
|
|
11160 |
top: 28vh;
|
|
11142 | 11161 |
bottom: 0; |
11143 | 11162 |
text-align: left; |
11144 | 11163 |
width: 100%; |
... | ... | |
11336 | 11355 |
} |
11337 | 11356 |
|
11338 | 11357 |
body .metadata-area h2 { |
11358 |
color: #ddd1b9; |
|
11339 | 11359 |
font-weight: 600; |
11340 | 11360 |
font-size: 12pt; |
11341 | 11361 |
} |
... | ... | |
11430 | 11450 |
font-size: 7pt; |
11431 | 11451 |
} |
11432 | 11452 |
|
11453 |
body .metadata-area .metadata-text .artefact-info .inter_like:before { |
|
11454 |
background-image: url(/images/Heart_Empty.svg?974f069a126736e569df0f463d68c026); |
|
11455 |
width: 3.125rem; |
|
11456 |
height: 3.125rem; |
|
11457 |
margin-right: 0; |
|
11458 |
} |
|
11459 |
|
|
11460 |
body .metadata-area .metadata-text .artefact-info .inter_like:hover, |
|
11461 |
body .metadata-area .metadata-text .artefact-info .inter_like:focus, |
|
11462 |
body .metadata-area .metadata-text .artefact-info .inter_like:active { |
|
11463 |
background-color: transparent !important; |
|
11464 |
border-color: transparent !important; |
|
11465 |
outline: none !important; |
|
11466 |
box-shadow: none !important; |
|
11467 |
} |
|
11468 |
|
|
11433 | 11469 |
body .metadata-area .metadata-text .artefact-info .inter_like_filled:before { |
11434 | 11470 |
background-image: url(/images/Heart_Filled.svg?e5b962dc0fd67a2042277b9826016c9c); |
11435 | 11471 |
width: 3.125rem; |
... | ... | |
11528 | 11564 |
border: 0.59055rem solid transparent; |
11529 | 11565 |
} |
11530 | 11566 |
|
11567 |
.top-bar { |
|
11568 |
padding-bottom: 4.59055rem; |
|
11569 |
background-color: #272727; |
|
11570 |
position: fixed; |
|
11571 |
width: 100%; |
|
11572 |
top: 0; |
|
11573 |
} |
|
11574 |
|
|
11531 | 11575 |
.arrow-left { |
11532 | 11576 |
margin-left: 80%; |
11533 | 11577 |
border-right: 0.59055rem solid #272727; |
... | ... | |
11542 | 11586 |
left: 0; |
11543 | 11587 |
} |
11544 | 11588 |
|
11589 |
.separator { |
|
11590 |
border-bottom: 1px solid #272727; |
|
11591 |
} |
|
11592 |
|
|
11545 | 11593 |
.sidenav { |
11546 | 11594 |
height: 100%; |
11547 | 11595 |
width: 250px; |
... | ... | |
11566 | 11614 |
background-color: #ffffff; |
11567 | 11615 |
} |
11568 | 11616 |
|
11617 |
.sidenav a:active, |
|
11618 |
.sidenav a:focus, |
|
11619 |
.sidenav a .active { |
|
11620 |
color: #ffffff; |
|
11621 |
background-color: #ead4b0; |
|
11622 |
} |
|
11623 |
|
|
11624 |
.dropdown-item.active, |
|
11625 |
.dropdown-item:active { |
|
11626 |
color: #272727; |
|
11627 |
background-color: #ffffff; |
|
11628 |
} |
|
11629 |
|
|
11630 |
.logo-kaplicky { |
|
11631 |
position: fixed; |
|
11632 |
top: 0; |
|
11633 |
left: calc(50vw - 50pt); |
|
11634 |
margin-top: 2rem; |
|
11635 |
} |
|
11636 |
|
|
11637 |
.vertical-center { |
|
11638 |
min-height: 100vh; |
|
11639 |
display: flex; |
|
11640 |
align-items: center; |
|
11641 |
} |
|
11642 |
|
|
11643 |
.error { |
|
11644 |
color: #ffffff; |
|
11645 |
font-size: xx-large; |
|
11646 |
display: block; |
|
11647 |
text-align: center; |
|
11648 |
} |
|
11649 |
|
|
11569 | 11650 |
@media screen and (max-height: 450px) { |
11570 | 11651 |
.sidenav a { |
11571 | 11652 |
font-size: 18px; |
resources/sass/_custom.scss | ||
---|---|---|
436 | 436 |
.metadata-area { |
437 | 437 |
|
438 | 438 |
h2 { |
439 |
color: $theme-color-two; |
|
439 | 440 |
font-weight: $font-weight-two; |
440 | 441 |
font-size: 12pt; |
441 | 442 |
} |
... | ... | |
530 | 531 |
font-size: 7pt; |
531 | 532 |
} |
532 | 533 |
|
534 |
.inter_like { |
|
535 |
|
|
536 |
&:before { |
|
537 |
background-image: url(../images/interface/Heart_Empty.svg); |
|
538 |
width: 3.125rem; |
|
539 |
height: 3.125rem; |
|
540 |
margin-right: 0; |
|
541 |
} |
|
542 |
|
|
543 |
&:hover, &:focus, &:active { |
|
544 |
background-color: transparent !important; |
|
545 |
border-color: transparent !important; |
|
546 |
outline: none !important; |
|
547 |
box-shadow: none !important; |
|
548 |
} |
|
549 |
} |
|
550 |
|
|
533 | 551 |
.inter_like_filled { |
534 | 552 |
|
535 | 553 |
&:before { |
resources/views/artefact/view.blade.php | ||
---|---|---|
39 | 39 |
<a href="{{ action('ArtefactController@like', ['id' => $artefact->id]) }}"> |
40 | 40 |
<button id="like_butt_{{$artefact->id}}" type="button" class="btn btn-primary button-image inter_like"></button> |
41 | 41 |
</a> |
42 |
|
|
43 | 42 |
@endif |
44 | 43 |
<h6 class="artefact-likes">{{$artefact->likes}}</h6> |
45 | 44 |
</div> |
resources/views/detail/index.blade.php | ||
---|---|---|
2 | 2 |
|
3 | 3 |
@section('title', 'Detail') |
4 | 4 |
|
5 |
@section('breadcrumb') |
|
6 |
<li class="breadcrumb-item" aria-current="page"><a href="{{ url('/') }}">Home</a></li> |
|
7 |
<li class="breadcrumb-item" aria-current="page"><a href="{{ url('/artefact') }}">Artefacts</a></li> |
|
8 |
<li class="breadcrumb-item" aria-current="page"><a href="{{ url('/artefact/' . $id) }}">Artefact</a></li> |
|
9 |
<li class="breadcrumb-item active" aria-current="page">Notes</li> |
|
10 |
@endsection |
|
11 |
|
|
12 | 5 |
@section('content') |
13 | 6 |
<div class="container"> |
14 |
<div class="jumbotron mt-5"> |
|
15 |
<div class="text-center"> |
|
16 |
@if (isset($arrArtefact)) |
|
17 |
<h1>Notes list</h1> |
|
18 |
<p> |
|
19 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
|
20 |
Mauris dolor felis, sagittis at, luctus sed, aliquam non, tellus. |
|
21 |
Fusce tellus odio, dapibus id fermentum quis, suscipit id erat. |
|
22 |
Morbi scelerisque luctus velit. Vivamus porttitor turpis ac leo. |
|
23 |
Morbi scelerisque luctus velit. |
|
24 |
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. |
|
25 |
</p> |
|
26 |
@else |
|
27 |
<h2>Given artefact does not exist!</h2> |
|
28 |
@endif |
|
7 |
<div class="metadata-area"> |
|
8 |
<div class="text-center mt-5"> |
|
9 |
<h2>notes</h2> |
|
29 | 10 |
</div> |
30 |
</div> |
|
31 |
@if(isset($arrArtefact)) |
|
32 |
<div class="artefact-area text-center mb-4"> |
|
33 |
<h2>{{$arrArtefact->name}}</h2> |
|
34 |
<h4>{{$arrArtefact->author}}, {{$arrArtefact->year}}</h4> |
|
35 |
<h5 class="text-muted">{{$arrArtefact->pages}} pages, <i class="fas fa-thumbs-up"></i> {{$likes}}</h5> |
|
36 |
</div> |
|
37 |
@if(count($metadata) > 0) |
|
38 |
<ul class="list-group"> |
|
39 |
@foreach($metadata as $meta) |
|
40 |
<div class="note-area mb-3"> |
|
41 |
<li class="list-group-item"> |
|
42 |
On {{$meta->page}} page:<br> |
|
43 |
{{$meta->noteCZ}}<br> |
|
44 |
{{$meta->noteEN}}<br> |
|
45 |
</li> |
|
11 |
<span class="arrow-down"></span> |
|
12 |
|
|
13 |
@if(!empty($metadata) || count($metadata) > 0) |
|
14 |
@foreach($metadata as $meta) |
|
15 |
<div id="row_{{$meta->id}}" class="row text-page"> |
|
16 |
<div class="pin-horizontal"> |
|
17 |
<div class="metadata"> |
|
18 |
<span>page {{$meta->page}}</span> |
|
19 |
<a href="#meta_{{$meta->id}}" class="arrow-down" data-toggle="collapse" data-target="#meta_{{$meta->id}}" onclick="openNote('#row_{{$meta->id}}')"></a> |
|
20 |
</div> |
|
46 | 21 |
</div> |
47 |
@endforeach |
|
48 |
</ul> |
|
22 |
<div id="meta_{{$meta->id}}" class="metadata-text collapse"> |
|
23 |
<p> |
|
24 |
{{$meta->noteEN}} |
|
25 |
</p> |
|
26 |
<div class="artefact-info"> |
|
27 |
<div class="artefact-name"> |
|
28 |
{{$meta->artefact->name}} |
|
29 |
</div> |
|
30 |
<div class="artefact-author"> |
|
31 |
{{$meta->artefact->author}} |
|
32 |
</div> |
|
33 |
<div class="text-center"> |
|
34 |
@if ($meta->favourite) |
|
35 |
<a href="{{ action('DetailsController@unlike', ['id' => $meta->id]) }}"> |
|
36 |
<button id="like_butt_{{$meta->id}}" type="button" class="btn btn-primary button-image inter_like_filled"></button> |
|
37 |
</a> |
|
38 |
@else |
|
39 |
<a href="{{ action('DetailsController@like', ['id' => $meta->id]) }}"> |
|
40 |
<button id="like_butt_{{$meta->id}}" type="button" class="btn btn-primary button-image inter_like"></button> |
|
41 |
</a> |
|
42 |
@endif |
|
43 |
</div> |
|
44 |
</div> |
|
45 |
</div> |
|
46 |
</div> |
|
47 |
@endforeach |
|
49 | 48 |
@else |
50 |
<ul class="list-group"> |
|
51 |
<li class="list-group-item"> |
|
52 |
<h3>No notes for this BOOK were found!</h3> |
|
53 |
</li> |
|
54 |
</ul> |
|
49 |
<div class="text-center mt-5"> |
|
50 |
<h2>No metadata!</h2> |
|
51 |
</div> |
|
55 | 52 |
@endif |
56 |
@endif
|
|
53 |
</div>
|
|
57 | 54 |
</div> |
55 |
|
|
56 |
<script> |
|
57 |
function openNote(element) { |
|
58 |
let metadata = $(element); |
|
59 |
let showed = metadata.find(".metadata-text").hasClass('show'); |
|
60 |
|
|
61 |
if (showed === false) |
|
62 |
{ |
|
63 |
metadata.find('.pin-horizontal').addClass("white-pin"); |
|
64 |
} |
|
65 |
else |
|
66 |
{ |
|
67 |
metadata.find('.pin-horizontal').removeClass("white-pin"); |
|
68 |
} |
|
69 |
|
|
70 |
} |
|
71 |
</script> |
|
58 | 72 |
@endsection |
routes/web.php | ||
---|---|---|
20 | 20 |
Route::get('/artefact/like/{id}', 'ArtefactController@like'); |
21 | 21 |
Route::get('/artefact/unlike/{id}', 'ArtefactController@unlike'); |
22 | 22 |
Route::get('/category/{id}', 'ArtefactController@showCategory'); |
23 |
Route::get('/detail/like/{id}', 'DetailsController@like'); |
|
24 |
Route::get('/detail/unlike/{id}', 'DetailsController@unlike'); |
|
23 | 25 |
Route::resource('/detail', 'DetailsController', array('only' => array('index', 'show'))); |
24 | 26 |
Route::resource('/categories', 'CategoriesController', array('only' => array('index'))); |
25 | 27 |
Route::resource('/favartefacts', 'FavoriteArtefactsController', array('only' => array('index', 'show', 'store'))); |
Také k dispozici: Unified diff
Issue #7955 @1h
[+] Vizualizace metadat
[+] Zprovoznění like/unlike
[+] Oprava dokumentace