Commit 7f787a11 authored by Emma's avatar Emma 🏳🌈

redo sort nav, tabs for submissions/comments

parent 92872b40
Pipeline #53592973 (#495) passed with stage
in 59 seconds
.icon {
line-height: 1;
vertical-align: middle;
vertical-align: text-bottom;
svg {
fill: currentColor;
......
......@@ -10,5 +10,6 @@
&__bar {
display: flex;
margin: 0 1rem 1rem 0 !important;
flex-wrap: wrap;
}
}
......@@ -59,6 +59,7 @@
border: none;
background: transparent;
padding: 0;
text-align: unset;
}
.vote-flex() {
......
......@@ -5,6 +5,18 @@
padding: 0.5rem 1rem;
width: 100%; // for buttons
&--active {
position: relative;
&::before {
content: '\2022'; // bullet
left: 0;
position: absolute;
text-align: center;
width: 1rem;
}
}
&:hover {
background-color: var(--accent);
color: var(--accent-fg);
......
.tab {
.unbuttonize();
background-color: var(--accent);
border-bottom: solid 3px var(--accent-alt);
color: var(--text);
cursor: pointer;
display: block;
padding: 0.5rem 0.75rem ~'calc(0.5rem - 3px)';
&--active {
&--active,
.no-js .dropdown:hover > &,
.js .dropdown--expanded > & {
border-bottom-color: var(--primary);
}
}
......@@ -179,6 +179,18 @@
"css": "envelope-open-o",
"code": 62135,
"src": "fontawesome"
},
{
"uid": "56a21935a5d4d79b2e91ec00f760b369",
"css": "sort",
"code": 61660,
"src": "fontawesome"
},
{
"uid": "4109c474ff99cad28fd5a2c38af2ec6f",
"css": "filter",
"code": 61616,
"src": "fontawesome"
}
]
}
\ No newline at end of file
......@@ -17,12 +17,20 @@ class SubmissionRepository extends ServiceEntityRepository {
public const SORT_TOP = 'top';
public const SORT_CONTROVERSIAL = 'controversial';
public const SORT_MOST_COMMENTED = 'most_commented';
public const TIME_ALL = 'all';
public const TIME_YEAR = 'year';
public const TIME_MONTH = 'month';
public const TIME_WEEK = 'week';
public const TIME_DAY = 'day';
public const DEFAULT_TIME = self::TIME_ALL;
public const TIME_WEEK = 'week';
public const TIME_MONTH = 'month';
public const TIME_YEAR = 'year';
public const TIME_ALL = 'all';
public const VALID_TIMES = [
self::TIME_DAY,
self::TIME_WEEK,
self::TIME_MONTH,
self::TIME_YEAR,
self::TIME_ALL,
];
/**
* `$sortBy` -> ordered column name mapping.
......@@ -97,11 +105,11 @@ class SubmissionRepository extends ServiceEntityRepository {
*/
public function findSubmissions(string $sortBy, array $options = [], Request $request = null) {
$maxPerPage = $options['max_per_page'] ?? self::MAX_PER_PAGE;
$time = $request ? $request->query->get('t') : null;
$time = $request->query->get('t', self::TIME_ALL);
// Silently fail on invalid time
if (!$this->isValidTime($time)) {
$time = self::DEFAULT_TIME;
if (!\in_array($time, self::VALID_TIMES, true)) {
$time = self::TIME_ALL;
}
$rsm = $this->createResultSetMappingBuilder('s');
......@@ -204,16 +212,6 @@ class SubmissionRepository extends ServiceEntityRepository {
return $submissions;
}
private function isValidTime($time): bool {
return \in_array($time, [
self::TIME_ALL,
self::TIME_YEAR,
self::TIME_MONTH,
self::TIME_WEEK,
self::TIME_DAY,
], true);
}
private static function filterQuery(QueryBuilder $qb, array $options): void {
if (!empty($options['forums'])) {
/* @noinspection NotOptimalIfConditionsInspection */
......
......@@ -12,6 +12,7 @@
<symbol id="envelope-open-o" viewBox="0 0 1000 1000"><path d="M823 509l21 29q5 6 4 13t-6 11q-24 19-71 55t-82 63-37 29q-22 18-34 27t-33 23-43 20-41 7h-2q-20 0-41-7t-42-20-34-23-34-27q-3-2-36-28t-80-62-68-53q-7-4-7-11t3-13l21-29q4-6 12-7t14 3q52 41 170 132 3 2 25 20t33 26 32 18 32 9h2q13 0 32-9t32-18 34-26 24-20q144-110 174-135 7-4 14-4t12 7zm106 402V393q-51-47-89-78-51-41-217-169-2-2-24-20t-34-27-31-18-33-10h-2q-13 0-32 10t-32 18-34 27-24 20q-120 92-176 137t-72 58-46 41q-8 7-12 11v518q0 7 6 12t12 6h822q7 0 12-6t6-12zm71-518v518q0 37-26 63t-63 26H89q-36 0-63-26T0 911V393q0-31 23-53 69-63 195-162T348 77q20-17 33-27t35-23 42-20 41-7h2q20 0 41 7t43 20 34 23 33 27q24 20 87 68t126 99 112 96q23 22 23 53z"/></symbol>
<symbol id="envelope-open" viewBox="0 0 1000 1000"><path d="M1000 365v546q0 37-26 63t-63 26H89q-36 0-63-26T0 911V365q0-8 6-13 5-4 22-20t23-20 26-21 39-31 53-40 80-60 108-79q2-2 29-22t40-29 36-20 38-10 39 10 36 20 39 29 29 22q62 45 108 79t80 60 54 40 39 31 25 21 23 20 22 20q6 5 6 13zM685 691q147-106 193-140 6-5 7-12t-4-13l-21-29q-4-6-12-7t-13 4q-129 94-192 139-2 2-29 22t-39 29-36 20-39 10-38-10-36-20-40-29-29-22q-104-74-192-139-6-5-13-4t-12 7l-21 29q-5 6-4 13t7 12q46 34 193 140 5 5 28 22t36 26 36 22 43 19 42 6 42-6 44-20 36-22 37-26 26-21z"/></symbol>
<symbol id="envelope" viewBox="0 0 1000 1000"><path d="M1000 396v443q0 37-26 63t-63 27H89q-36 0-63-27T0 839V396q25 27 56 49 202 137 278 192 32 24 51 37t53 27 61 13h2q28 0 61-13t53-27 51-37q95-68 278-192 32-22 56-49zm0-164q0 44-27 84t-68 69Q695 531 643 566q-5 4-23 17t-30 22-29 18-32 15-28 5h-2q-12 0-27-5t-32-15-30-18-30-22-23-17q-51-35-147-101T96 385q-35-23-65-64T0 244q0-43 23-72t66-29h822q36 0 63 26t26 63z"/></symbol>
<symbol id="filter" viewBox="0 0 785.7 1000"><path d="M783 165q9 22-8 39L500 479v414q0 23-22 33-7 3-14 3-15 0-25-11L296 775q-10-11-10-25V479L11 204q-18-17-8-39 9-22 33-22h714q23 0 33 22z"/></symbol>
<symbol id="forward" viewBox="0 0 1000 1000"><path d="M1000 357q0 15-11 25L704 668q-11 11-25 11t-25-11-11-25V500H518q-55 0-98 3t-86 12-74 24-59 39-45 56-27 77-10 101q0 31 3 69 0 4 2 13t1 15q0 8-5 14t-13 6q-9 0-15-10-4-5-8-12t-7-17-6-13Q0 718 0 625q0-111 30-186 90-225 488-225h125V71q0-14 11-25t25-10 25 10l285 286q11 11 11 25z"/></symbol>
<symbol id="hammer" viewBox="0 0 1000 1000"><path d="M988 857q0 30-20 50l-60 61q-22 20-51 20t-50-20L604 764q-21-20-21-50 0-29 24-53L464 518l-70 70q-8 8-19 8t-19-8l7 7 7 7 6 6q5 5 5 8t4 8 3 9 0 10q0 21-15 38-2 1-9 10t-11 11-10 9-13 9-12 5-14 3q-23 0-38-16L38 484q-16-15-16-38 0-7 3-14t5-12 9-13 9-10 11-11 10-9q17-15 38-15h10q4 0 9 3t8 4 8 5 6 6 7 7 7 7q-8-8-8-19t8-19l194-194q8-8 19-8t19 8l-7-7-7-7q-1-1-6-7t-5-7-3-8-4-9 0-10q0-21 15-38 2-2 9-10t11-11 10-10 13-8 12-5 14-3q23 0 38 16l228 228q16 15 16 38 0 7-3 14t-5 12-8 13-10 10-11 11-10 9q-17 15-38 15h-10q-4 0-9-4t-8-3-7-5-7-6-7-7-7-7q8 8 8 19t-8 19l-70 70 143 143q24-24 53-24t51 21l203 202q20 22 20 51z"/></symbol>
<symbol id="hashtag" viewBox="0 0 1000 1000"><path d="M553 571l36-142H447l-36 142h142zm429-281l-32 125q-4 14-17 14H751l-36 142h173q9 0 14 7 6 8 4 16l-32 125q-2 13-17 13H675l-45 183q-4 14-18 14H487q-9 0-14-7t-4-16l44-174H371l-45 183q-4 14-17 14H183q-8 0-14-7-5-7-3-16l43-174H36q-9 0-14-7-5-6-4-15l32-125q4-14 17-14h182l36-142H112q-9 0-14-7-6-8-4-16l32-125q2-13 17-13h182l46-183q3-14 17-14h125q9 0 14 7t4 16l-44 174h142l45-183q4-14 18-14h125q8 0 14 7 5 7 3 16l-43 174h173q9 0 14 7 5 6 4 15z"/></symbol>
......@@ -26,6 +27,7 @@
<symbol id="plus" viewBox="0 0 785.7 1000"><path d="M786 411v107q0 22-16 38t-38 15H500v233q0 22-16 37t-38 16H339q-22 0-38-16t-15-37V571H54q-23 0-38-15T0 518V411q0-23 16-38t38-16h232V125q0-22 15-38t38-16h107q23 0 38 16t16 38v232h232q23 0 38 16t16 38z"/></symbol>
<symbol id="settings" viewBox="0 0 1071.4 1000"><path d="M500 500q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101zm429 286q0-29-22-51t-50-21-50 21-21 51q0 29 21 50t50 21 51-21 21-50zm0-572q0-29-22-50t-50-21-50 21-21 50q0 30 21 51t50 21 51-21 21-51zM714 449v103q0 6-4 11t-8 6l-87 14q-6 19-18 42 19 27 50 64 4 6 4 11 0 7-4 11-12 17-46 50t-43 33q-7 0-12-4l-64-50q-21 11-43 17-6 60-13 87-4 13-17 13H305q-6 0-11-4t-5-10l-13-85q-19-6-42-18l-66 50q-4 4-11 4-6 0-12-4-80-75-80-90 0-5 4-10 5-8 23-30t26-34q-13-24-20-46l-85-13q-5-1-9-5t-4-11V447q0-5 4-10t9-6l86-14q7-19 18-42-19-27-50-64-4-6-4-11 0-7 4-12 12-16 46-49t44-33q6 0 12 4l64 50q19-10 43-18 6-60 13-86 3-13 16-13h104q6 0 11 4t6 10l13 85q19 6 42 17l65-49q5-4 12-4 6 0 11 4 81 75 81 90 0 4-4 10-7 9-24 30t-25 34q13 27 19 46l85 12q6 2 9 6t4 11zm357 298v78q0 9-83 17-6 15-16 29 28 63 28 77 0 2-2 4-68 40-69 40-5 0-26-27t-29-37q-11 1-17 1t-17-1q-7 11-29 37t-25 27q-1 0-69-40-3-2-3-4 0-14 29-77-10-14-17-29-83-8-83-17v-78q0-9 83-18 7-16 17-29-29-63-29-77 0-2 3-4 2-1 19-11t33-19 17-9q4 0 25 26t29 38q12-1 17-1t17 1q28-40 51-63l4-1q2 0 69 39 2 2 2 4 0 14-28 77 9 13 16 29 83 9 83 18zm0-572v78q0 9-83 18-6 15-16 29 28 63 28 77 0 2-2 4-68 39-69 39-5 0-26-26t-29-38q-11 1-17 1t-17-1q-7 12-29 38t-25 26q-1 0-69-39-3-2-3-4 0-14 29-77-10-14-17-29-83-9-83-18v-78q0-9 83-17 7-16 17-29-29-63-29-77 0-2 3-4 2-1 19-11t33-19 17-9q4 0 25 26t29 37q12-1 17-1t17 1q28-39 51-62l4-1q2 0 69 39 2 2 2 4 0 14-28 77 9 13 16 29 83 8 83 17z"/></symbol>
<symbol id="sitemap" viewBox="0 0 1000 1000"><path d="M1000 696v179q0 22-16 38t-38 16H768q-22 0-38-16t-16-38V696q0-22 16-38t38-15h53V536H536v107h53q23 0 38 15t16 38v179q0 22-16 38t-38 16H411q-23 0-38-16t-16-38V696q0-22 16-38t38-15h53V536H179v107h53q23 0 38 15t16 38v179q0 22-16 38t-38 16H54q-23 0-38-16T0 875V696q0-22 16-38t38-15h53V536q0-29 21-51t51-21h285V357h-53q-23 0-38-16t-16-37V125q0-22 16-38t38-16h178q23 0 38 16t16 38v179q0 22-16 37t-38 16h-53v107h285q29 0 51 21t21 51v107h53q23 0 38 15t16 38z"/></symbol>
<symbol id="sort" viewBox="0 0 571.4 1000"><path d="M571 607q0 15-10 25L311 882q-11 11-25 11t-25-11L11 632Q0 622 0 607t11-25 25-11h500q14 0 25 11t10 25zm0-214q0 14-10 25t-25 11H36q-15 0-25-11T0 393t11-25l250-250q10-11 25-11t25 11l250 250q10 10 10 25z"/></symbol>
<symbol id="spinner" viewBox="0 0 1000 1000"><path d="M294 778q0 29-21 50t-51 21q-29 0-50-21t-21-50q0-30 21-51t50-21 51 21 21 51zm277 115q0 29-20 50t-51 21-50-21-21-50 21-51 50-21 51 21 20 51zM179 500q0 30-21 50t-51 21-50-21-21-50 21-51 50-20 51 20 21 51zm670 278q0 29-21 50t-50 21q-30 0-51-21t-20-50 20-51 51-21 50 21 21 51zM311 222q0 37-26 63t-63 26-63-26-26-63 26-63 63-26 63 26 26 63zm653 278q0 30-21 50t-50 21-51-21-21-50 21-51 51-20 50 20 21 51zM607 107q0 45-31 76t-76 31-76-31-31-76 31-76 76-31 76 31 31 76zm296 115q0 52-37 88t-88 37q-52 0-88-37t-37-88q0-51 37-88t88-37q51 0 88 37t37 88z"/></symbol>
<symbol id="text" viewBox="0 0 857.1 1000"><path d="M819 212q16 16 27 42t11 50v642q0 23-15 38t-38 16H54q-23 0-38-16T0 946V54q0-23 16-38T54 0h500q22 0 49 11t42 27zM571 76v210h210q-5-17-12-23L594 88q-6-7-23-12zm215 853V357H554q-23 0-38-16t-16-37V71H71v858h715zM214 446q0-7 5-12t13-5h393q8 0 13 5t5 12v36q0 8-5 13t-13 5H232q-8 0-13-5t-5-13v-36zm411 125q8 0 13 5t5 13v36q0 8-5 13t-13 5H232q-8 0-13-5t-5-13v-36q0-8 5-13t13-5h393zm0 143q8 0 13 5t5 13v36q0 8-5 13t-13 5H232q-8 0-13-5t-5-13v-36q0-8 5-13t13-5h393z"/></symbol>
<symbol id="trash" viewBox="0 0 785.7 1000"><path d="M286 768V375q0-8-5-13t-13-5h-36q-8 0-13 5t-5 13v393q0 8 5 13t13 5h36q8 0 13-5t5-13zm143 0V375q0-8-5-13t-13-5h-36q-8 0-13 5t-5 13v393q0 8 5 13t13 5h36q8 0 13-5t5-13zm142 0V375q0-8-5-13t-12-5h-36q-8 0-13 5t-5 13v393q0 8 5 13t13 5h36q7 0 12-5t5-13zM268 214h250l-27-65q-4-5-9-6H305q-6 1-10 6zm518 18v36q0 8-5 13t-13 5h-54v529q0 46-26 80t-63 34H161q-37 0-63-33t-27-79V286H18q-8 0-13-5t-5-13v-36q0-8 5-13t13-5h172l39-93q9-21 31-35t44-15h178q23 0 44 15t30 35l39 93h173q8 0 13 5t5 13z"/></symbol>
......
......@@ -19,10 +19,6 @@
<a href="{{ path('wiki') }}" class="site-nav__link">{{ 'nav.wiki'|trans }}</a>
</li>
<li class="site-nav__item">
<a href="{{ path('comment_list') }}" class="site-nav__link">{{ 'nav.comments'|trans }}</a>
</li>
{% if is_granted('ROLE_ADMIN') %}
<li class="dropdown site-nav__item dropdown-container">
<a href="#" class="dropdown__toggle site-nav__link no-underline dropdown-toggle">
......
{% from 'submission/_macros.html.twig' import submission_time %}
{%- if (time != null and time != 'all') or (sort_by != 'hot' and sort_by != 'new') -%}
<ul class="unlistify tabs__bar">
{{- submission_time(time) -}}
</ul>
{%- endif -%}
{% macro front_post_types(current) %}
<ul class="unlistify tabs__bar">
<li class="tabs__tab {{ current == 'submissions' ? 'tabs__tab--active' }}">
<a href="{{ path('front') }}"
class="tab tabs__link {{ current == 'submissions' ? 'tab--active tabs__link--active' }}">
{{- 'nav.submissions'|trans -}}
</a>
</li>
<li class="tabs__tab {{ current == 'comments' ? 'tabs__tab--active' }}">
<a href="{{ path('comment_list') }}"
class="tab tabs__link {{ current == 'comments' ? 'tab--active tabs__link--active' }}">
{{- 'nav.comments'|trans -}}
</a>
</li>
</ul>
{% endmacro front_post_types %}
{% macro forum_post_types(forum_name, current) %}
<ul class="unlistify tabs__bar">
<li class="tabs__tab {{ current == 'submissions' ? 'tabs__tab--active' }}">
<a href="{{ path('forum', { forum_name: forum_name }) }}"
class="tab tabs__link {{ current == 'submissions' ? 'tab--active tabs__link--active' }}">
{{- 'nav.submissions'|trans -}}
</a>
</li>
<li class="tabs__tab {{ current == 'comments' ? 'tabs__tab--active' }}">
<a href="{{ path('forum_comments', { forum_name: forum_name }) }}"
class="tab tabs__link {{ current == 'comments' ? 'tab--active tabs__link--active' }}">
{{- 'nav.comments'|trans -}}
</a>
</li>
</ul>
{% endmacro forum_post_types %}
{% macro submission_sort(current) %}
{% from _self import _submission_sort_items, _tab_button %}
{% set current_label = 'submissions.sort_by_%s'|format(current)|trans %}
<li class="dropdown tabs__tab">
{{ _tab_button(current_label, 'label.sort_by_mode', '%mode%', 'sort') }}
<ul class="dropdown__menu card unlistify">
{{ _submission_sort_items(current, ['hot', 'new'], null) }}
{{ _submission_sort_items(current, ['top', 'controversial', 'most_commented'], 'day') }}
</ul>
</li>
{% endmacro submission_sort %}
{% macro _submission_sort_items(current, types, time) %}
{% set attr = app.request.attributes %}
{% for type in types %}
<li>
<a href="{{ path(attr.get('_route'), (attr.get('_route_params') ?? [])|merge({sortBy: type, t: time})) }}"
class="no-wrap menu-link {{ type == current ? 'menu-link--active' }}">
{{- ('submissions.sort_by_'~type)|trans -}}
</a>
</li>
{% endfor %}
{% endmacro _submission_sort_items %}
{% macro submission_filter(choice, sort_by) %}
{% from _self import _tab_button %}
{% from '_macros/icon.html.twig' import icon %}
{% set filter_modes = {
featured: { label: 'front.featured'|trans },
subscribed: { label: 'front.subscribed'|trans, condition: is_granted('ROLE_USER') },
all: { label: 'front.all'|trans },
moderated: { label: 'nav.moderated'|trans, condition: (app.user.moderatorTokens ?? [])|length > 0 },
} %}
{% set current_label = filter_modes[choice].label %}
<li class="dropdown tabs__tab">
{{ _tab_button(current_label, 'label.filter_on_mode', '%mode%', 'filter') }}
<ul class="dropdown__menu card unlistify">
{% for route, mode in filter_modes if (mode.condition ?? true) %}
<li>
<a href="{{ path(route, {sortBy: sort_by}) }}"
class="no-wrap menu-link {{ choice == route ? 'menu-link--active' }}">
{{- mode.label -}}
</a>
</li>
{% endfor %}
</ul>
</li>
{% endmacro submission_filter %}
{% macro submission_time(sort_by) %}
{% from _self import _tab_button %}
{% set current = app.request.query.get('t', 'all') %}
{% set times = constant('App\\Repository\\SubmissionRepository::VALID_TIMES') %}
{% if current not in times %}
{% set current = 'all' %}
{% endif %}
{% if app.request.query.has('t') or sort_by not in ['hot', 'new'] %}
{% set attr = app.request.attributes %}
{% set current_label = 'submissions.time_%s'|format(current)|trans %}
<li class="dropdown tabs__tab">
{{ _tab_button(current_label, 'label.from_time', '%time%', 'clock') }}
<ul class="dropdown__menu card unlistify">
{% for time in times %}
<li>
<a href="{{ path(attr.get('_route'), (attr.get('_route_params') ?? [])|merge({t: time})) }}"
class="no-wrap menu-link {{ time == current ? 'menu-link--active' }}">
{{- ('submissions.time_'~time)|trans -}}
</a>
</li>
{% endfor %}
</ul>
</li>
{% endif %}
{% endmacro submission_time %}
{% macro _tab_button(choice_label, label_name, label_key, icon) %}
{% from '_macros/icon.html.twig' import icon %}
<button type="button"
class="dropdown__toggle tab no-underline"
aria-label="{{ label_name|trans({ (label_key): choice_label }) }}">
{{ icon(icon) }}
<span class="no-underline__exempt">{{ choice_label }}</span>
<span class="dropdown__arrow"></span>
</button>
{% endmacro _tab_button %}
{% extends 'base.html.twig' %}
{% from '_macros/post_nav.html.twig' import front_post_types %}
{% from 'comment/_macros.html.twig' import comment %}
{% block page_classes 'comment-list-page' %}
......@@ -9,6 +10,10 @@
{% endblock %}
{% block body %}
<nav class="tabs">
{{ front_post_types('comments') }}
</nav>
<h1 class="page-heading">{{ block('title') }}</h1>
{% for comment in comments %}
......
......@@ -73,11 +73,6 @@
{# sorted nav items #}
{% with { items: {} } %}
{% set item %}
<li><a href="{{ path('forum_comments', {forum_name: forum.name}) }}">{{ 'nav.recent_comments'|trans }}</a></li>
{% endset %}
{% set items = items|merge({('nav.recent_comments'|trans): item}) %}
{% set item %}
<li><a href="{{ path('forum_bans', {forum_name: forum.name}) }}">{{ 'nav.bans'|trans }}</a></li>
{% endset %}
......
{% extends 'forum/base.html.twig' %}
{% from '_macros/post_nav.html.twig' import forum_post_types %}
{% from 'comment/_macros.html.twig' import comment %}
{% block page_classes 'comment-list-page' %}
......@@ -13,6 +15,10 @@
'%forum%': '<a href="%s">/f/%s</a>'|format(path('forum', {forum_name: forum.name})|e, forum.name|e)
})|raw }}</h1>
<nav class="unlistify tabs">
{{ forum_post_types(forum.name, 'comments') }}
</nav>
{% if comments|length > 0 %}
{% for comment in comments %}
{{ comment(comment, {show_context: true}) }}
......
{% extends 'forum/base.html.twig' %}
{% from 'submission/_macros.html.twig' import submission, submission_sort %}
{% from '_macros/post_nav.html.twig' import forum_post_types, submission_sort, submission_time %}
{% from 'submission/_macros.html.twig' import submission %}
{% block title %}{{ forum.title }}{% endblock %}
......@@ -21,7 +22,7 @@
{% endif %}
{% endblock %}
{% block page_classes %}forum-front{% endblock %}
{% block page_classes 'forum-front' %}
{% block body %}
{% filter spaceless %}
......@@ -31,12 +32,13 @@
</h1>
{% endfilter %}
<nav class="tabs submission-sort">
<nav class="tabs">
{{ forum_post_types(forum.name, 'submissions') }}
<ul class="unlistify tabs__bar">
{{- submission_sort(sort_by) -}}
{{ submission_sort(sort_by) }}
{{ submission_time(sort_by) }}
</ul>
{% include '_includes/time_filters.html.twig' with {sort_by: sort_by, time: app.request.query.get('t')} %}
</nav>
{% if submissions.isEmpty() %}
......
{% extends 'base.html.twig' %}
{% from 'submission/_macros.html.twig' import submission, submission_sort, submission_time %}
{% from '_macros/post_nav.html.twig' import submission_sort, submission_time %}
{% from 'submission/_macros.html.twig' import submission %}
{% block page_classes 'multi-forum-page' %}
......@@ -10,10 +11,11 @@
{% block title '/f/'~forums|join(', /f/') %}
{% block body %}
<nav class="tabs submission-sort">
<ul class="tabs__bar">{{ submission_sort(sort_by) }}</ul>
{% include '_includes/time_filters.html.twig' with {sort_by: sort_by, time: app.request.query.get('t')} %}
<nav class="tabs">
<ul class="unlistify tabs__bar">
{{ submission_sort(sort_by) }}
{{ submission_time(sort_by) }}
</ul>
</nav>
{% for submission in submissions %}
......
{% extends 'base.html.twig' %}
{% from 'submission/_macros.html.twig' import submission, submission_sort %}
{% from '_macros/post_nav.html.twig' import submission_sort, submission_time %}
{% from 'submission/_macros.html.twig' import submission %}
{% block page_classes 'forum-category-page' %}
{% block title 'heading.category'|trans({'%category%': category.title}) %}
......@@ -42,12 +43,11 @@
{% block body %}
<h1 class="page-heading">{{ 'heading.category'|trans({'%category%': category.title}) }}</h1>
<nav class="tabs submission-sort">
<ul class="tabs__bar">
{{- submission_sort(sort_by) -}}
<nav class="tabs">
<ul class="unlistify tabs__bar">
{{ submission_sort(sort_by) }}
{{ submission_time(sort_by) }}
</ul>
{% include '_includes/time_filters.html.twig' with {sort_by: sort_by, time: app.request.query.get('t')} %}
</nav>
{% for submission in submissions %}
......
{% extends 'base.html.twig' %}
{% from 'submission/_macros.html.twig' import submission, submission_sort %}
{% from _self import submission_filter %}
{% from 'submission/_macros.html.twig' import submission %}
{% from '_macros/post_nav.html.twig' import front_post_types,
submission_filter,
submission_sort,
submission_time %}
{% block head %}
<link rel="canonical" href="{{ url('front') }}">
......@@ -18,11 +21,14 @@
{% endblock %}
{% block body %}
<nav class="tabs submission-sort">
<ul class="unlistify tabs__bar">{{ submission_sort(sort_by) }}</ul>
<ul class="unlistify tabs__bar">{{ submission_filter(listing, sort_by) }}</ul>
{%- include '_includes/time_filters.html.twig' with {sort_by: sort_by, time: app.request.query.get('t')} -%}
<nav class="tabs">
{{ front_post_types('submissions') }}
<ul class="unlistify tabs__bar">
{{ submission_sort(sort_by) }}
{{ submission_filter(listing, sort_by) }}
{{ submission_time(sort_by) }}
</ul>
</nav>
{% block front_alerts '' %}
......@@ -39,41 +45,3 @@
{% include '_includes/search.html.twig' %}
{% endif %}
{% endblock %}
{%- macro submission_filter(choice, sort_by) -%}
{% with { active: choice == 'featured' } %}
<li class="tabs__tab {{ active ? 'tabs__tab--active active' }}">
<a href="{{ path('featured', {sortBy: sort_by}) }}" class="tab tabs__link {{ active ? 'tab--active tabs__link--active' }}">
{{- 'front.featured'|trans -}}
</a>
</li>
{% endwith %}
{% if is_granted('ROLE_USER') %}
{% with { active: choice == 'subscribed' } %}
<li class="tabs__tab {{ active ? 'tabs__tab--active active' }}">
<a href="{{ path('subscribed', {sortBy: sort_by}) }}" class="tab tabs__link {{ active ? 'tab--active tabs__link--active' }}">
{{- 'front.subscribed'|trans -}}
</a>
</li>
{% endwith %}
{% endif %}
{% with { active: choice == 'all' } %}
<li class="tabs__tab {{ active ? 'tabs__tab--active active' }}">
<a href="{{ path('all', {sortBy: sort_by}) }}" class="tab tabs__link {{ active ? 'tab--active tabs__link--active' }}">
{{- 'front.all'|trans -}}
</a>
</li>
{% endwith %}
{% if choice == 'moderated' or app.user and app.user.moderatorTokens|length > 0 %}
{% with { active: choice == 'moderated' } %}
<li class="tabs__tab {{ active ? 'tabs__tab--active active' }}">
<a href="{{ path('moderated', {sortBy: sort_by}) }}" class="tab tabs__link {{ active ? 'tab--active tabs__link--active' }}">
{{- 'nav.moderated'|trans -}}
</a>
</li>
{% endwith %}
{% endif %}
{%- endmacro -%}
......@@ -11,45 +11,3 @@
{{ block('submission') }}
{%- endwith -%}
{%- endmacro -%}
{%- macro submission_sort_generic(current, types, time) -%}
{%- set attr = app.request.attributes -%}
{%- filter spaceless -%}
{%- for type in types -%}
<li class="tabs__tab {{ type == current ? 'tabs__tab--active active' }}">
<a href="{{ path(attr.get('_route'), (attr.get('_route_params') ?? [])|merge({sortBy: type, t: time})) }}"
class="tab tabs__link {{ type == current ? 'tab--active tabs__link--active' }}">
{{- ('submissions.sort_by_'~type)|trans -}}
</a>
</li>
{%- endfor -%}
{%- endfilter -%}
{%- endmacro -%}
{%- macro submission_sort(current) -%}
{%- import _self as macros -%}
{# Sorting options are impacted by time filters, which is what the following is about #}
{# Hot and New shouldn't be time filtered, hence null . #}
{{- macros.submission_sort_generic(current, ['hot', 'new'], null) -}}
{# When changing sorting modes, we set it to 'all' #}
{{- macros.submission_sort_generic(current, ['top', 'controversial', 'most_commented'], 'all') -}}
{%- endmacro -%}
{%- macro submission_time(current) -%}
{%- set attr = app.request.attributes -%}
{%- set times = ['all', 'year', 'month', 'week', 'day'] -%}
{%- set current = current in times ? current : 'all' -%}
{%- filter spaceless -%}
{%- for time in times -%}
<li class="tabs__tab {{ time == current ? 'tabs__tab--active active' }}">
<a href="{{ path(attr.get('_route'), (attr.get('_route_params') ?? [])|merge({t: time})) }}"
class="tab tabs__link {{ time == current ? 'tab--active tabs__link--active' }}">
{{- ('submissions.time_'~time)|trans -}}
</a>
</li>
{%- endfor -%}
{%- endfilter -%}
{%- endmacro -%}
......@@ -323,6 +323,9 @@ label:
search_query: Search query
notify_on_reply: Notify on reply
notify_on_mentions: Notify on mentions
sort_by_mode: 'Sort by: %mode%'
filter_on_mode: 'Filter on: %mode%'
from_time: 'From: %time%'
log:
comment_deletion: '%user% deleted comment by %author% in "%submission%"'
......@@ -365,7 +368,8 @@ nav:
my_account: My account
user_settings: User settings
forums: Forums
comments: Recent comments
submissions: Submissions
comments: Comments
messages: Messages
wiki: Wiki
next: Next
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment