aboutsummaryrefslogtreecommitdiff
path: root/app/templates/macros/topics.html
blob: c4fe32d2eef8f1c75d719c4a970fa6fbc2a160bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user) -%}
<table class="table">
	<tr>
		<th></th>
		<th>Title</th>
		{% if show_author %}<th>Author</th>{% endif %}
		<th>Name</th>
		<th>Date</th>
		<th>Actions</th>
	</tr>
	{% for topic in topics %}
		<tr class="{% if topic.wip %}wiptopic{% endif %}{% if topic.discarded %}discardtopic{% endif %}">
			<td>
				[{{ topic.type.value }}]
			</td>
			<td>
				<a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
				{% if topic.wip %}[WIP]{% endif %}
			</td>
			{% if show_author %}
				<td><a href="{{ url_for('users.profile', username=topic.author.username) }}">{{ topic.author.display_name}}</a></td>
			{% endif %}
			<td>{{ topic.name or ""}}</td>
			<td>{{ topic.created_at | date }}</td>
			<td class="btn-group">
				{% if current_user == topic.author or topic.author.checkPerm(current_user, "CHANGE_AUTHOR") %}
					<a class="btn btn-primary"
							href="{{ url_for('packages.create_edit', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">
						Create
					</a>
				{% endif %}
				{% if show_discard and current_user.is_authenticated and topic.checkPerm(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 %}
			</td>
		</tr>
	{% endfor %}
</table>
{% endmacro %}


{% macro render_topics(topics, current_user, show_author=True) -%}
<ul>
	{% 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.checkPerm(current_user, "CHANGE_AUTHOR") %}
				| <a href="{{ url_for('packages.create_edit', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">Create</a>
			{% endif %}
		</li>
	{% endfor %}
</ul>
{% endmacro %}