aboutsummaryrefslogtreecommitdiff
path: root/app/templates/macros/threads.html
blob: 16b67a0494845f2adb83c94f060e519c1389eed2 (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
{% macro render_thread(thread, current_user) -%}

<ul class="comments mt-4 mb-0">
	{% for r in thread.replies %}
	<li class="row my-2 mx-0">
		<div class="col-md-1 p-1">
			<a href="{{ url_for('users.profile', username=r.author.username) }}">
				<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
			</a>
		</div>
		<div class="col">
			<div class="card">
				<div class="card-header">
					<a class="author {{ r.author.rank.name }}"
							href="{{ url_for('users.profile', username=r.author.username) }}">
						{{ r.author.display_name }}
					</a>
					<a name="reply-{{ r.id }}" class="text-muted float-right"
							href="{{ url_for('threads.view', id=thread.id) }}#reply-{{ r.id }}">
						{{ r.created_at | datetime }}
					</a>
				</div>

				<div class="card-body">
					{{ r.comment | markdown }}
				</div>
			</div>
		</div>
	</li>
	{% endfor %}
</ul>

{% if current_user.is_authenticated %}
<div class="row mt-0 mb-4 comments mx-0">
	<div class="col-md-1 p-1">
		<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ current_user.getProfilePicURL() }}">
	</div>
	<div class="col">
		<div class="card">
			<div class="card-header {{ current_user.rank.name }}">
				{{ current_user.display_name }}
				<a name="reply"></a>
			</div>

			{% if current_user.canCommentRL() %}
				<form method="post" action="{{ url_for('threads.view', id=thread.id)}}" class="card-body">
					<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
					<textarea class="form-control markdown" required maxlength=500 name="comment"></textarea><br />
					<input class="btn btn-primary" type="submit" value="Comment" />
				</form>
			{% else %}
				<div class="card-body">
					<textarea class="form-control" readonly disabled>Please wait before commenting again.</textarea><br />
					<input class="btn btn-primary" type="submit" disabled value="Comment" />
				</div>
			{% endif %}
		</div>
	</div>
</div>
{% endif %}
{% endmacro %}

{% macro render_threadlist(threads, list_group=False) -%}
	{% if not list_group %}<ul>{% endif %}
		{% for t in threads %}
			<li {% if list_group %}class="list-group-item"{% endif %}>
				{% if list_group %}
					<a href="{{ url_for('threads.view', id=t.id) }}">
						{% if t.private %}&#x1f512; {% endif %}
						{{ t.title }}
						by {{ t.author.display_name }}
					</a>
				{% else %}
					{% if t.private %}&#x1f512; {% endif %}
					<a href="{{ url_for('threads.view', id=t.id) }}">{{ t.title }}</a>
					by {{ t.author.display_name }}
				{% endif %}
			</li>
		{% else %}
			<li {% if list_group %}class="list-group-item"{% endif %}><i>No threads found</i></li>
		{% endfor %}
	{% if not list_group %}</ul>{% endif %}
{% endmacro %}