]> git.lizzy.rs Git - cheatdb.git/blob - app/templates/macros/topics.html
Add links to topic lists in user dropdown
[cheatdb.git] / app / templates / macros / topics.html
1 {% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user) -%}
2 <table class="table">
3         <tr>
4                 <th></th>
5                 <th>Title</th>
6                 {% if show_author %}<th>Author</th>{% endif %}
7                 <th>Name</th>
8                 <th>Date</th>
9                 <th>Actions</th>
10         </tr>
11         {% for topic in topics %}
12                 <tr class="{% if topic.wip %}wiptopic{% endif %}{% if topic.discarded %}discardtopic{% endif %}">
13                         <td>
14                                 [{{ topic.type.value }}]
15                         </td>
16                         <td>
17                                 <a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
18                                 {% if topic.wip %}[WIP]{% endif %}
19                         </td>
20                         {% if show_author %}
21                                 <td><a href="{{ url_for('user_profile_page', username=topic.author.username) }}">{{ topic.author.display_name}}</a></td>
22                         {% endif %}
23                         <td>{{ topic.name or ""}}</td>
24                         <td>{{ topic.created_at | date }}</td>
25                         <td class="btn-group">
26                                 <a class="btn btn-primary"
27                                         href="{{ url_for('create_edit_package_page', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">
28                                         Create
29                                 </a>
30                                 {% if show_discard and current_user.is_authenticated and topic.checkPerm(current_user, "TOPIC_DISCARD") %}
31                                         <a class="btn btn-{% if topic.discarded %}success{% else %}danger{% endif %} topic-discard" data-tid={{ topic.topic_id }}>
32                                                 {% if topic.discarded %}
33                                                         Show
34                                                 {% else %}
35                                                         Discard
36                                                 {% endif %}
37                                         </a>
38                                 {% endif %}
39                                 {% if topic.link %}
40                                         <a class="btn btn-info" href="{{ topic.link }}">{{ topic.link | domain | truncate(18) }}</a>
41                                 {% endif %}
42                         </td>
43                 </tr>
44         {% endfor %}
45 </table>
46 {% endmacro %}
47
48
49 {% macro render_topics(topics, current_user, show_author=True) -%}
50 <ul>
51         {% for topic in topics %}
52                 <li{% if topic.wip %} class="wiptopic"{% endif %}>
53                         <a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
54                         {% if topic.wip %}[WIP]{% endif %}
55                         {% if topic.name %}[{{ topic.name }}]{% endif %}
56                         {% if show_author %}
57                                 by <a href="{{ url_for('user_profile_page', username=topic.author.username) }}">{{ topic.author.display_name }}</a>
58                         {% endif %}
59                         {% if topic.author == current_user or topic.author.checkPerm(current_user, "CHANGE_AUTHOR") %}
60                                 | <a href="{{ url_for('create_edit_package_page', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">Create</a>
61                         {% endif %}
62                 </li>
63         {% endfor %}
64 </ul>
65 {% endmacro %}