aboutsummaryrefslogtreecommitdiffhomepage
path: root/apioforum/templates/view_forum.html
blob: 4cc5f5dba9dae6487f8ec6d0f3c238d227ea4fc7 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{% extends 'base.html' %}
{% from 'common.html' import ts, tag, disp_user, post_url, forum_breadcrumb, ab, vote_meter, pagination_nav %}
{% block header %}
<h1>{% block title %}{{forum.name}}{% endblock %} <span class="thing-id">#{{forum.id}}</span></h1>
{% if forum.id != 1 %}
	{{ forum_breadcrumb(forum) }}
{% endif %}
{%endblock%}

{%block content%}
{{forum.description|md|safe}} 

<hr/>
<div class="forum-info">
	{% if bureaucrats|length > 0 %}
		<p>
			bureaucrats in this forum:
			{% for b in bureaucrats %}
				{{disp_user(b)}}
			{% endfor %}
		</p>
	{% endif %}

	{% set role = get_user_role(forum.id, g.user) %}
	{% if role != "other" %}
	<p>your role in this forum: {{role}}</p>
	{% endif %}

</div>

<p>
	{% if is_bureaucrat(forum.id, g.user) %}
		{{ab("forum settings",url_for('forum.edit_forum',forum_id=forum.id))}}
		{{ab("role/permission settings",url_for('forum.edit_roles',forum_id=forum.id))}}
		{{ab("assign roles",url_for('forum.view_user_role',forum_id=forum.id))}}
	{% endif %}
	{% if has_permission(forum.id, g.user, "p_create_subforum") %}
		{{ab("create subforum",url_for('forum.create_forum',forum_id=forum.id))}}
	{% endif %}
	{% if not is_bureaucrat(forum.id, g.user) and has_permission(forum.id, g.user, "p_approve") %}
		{{ab("approve users",url_for('forum.view_user_role',forum_id=forum.id))}}
	{% endif %}
</p>

{% if subforums %}
<h2>subforæ</h2>
<div class="forum-list">
	{% for subforum in subforums %}
		<div class="listing">
			<div class="listing-main">
				<div class="listing-title">
					<a href="{{url_for('forum.view_forum',forum_id=subforum.id)}}">
						{{- subforum.name -}}
					</a>
				</div>
			</div>
			<div class="listing-caption">
				{% if subforum.updated %}
					last activity {{ts(subforum.updated)}} ago
				{% else %}
					no threads
				{% endif %}
			</div>
		</div>
	{% endfor %}
</div>
{% endif %}

<h2>threads</h2>
<p>
{% if has_permission(forum.id, g.user, "p_create_threads") %}
<a class="actionbutton" href="{{url_for('forum.create_thread',forum_id=forum.id)}}">create new thread</a>
{% elif has_permission(forum.id, g.user, "p_create_threads", login_required=False) %}
please log in to create a new thread
{% else %}
you do not have permission to create threads in this forum
{% endif %}

{% macro sortby_option(code, text) %}
{% if current_sortby==code %}
<option selected value="{{code}}">{{text}}</option>
{% else %}
<option value="{{code}}">{{text}}</option>
{% endif %}
{% endmacro %}


<details
{%- if current_sortby != "ad" or tagfilter_tag is not none %}
 open
{%- endif -%}>
	<summary>sorting and filtering options</summary>
	
<form class="inline-form small-form" method="get">
	<fieldset>
	<label for="sortby">sort threads by</label>
	<select name="sortby">
		{{ sortby_option("ad", "last activity (newest first)") }}
		{{ sortby_option("aa", "last activity (oldest first)") }}
		{{ sortby_option("cd", "creation time (newest first)") }}
		{{ sortby_option("ca", "creation time (oldest first)") }}
	</select>
	<p>filter by tag:</p>
	<input {% if tagfilter_tag is none %}checked{% endif %} type=radio id=tagfilter-none name=tagfilter value="">
	<label for=tagfilter-none>don't</label>

	{% for the_tag in avail_tags %}
	<br>
	<input type="radio" id="tagfilter-{{the_tag.id}}"
	       name="tagfilter" value="{{the_tag.id}}"
	       {% if tagfilter_tag.id == the_tag.id %}checked{% endif %}>
	<label for="tagfilter-{{the_tag.id}}">
		{{tag(the_tag)}}
	</label>
	{% endfor %}
	<br><br>


	<input type="submit" value="apply">
	</fieldset>
</form>

</details>
</p>

{{ pagination_nav(page,max_pageno,'forum.view_forum',forum_id=forum.id) }}
<div class="thread-list">
	{%for thread in threads%}
		<div class="listing">
			<div class="listing-main">
				<div class="listing-title">
					<a href="{{url_for('thread.view_thread',thread_id=thread.id)}}">
						{{- thread.title -}}
					</a>
				</div>
				<div class="thread-listing-tags">
					{% for the_tag in thread_tags[thread.id] %}
						{{tag(the_tag)}}
					{% endfor %}
				</div>
				<div class="thread-listing-creation">
					<div class="thread-listing-creator">
						{{ disp_user(thread.creator) }} 
					</div>
					{{ ts(thread.created) }}
				</div>
			</div>
			{% if not thread.mrp_deleted %}
				<div class="listing-caption">
					{{ disp_user(thread.mrp_author) }}
					<span class="thread-preview-ts">
						{{ ts(thread.mrp_created) }}
					</span>
					<span class="thread-preview-post">
						<a href="{{post_jump(thread.mrp_id)}}">
							{{ thread.mrp_content[:500]|e }}
						</a>
					</span>
				</div>
			{% else %}
				<div class="listing-caption">
					<a class="thread-preview-post" 
					   href="{{post_jump(thread.mrp_id)}}">
						latest post
					</a>
				</div>
			{% endif %}
			{% if thread_polls[thread.id] %}
				<div class="thread-vote-summary">
					{{ vote_meter(thread_polls[thread.id]) }}
				</div>
			{% endif %}
		</div>
	{%endfor%}
</div>

	
{%endblock%}