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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
{% set canReply =
not ctx.topic.isLocked
and currentUser is not null
and currentUser.hasPermission(permission("CREATE_OWN_POST")) %}
{% set canEdit =
currentUser is not null and (
(
ctx.topicAuthor is not null
and currentUser.id == ctx.topicAuthor.id
and ctx.topicAuthor.hasPermission(permission("EDIT_OWN_TOPIC"))
)
or currentUser.hasPermission(permission("EDIT_OTHER_TOPIC"))
) %}
{% set canDelete =
currentUser is not null and (
(
ctx.topicAuthor is not null
and currentUser.id == ctx.topicAuthor.id
and ctx.topicAuthor.hasPermission(permission("DELETE_OWN_TOPIC"))
)
or currentUser.hasPermission(permission("DELETE_OTHER_TOPIC"))
) %}
{% set title = ctx.topic.title %}
{% extends "base.twig" %}
{% block content %}
{% if canEdit %}
<div class="modal fade" tabindex="-1" role="dialog" id="diag-edit-post">
<form class="modal-dialog" role="document" action="?_action=updatepost" method="post">
<input type="hidden" id="i_edit_post" name="post">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">{{ __("Edit post") }}</h4>
</div>
<div class="modal-body">
<label class="sr-only" for="i_edit_message">{{ __("Message:") }}</label>
<div class="panel panel-default">
<div class="panel-heading" style="padding:4px">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group">
<button data-area="#i_edit_message" title="{{ __("Bold") }}" data-editor-command="bold" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-bold"></i></button>
<button data-area="#i_edit_message" title="{{ __("Italic") }}" data-editor-command="italic" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-italic"></i></button>
<button data-area="#i_edit_message" title="{{ __("Underlined") }}" data-editor-command="underline" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-underline"></i></button>
<button data-area="#i_edit_message" title="{{ __("Strikethrough") }}" data-editor-command="strikethrough" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-strikethrough"></i></button>
</div>
<div class="btn-group" role="group">
<button data-area="#i_edit_message" title="{{ __("Superscript") }}" data-editor-command="sup" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-superscript"></i></button>
<button data-area="#i_edit_message" title="{{ __("Subscript") }}" data-editor-command="sub" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-subscript"></i></button>
</div>
<div class="btn-group" role="group">
<button data-area="#i_edit_message" title="{{ __("Quote") }}" data-editor-command="quote" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-quote-left"></i></button>
<button data-area="#i_edit_message" title="{{ __("Spoiler") }}" data-editor-command="spoiler" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-eye"></i></button>
</div>
</div>
</div>
<div class="panel-body" style="padding:0">
<textarea class="form-control" id="i_edit_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:500px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;margin:-1px;width:calc(100% + 2px)"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-remove" aria-hidden="true"></span> {{ __("Cancel") }}</button>
<button type="submit" class="btn btn-success"><span class="fa fa-save" aria-hidden="true"></span> {{ __("Save changes") }}</button>
</div>
</div>
</form>
</div>
{% endif %}
{% if currentUser is null %}
<div class="modal fade" tabindex="-1" role="dialog" id="diag-cant-view-attachment">
<div class="modal-dialog modal-danger" role="document">
<div class="modal-content panel-danger">
<div class="modal-header panel-heading">
<h4 class="modal-title"><span class="fa fa-exclamation-circle" aria-hidden="true"></span> {{ __("Permission denied") }}</h4>
</div>
<div class="modal-body">
{{ __("You must be logged in to view attachments") }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-close" aria-hidden="true"></span> {{ __("Close") }}</button>
<a href="?_action=auth&next={{ g.server.REQUEST_URI|url_encode }}" class="btn btn-success"><span class="fa fa-user" aria-hidden="true"></span> {{ __("Log in") }}</a>
</div>
</div>
</div>
</div>
<script>
$(function() {
$(".attachment").click(function(e) {
e.preventDefault();
$("#diag-cant-view-attachment").modal();
});
});
</script>
{% else %}
<div class="modal fade" tabindex="-1" role="dialog" id="diag-image-attachment">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">{{ __("Attachment") }}</h4>
</div>
<div class="modal-body">
<img class="image-attachment-view attachment-view" id="image-attachment-view" alt="">
</div>
<div class="modal-footer">
<a href="" download id="image-attachment-dl-btn" class="btn btn-default"><span class="fa fa-download" aria-hidden="true"></span> {{ __("Download") }}</a>
</div>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" role="dialog" id="diag-video-attachment">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">{{ __("Attachment") }}</h4>
</div>
<div class="modal-body">
<video class="video-attachment-view attachment-view" id="video-attachment-view" controls></video>
</div>
<div class="modal-footer">
<a href="" download id="video-attachment-dl-btn" class="btn btn-default"><span class="fa fa-download" aria-hidden="true"></span> {{ __("Download") }}</a>
</div>
</div>
</div>
</div>
<script>
$(function() {
$(".image-attachment:not(.video-attachment)").click(function(e) {
e.preventDefault();
var attUrl = "?_action=attachment&attachment=" + encodeURIComponent($(this).attr("data-attachment-id"));
$("#image-attachment-view").attr("src", attUrl);
$("#image-attachment-dl-btn").attr("href", attUrl);
$("#diag-image-attachment").modal();
});
$(".image-attachment.video-attachment").click(function(e) {
e.preventDefault();
var attUrl = "?_action=attachment&attachment=" + encodeURIComponent($(this).attr("data-attachment-id"));
$("#video-attachment-view").attr("src", attUrl);
$("#video-attachment-dl-btn").attr("href", attUrl);
$("#diag-video-attachment").modal();
});
$("#diag-video-attachment").on("hide.bs.modal", function() {
$("#video-attachment-view")[0].pause();
});
});
</script>
{% endif %}
{% set formError = getAndClearFormError("updateTopic") %}
{% if formError %}
{% include "components/alert_error.twig" with { message: formError } %}
{% endif %}
{% set formError = getAndClearFormError("lockTopic") %}
{% if formError %}
{% include "components/alert_error.twig" with { message: formError } %}
{% endif %}
{% set formError = null %}
<div class="page-header margin-top-0 clearfix">
<div id="displayHeading">
<div role="heading" class="h1 seamless-inline">
{% if ctx.topic.isLocked %}
<span class="fa fa-lock text-muted" aria-hidden="true"></span>
{% endif %}
{{ ctx.topic.title }}
<div class="pull-right text-normal">
{% if canEdit and not ctx.topic.isLocked %}
<button id="btn-edit-title" class="btn btn-default js-only"><span class="fa fa-pencil" aria-hidden="true"></span> {{ __("Edit title") }}</button>
{% endif %}
{% if canReply %}
<button id="btn-reply" class="btn btn-default js-only"><span class="fa fa-comment" aria-hidden="true"></span> {{ __("Reply") }}</button>
{% endif %}
{% if canEdit %}
{% if ctx.topic.isLocked %}
<form action="?_action=locktopic" method="post" class="seamless-inline">
<input type="hidden" name="topic" value="{{ ctx.topic.id }}">
<input type="hidden" name="locked" value="false">
<button type="submit" class="btn btn-success"><span class="fa fa-unlock" aria-hidden="true"></span> {{ __("Unlock topic") }}</button>
</form>
{% else %}
<form action="?_action=locktopic" method="post" class="seamless-inline">
<input type="hidden" name="topic" value="{{ ctx.topic.id }}">
<input type="hidden" name="locked" value="true">
<button type="submit" class="btn btn-warning"><span class="fa fa-lock" aria-hidden="true"></span> {{ __("Lock topic") }}</button>
</form>
{% endif %}
{% endif %}
{% if canDelete %}
<form action="?_action=deletetopic" method="post" class="seamless-inline">
<input type="hidden" name="topic" value="{{ ctx.topic.id }}">
<button type="submit" class="btn btn-danger"><span class="fa fa-trash" aria-hidden="true"></span> {{ __("Delete topic") }}</button>
</form>
{% endif %}
</div>
</div><br>
{{ __("Started by %user% on %date%", {
"user": (ctx.topicAuthor is not null) ? ('<a href="?_action=viewuser&user=' ~ ctx.topicAuthor.id|url_encode|e("html") ~ '">' ~ ctx.topicAuthor.displayName|e("html") ~ '</a>') : __("(deleted)"),
"date": '<span class="_time">' ~ ctx.topic.creationDate.format("c")|e("html") ~ '</span>',
}) }}
</div>
{% if canEdit %}
<form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline">
<input type="hidden" name="topic" value="{{ ctx.topic.id }}">
<div class="row">
<div class="col-md-8">
<input type="text" class="form-control" name="title" id="i_edit_title" data-original-value="{{ ctx.topic.title }}" value="{{ ctx.topic.title }}" style="box-sizing: border-box; width: 100%; font-size: 36px; height: 56px">
</div>
<div class="col-md-4 text-right">
<button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="fa fa-close" aria-hidden="true"></span> {{ __("Cancel") }}</button>
<button type="submit" class="btn btn-success"><span class="fa fa-save" aria-hidden="true"></span> {{ __("Save changes") }}</button>
</div>
</div>
</form>
{% endif %}
</div>
<script>
{% if canEdit %}
$(function() {
$("#btn-edit-title").click(function() {
$("#displayHeading").hide();
$("#editHeading").show();
$("#i_edit_title").val($("#i_edit_title").attr("data-original-value")).focus();
});
$("#topicTitleEditCancel").click(function() {
$("#displayHeading").show();
$("#editHeading").hide();
});
$("._edit-post").click(function() {
var $post = $("#post-" + $(this).attr("data-post-id"));
var $postContent = $post.find(".post-content");
$("#i_edit_message").css("height", "").val($post.attr("data-text"));
$("#i_edit_post").val($(this).attr("data-post-id"));
$("#diag-edit-post").modal();
});
$("#diag-edit-post").on("shown.bs.modal", function() {
$("#i_edit_message").focus();
});
});
{% endif %}
{% if canReply %}
$(function() {
function focusReplyBox() {
var msgInput = $("#i_message");
msgInput[0].scrollIntoView();
msgInput.focus();
}
$("#btn-reply").click(function() {
focusReplyBox();
});
$("._reply-post").click(function() {
var text = $("#post-" + $(this).attr("data-post-id")).attr("data-text");
var val = $("#i_message").val();
var lines = text.split("\n");
for (var i = 0; i < lines.length; ++i)
val += "\n> " + lines[i];
val += "\n\n";
$("#i_message").val(val.replace(/^\n+/, ""));
focusReplyBox();
});
});
{% endif %}
</script>
{% for item in ctx.allItems %}
{% if item.type == "post" %}
{% include "components/post.twig" with {
post: item.post,
postAuthor: item.postAuthor,
topic: item.topic,
attachments: item.attachments,
hide_actions: false,
hide_pfp: false,
} %}
{% elseif item.type == "logMessage" %}
{% include "components/topic_log.twig" with {
type: item.type,
logMessage: item.logMessage,
postAuthor: item.postAuthor,
topicAuthor: item.topicAuthor,
topic: item.topic,
hide_actions: false,
hide_pfp: false,
} %}
{% endif %}
{% endfor %}
{% if ctx.topic.isLocked %}
<div class="well icon-well text-warning margin-top-4x">
<span class="fa fa-lock text-warning" aria-hidden="true"></span>
<em>{{ __("This topic has been locked") }}</em>
</div>
{% elseif currentUser is not null %}
{% set formId = "addpost" %}
<h3 id="form">{{ __("Reply to this topic") }}</h3>
{% set formError = getAndClearFormError(formId) %}
{% if formError %}
{% include "components/alert_error.twig" with { message: formError } %}
{% endif %}
<form action="{{ g.server.REQUEST_URI }}#form" method="post" enctype="multipart/form-data">
<input type="hidden" name="form_id" value="{{ formId }}">
<div class="form-group">
<label for="i_message">{{ __("Message:") }}</label>
<div class="panel panel-default">
<div class="panel-heading" style="padding:4px">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group">
<button data-area="#i_message" title="{{ __("Bold") }}" data-editor-command="bold" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-bold"></i></button>
<button data-area="#i_message" title="{{ __("Italic") }}" data-editor-command="italic" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-italic"></i></button>
<button data-area="#i_message" title="{{ __("Underlined") }}" data-editor-command="underline" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-underline"></i></button>
<button data-area="#i_message" title="{{ __("Strikethrough") }}" data-editor-command="strikethrough" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-strikethrough"></i></button>
</div>
<div class="btn-group" role="group">
<button data-area="#i_message" title="{{ __("Superscript") }}" data-editor-command="sup" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-superscript"></i></button>
<button data-area="#i_message" title="{{ __("Subscript") }}" data-editor-command="sub" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-subscript"></i></button>
</div>
<div class="btn-group" role="group">
<button data-area="#i_message" title="{{ __("Quote") }}" data-editor-command="quote" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-quote-left"></i></button>
<button data-area="#i_message" title="{{ __("Spoiler") }}" data-editor-command="spoiler" type="button" class="btn btn-default btn-xs"><i class="fa fa-fw fa-eye"></i></button>
</div>
</div>
</div>
<div class="panel-body" style="padding:0">
<textarea class="form-control" id="i_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:499px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;margin:-1px;width:calc(100% + 2px)"></textarea>
</div>
</div>
</div>
<div class="form-group">
<label for="i_files">{{ __("Attachments: <small>(max. %max_attachment_count% files, max. %max_attachment_size% MiB each)</small>", {
"max_attachment_count": constant("MAX_ATTACHMENT_COUNT"),
"max_attachment_size": constant("MAX_ATTACHMENT_SIZE") // (2**20),
}) }}</label>
<input type="file" name="files[]" id="i_files" multiple accept="*/*">
</div>
<button type="submit" class="btn btn-success">{{ __("Post reply") }} <span class="fa fa-send" aria-hidden="true"></span></button>
</form>
{% else %}
<div class="well margin-top-4x text-center">
<div class="h3 margin-top-0">{{ __("Log in to reply to this topic") }}</div>
<a href="?_action=auth&next={{ g.server.REQUEST_URI|url_encode }}" class="btn btn-success">
<span class="fa fa-user" aria-hidden="true"></span>
{{ __("Log in") }}
</a>
</div>
{% endif %}
{% endblock %}
|