render motds in topic and topics views
This commit is contained in:
@@ -186,6 +186,7 @@ def create_app():
|
||||
return {
|
||||
'get_post_url': get_post_url,
|
||||
'get_prefers_theme': get_prefers_theme,
|
||||
'get_motds': MOTD.get_all,
|
||||
}
|
||||
|
||||
@app.template_filter("ts_datetime")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% from 'common/icons.html' import icn_image, icn_spoiler, icn_info, icn_lock, icn_warn, icn_error, icn_bookmark %}
|
||||
{% from 'common/icons.html' import icn_image, icn_spoiler, icn_info, icn_lock, icn_warn, icn_error, icn_bookmark, icn_megaphone %}
|
||||
{% macro pager(current_page, page_count) %}
|
||||
{% set left_start = [1, current_page - 5] | max %}
|
||||
{% set right_end = [page_count, current_page + 5] | min %}
|
||||
@@ -61,6 +61,19 @@
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro motd(motd_obj) %}
|
||||
<div class="motd">
|
||||
<div class="motd-icon-container contain-svg">
|
||||
{{ icn_megaphone(80) }}
|
||||
<i><abbr title="Message of the Day">MOTD</abbr></i>
|
||||
</div>
|
||||
<div class="motd-content-container">
|
||||
<div class="motd-title">{{ motd_obj.title }}</div>
|
||||
<div class="motd-body">{{ motd_obj.body_rendered | safe}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro timestamp(unix_ts) -%}
|
||||
<span class="timestamp" data-utc="{{ unix_ts }}">{{ unix_ts | ts_datetime('%Y-%m-%d %H:%M')}} <abbr title="Server Time">ST</abbr></span>
|
||||
{%- endmacro %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% from 'common/macros.html' import pager, timestamp %}
|
||||
{% from 'common/macros.html' import pager, timestamp, motd %}
|
||||
{% from 'common/icons.html' import icn_lock, icn_sticky %}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}browsing topic {{ topic['name'] }}{% endblock %}
|
||||
@@ -27,6 +27,14 @@
|
||||
{{ infobox("This topic is locked.;Only moderators can create new threads.", InfoboxKind.INFO) }}
|
||||
{% endif %}
|
||||
|
||||
{%- with motds = get_motds() -%}
|
||||
{%- if motds -%}
|
||||
{%- for motd_obj in motds -%}
|
||||
{{- motd(motd_obj) -}}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endwith -%}
|
||||
|
||||
{% if threads_list | length == 0 %}
|
||||
<p>There are no threads in this topic.</p>
|
||||
{% else %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% from 'common/icons.html' import icn_lock %}
|
||||
{% from 'common/macros.html' import timestamp %}
|
||||
{% from 'common/macros.html' import timestamp, motd %}
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<nav class="darkbg">
|
||||
@@ -9,6 +9,13 @@
|
||||
<a class="linkbutton" href={{ url_for("mod.sort_topics") }}>Sort topics</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{%- with motds = get_motds() -%}
|
||||
{%- if motds -%}
|
||||
{%- for motd_obj in motds -%}
|
||||
{{- motd(motd_obj) -}}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endwith -%}
|
||||
{% if topic_list | length == 0 %}
|
||||
<p>There are no topics.</p>
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user