Remove some forum topic related features (#527)

This commit is contained in:
rubenwardy
2024-04-03 18:30:08 +01:00
committed by GitHub
parent bb81e1387a
commit 6280cd5947
12 changed files with 20 additions and 230 deletions

View File

@@ -1,4 +1,4 @@
{% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user, class_=None) -%}
{% macro render_topics_table(topics, show_author=True, current_user=current_user, class_=None) -%}
<table class="table {{ class_ }}">
<tr>
<th></th>
@@ -9,7 +9,7 @@
<th>{{ _("Actions") }}</th>
</tr>
{% for topic in topics %}
<tr class="{% if topic.wip %}wiptopic{% endif %} {% if topic.discarded %}discardtopic{% endif %}">
<tr class="{% if topic.wip %}wiptopic{% endif %}">
<td>
[{{ topic.type.text }}]
</td>
@@ -29,15 +29,6 @@
{{ _("Create") }}
</a>
{% endif %}
{% if show_discard and current_user.is_authenticated and topic.check_perm(current_user, "TOPIC_DISCARD") %}
<a class="btn btn-{% if topic.discarded %}success{% else %}danger{% endif %} topic-discard" data-tid={{ topic.topic_id }}>
{% if topic.discarded %}
{{ _("Show") }}
{% else %}
{{ _("Discard") }}
{% endif %}
</a>
{% endif %}
{% if topic.link %}
<a class="btn btn-info" href="{{ topic.link }}">{{ topic.link | domain | truncate(18) }}</a>
{% endif %}
@@ -48,24 +39,22 @@
{% endmacro %}
{% macro render_topics(topics, current_user, show_author=True) -%}
<ul>
{% macro render_topics(topics, current_user) -%}
<div class="list-group">
{% for topic in topics %}
<li{% if topic.wip %} class="wiptopic"{% endif %}>
<a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
{% if topic.wip %}[{{ _("WIP") }}]{% endif %}
{% if topic.discarded %}[{{ _("Old") }}]{% endif %}
{% if topic.name %}[{{ topic.name }}]{% endif %}
{% if show_author %}
by <a href="{{ url_for('users.profile', username=topic.author.username) }}">{{ topic.author.display_name }}</a>
{% endif %}
{% if topic.author == current_user or topic.author.check_perm(current_user, "CHANGE_AUTHOR") %}
|
<a href="{{ url_for('packages.create_edit', author=topic.author.username, repo=topic.get_repo_url(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">
{{ _("Create") }}
</a>
{% endif %}
</li>
<a class="list-group-item list-group-item-action" href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">
<span class="float-end text-muted">
{{ topic.created_at | date }}
</span>
{% set title %}
<strong>{{ topic.title }}</strong>
{% endset %}
{{ _("%(title)s by %(author)s", title=title, author=topic.author.display_name) }}
<span class="text-muted">
{% if topic.wip %}[{{ _("WIP") }}]{% endif %}
{% if topic.name %}[{{ topic.name }}]{% endif %}
</span>
</a>
{% endfor %}
</ul>
</div>
{% endmacro %}

View File

@@ -35,12 +35,6 @@
{{ _("Missing Screenshots") }}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if current_tab == 'topics' %}active{% endif %}"
href="{{ url_for('todo.topics') }}">
{{ _("Forum Topics") }}
</a>
</li>
</ul>
</div>
</nav>

View File

@@ -1,101 +0,0 @@
{% extends "todo/todo_base.html" %}
{% block title %}
Topics to be Added
{% endblock %}
{% block content %}
<div class="float-end">
<div class="btn-group btn-group-sm me-2">
<a class="btn btn-secondary {% if sort_by=='date' %}active{% endif %}"
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='date') }}">
{{ _("Sort by date") }}
</a>
<a class="btn btn-secondary {% if sort_by=='name' %}active{% endif %}"
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='name') }}">
{{ _("Sort by name") }}
</a>
<a class="btn btn-secondary {% if sort_by=='views' %}active{% endif %}"
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=n, sort='views') }}">
{{ _("Sort by views") }}
</a>
</div>
<div class="btn-group btn-group-sm">
{% if current_user.rank.at_least(current_user.rank.APPROVER) %}
{% if n >= 10000 %}
<a class="btn btn-secondary"
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
{{ _("Paginated list") }}
</a>
{% else %}
<a class="btn btn-secondary"
href="{{ url_for('todo.topics', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
{{ _("Unlimited list") }}
</a>
{% endif %}
{% endif %}
<a class="btn btn-secondary" href="{{ url_for('todo.topics', q=query, show_discarded=not show_discarded, n=n, sort=sort_by) }}">
{% if not show_discarded %}
{{ _("Show discarded topics") }}
{% else %}
{{ _("Hide discarded topics") }}
{% endif %}
</a>
</div>
</div>
<h1>{{ _("Topics to be Added") }}</h1>
{% if topic_count > 0 %}
<p>
{{ total - topic_count }} / {{ total }} topics have been added as packages to CDB.
{{ topic_count }} remaining.
</p>
<div class="progress">
{% set perc = 100 * (total - topic_count) / total %}
<div class="progress-bar bg-success" role="progressbar"
style="width: {{ perc }}%" aria-valuenow="{{ perc }}" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% else %}
<p>
The forum topic crawler needs to run at least once for this section to work.
</p>
{% endif %}
<form method="GET" action="{{ url_for('todo.topics') }}" class="my-4">
<input type="hidden" name="show_discarded" value={{ show_discarded and "True" or "False" }} />
<input type="hidden" name="n" value={{ n }} />
<input type="hidden" name="sort" value={{ sort_by or "date" }} />
<input name="q" type="text" placeholder="Search topics" value="{{ query or ''}}">
<input class="btn btn-secondary my-2 my-sm-0 me-sm-2" type="submit" value="Search" />
</form>
{% from "macros/topics.html" import render_topics_table %}
{{ render_topics_table(topics, show_discard=True, current_user=current_user) }}
<ul class="pagination mt-4">
<li class="page-item {% if not prev_url %}disabled{% endif %}">
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>&laquo;</a>
</li>
{% for i in range(1, page_max+1) %}
<li class="page-item {% if i == page %}active{% endif %}">
<a class="page-link"
href="{{ url_for('todo.topics', page=i, query=query, show_discarded=show_discarded, n=n, sort=sort_by) }}">
{{ i }}
</a>
</li>
{% endfor %}
<li class="page-item {% if not next_url %}disabled{% endif %}">
<a class="page-link" {% if next_url %}href="{{ next_url }}"{% endif %}>&raquo;</a>
</li>
</ul>
{% endblock %}
{% block scriptextra %}
<script>
const csrf_token = "{{ csrf_token() }}";
</script>
<script src="/static/js/topic_discard.js"></script>
{% endblock %}

View File

@@ -203,12 +203,11 @@
{% if topics_to_add %}
<p>
{{ _("List of your forum topics which do not have a matching package.") }}
{{ _("Topics with a strikethrough have been marked as discarded.") }}
</p>
<div style="max-height: 20em; overflow-y: auto">
{% from "macros/topics.html" import render_topics_table %}
{{ render_topics_table(topics_to_add, show_author=False, show_discard=True, current_user=current_user) }}
{{ render_topics_table(topics_to_add, show_author=False, current_user=current_user) }}
</div>
{% else %}
<p class="card-body">{{ _("Congrats! You don't have any topics which aren't on CDB.") }}</p>
@@ -220,5 +219,4 @@
<script>
const csrf_token = "{{ csrf_token() }}";
</script>
<script src="/static/js/topic_discard.js"></script>
{% endblock %}