byceps/byceps

View on GitHub
byceps/blueprints/site/board/templates/site/board/category_view.html

Summary

Maintainability
Test Coverage
{% extends 'layout/base.html' %}
{% from 'macros/board.html' import render_flag_new %}
{% from 'macros/icons.html' import render_icon %}
{% from 'macros/pagination.html' import render_pagination_nav %}
{% from 'macros/subnav.html' import render_subnav_for_menu_id %}
{% from 'macros/user.html' import render_user_avatar_and_name %}
{% set current_page = 'board' %}
{% set page_title = [_('Board'), category.title] %}

{% block subnav %}
  {%- if subnav_menu_id|default %}
{{ render_subnav_for_menu_id(subnav_menu_id, current_page) }}
  {%- endif %}
{% endblock %}

{% block body %}

  <nav class="breadcrumbs">
    <ol>
      <li><a href="{{ url_for('.category_index') }}">{{ _('Board') }}</a></li>
    </ol>
  </nav>
  <h1 class="title">{{ category.title }}</h1>

  {%- if topics.items %}
  <table class="itemlist is-vcentered is-wide board-topic-index">
    <thead>
      <tr>
        <th>{{ _('Topic') }}</th>
        <th class="centered">{{ _('Replies') }}</th>
        <th>{{ _('Latest post') }}</th>
      </tr>
    </thead>
    <tbody>
      {%- for topic in topics.items %}
      <tr id="topic-{{ topic.id }}"{% if topic.hidden %} class="dimmed"{% endif %}>
        <td>
          <a class="board-index-item-link disguised" href="{{ url_for('.topic_view', topic_id=topic.id) }}">
            <div class="board-index-item-title">
              {%- if topic.contains_unseen_postings %} {{ render_flag_new() }}{% endif %}
              {%- if topic.posting_limited_to_moderators %}{{ render_icon('announce', title=_('Announcements')) }} {% endif -%}
              {%- if topic.hidden %}{{ render_icon('hidden', title='%s (%s %s)'|format(_('hidden'), _('by'), topic.hidden_by.screen_name)) }} {% endif -%}
              {%- if topic.locked %}{{ render_icon('lock', title=_('locked')) }} {% endif -%}
              {%- if topic.pinned %}{{ render_icon('pin', title=_('pinned')) }} {% endif -%}
              <strong>{{ topic.title }}</strong>
            </div>
            <div class="board-index-item-meta">
              {{ _('started by') }} {{ render_user_avatar_and_name(topic.creator, size=16) }}
            </div>
          </a>
        </td>
        <td class="centered bignumber">{{ topic.reply_count|numberformat }}</td>
        <td class="nowrap">{{ topic.last_updated_at|dateformat }}, {{ topic.last_updated_at|timeformat('short') }}<br>{{ _('by') }} {{ render_user_avatar_and_name(topic.last_updated_by, size=16) }}</td>
      </tr>
      {%- endfor %}
    </tbody>
  </table>
  {%- else %}
  <div class="main-body-box">
    <p class="dimmed">{{ _('No topics exist in this category.') }}</p>
  </div>
  {%- endif %}

{{ render_pagination_nav(topics, 'board.category_view', {'slug': category.slug}) }}

  {%- set current_user_may_create_topic = has_current_user_permission('board_topic.create') %}

  <div class="button-row is-right-aligned">

    {%- if current_user_may_create_topic %}
    <a class="button" href="{{ url_for('.topic_create_form', category_id=category.id) }}">{{ render_icon('add') }} <span>{{ _('Create topic') }}</span></a>
    {%- else %}
    <span class="button button--disabled">{{ render_icon('add') }} <span>{{ _('Create topic') }}</span></span>
    {%- endif %}

    {%- if g.user.authenticated %}
    <button class="button" data-action="mark-all-topics-in-category-as-viewed" href="{{ url_for('.mark_all_topics_in_category_as_viewed', category_id=category.id) }}" title="{{ _('Mark all topics in this category as unread') }}">{{ render_icon('view') }}</button>
    {%- endif %}

  </div>

  {%- if not current_user_may_create_topic %}
  <small>
    <p style="text-align: right;">{{ _('You have to be <a href="%(url)s">logged in</a> to be able to create topics.', url=url_for('authn_login.log_in_form')) }}</p>
  </small>
  {%- endif %}

{%- endblock %}

{% block scripts %}
    <script>
      onDomReady(() => {
        confirmed_post_on_click('[data-action="mark-all-topics-in-category-as-viewed"]', '{{ _('Mark all topics in this category as unread?') }}');
      });
    </script>
{%- endblock %}