sub-topics - public-facing UI #44

This commit is contained in:
rimu 2024-03-06 21:37:07 +13:00
parent 2271b815e9
commit b7f187e706
3 changed files with 12 additions and 2 deletions

View file

@ -147,7 +147,7 @@ def home_page(type, sort):
@bp.route('/topics', methods=['GET'])
def list_topics():
verification_warning()
topics = Topic.query.order_by(Topic.name).all()
topics = Topic.query.filter_by(parent_id=None).order_by(Topic.name).all()
return render_template('list_topics.html', topics=topics, title=_('Browse by topic'),
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1',

View file

@ -17,7 +17,14 @@
</nav>
<h1 class="mt-2">{{ topic.name }}
</h1>
{% if sub_topics %}
<h3 class="mb-0" id="sub-topics">{{ _('Sub-topics') }}</h3>
<ul class="nav" role="listbox" aria-labelledby="sub-topics">
{% for topic in sub_topics %}
<li class="nav-item" role="option"><a class="nav-link" href="/topic/{{ topic.machine_name }}">{{ topic.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% include "community/_community_nav.html" %}
{% if post_layout == 'masonry' or post_layout == 'masonry_wide' %}
<div class="post_list_{{ post_layout }}">

View file

@ -77,9 +77,12 @@ def show_topic(topic_name):
topic_name=topic_name,
page=posts.prev_num, sort=sort, layout=post_layout) if posts.has_prev and page != 1 else None
sub_topics = Topic.query.filter_by(parent_id=topic.id).order_by(Topic.name).all()
return render_template('topic/show_topic.html', title=_(topic.name), posts=posts, topic=topic, sort=sort,
page=page, post_layout=post_layout, next_url=next_url, prev_url=prev_url,
topic_communities=topic_communities, content_filters=content_filters,
sub_topics=sub_topics,
rss_feed=f"https://{current_app.config['SERVER_NAME']}/topic/{topic_name}.rss",
rss_feed_name=f"{topic.name} on {g.site.name}",
show_post_community=True, moderating_communities=moderating_communities(current_user.get_id()),