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') $articles = $articles->orderBy('created_at', 'DESC')
->paginate(20); ->paginate(20);
// decode module settings
foreach ($articles as $article) {
$article->module_settings = json_decode($article->module_settings);
}
return Controller::VisitorsView($content->template, [ return Controller::VisitorsView($content->template, [
'page' => $content, 'page' => $content,
'articles' => $articles, 'articles' => $articles,
+17 -45
View File
@@ -1844,28 +1844,6 @@ h6 {
font-size: 1rem; 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 { a:hover,a:focus {
color: #779000; color: #779000;
text-decoration: underline; 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) { @media screen and (min-width: 40em) {
.medium-text-left { .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%; font-weight: bold; font-size: 120%;
padding: 0; padding: 0;
padding-right: 15px; 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> <small>{{$page->author->name}}</small>
</div> </div>
<div class="m-t-25 text-center"> @if(isset($page->module_settings->allowComments) && $page->module_settings->allowComments != 0)
<a href="#comments"><i class="fa fa-comments"></i> {{$page->comments->count()}}</a> <div class="m-t-25 text-center">
</div> <a href="#comments"><i class="fa fa-comments"></i> {{$page->comments->count()}}</a>
</div>
@endif
</aside> </aside>
<div class="column large-11"> <div class="column large-11">
<h1>{{$page->title}}</h1>
<article class="text-justify"> <article class="text-justify">
<h1>{{$page->title}}</h1>
{!! $page->content !!} {!! $page->content !!}
</article> </article>
</div> </div>
</div> </div>
<div class="row m-t-50"> @if(isset($page->module_settings->allowComments) && $page->module_settings->allowComments != 0)
<a name="comments"></a> <div class="row m-t-50">
<a name="comments"></a>
<h3>Komentáře</h3>
@foreach($page->comments as $comment)
<div class="row comment"> <h2>Komentáře</h2>
<aside class="column text-center large-1"> @foreach($page->comments as $comment)
<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
<?php <div class="row comment">
$loggedUser = \Auth::user(); <aside class="column text-center large-1">
?> <img src="@gravatar($comment->author->email, 30)" class="gravatar" alt="">
<div class="row m-t-25 "> <br />
<div class="column large-1"> <small>
@if($loggedUser) @date($comment->created_at, false)
<img src="@gravatar($loggedUser->email)" class="gravatar" alt=""> </small>
@endif </aside>
</div> <div class="column large-11">
<div class="column large-11"> <header>
@if(session('success')) <a name="{{$comment->id}}"></a>
<div class="callout succes"> <h6><a href="#{{$comment->id}}">{{$comment->author->name}}</a></h6>
Komentář úspěšně uložen. @if (!$loggedUser) Po schválení se zde objeví. @endif </header>
<article>
{{$comment->content}}
</article>
</div> </div>
@endif <div class="clearfix"></div>
</div>
@endforeach
<form method="post" action="{{route('comments.new', ['id' => $page->id])}}"> <?php
{!! csrf_field() !!} $loggedUser = \Auth::user();
?>
@if(!$loggedUser) <div class="row m-t-25 ">
<div class="row"> <div class="column large-1">
<div class="column medium-6"> @if($loggedUser)
<input type="text" name="name" required placeholder="Jméno"> <img src="@gravatar($loggedUser->email)" class="gravatar" alt="">
</div> @endif
<div class="column medium-6"> </div>
<input type="email" name="email" required placeholder="E-mail"> <div class="column large-11">
</div> @if(session('success'))
<div class="callout succes">
Komentář úspěšně uložen. @if (!$loggedUser) Po schválení se zde objeví. @endif
</div> </div>
@endif @endif
<div class="row"> <form method="post" action="{{route('comments.new', ['id' => $page->id])}}">
<div class="column medium-12"> {!! csrf_field() !!}
<textarea name="message" required>{{old('message')}}</textarea>
<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>
</div> </form>
</form> </div>
</div> </div>
@endif
</div> </div>
</div>
@endsection @endsection
@@ -6,7 +6,7 @@
{{--<h1 class="text-center uppercase m-b-25">{{$page->title}}</h1>--}} {{--<h1 class="text-center uppercase m-b-25">{{$page->title}}</h1>--}}
{{--<div class="row">--}} {{--<div class="row">--}}
{{--{!! $page->content !!}--}} {{--{!! $page->content !!}--}}
{{--</div>--}} {{--</div>--}}
@foreach($articles as $article) @foreach($articles as $article)
@@ -14,7 +14,7 @@
<div class="row"> <div class="row">
<aside class="column text-right large-3"> <aside class="column text-right large-3">
<div class="date"> <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> <br>
<span class="date uppercase month">@monthName($article->created_at)</span> <span class="date uppercase month">@monthName($article->created_at)</span>
</div> </div>
@@ -37,11 +37,13 @@
<a href="{{route('page.content', ['url' => $article->url])}}">více</a> <a href="{{route('page.content', ['url' => $article->url])}}">více</a>
</article> </article>
<footer class="text-right"> @if(isset($article->module_settings->allowComments) && $article->module_settings->allowComments != 0)
<a href="{{route('page.content', ['url' => $article->url])}}#comments"> <footer class="text-right">
<i class="fa fa-fw fa-comments"></i> {{$article->comments->count()}} <a href="{{route('page.content', ['url' => $article->url])}}#comments">
</a> <i class="fa fa-fw fa-comments"></i> {{$article->comments->count()}}
</footer> </a>
</footer>
@endif
</div> </div>
</div> </div>