]> git.lizzy.rs Git - cheatdb.git/blob - app/templates/macros/threads.html
f9f298a5f7e49b9e3d09771ede1b76f152f87320
[cheatdb.git] / app / templates / macros / threads.html
1 {% macro render_thread(thread, current_user) -%}
2
3 <ul class="comments mt-4 mb-0">
4         {% for r in thread.replies %}
5         <li class="row my-2 mx-0">
6                 <div class="col-md-1 p-1">
7                         <a href="{{ url_for('users.profile', username=r.author.username) }}">
8                                 <img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
9                         </a>
10                 </div>
11                 <div class="col pr-0">
12                         <div class="card">
13                                 <div class="card-header">
14                                         <a class="author {{ r.author.rank.name }}"
15                                                         href="{{ url_for('users.profile', username=r.author.username) }}">
16                                                 {{ r.author.display_name }}
17                                         </a>
18                                         <a name="reply-{{ r.id }}" class="text-muted float-right"
19                                                         href="{{ url_for('threads.view', id=thread.id) }}#reply-{{ r.id }}">
20                                                 {{ r.created_at | datetime }}
21                                         </a>
22                                 </div>
23
24                                 <div class="card-body">
25                                         {{ r.comment | markdown }}
26                                 </div>
27                         </div>
28                 </div>
29         </li>
30         {% endfor %}
31 </ul>
32
33 {% if thread.locked %}
34         <p class="my-0 py-4 text-center">
35                 <i class="fas fa-lock mr-3"></i>
36                 {{ _("This thread has been locked by a moderator.") }}
37         </p>
38 {% endif %}
39
40 {% if current_user.is_authenticated %}
41 <div class="row mt-0 mb-4 comments mx-0">
42         <div class="col-md-1 p-1">
43                 <img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ current_user.getProfilePicURL() }}">
44         </div>
45         <div class="col">
46                 <div class="card">
47                         <div class="card-header {{ current_user.rank.name }}">
48                                 {{ current_user.display_name }}
49                                 <a name="reply"></a>
50                         </div>
51
52                         {% if not current_user.canCommentRL() %}
53                                 <div class="card-body">
54                                         <textarea class="form-control" readonly disabled>{{ _("Please wait before commenting again.") }}</textarea><br />
55                                         <input class="btn btn-primary" type="submit" disabled value="Comment" />
56                                 </div>
57                         {% elif not thread.checkPerm(current_user, "COMMENT_THREAD") %}
58                                 <div class="card-body">
59                                         {% if thread.locked %}
60                                                 <textarea class="form-control" readonly disabled>{{ _("This thread has been locked.") }}</textarea><br />
61                                         {% else %}
62                                                 <textarea class="form-control" readonly disabled>{{ _("You don't have permission to post.") }}</textarea><br />
63                                         {% endif %}
64                                         <input class="btn btn-primary" type="submit" disabled value="Comment" />
65                                 </div>
66                         {% else %}
67                                 <form method="post" action="{{ url_for('threads.view', id=thread.id)}}" class="card-body">
68                                         <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
69                                         <textarea class="form-control markdown" required maxlength=500 name="comment"></textarea><br />
70                                         <input class="btn btn-primary" type="submit" value="Comment" />
71                                 </form>
72                         {% endif %}
73                 </div>
74         </div>
75 </div>
76 {% endif %}
77 {% endmacro %}
78
79 {% macro render_threadlist(threads, compact=False) -%}
80         {% for t in threads %}
81                 <a class="list-group-item list-group-item-action"
82                                 href="{{ url_for('threads.view', id=t.id) }}">
83                         {% if compact %}
84                                 {% if t.private %}&#x1f512; {% endif %}
85                                 <strong>{{ t.title }}</strong>
86                                 by {{ t.author.display_name }}
87                         {% else %}
88                                 <div class="row">
89                                         <div class="col-sm">
90                                                 <span class="mr-3">
91                                                         {% if not t.review and t.private %}
92                                                                 <i class="fas fa-lock" style="color:#ffac33;"></i>
93                                                         {% elif not t.review %}
94                                                                 <i class="fas fa-comment-alt" style="color:#666;"></i>
95                                                         {% elif t.review.recommends %}
96                                                                 <i class="fas fa-thumbs-up" style="color:#6f6;"></i>
97                                                         {% else %}
98                                                                 <i class="fas fa-thumbs-down" style="color:#f66;"></i>
99                                                         {% endif %}
100                                                 </span>
101
102                                                 <strong>{{ t.title }}</strong>
103                                                 by {{ t.author.display_name }}
104                                         </div>
105
106                                         <div class="col-sm">
107                                                 {% if t.package %}
108                                                         {{ _("%(title)s by %(author)s",
109                                                                         title="<b>" | safe + t.package.title + "</b>" | safe,
110                                                                         author=t.package.author.display_name) }}
111                                                 {% endif %}
112                                         </div>
113
114                                         <div class="col-sm-auto text-muted text-right">
115                                                 {{ t.created_at | datetime }}
116                                         </div>
117                                 </div>
118                         {% endif %}
119                 </a>
120         {% else %}
121                 <p class="list-group-item"><i>No threads found</i></p>
122         {% endfor %}
123 {% endmacro %}