/
macro.vm
executable file
·971 lines (939 loc) · 39.9 KB
/
macro.vm
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
#######################################################
## ##
## COMMONLY USED MACROS ##
## ##
################# COMMENTS MACROS #####################
#macro(newcommentform $parentid $hidden $uri)
#if ($hidden) #set($hide = "hide") #else #set($hide = "") #end
<div class="newcommentform mvm ${hide}">
<form method="post" action="$commentlink" class="new-comment-form">
##sectoken(false "ADD_COMMENT_$!parentid") ## BREAKS AJAX - NOT USED
<div class="row">
<div class="col s10">
<div class="input-field">
#set($maxplus1 = $!maxCommentLength + 1)
<label for="new-comment-$!{parentid}">$!lang.get('comment.title')</label>
<input id="new-comment-$!{parentid}" type="text" name="comment" value=""
data-length="$!maxCommentLength" maxlength="$!maxplus1" class="validate charcounter" required>
<span class="helper-text" data-error="$!maxCommentLengthError"></span>
</div>
<input type="hidden" name="parentid" value="$!parentid">
</div>
<div class="col s2 center">
<button type="submit" class="btn waves-effect waves-light new-comment-btn">$!lang.get('add')</button>
</div>
</div>
</form>
</div>
#end
###########################################
#macro(commentbox $showcomment)
#if ($showcomment == "") #set($hide = "hide") #else #set($hide = "") #end
<div class="commentbox pll smallText ${hide}">
#if ($showcomment.hidden)
#set($hidden = "hide")
<span>$!lang.get("comments.hidden") </span>
<a href="#" title="$!lang.get('comments.show')" class="show-comment">$!lang.get("comments.show")</a>
#else
#set($hidden = "noclass")
#end
<div class="mbs ${hidden}">
#votebox($showcomment "left mrm pbs")
#set($_commentHtml = $utils.markdownToHtml($!showcomment.comment))
<span class="comment-text">$!{_commentHtml}</span>
#set($commentAuthor = {'name': $!showcomment.authorName, 'id': $showcomment.creatorid})
—
<span class="comment-author">#personlink($commentAuthor)</span>
<span class="comment-timestamp mrs grey-text"><i class="fa fa-clock-o"></i> #formatdate($showcomment.timestamp '')</span>
#if ($showcomment == "")
#getreportlink($showcomment "$commentlink/$!showcomment.id" "notext")
<a href="$commentlink/$!showcomment.id/delete" title="$!lang.get('delete')"
class="delete-comment red-text">$!lang.get('delete')</a>
#elseif ($authenticated && ($showcomment.creatorid == $authUser.id || $scooldUtils.isMod($authUser)))
<a href="$commentlink/$!showcomment.id/delete" title="$!lang.get('delete')"
class="delete-comment red-text">$!lang.get('delete')</a>
#else
#getreportlink($showcomment "$commentlink/$!showcomment.id" "noicon")
#end
</div>
</div>
#end
####################################
#macro(commentspage $comments)
#foreach($comment in $comments)
#commentbox($comment)
#end
#end
####################################
#macro(spacebox $space )
<div class="col s12 m6 l3 spacebox">
<div class="card-panel center-align">
<a href="$adminlink/remove-space?space=$!space.id:$space.name" class="red-text right tooltipped pts delete-space"
data-tooltip="$!lang.get('delete')"><i class="fa fa-times fa-lg"></i></a>
<p class="mediumText">
<a href="$questionslink/space/$!space.id" title="$!{spaceName}">$!space.name</a>
</p>
</div>
</div>
#end
####################################
#macro(spacespage $spaces )
#foreach($space in $spaces)
#spacebox($space)
#end
#end
####################################
#macro(webhookbox $webhook )
<div class="col s12 webhookbox">
<div class="card-panel">
<a href="$adminlink/delete-webhook?id=$!webhook.id" class="red-text right tooltipped pts delete-webhook"
data-tooltip="$!lang.get('delete')"><i class="fa fa-times fa-lg"></i></a>
<div class="mediumText">
#if($webhook.active)#set($showActiveWebhook = "")#else #set($showActiveWebhook = "hide")#end
#if(!$webhook.active)#set($showInactiveWebhook = "")#else #set($showInactiveWebhook = "hide")#end
<a href="$adminlink/toggle-webhook?id=$!webhook.id" class="tooltipped toggle-webhook ${showActiveWebhook}" data-tooltip="Deactivate"><i class="fa fa-circle green-text"></i></a>
<a href="$adminlink/toggle-webhook?id=$!webhook.id" class="tooltipped toggle-webhook ${showInactiveWebhook}" data-tooltip="Activate"><i class="fa fa-circle red-text"></i></a>
<span class="mrm">$!webhook.targetUrl</span>
#if($webhook.create)
<span class="chip"><tt>create</tt></span>
#end
#if($webhook.update)
<span class="chip"><tt>update</tt></span>
#end
#if($webhook.delete)
<span class="chip"><tt>delete</tt></span>
#end
#if($webhook.createAll)
<span class="chip"><tt>createAll</tt></span>
#end
#if($webhook.updateAll)
<span class="chip"><tt>updateAll</tt></span>
#end
#if($webhook.deleteAll)
<span class="chip"><tt>deleteAll</tt></span>
#end
#if($webhook.typeFilter)
<span class="chip"><tt><i class="fa fa-filter gray"></i> $!webhook.typeFilter</tt></span>
#end
#foreach($event in $webhook.customEvents)
<span class="chip"><tt>$!event</tt></span>
#end
#if(!$webhook.urlEncoded)
<span class="chip" title="application/json"><tt>{JSON}</tt></span>
#end
<span class="chip">
<a href="#" class="next-span-toggle click2hide"><i class="fa fa-key"></i></a>
<span class="hide"><i class="fa fa-key"></i> <tt>$!webhook.secret</tt></span>
</span>
#if($webhook.tooManyFailures)
<div class="red-text">
<i class="fa fa-exclamation-circle"></i> Webhook was disabled due to too many failed delivery attempts.
</div>
#end
</div>
</div>
</div>
#end
####################################
#macro(webhookspage $webhooks )
#foreach($webhook in $webhooks)
#webhookbox($webhook)
#end
#end
################# QUESTIONS MACROS #####################
#macro(tagsbox $tags $link)
#foreach($showtag in $tags)
#if ($showtag && $showtag.trim() != "")
#if (!$link || $link.isEmpty())
<span class="chip mrs">
<i class="fa fa-tag grey-text"></i> $!showtag
</span>
#else
<a href="$link/tag/$!utils.urlEncode($showtag)" title="Posts tagged $!showtag" class="chip mrs">
<i class="fa fa-tag grey-text"></i> $!showtag
</a>
#end
#end
#end
#end
################# PAGINATION #####################
#macro(paginate $macroCode $pager $_rpath $pageparam)
#if($pager && $pager.count > 0)
#set($pageCount = ($pager.count / $pager.limit))
#if($pager.count % $pager.limit > 0) #set($pageCount = $pageCount + 1) #end
#if($pageCount > $MAX_PAGES)#set($pageCount = $MAX_PAGES)#end
#if ($pager.page <= 1) #set($prev = 1) #else #set($prev = $pager.page - 1) #end
#if(!$_rpath || $_rpath.isEmpty())
#if($request.queryString)
#set($_rpath = "$!{request.requestURI}?$!{request.queryString}")
#else
#set($_rpath = "$!{request.requestURI}")
#end
#end
#set($rexp = "${pageparam}=(\d+|&)+")
#set($_rpath = $_rpath.replaceAll($rexp, ""))
#set($_rpath = $_rpath.replaceAll("(&|&|\?)$", ""))
<div class="page-content">#evaluate($scooldUtils.getMacroCode($macroCode))</div>
#if ($_rpath.contains("?"))#set($paramseparator = "&")#else #set($paramseparator = "?")#end
#if ($pager.count > $pager.limit && $macroCode && !$macroCode.trim().isEmpty())
<div class="pages center mtl">
#if($numericPaginationEnabled)
#set($maxPageLinks = 7)
#set($activeClass = "active light-blue")
#if ($pager.page >= $pageCount) #set($next = 1) #else #set($next = $pager.page + 1) #end
<ul class="pagination ptl">
<li><a href="${_rpath}${paramseparator}${pageparam}=$!prev"><i class="fa fa-chevron-left grey-text"></i></a></li>
#if($pager.page <= $maxPageLinks)
#set($startPage = 1)
#if($pageCount < $maxPageLinks)#set($endPage = $pageCount)#else#set($endPage = $maxPageLinks)#end
#foreach($page in [$startPage..$endPage])
#if($page == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=$!page">$!page</a></li>
#end
#if($pageCount > $maxPageLinks)
<i class="fa fa-ellipsis-h pvm phm"></i>
#if($pageCount == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=$pageCount">$pageCount</a></li>
#end
#elseif($pager.page > $maxPageLinks && $pager.page < ($pageCount - $maxPageLinks))
#set($startPage = $pager.page - ($maxPageLinks / 2))
#set($endPage = $pager.page + ($maxPageLinks / 2))
#if(1 == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=1">1</a></li>
<i class="fa fa-ellipsis-h pvm phm"></i>
#foreach($page in [$startPage..$endPage])
#if($page == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=$!page">$!page</a></li>
#end
<i class="fa fa-ellipsis-h pvm phm"></i>
#if($pageCount == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=$pageCount">$pageCount</a></li>
#else
#if(1 == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=1">1</a></li>
<i class="fa fa-ellipsis-h pvm phm"></i>
#set($startPage = $pageCount - $maxPageLinks)
#set($endPage = $pageCount)
#foreach($page in [$startPage..$endPage])
#if($page == $pager.page)#set($currPage = $activeClass)#else#set($currPage = "")#end
<li class="waves-effect ${currPage}"><a href="${_rpath}${paramseparator}${pageparam}=$!page">$!page</a></li>
#end
#end
<li><a href="${_rpath}${paramseparator}${pageparam}=$!next"><i class="fa fa-chevron-right grey-text"></i></a></li>
</ul>
#else
#set($next = $pager.page + 1)
<a href="${_rpath}${paramseparator}${pageparam}=$!next" class="more-link pagelink chip" title="Load more">$!lang.get("more")</a>
<span class="hide page-macro-code">$!macroCode</span>
<span class="$!{next}"></span>
#end
</div>
#end
#end
#end
####################################
#macro(smallpersonbox $showu)
#if($showu)#set($userboxid = "$!{showu.id}")#else#set($userboxid = "")#end
<div class="row mbn userbox user-${userboxid}">
<div class="col s4 m5 l3">
#if ($showu)
<a href="$profilelink/$!showu.creatorid/#stripstr($!showu.name)" title="$!showu.name">
<img src="#profilepic($!showu)" width="50" class="profile-pic responsive-img">
</a>
#else
<img src="$!imageslink/anon.svg" width="50" class="responsive-img" alt="Profile picture">
#end
</div>
<div class="col s8 m7 l9">
<div class="right prm">
#if($showu && $showu.id)
#set($contextboxid = $utils.generateSecurityToken(10, true))
<a class="dropdown-trigger grey-text" href="#" data-target="$contextboxid"><i class="fa fa-ellipsis-v"></i></a>
<ul id="${contextboxid}" class="dropdown-content">
<li>#getreportlink($showu "$profilelink/$!showu.id" "")</li>
</ul>
#end
</div>
<div class="userbox-body">
#if ($showu)
<a href="$profilelink/$!showu.creatorid/#stripstr($!showu.name)" class="smallText">$showu.name</a>
#else
<span class="grey-text">$!lang.get("profile.deleted")</span>
#end
#if ($showu)
<br>
<span class="chip">$!utils.abbreviateInt($!showu.votes, 0)</span>
#if($showu.badges && $showu.badgesMap && $showu.badgesMap.size() > 0)
$showu.badgesMap.size() <i class="fa fa-star yellow-text text-darken-3"></i>
#end
#if ($showu.groups == "admins")
<i class="fa fa-asterisk orange-text tooltipped" data-position="top" data-delay="0" data-tooltip="$!lang.get('admin')"></i>
#end
#if ($showu.groups == "mods")
<i class="fa fa-dot-circle-o orange-text tooltipped" data-position="top" data-delay="0" data-tooltip="$!lang.get('mod')"></i>
#end
#end
</div>
</div>
</div>
#end
####################################
#macro(tinypersonbox $showu)
<div>
#if ($showu)
<a href="$profilelink/$!showu.creatorid/#stripstr($!showu.name)" title="$!showu.name [$!showu.votes]">
<img src="#profilepic($!showu)" width="32" class="profile-pic responsive-img">
</a>
#else
<img src="$!imageslink/anon.svg" width="32" class="responsive-img" alt="Profile picture">
#end
</div>
#end
####################################
#macro(personlink $showu)
<span>
#if ($showu && $showu.groups && !$showu.groups.isEmpty())
#if($showu.badges && $showu.badgesMap && $showu.badgesMap.size() > 0)
$showu.badgesMap.size() <i class="fa fa-star yellow-text text-darken-3"></i>
#end
#if ($showu.groups == "admins")
<i class="fa fa-asterisk orange-text tooltipped" data-position="top" data-delay="0" data-tooltip="$!lang.get('admin')"></i>
#end
#if ($showu.groups == "mods")
<i class="fa fa-dot-circle-o orange-text tooltipped" data-position="top" data-delay="0" data-tooltip="$!lang.get('mod')"></i>
#end
#end
#if ($showu)
#if ($showu.name)#set($seopsuffix = "/#stripstr($!showu.name)" )#else#set($seopsuffix = "" )#end
<a href="$profilelink/$!{showu.id}$!{seosuffix}" title="Go to profile">$!showu.name</a>
#else
$!lang.get("profile.deleted")
#end
</span>
#end
####################################
#macro(peoplepage $people)
#foreach($showFriend in $people)
<div class="col s12 m6 l4">
<div class="card personbox">
<div class="row user-card">
<div class="col s3 m4" title="$!showFriend.name">
<a href="$profilelink/$!showFriend.creatorid/#stripstr($!showFriend.name)" title="$!showFriend.name">
<img src="#profilepic($showFriend)" class="profile-pic responsive-img pts pls">
</a>
</div>
<div class="col s9 m8">
#if(!$isAdmin)
<div class="right prm ptm">
#set($contextboxid = $utils.generateSecurityToken(10, true))
<a class="dropdown-trigger grey-text" href="#" data-target="$contextboxid"><i class="fa fa-ellipsis-v"></i></a>
<ul id="${contextboxid}" class="dropdown-content">
<li>#getreportlink($showFriend "$profilelink/$!showFriend.id" "")</li>
</ul>
</div>
#end
<div class="person-name pts">
#if($isAdmin && $request.getParameter("bulkedit"))
<span class="grey-text l">
<label for="$!showFriend.id">
<input type="checkbox" name="selectedUsers" value="$!showFriend.id" class="filled-in" id="$!showFriend.id">
<span>
<a href="$profilelink/${showFriend.creatorid}/#stripstr($!showFriend.name)">$!{showFriend.name}</a>
</span>
</label>
</span>
#else
<a href="$profilelink/${showFriend.creatorid}/#stripstr($!showFriend.name)">$!{showFriend.name}</a>
#end
</div>
#if($isAdmin && $request.getParameter("bulkedit"))
<div class="smallText">
<i class="fa fa-th-large grey-text"></i>
#if(!$showFriend.hasSpaces())$!lang.get('defaultspace')#end
#foreach($space in $showFriend.spaces)
#set($spaceString = $scooldUtils.getSpaceName($space))
${spaceString}#if($foreach.count < $showFriend.spaces.size()),#end
#set($spaceId = $scooldUtils.getSpaceId($space))
<input type="hidden" name="user-space-ids" value="$!{spaceId}">
#end
</div>
#end
<span class="chip mts" title="$!lang.get('reputation')">$utils.abbreviateInt($!showFriend.votes, 0)</span>
#if($showFriend.badges && $showFriend.badgesMap && $showFriend.badgesMap.size() > 0)
$showFriend.badgesMap.size() <i class="fa fa-star yellow-text text-darken-3"></i>
#end
#if ($showFriend.groups == "admins")
<i class="fa fa-asterisk orange-text mhs tooltipped" data-delay="0" data-tooltip="$!lang.get('admin')"></i>
#end
#if ($showFriend.groups == "mods")
<i class="fa fa-dot-circle-o orange-text mhs tooltipped" data-delay="0" data-tooltip="$!lang.get('mod')"></i>
#end
#if($showFriend.lastseen)
<div class="grey-text r prm tooltipped lastseen" data-position="top" data-tooltip="$!{lang.get('profile.about.lastseen')}">
<i class="fa fa-clock-o"></i> #formatdate($!{showFriend.lastseen} "")
</div>
#end
</div>
</div>
</div>
</div>
#end
#end
####################################
#macro(getreportlink $reportable $link $clazz)
#if ($reportable)
#set($_href = "$reportslink/form?parentid=$!reportable.id&type=$!reportable.type")
#if (!$link.isEmpty())
#set($encodedLink = $utils.urlEncode($link))
#set($_href = "${_href}&link=$encodedLink")
#end
#if ($clazz.contains("notext")) #set($_showtxt = "" ) #else #set($_showtxt = " $!lang.get('report')") #end
<a href="#main-modal" title="Report a problem" data-fetch="$!{_href}" class="modal-trigger $!{clazz}">
#if(!$clazz.contains("noicon"))<i class="fa fa-flag"></i>#end $!_showtxt
</a>
#end
#end
####################################
#macro(questionspage $posts )
#set($showSpaceLabel = $scooldUtils.isAllSpaces($currentSpace) || $isMod)
#foreach($showpost in $posts)
#set($actionlink = "#getpostlink($showpost false true)")
#set($actionlink2 = "#getpostlink($showpost true true)")
#if($showpost.id == $request.getParameter("deleted"))
#set($deleted = "hide")
#else
#set($deleted = "")
#end
#if($authenticated && $showpost.followers && $showpost.followers.containsKey($authUser.user.id))
#set($followedPostClass = "following-post")
#else
#set($followedPostClass = "")
#end
#if($showpost.type == "unapprovedquestion")
#set($unapprovedClass = "unapproved-post")
#else
#set($unapprovedClass = "")
#end
#if($compactViewEnabled)
#set($panelClass = "card mvm" )
#else
#set($panelClass = "card-panel" )
#end
<div id="$!showpost.id" class="${panelClass} ${followedPostClass} $!{deleted} $!{unapprovedClass}">
<div class="row mbn questionbox">
#set($votes = $showpost.votes)
#set($viewcount = $showpost.viewcount)
#set($answercount = $showpost.answercount)
#if (!$votes) #set($votes = 0) #end
#if (!$viewcount) #set($viewcount = 0) #end
#if (!$answercount) #set($answercount = 0) #end
#if ($showpost.answerid && !$showpost.answerid.isEmpty())
#set($bgclass = "light-green white-text" )
#else
#set($bgclass = "orange lighten-5" )
#end
#if ($votes < 0)
#set($bgclass1 = "red lighten-2 white-text" )
#elseif($votes >= 100)
#set($bgclass1 = "yellow lighten-3" )
#else
#set($bgclass1 = "" )
#end
#if($compactViewEnabled)
<div class="col s12">
<div class="pvm">
#set($firstLink = $scooldUtils.getFirstLinkInPost($!showpost.body))
#set($isFirstLinkImage = $firstLink.endsWith(".gif") || $firstLink.endsWith(".svg") ||
$firstLink.endsWith(".png") || $firstLink.endsWith(".jpg") ||
$firstLink.endsWith(".jpeg") || $firstLink.endsWith(".webp"))
#if($isFirstLinkImage)
<img src="$!firstLink" width="80" alt="image" class="mrm mbm left">
#end
<div>
<span class="phs kbd lightborder tooltipped $!{bgclass1}" data-tooltip="$!lang.get('votes')">$!utils.abbreviateInt($!votes, 0)</span>
<span class="phs kbd lightborder tooltipped $!{bgclass}" data-tooltip="$!lang.get('answers.title')">$utils.abbreviateInt($!answercount, 0)</span>
<span class="phs kbd lightborder tooltipped mrm" data-tooltip="$!lang.get('posts.views')">$utils.abbreviateInt($!viewcount, 0)</span>
#if($showpost.isSticky())
<i class="fa fa-thumb-tack grey-text tooltipped mrs" data-tooltip="Sticky"></i>
#end
#if($showpost.location && !$showpost.location.isEmpty() && $scooldUtils.isNearMeFeatureEnabled())
<i class="fa fa-map-marker grey-text tooltipped mrs" data-tooltip="$showpost.location"></i>
#end
#if($showpost.type == "unapprovedquestion")
<i class="fa fa-exclamation-circle grey-text tooltipped" data-tooltip="$!lang.get('posts.unapproved')"></i>
#end
<a href="$!actionlink/$showpost.id/#stripstr($!showpost.title)" class="mediumText">
#if($showSpaceLabel)
#set($spaceLabel = "$!scooldUtils.getSpaceName($!showpost.space)")
#if(!$spaceLabel.trim().isEmpty())
<small class="grey-text"><strong class="mrs">$spaceLabel</strong><i class="fa fa-angle-right"></i></small>
#end
#end
$!showpost.title
</a>
</div>
<div>
#foreach($showtag in $showpost.tags)
#if ($showtag && $showtag.trim() != "")
<a href="$questionslink/tag/$!utils.urlEncode($showtag)" title="Posts tagged $!showtag" class="mrm">
<tt class="grey-text">#</tt>$!showtag
</a>
#end
#end
#if($firstLink && !$isFirstLinkImage)
<i class="fa fa-link grey-text"></i> <a href="$!firstLink">$firstLink</a>
#end
<span class="right">
#personlink($showpost.author)
<span class="grey-text"><i class="fa fa-clock-o"></i> #formatdate($showpost.timestamp "")</span>
</span>
</div>
</div>
</div>
#else
<div class="col m2 l1 center-align hide-on-med-and-down">
<div class="qstatsbox">
<div class="largeText lightborder tooltipped $!{bgclass1}" data-tooltip="$!lang.get('votes')">$!utils.abbreviateInt($!votes, 0)</div>
<div class="mvs lightborder tooltipped $!{bgclass}" data-tooltip="$!lang.get('answers.title')">$utils.abbreviateInt($!answercount, 0)</div>
<div class="mvs lightborder tooltipped" data-tooltip="$!lang.get('posts.views')">$utils.abbreviateInt($!viewcount, 0)
<small class="hide-on-med-and-down">$!lang.get('posts.views')</small>
</div>
</div>
</div>
<div class="col s12 l11">
<div class="qstatsbox hide-on-large-only">
<span class="lightborder phm tooltipped $!{bgclass1}" data-tooltip="$!lang.get('votes')">$!utils.abbreviateInt($!votes, 0)</span>
<span class="mvs phm lightborder tooltipped $!{bgclass}" data-tooltip="$!lang.get('answers.title')">$utils.abbreviateInt($!answercount, 0)</span>
<span class="mvs phm lightborder tooltipped" data-tooltip="$!lang.get('posts.views')">$utils.abbreviateInt($!viewcount, 0)
<small>$!lang.get('posts.views')</small>
</span>
</div>
<div class="row mbn">
<div class="col s10 m11 l9">
#if($showSpaceLabel)
<div><small class="grey-text"><strong>$scooldUtils.getSpaceName($showpost.space)</strong></small></div>
#end
<div class="mediumText">
#if($showpost.location && !$showpost.location.isEmpty() && $scooldUtils.isNearMeFeatureEnabled())
<i class="fa fa-map-marker grey-text tooltipped mrs" data-tooltip="$showpost.location"></i>
#end
#if($showpost.type == "unapprovedquestion")
<i class="fa fa-exclamation-circle grey-text tooltipped" data-tooltip="$!lang.get('posts.unapproved')"></i>
#end
<a href="$!actionlink/$showpost.id/#stripstr($!showpost.title)" class="mediumText">$!showpost.title</a>
</div>
<div class="mbs">
#set($showBody = $utils.stripHtml($utils.markdownToHtml($utils.stripHtml($!showpost.body))) )
<div>$!utils.abbreviate($showBody, 160)</div>
</div>
</div>
<div class="col s2 m1 l3">
#if(!$request.requestURI.startsWith("/profile"))
<div class=" hide-on-med-and-down">
#smallpersonbox($showpost.author)
</div>
<div class="hide-on-large-only">
#tinypersonbox($showpost.author)
</div>
#end
</div>
</div>
<div class="row mbn">
<div class="col m10 s12">
<div>#tagsbox($showpost.tags $actionlink2)</div>
</div>
<div class="col m2 s12 mlm grey-text r">
<i class="fa fa-clock-o"></i> #formatdate($showpost.timestamp "")
</div>
</div>
</div>
#end
</div>
</div>
#end
#end
####################################
#macro(compactanswerspage $answers)
#foreach($answer in $answers)
#if($answer.type == "unapprovedreply") #set($unapprovedClass = "unapproved-post") #else #set($unapprovedClass = "") #end
<div class="card-panel $!{unapprovedClass}">
<div class="row mbn compactanswerbox">
<div class="col s12 m10 l9 columns">
<span class="lightborder phm mrm">$!answer.votes</span>
<span>
#if($answer.type == "unapprovedreply")
<i class="fa fa-exclamation-circle grey-text tooltipped" data-tooltip="$!lang.get('posts.unapproved')"></i>
#end
<a href="$questionlink/$answer.parentid#post-$!answer.id" title="View answer">$!answer.title</a>
</span>
#if(!$request.requestURI.startsWith("/profile"))
<div>
$!utils.abbreviate($answer.body, 200).replaceAll('\s', ' ')
</div>
#end
</div>
<div class="col s12 m2 l3 columns">
#if(!$request.requestURI.startsWith("/profile"))
<div class="r">
#tinypersonbox($answer.author)
</div>
#end
<div class="grey-text r">
<i class="fa fa-clock-o"></i> #formatdate($answer.timestamp "")
</div>
</div>
</div>
</div>
#end
#end
####################################
#macro(answerspage $answers $parentpost)
#foreach($answer in $answers)
#postbox($answer $parentpost)
#end
#end
####################################
#macro(postbox $showpost $parentpost)
#set($actionlink = "#getpostlink($showpost false true)")
#if($request.getServletPath().endsWith("/edit-post-$!showpost.id"))#set($resumeEditPost = "resume-editing")#else#set($resumeEditPost = "" )#end
<div id="$!showpost.id" class="postbox $!{showpost.type}box $!{resumeEditPost}">
#if($showpost.isReply())<hr>#end
<div id="post-$!showpost.id" class="viewbox mbm">
<div class="postbody pvs">
#set($_bodyHtml = $utils.markdownToHtml($!showpost.body))
$!{_bodyHtml}
</div>
<div class="row">
<div class="col s4 m4 l4">
<div class="left mtm mrl approve-answer-btn">
#set($approvedAnswer = $showpost.id.equals($parentpost.answerid))
#if ($approvedAnswer) #set($onclass = "green-text text-lighten-1") #else #set($onclass = "") #end
#if ($authenticated && $showpost.isReply() && ($parentpost.creatorid.equals($authUser.id) || $isAdmin))
<a href="$questionlink/$!parentpost.id/approve/$!showpost.id" class="approve-answer $!{onclass}"
title="Approve answer"><i class="fa fa-check-circle fa-3x"></i></a>
#elseif ($approvedAnswer)
<span class="green-text"><i class="fa fa-check-circle fa-3x"></i></span>
#end
</div>
#votebox($showpost "hugeText mtm")
</div>
<div class="col s8 m3 l4">
<div class="ptl center-align">
<div>$!lang.get("posts.posted") #formatdate($showpost.timestamp "")</div>
#if($showpost.type == "unapprovedreply" || $showpost.type == "unapprovedquestion")
<div><small class="orange-text"><i class="fa fa-exclamation-circle"></i> $!lang.get('posts.unapproved')</small></div>
#end
#if ($showpost.lasteditby)
<a href="$revisionslink/$!showpost.id" title="Revision history">
$!lang.get("posts.edited") #formatdate($showpost.lastedited "")
</a>
#end
</div>
</div>
<div class="col s8 m5 l4">
<div class="pam">
#smallpersonbox($showpost.author)
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<div class="lightborder pam post-actions">
<a href="#post-$!showpost.id" title="Permalink" class="right permalink"><i class="fa fa-bookmark"></i></a>
#if ($scooldUtils.isMod($authUser) && ($showpost.type == "unapprovedreply" || $showpost.type == "unapprovedquestion"))
<a href="$!actionlink/$showpost.id/approve" title="Approve" class="post-refresh green-text prm"><i class="fa fa-check"></i> $!lang.get("posts.approve")</a>
#end
#if ($scooldUtils.canEdit($showpost, $authUser))
<a href="#" title="Edit" class="editlink prm"><i class="fa fa-pencil-square"></i> $!lang.get("edit")</a>
#end
#if (($authenticated && $showpost.creatorid == $authUser.id) || $scooldUtils.isMod($authUser))
<a href="$!actionlink/$showpost.id/delete" class="delete-post red-text prm" title="Delete"><i class="fa fa-times"></i> $!lang.get("delete")</a>
#end
#if ($canComment && !$showpost.isFeedback())
<a href="#" title="Add a comment" class="next-div-toggle prm"><i class="fa fa-commenting"></i> $!lang.get("comments.write")</a>
#end
#if ($showpost.lasteditby)
<a href="$revisionslink/$!showpost.id" title="Revision history" class="prm"><i class="fa fa-th-list"></i> $!lang.get("revisions.title")</a>
#end
#if ($scooldUtils.isMod($authUser) && $showpost.isQuestion())
#if ($parentpost.isClosed())
<a href="$!actionlink/$showpost.id/close" title="Reopen" class="post-refresh prm"><i class="fa fa-unlock"></i> $!lang.get("reopen")</a>
#else
<a href="$!actionlink/$showpost.id/close" title="Close" class="post-refresh-ask prm"><i class="fa fa-lock"></i> $!lang.get("close")</a>
#end
#end
#if (!$authenticated || ($authenticated && $showpost.creatorid != $authUser.id))
#getreportlink($showpost "$questionlink/$!showpost.id" "prm")
#end
#if ($canComment)
#newcommentform($showpost.id true "$questionlink/$showpost.id")
#end
</div>
</div>
</div>
</div>
#if ($scooldUtils.canEdit($showpost, $authUser))
<div class="editbox pvm hide">
<form method="post" action="$questionlink/$!showpost.id/edit" class="edit-post-form">
#sectoken(false "EDIT_POST_$!showpost.id")
#if(!$showpost.isReply())
<div class="input-field">
<i class="fa fa-paragraph pvm prefix grey-text"></i>
<label for="title_text">$!lang.get('posts.title')</label>
<input type="text" name="title" class="validate" maxlength="255" minlength="2"
value="$!showpost.title" id="edit-$!{showpost.id}-title" required>
#getmessagebox("red white-text" $error.get("title"))
</div>
#end
<i class="fa fa-pencil fa-2x left grey-text"></i>
<div class="pll mll">
<textarea class="edit-post" name="body" length="$MAX_TEXT_LENGTH" minlength="10"
id="edit-$!{showpost.id}-body">$!showpost.body</textarea>
#getmessagebox("red white-text" $error.get("body"))
</div>
#if(!$showpost.isReply())
<div class="input-field">
<i class="fa fa-tag fa-2x grey-text prefix ptm"></i>
<div class="chips chips-autocomplete" title="$!lang.get('tags.title')"></div>
<input type="hidden" name="tags" value="$!showpost.tagsString" id="edit-$!{showpost.id}-tags">
#getmessagebox("red white-text" $error.get("tags"))
</div>
#spaceselect($showpost)
#if($scooldUtils.isNearMeFeatureEnabled())
<div class="input-field">
<i class="fa fa-map-marker ptm prefix grey-text"></i>
<input id="location_text" name="location" class="locationbox validate" type="text" value="$!showpost.location"
placeholder="$!{lang.get('profile.about.location')}">
<input type="hidden" name="latlng" value="">
<input type="hidden" name="address" value="">
</div>
#end
#end
<div class="mtl ptm mbl">
<button class="btn waves-effect waves-light" type="submit">
<i class="fa fa-save left"></i> $!lang.get('save')
</button>
<button class="btn waves-effect waves-light canceledit">$!lang.get('close')</button>
</div>
</form>
</div>
#end
<div class="comments post-comments">
#paginate("postcomments" $showpost.itemcount "$commentlink?getcomments=true&parentid=$showpost.id" "page")
</div>
</div>
#end
###################################
#macro(spaceselect $post )
#if($authUser.hasSpaces() || $isMod)
<div class="input-field">
<i class="fa fa-th-large fa-2x prefix grey-text"></i>
<div class="mll pll">
<select name="space" class="browser-default pll">
#if($post)
#set($selectedPostSpace = $!scooldUtils.getSpaceName($!post.space))
#else
#set($selectedPostSpace = $!scooldUtils.getSpaceName($!scooldUtils.getValidSpaceIdExcludingAll($authUser, "", $request)))
#end
<option value="$!post.space" disabled selected>#if($scooldUtils.isDefaultSpace($selectedPostSpace))$!lang.get('defaultspace')#else $!selectedPostSpace #end</option>
#if($scooldUtils.canAccessSpace($authUser, "default"))
<option value="">$!lang.get('defaultspace')</option>
#end
#foreach($space in $authUser.spaces)
<option value="$!space">$!scooldUtils.getSpaceName($space)</option>
#end
</select>
</div>
</div>
#getmessagebox("red white-text" $error.get("space"))
#end
#end
###################################
#macro(badgebox $showbadge $num)
#set($badgeinfo = $!lang.get("about.badges.$showbadge") )
<span class="chip" title="$!badgeinfo">
<span class="fa fa-star yellow-text text-darken-3"></span>
#if ($num && $num > 1) $!lang.get("$showbadge") <sup>$num</sup> #else $!lang.get("$showbadge") #end
</span>
#end
###################################
#macro(showcount $param )
#if ($param && $param > 1)
<small class="grey-text">$!param</small>
#end
#end
################# MISC MACROS #####################
#macro(votebox $votable $sizeClass)
#if ($votable)
<div class="votebox ${sizeClass}">
#if($votable.votes && $votable.votes != 0)#set($_vvotes = $votable.votes)#else#set($_vvotes = " ")#end
#if (!$authenticated)
<a href="${signinlink}?returnto=$!{returnto}">
<i class="fa fa-chevron-up upvote grey-text mrs" title="$!lang.get('voteup.tooltip')"></i>
</a>
<div class="votecount hide-on-med-and-up tooltipped" data-tooltip="$votable.votes">$!_vvotes</div>
<a href="${signinlink}?returnto=$!{returnto}">
<i class="fa fa-chevron-down downvote grey-text mrs" title="$!lang.get('votedown.tooltip')"></i>
</a>
#elseif($authenticated && $votable.creatorid == $authUser.id)
<i class="fa fa-chevron-up upvote grey-text mrs" title="$!lang.get('voteup.tooltip')"></i>
<div class="votecount hide-on-med-and-up tooltipped" data-tooltip="$votable.votes">$!_vvotes</div>
<i class="fa fa-chevron-down downvote grey-text mrs" title="$!lang.get('votedown.tooltip')"></i>
#else
<a href="$voteuplink/$!votable.type/$!votable.id" class="upvote votelink" title="$!lang.get('voteup.tooltip')">
<i class="fa fa-chevron-up upvote mrs" title="$!lang.get('voteup.tooltip')"></i>
</a>
<div class="votecount hide-on-med-and-up tooltipped" data-tooltip="$votable.votes">$!_vvotes</div>
<a href="$votedownlink/$!votable.type/$!votable.id" class="downvote votelink" title="$!lang.get('votedown.tooltip')">
<i class="fa fa-chevron-down downvote mrs" title="$!lang.get('votedown.tooltip')"></i>
</a>
#end
<span class="votecount hide-on-small-only tooltipped" data-tooltip="$votable.votes">$!_vvotes</span>
</div>
#end
#end
###################################
#macro(formvc $ctype)
<input type="hidden" name="vc" value="#$!{ctype}box(\$obj)">
#end
###################################
#macro(formvj $ctype $fields)
<input type="hidden" name="vj" value="$!{utils.getJSONValidationObject($ctype, $fields, $lang)}" disabled="disabled">
#end
#####################################
#macro(formatdate $date $format)
#if ($date && !$format.trim().isEmpty())
$utils.formatDate($date, $format, $currentLocale)
#elseif ($date)
#set($delta = $utils.timestamp() - $date)
#set($Integer = 0)
#set($approxtime = $utils.humanTime.approximately($delta))
#if (!$approxtime || $approxtime.isEmpty() || $approxtime.endsWith("ms")) #set($approxtime = "2s") #end
#set($lastindx = $approxtime.length() - 1 )
#set($suffix = $approxtime.substring($lastindx))
#set($approx = $Integer.parseInt($approxtime.substring(0, $lastindx)))
#set($sufstr = "humantime.$suffix" )
<span title="$utils.formatDate($date, 'dd MMMM yyyy, HH:mm', $currentLocale)">
$!utils.formatMessage($!lang.get($!sufstr), $!approx)
</span>
#end
#end
#####################################
#macro(reportform $type $parentid $link)
<form method="post" class="create-report-form pal" action="$reportslink">
#sectoken(false)
<h3>$!lang.get("reportproblem")</h3>
<div class="ptl mvl">
<label class="blocklabel">$!lang.get("reports.category")</label>
<select name="subType">
#foreach($type in $reportTypes)
#if ($type.name() == "OTHER")
<option selected="selected" value="$!type.name()">$!lang.get("reports.$type.toString()")</option>
#else
<option value="$!type.name()">$!lang.get("reports.$type.toString()")</option>
#end
#end
</select>
<div class="input-field mtl">
<label>$!lang.get("reports.description")</label>
<textarea name="description" class="materialize-textarea" rows="4"></textarea>
</div>
<input type="hidden" name="parentid" value="$!parentid">
#if ($link && !$link.isEmpty())
<input type="hidden" name="link" value="$!link">
#end
</div>
<br>
<div class="center mtl ptl">
<button id="sendreport-btn" type="submit" class="btn waves-effect waves-light">$!lang.get('send')</button>
<a href="#main-modal" class="btn-flat waves-effect waves-light modal-action modal-close">$!lang.get('close')</a>
</div>
</form>
#end
#####################################
#macro(getmessagebox $class $text)
#if($text && !$text.isEmpty())
<div class="chip phl ${class}">
<i class="fa fa-close close"></i>
<div class="msg mrl left">#if($text == "") #else $text #end</div>
</div>
#end
#end
#####################################
#macro(getpostlink $p $plural $noid)$p.getPostLink($plural, $noid)#end
#####################################
#macro(ajaxloading $hide)
#if ($hide) #set($hidden = "hide") #else #set($hidden = "") #end
<div class="progress ajaxwait $!{hidden}"><div class="indeterminate"></div></div>
#end
#####################################
#macro(profilepic $user)#if($user && $user.picture && $user.picture.matches("^(http:|https:).*"))$peoplelink/avatar?url=$utils.urlEncode($!user.picture)#elseif($user && $user.picture && $user.picture.matches("^(data:).*"))$user.picture #else $!imageslink/anon.svg #end#end
#####################################
#macro(infostrip )
#if ($request.getParameter("success"))
#set($infoStripClass = "green white-text")
#elseif ($request.getParameter("error"))
#set($infoStripClass = "red white-text")
#else
#set($infoStripClass = "")
#end
#if ($badgelist && !$badgelist.isEmpty())
#if ($badgelist.size() > 1)
#set($infoStripMsg = $!lang.get("newbadges"))
#else
#set($infoStripMsg = $!lang.get("newbadge"))
#end
#set($hideInfoStrip = "click2hide")
#elseif ($request.getParameter("code"))
#set($infoStripMsg = $!lang.get("msgcode.${request.getParameter('code')}"))
#set($hideInfoStrip = "click2hide")
#else
#set($hideInfoStrip = "")
#end
#if (!$infoStripMsg || $infoStripMsg.trim().isEmpty())
#set($hideInfoStrip = "hide")
#end
<noscript>
<div class="infostrip errorBox pvm center">
<i class="fa fa-warning"></i> $!{lang.get("nojavascript")}
</div>
</noscript>
<div class="card-panel infostrip ${hideInfoStrip} ${infoStripClass}">
#if(!$hideInfoStrip.contains("click2hide"))
<a href="#" class="right close-infostrip"><i class="fa fa-times"></i></a>
#end
#set($_infoStripMsg = $infoStripMsg )
<div class="infostrip-content">
$!_infoStripMsg
#if (!$badgelist.isEmpty())
#foreach($badge in $badgelist)
#badgebox($badge 0)
#end
#end
</div>
</div>
#end
#####################################
#macro(stripstr $str )$!utils.urlEncode($!utils.noSpaces($!utils.stripAndTrim($str, " "), "-"))#end
#####################################
#macro(setsortbyselection $paramMap $defkey )
#set($sbparam = $request.getParameter("sortby")) #set($sbclazz = "grey darken-2 white-text" )
#if ($sbparam && !$sbparam.isEmpty()) #set($paramMap[$sbparam] = $sbclazz) #else #set($paramMap[$defkey] = $sbclazz) #end
#end
#####################################
#macro(sortorderparam $prefix $sortparam)
#if ("false" != $request.getParameter("desc") && $sortparam == $request.getParameter("sortby"))$!{prefix}desc=false#end
#end
#####################################
#macro(sortorderparamasc $prefix $sortparam)
#if ("false" == $request.getParameter("desc") && $sortparam == $request.getParameter("sortby"))$!{prefix}desc=true#else$!{prefix}desc=false#end
#end
#####################################
#macro(sortordericon $sortparam)
#if ("false" == $request.getParameter("desc") && $sortparam == $request.getParameter("sortby"))<i class="fa fa-sort-amount-asc phs" title="Ascending order"></i>#end
#end
#####################################
#macro(sectoken $bare $formId)
## RESERVED FOR FUTURE USE
#end
################# END MACROS ###################################################