Changes the news post previews up a little

This commit is contained in:
flash 2018-08-15 15:08:20 +02:00
parent 1bf81d7a7d
commit 8ea1506a1c
8 changed files with 106 additions and 113 deletions

View file

@ -1,12 +1,9 @@
@mio-news-mobile: 700px; @mio-news-mobile: 700px;
.news__container { .news__container {
&__content {
margin: 2px;
display: flex; display: flex;
@media (max-width: @mio-news-mobile) { @media (max-width: @mio-news-mobile) {
flex-direction: column; flex-direction: column;
} }
}
} }

View file

@ -1,7 +1,6 @@
.news__list { .news__list {
margin: 0; margin: 0;
margin-bottom: 2px; margin-bottom: 2px;
box-shadow: initial;
&__item { &__item {
text-decoration: none; text-decoration: none;

View file

@ -1,6 +1,5 @@
.news__preview { .news__preview {
margin: 0; margin: 0;
box-shadow: initial;
&:not(:last-child) { &:not(:last-child) {
margin-bottom: 2px; margin-bottom: 2px;
@ -11,39 +10,51 @@
flex-shrink: 1; flex-shrink: 1;
} }
&__content { &__container {
display: flex;
margin: 1px;
flex-direction: column;
}
&__content {
flex-grow: 1;
flex-shrink: 1;
display: flex; display: flex;
margin: 2px;
} }
&__text { &__text {
flex-grow: 1; flex: 1 1 auto;
flex-shrink: 1;
margin-left: 2px;
} }
&__info { &__info {
text-align: right; display: flex;
flex-grow: 0; justify-content: space-between;
flex-shrink: 0; border-top: 1px solid #9475b2;
font-size: .9em;
padding: 0 2px;
margin-top: 1px;
} }
&__date { &__link {
display: block; color: inherit;
text-decoration: underline dotted;
&:hover {
text-decoration: underline;
}
} }
&__user { &__user {
text-align: center;
flex: 0 0 auto;
text-decoration: none; text-decoration: none;
color: inherit; color: inherit;
display: inline-flex; display: flex;
flex-direction: column;
&__name {
font-weight: 700;
}
&__avatar { &__avatar {
height: 20px; height: 50px;
width: 20px; width: 50px;
margin-left: 4px; margin-left: 4px;
} }
} }

View file

@ -34,7 +34,7 @@ $news = Database::query('
ON u.`display_role` = r.`role_id` ON u.`display_role` = r.`role_id`
WHERE p.`is_featured` = true WHERE p.`is_featured` = true
ORDER BY p.`created_at` DESC ORDER BY p.`created_at` DESC
LIMIT 3 LIMIT 5
')->fetchAll(PDO::FETCH_ASSOC); ')->fetchAll(PDO::FETCH_ASSOC);
$statistics = Cache::instance()->get('index:stats:v1', function () { $statistics = Cache::instance()->get('index:stats:v1', function () {

View file

@ -34,18 +34,11 @@
</div> </div>
{% endif %} {% endif %}
<div class="container news__container">
<a class="container__title container__title--link" href="/news.php">Featured News</a>
<div class="news__container__content">
<div class="news__preview__listing">
{% for post in featured_news %} {% for post in featured_news %}
{{ news_preview(post) }} {{ news_preview(post) }}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</div>
</div>
</div>
{% if embed_linked_data is defined and embed_linked_data %} {% if embed_linked_data is defined and embed_linked_data %}
<script type="application/ld+json"> <script type="application/ld+json">

View file

@ -9,9 +9,7 @@
}) %} }) %}
{% block content %} {% block content %}
<div class="container news__container"> <div class="news__container">
<div class="container__title news__container__title">News » {{ category.category_name }}</div>
<div class="news__container__content">
<div class="news__preview__listing"> <div class="news__preview__listing">
{% for post in posts %} {% for post in posts %}
{{ news_preview(post) }} {{ news_preview(post) }}
@ -19,16 +17,14 @@
</div> </div>
<div class="news__sidebar"> <div class="news__sidebar">
{% if category.category_description|length > 0 %} <div class="container news__list">
<div class="container news__container"> <div class="container__title news__container__title">
<div class="container__title"> News » {{ category.category_name }}
Description
</div> </div>
<div class="container__content"> <div class="container__content">
{{ category.category_description }} {{ category.category_description|length > 0 ? category.category_description : '' }}
</div> </div>
</div> </div>
{% endif %}
{% if featured|length > 0 %} {% if featured|length > 0 %}
<div class="container news__list"> <div class="container news__list">
@ -46,5 +42,4 @@
{{ pagination(category.posts_count, posts_take, posts_offset, '/news.php?c=' ~ category.category_id) }} {{ pagination(category.posts_count, posts_take, posts_offset, '/news.php?c=' ~ category.category_id) }}
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}

View file

@ -6,9 +6,7 @@
{% set canonical_url = '/news.php'|url_construct({'o':posts_offset}) %} {% set canonical_url = '/news.php'|url_construct({'o':posts_offset}) %}
{% block content %} {% block content %}
<div class="container news__container"> <div class="news__container">
<div class="container__title news__container__title">News</div>
<div class="news__container__content">
<div class="news__preview__listing"> <div class="news__preview__listing">
{% for post in posts %} {% for post in posts %}
{{ news_preview(post) }} {{ news_preview(post) }}
@ -37,5 +35,4 @@
{{ pagination(posts_count, posts_take, posts_offset, '/news.php') }} {{ pagination(posts_count, posts_take, posts_offset, '/news.php') }}
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}

View file

@ -4,33 +4,34 @@
{{ post.post_title }} {{ post.post_title }}
</a> </a>
<div class="news__preview__container">
<div class="news__preview__content"> <div class="news__preview__content">
<div class="news__preview__text"> <div class="news__preview__text">
{{ post.post_text|first_paragraph|parse_text('md')|raw }} {{ post.post_text|first_paragraph|parse_text('md')|raw }}
</div> </div>
{% if post.user_id is not null %}
<a class="news__preview__user" href="/profile.php?u={{ post.user_id }}">
<div class="avatar news__preview__user__avatar" style="background-image:url('/profile.php?u={{ post.user_id }}&amp;m=avatar')"></div>
<div class="news__preview__user__name" style="{{ post.user_colour|html_colour({
'color': '%s',
'text-shadow': '0 0 5px %s',
}) }}">
{{ post.username }}
</div>
</a>
{% endif %}
</div>
<div class="news__preview__info"> <div class="news__preview__info">
<a href="/news.php?p={{ post.post_id }}" class="news__preview__link">
<time class="news__preview__date" datetime="{{ post.created_at|date('c') }}" title="{{ post.created_at|date('r') }}"> <time class="news__preview__date" datetime="{{ post.created_at|date('c') }}" title="{{ post.created_at|date('r') }}">
{{ post.created_at|time_diff }} {{ post.created_at|time_diff }}
</time> </time>
{% if post.user_id is not null %}
<a class="news__preview__user" href="/profile.php?u={{ post.user_id }}">
<div class="news__preview__user__name" style="{{ post.user_colour|html_colour }}">
{{ post.username }}
</div>
<div class="avatar news__preview__user__avatar" style="background-image:url('/profile.php?u={{ post.user_id }}&amp;m=avatar')"></div>
</a> </a>
{% endif %}
<a href="/news.php?p={{ post.post_id }}#comments" style="color: inherit; text-decoration: none; display: block"> <a href="/news.php?p={{ post.post_id }}#comments" class="news__preview__link">
{% if post.post_comments < 1 %} {{ post.post_comments < 1 ? 'No' : post.post_comments|number_format }} comment{{ post.post_comments != 1 ? 's' : '' }}
No comments
{% elseif post.post_comments == 1 %}
1 comment
{% else %}
{{ post.post_comments }} comments
{% endif %}
</a> </a>
</div> </div>
</div> </div>