FEATURE: hide comments when article does not allow them

This commit is contained in:
Michal Kváček
2016-10-04 12:58:42 +02:00
parent 3024ae8b23
commit ce82b67c47
4 changed files with 98 additions and 115 deletions
@@ -101,6 +101,11 @@ class ArticleList extends Handler
$articles = $articles->orderBy('created_at', 'DESC')
->paginate(20);
// decode module settings
foreach ($articles as $article) {
$article->module_settings = json_decode($article->module_settings);
}
return Controller::VisitorsView($content->template, [
'page' => $content,
'articles' => $articles,
+17 -45
View File
@@ -1844,28 +1844,6 @@ h6 {
font-size: 1rem;
}
@media screen and (min-width: 40em) {
h1 {
font-size: 1.25rem;
}
h2 {
font-size: 1.25rem;
}
h3 {
font-size: 1.9375rem;
}
h4 {
font-size: 1.5625rem;
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
}
a:hover,a:focus {
color: #779000;
text-decoration: underline;
@@ -7689,29 +7667,6 @@ article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,secti
}
@media screen and (min-width: 40em) {
h1 {
font-size: 1.25rem;
}
h2 {
font-size: 1.25rem;
}
h3 {
font-size: 1.9375rem;
}
h4 {
font-size: 1.5625rem;
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
}
@media screen and (min-width: 40em) {
.medium-text-left {
@@ -9304,4 +9259,21 @@ article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,secti
font-weight: bold; font-size: 120%;
padding: 0;
padding-right: 15px;
}
article h1 {
font-size: 2em;
}
article h2 {
margin-top: 20px;
font-size: 1.5em;
}
article h3 {
margin-top: 20px;
font-size: 1.2em;
}
.comment aside {
line-height: 1;
}
@@ -17,86 +17,90 @@
<small>{{$page->author->name}}</small>
</div>
<div class="m-t-25 text-center">
<a href="#comments"><i class="fa fa-comments"></i> {{$page->comments->count()}}</a>
</div>
@if(isset($page->module_settings->allowComments) && $page->module_settings->allowComments != 0)
<div class="m-t-25 text-center">
<a href="#comments"><i class="fa fa-comments"></i> {{$page->comments->count()}}</a>
</div>
@endif
</aside>
<div class="column large-11">
<h1>{{$page->title}}</h1>
<article class="text-justify">
<h1>{{$page->title}}</h1>
{!! $page->content !!}
</article>
</div>
</div>
<div class="row m-t-50">
<a name="comments"></a>
@if(isset($page->module_settings->allowComments) && $page->module_settings->allowComments != 0)
<div class="row m-t-50">
<a name="comments"></a>
<h3>Komentáře</h3>
@foreach($page->comments as $comment)
<div class="row comment">
<aside class="column text-center large-1">
<img src="@gravatar($comment->author->email, 30)" class="gravatar" alt="">
<br />
<small>
@date($comment->created_at, false)
</small>
</aside>
<div class="column large-11">
<header>
<a name="{{$comment->id}}"></a>
<h6><a href="#{{$comment->id}}">{{$comment->author->name}}</a></h6>
</header>
<article>
{{$comment->content}}
</article>
</div>
<div class="clearfix"></div>
</div>
@endforeach
<h2>Komentáře</h2>
@foreach($page->comments as $comment)
<?php
$loggedUser = \Auth::user();
?>
<div class="row m-t-25 ">
<div class="column large-1">
@if($loggedUser)
<img src="@gravatar($loggedUser->email)" class="gravatar" alt="">
@endif
</div>
<div class="column large-11">
@if(session('success'))
<div class="callout succes">
Komentář úspěšně uložen. @if (!$loggedUser) Po schválení se zde objeví. @endif
<div class="row comment">
<aside class="column text-center large-1">
<img src="@gravatar($comment->author->email, 30)" class="gravatar" alt="">
<br />
<small>
@date($comment->created_at, false)
</small>
</aside>
<div class="column large-11">
<header>
<a name="{{$comment->id}}"></a>
<h6><a href="#{{$comment->id}}">{{$comment->author->name}}</a></h6>
</header>
<article>
{{$comment->content}}
</article>
</div>
@endif
<div class="clearfix"></div>
</div>
@endforeach
<form method="post" action="{{route('comments.new', ['id' => $page->id])}}">
{!! csrf_field() !!}
@if(!$loggedUser)
<div class="row">
<div class="column medium-6">
<input type="text" name="name" required placeholder="Jméno">
</div>
<div class="column medium-6">
<input type="email" name="email" required placeholder="E-mail">
</div>
<?php
$loggedUser = \Auth::user();
?>
<div class="row m-t-25 ">
<div class="column large-1">
@if($loggedUser)
<img src="@gravatar($loggedUser->email)" class="gravatar" alt="">
@endif
</div>
<div class="column large-11">
@if(session('success'))
<div class="callout succes">
Komentář úspěšně uložen. @if (!$loggedUser) Po schválení se zde objeví. @endif
</div>
@endif
<div class="row">
<div class="column medium-12">
<textarea name="message" required>{{old('message')}}</textarea>
<form method="post" action="{{route('comments.new', ['id' => $page->id])}}">
{!! csrf_field() !!}
<button type="submit" class="button success">Uložit</button>
@if(!$loggedUser)
<div class="row">
<div class="column medium-6">
<input type="text" name="name" required placeholder="Jméno">
</div>
<div class="column medium-6">
<input type="email" name="email" required placeholder="E-mail">
</div>
</div>
@endif
<div class="row">
<div class="column medium-12">
<textarea name="message" required>{{old('message')}}</textarea>
<button type="submit" class="button success">Uložit</button>
</div>
</div>
</div>
</form>
</form>
</div>
</div>
@endif
</div>
</div>
@endsection
@@ -6,7 +6,7 @@
{{--<h1 class="text-center uppercase m-b-25">{{$page->title}}</h1>--}}
{{--<div class="row">--}}
{{--{!! $page->content !!}--}}
{{--{!! $page->content !!}--}}
{{--</div>--}}
@foreach($articles as $article)
@@ -14,7 +14,7 @@
<div class="row">
<aside class="column text-right large-3">
<div class="date">
<span class="date day big">@customDate('j', $article->created_at)</span>
<span class="date day big">@customDate('j', $article->created_at)</span>
<br>
<span class="date uppercase month">@monthName($article->created_at)</span>
</div>
@@ -37,11 +37,13 @@
<a href="{{route('page.content', ['url' => $article->url])}}">více</a>
</article>
<footer class="text-right">
<a href="{{route('page.content', ['url' => $article->url])}}#comments">
<i class="fa fa-fw fa-comments"></i> {{$article->comments->count()}}
</a>
</footer>
@if(isset($article->module_settings->allowComments) && $article->module_settings->allowComments != 0)
<footer class="text-right">
<a href="{{route('page.content', ['url' => $article->url])}}#comments">
<i class="fa fa-fw fa-comments"></i> {{$article->comments->count()}}
</a>
</footer>
@endif
</div>
</div>