Show More
@@ -1,371 +1,376 b'' | |||
|
1 | 1 | * { |
|
2 | 2 | font-size: inherit; |
|
3 | 3 | margin: 0; |
|
4 | 4 | padding: 0; |
|
5 | 5 | } |
|
6 | 6 | html { |
|
7 | 7 | background: #fff; |
|
8 | 8 | color: #000; |
|
9 | 9 | font: medium sans-serif; |
|
10 | 10 | } |
|
11 | 11 | a { |
|
12 | 12 | color: inherit; |
|
13 | 13 | text-decoration: underline; |
|
14 | 14 | } |
|
15 | 15 | li { |
|
16 | 16 | list-style-position: inside; |
|
17 | 17 | } |
|
18 | 18 | |
|
19 | 19 | #admin_panel { |
|
20 | 20 | background: #182F6F; |
|
21 | 21 | color: #fff; |
|
22 | 22 | padding: .5ex 1ex .5ex 1ex; |
|
23 | 23 | } |
|
24 | 24 | |
|
25 | 25 | .navigation_panel { |
|
26 | 26 | background: #182F6F; |
|
27 | 27 | color: #B4CFEC; |
|
28 | 28 | margin-bottom: 1em; |
|
29 | 29 | padding: .5ex 1ex 1ex 1ex; |
|
30 | 30 | } |
|
31 | 31 | .navigation_panel::after { |
|
32 | 32 | clear: both; |
|
33 | 33 | content: "."; |
|
34 | 34 | display: block; |
|
35 | 35 | height: 0; |
|
36 | 36 | line-height: 0; |
|
37 | 37 | visibility: hidden; |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | .navigation_panel a:link, .navigation_panel a:visited, .navigation_panel a:hover { |
|
41 | 41 | text-decoration: none; |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | .navigation_panel .link { |
|
45 | 45 | border-right: 1px solid #fff; |
|
46 | 46 | color: #fff; |
|
47 | 47 | font-weight: bold; |
|
48 | 48 | margin-right: 1ex; |
|
49 | 49 | padding-right: 1ex; |
|
50 | 50 | } |
|
51 | 51 | .navigation_panel .link:last-child { |
|
52 | 52 | border-left: 1px solid #fff; |
|
53 | 53 | border-right: none; |
|
54 | 54 | float: right; |
|
55 | 55 | margin-left: 1ex; |
|
56 | 56 | margin-right: 0; |
|
57 | 57 | padding-left: 1ex; |
|
58 | 58 | padding-right: 0; |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | .navigation_panel .tag { |
|
62 | 62 | color: #fff; |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | .input_field { |
|
66 | 66 | |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | .input_field_name { |
|
70 | 70 | |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | .input_field_error { |
|
74 | 74 | color: #FF0000; |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | |
|
78 | 78 | .title { |
|
79 | 79 | color: #182F6F; |
|
80 | 80 | font-weight: bold; |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | .post-form-w { |
|
84 | 84 | background: #182F6F; |
|
85 | 85 | border-radius: 1ex; |
|
86 | 86 | color: #fff; |
|
87 | 87 | margin: 1em 1ex; |
|
88 | 88 | padding: 1ex; |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | .form-row { |
|
92 | 92 | display: table; |
|
93 | 93 | width: 100%; |
|
94 | 94 | } |
|
95 | 95 | .form-label, .form-input { |
|
96 | 96 | display: table-cell; |
|
97 | 97 | vertical-align: top; |
|
98 | 98 | } |
|
99 | 99 | .form-label { |
|
100 | 100 | padding: .25em 1ex .25em 0; |
|
101 | 101 | width: 14ex; |
|
102 | 102 | } |
|
103 | 103 | .form-input { |
|
104 | 104 | padding: .25em 0; |
|
105 | 105 | } |
|
106 | 106 | .form-input > * { |
|
107 | 107 | background: #fff; |
|
108 | 108 | color: #000; |
|
109 | 109 | border: none; |
|
110 | 110 | padding: 0; |
|
111 | 111 | resize: vertical; |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | .form-input > :not(.file_wrap) { |
|
115 | 115 | width: 100%; |
|
116 | 116 | } |
|
117 | 117 | |
|
118 | 118 | .form-submit { |
|
119 | 119 | border-bottom: 1px solid #666; |
|
120 | 120 | margin-bottom: .5em; |
|
121 | 121 | padding-bottom: .5em; |
|
122 | 122 | } |
|
123 | 123 | .form-title { |
|
124 | 124 | font-weight: bold; |
|
125 | 125 | margin-bottom: .5em; |
|
126 | 126 | } |
|
127 | 127 | .post-form .settings_item { |
|
128 | 128 | margin: .5em 0; |
|
129 | 129 | } |
|
130 | 130 | .form-submit input { |
|
131 | 131 | margin-top: .5em; |
|
132 | 132 | padding: .2em 1ex; |
|
133 | 133 | } |
|
134 | 134 | .form-label { |
|
135 | 135 | text-align: left; |
|
136 | 136 | } |
|
137 | 137 | |
|
138 | 138 | .block { |
|
139 | 139 | display: inline-block; |
|
140 | 140 | vertical-align: top; |
|
141 | 141 | } |
|
142 | 142 | |
|
143 | 143 | .post_id { |
|
144 | 144 | color: #a00; |
|
145 | 145 | } |
|
146 | 146 | |
|
147 | 147 | .post { |
|
148 | 148 | clear: left; |
|
149 | 149 | margin: 0 1ex 1em 1ex; |
|
150 | 150 | overflow-x: auto; |
|
151 | 151 | word-wrap: break-word; |
|
152 | 152 | background: #FFF; |
|
153 | 153 | padding: 1ex; |
|
154 | 154 | border: 1px solid #666; |
|
155 | 155 | box-shadow: 1px 1px 2px 1px #666; |
|
156 | 156 | } |
|
157 | 157 | |
|
158 | 158 | #posts > .post:last-child { |
|
159 | 159 | border-bottom: none; |
|
160 | 160 | padding-bottom: 0; |
|
161 | 161 | } |
|
162 | 162 | |
|
163 | 163 | .metadata { |
|
164 | 164 | background: #C0E4E8; |
|
165 | 165 | border: 1px solid #7F9699; |
|
166 | 166 | border-radius: .4ex; |
|
167 | 167 | display: table; |
|
168 | 168 | margin-top: .5em; |
|
169 | 169 | padding: .4em; |
|
170 | 170 | } |
|
171 | 171 | |
|
172 | 172 | .post ul, .post ol { |
|
173 | 173 | margin: .5em 0 .5em 3ex; |
|
174 | 174 | } |
|
175 | 175 | .post li { |
|
176 | 176 | margin: .2em 0; |
|
177 | 177 | } |
|
178 | 178 | .post p { |
|
179 | 179 | margin: .5em 0; |
|
180 | 180 | } |
|
181 | 181 | .post blockquote { |
|
182 | 182 | border-left: 3px solid #182F6F; |
|
183 | 183 | margin: .5em 0 .5em 3ex; |
|
184 | 184 | padding-left: 1ex; |
|
185 | 185 | } |
|
186 | 186 | .post blockquote > blockquote { |
|
187 | 187 | padding-top: .1em; |
|
188 | 188 | } |
|
189 | 189 | |
|
190 | 190 | .post > .image { |
|
191 | 191 | float: left; |
|
192 | 192 | margin-right: 1ex; |
|
193 | 193 | } |
|
194 | 194 | .post > .metadata { |
|
195 | 195 | clear: left; |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | .post > .message .get { |
|
199 | 199 | color: #182F6F; font-weight: bold; |
|
200 | 200 | } |
|
201 | 201 | |
|
202 | 202 | .dead_post > .metadata { |
|
203 | 203 | background: #eee; |
|
204 | 204 | } |
|
205 | 205 | |
|
206 | 206 | .quote, .multiquote { |
|
207 | 207 | color: #182F6F; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | .spoiler { |
|
211 | 211 | background: black; |
|
212 | 212 | color: black; |
|
213 | 213 | } |
|
214 | 214 | |
|
215 | 215 | .spoiler:hover { |
|
216 | 216 | background: #ffffff; |
|
217 | 217 | } |
|
218 | 218 | |
|
219 | 219 | .comment { |
|
220 | 220 | color: #557055; |
|
221 | 221 | } |
|
222 | 222 | |
|
223 | 223 | .last-replies { |
|
224 | 224 | margin-left: 6ex; |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | .thread > .post > .message > .post-info { |
|
228 | 228 | border-bottom: 1px solid #ccc; |
|
229 | 229 | padding-bottom: .5em; |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | :target .post_id { |
|
233 | 233 | background: #182F6F; |
|
234 | 234 | color: #FFF; |
|
235 | 235 | text-decoration: none; |
|
236 | 236 | } |
|
237 | 237 | |
|
238 | 238 | .image-mode-tab { |
|
239 | 239 | background: #182F6F; |
|
240 | 240 | color: #FFF; |
|
241 | 241 | display: table; |
|
242 | 242 | margin: 1em auto 1em 0; |
|
243 | 243 | padding: .2em .5ex; |
|
244 | 244 | } |
|
245 | 245 | |
|
246 | 246 | .image-mode-tab > label { |
|
247 | 247 | margin: 0 1ex; |
|
248 | 248 | } |
|
249 | 249 | |
|
250 | 250 | .image-mode-tab > label > input { |
|
251 | 251 | margin-right: .5ex; |
|
252 | 252 | } |
|
253 | 253 | |
|
254 | 254 | .tag_info, .page_link { |
|
255 | 255 | margin: 1em 0; |
|
256 | 256 | text-align: center; |
|
257 | 257 | } |
|
258 | 258 | |
|
259 | 259 | .form-errors { |
|
260 | 260 | margin-left: 1ex; |
|
261 | 261 | } |
|
262 | 262 | |
|
263 | 263 | .moderator_info { |
|
264 | 264 | font-weight: bold; |
|
265 | 265 | float: right; |
|
266 | 266 | } |
|
267 | 267 | |
|
268 | 268 | .refmap { |
|
269 | 269 | border: 1px dashed #aaa; |
|
270 | 270 | padding: 0.5em; |
|
271 | 271 | display: table; |
|
272 | 272 | } |
|
273 | 273 | |
|
274 | 274 | .fav { |
|
275 | 275 | color: blue; |
|
276 | 276 | } |
|
277 | 277 | |
|
278 | 278 | .not_fav { |
|
279 | 279 | color: #ccc; |
|
280 | 280 | } |
|
281 | 281 | |
|
282 | 282 | .role { |
|
283 | 283 | text-decoration: underline; |
|
284 | 284 | } |
|
285 | 285 | |
|
286 | 286 | .form-email { |
|
287 | 287 | display: none; |
|
288 | 288 | } |
|
289 | 289 | |
|
290 | 290 | .bar-value { |
|
291 | 291 | background: #E3E7F2; |
|
292 | 292 | padding: .1em 1ex; |
|
293 | 293 | moz-box-sizing: border-box; |
|
294 | 294 | box-sizing: border-box; |
|
295 | 295 | height: 1.5em; |
|
296 | 296 | } |
|
297 | 297 | |
|
298 | 298 | .bar-bg { |
|
299 | 299 | background: #EA4649; |
|
300 | 300 | border: 1px solid #666; |
|
301 | 301 | margin: 0 1ex 1em 1ex; |
|
302 | 302 | position: relative; |
|
303 | 303 | overflow: hidden; |
|
304 | 304 | } |
|
305 | 305 | |
|
306 | 306 | .bar-text { |
|
307 | 307 | padding: 2px; |
|
308 | 308 | position: absolute; |
|
309 | 309 | left: 0; |
|
310 | 310 | top: 0; |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | .skipped_replies { |
|
314 | 314 | margin: 1ex; |
|
315 | 315 | } |
|
316 | 316 | |
|
317 | 317 | #mark-panel { |
|
318 | 318 | background: #eee; |
|
319 | 319 | border-bottom: 1px solid #182F6F; |
|
320 | 320 | } |
|
321 | 321 | |
|
322 | 322 | .mark_btn { |
|
323 | 323 | display: inline-block; |
|
324 | 324 | padding: .2em 1ex; |
|
325 | 325 | border-left: 1px solid #182F6F; |
|
326 | 326 | } |
|
327 | 327 | |
|
328 | 328 | .mark_btn:first-child { |
|
329 | 329 | border-left: none; |
|
330 | 330 | } |
|
331 | 331 | |
|
332 | 332 | .mark_btn:last-child { |
|
333 | 333 | border-right: 1px solid #182F6F; |
|
334 | 334 | } |
|
335 | 335 | |
|
336 | 336 | .current_page { |
|
337 | 337 | border-bottom: 1px solid #FFF; |
|
338 | 338 | padding: 0px 0.5ex; |
|
339 | 339 | } |
|
340 | 340 | |
|
341 | 341 | .image-mode-tab a { |
|
342 | 342 | text-decoration: none; |
|
343 | 343 | } |
|
344 | 344 | .image-mode-tab .current_mode::before { |
|
345 | 345 | content: "β "; |
|
346 | 346 | padding: 0 0 0 .5ex; |
|
347 | 347 | color: #182F6F; |
|
348 | 348 | background: #FFF; |
|
349 | 349 | } |
|
350 | 350 | .image-mode-tab .current_mode { |
|
351 | 351 | padding: 0 .5ex 0 0; |
|
352 | 352 | color: #182F6F; |
|
353 | 353 | background: #FFF; |
|
354 | 354 | } |
|
355 | 355 | |
|
356 | 356 | .gallery_image_metadata { |
|
357 | 357 | margin-bottom: 1em; |
|
358 | 358 | } |
|
359 | 359 | |
|
360 | 360 | .swappable-form-full > form { |
|
361 | 361 | display: table; |
|
362 | 362 | width: 100%; |
|
363 | 363 | } |
|
364 | 364 | |
|
365 | 365 | #id_models li { |
|
366 | 366 | list-style: none; |
|
367 | 367 | } |
|
368 | 368 | |
|
369 | 369 | #id_q { |
|
370 | 370 | margin-left: 1ex; |
|
371 | 371 | } |
|
372 | ||
|
373 | .br { | |
|
374 | margin-top: 0.5em; | |
|
375 | margin-bottom: 0.5em; | |
|
376 | } |
@@ -1,137 +1,137 b'' | |||
|
1 | 1 | from django.db import transaction |
|
2 | 2 | from django.shortcuts import render, redirect |
|
3 | 3 | |
|
4 | 4 | from boards import utils, settings |
|
5 | 5 | from boards.abstracts.paginator import get_paginator |
|
6 | 6 | from boards.abstracts.settingsmanager import get_settings_manager |
|
7 | 7 | from boards.forms import ThreadForm, PlainErrorList |
|
8 | 8 | from boards.models import Post, Thread, Ban, Tag |
|
9 | 9 | from boards.views.banned import BannedView |
|
10 | 10 | from boards.views.base import BaseBoardView, CONTEXT_FORM |
|
11 | 11 | from boards.views.posting_mixin import PostMixin |
|
12 | 12 | |
|
13 | 13 | |
|
14 | 14 | FORM_TAGS = 'tags' |
|
15 | 15 | FORM_TEXT = 'text' |
|
16 | 16 | FORM_TITLE = 'title' |
|
17 | 17 | FORM_IMAGE = 'image' |
|
18 | 18 | |
|
19 | 19 | TAG_DELIMITER = ' ' |
|
20 | 20 | |
|
21 | 21 | PARAMETER_CURRENT_PAGE = 'current_page' |
|
22 | 22 | PARAMETER_PAGINATOR = 'paginator' |
|
23 | 23 | PARAMETER_THREADS = 'threads' |
|
24 | 24 | |
|
25 | 25 | TEMPLATE = 'boards/posting_general.html' |
|
26 | 26 | DEFAULT_PAGE = 1 |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | class AllThreadsView(PostMixin, BaseBoardView): |
|
30 | 30 | |
|
31 | 31 | def __init__(self): |
|
32 | 32 | self.settings_manager = None |
|
33 | 33 | super(AllThreadsView, self).__init__() |
|
34 | 34 | |
|
35 | 35 | def get(self, request, page=DEFAULT_PAGE, form=None): |
|
36 | 36 | params = self.get_context_data(request=request) |
|
37 | 37 | |
|
38 | 38 | if not form: |
|
39 | 39 | form = ThreadForm(error_class=PlainErrorList) |
|
40 | 40 | |
|
41 | 41 | self.settings_manager = get_settings_manager(request) |
|
42 | 42 | paginator = get_paginator(self.get_threads(), |
|
43 | 43 | settings.THREADS_PER_PAGE) |
|
44 | 44 | paginator.current_page = int(page) |
|
45 | 45 | |
|
46 | 46 | threads = paginator.page(page).object_list |
|
47 | 47 | |
|
48 | 48 | params[PARAMETER_THREADS] = threads |
|
49 | 49 | params[CONTEXT_FORM] = form |
|
50 | 50 | |
|
51 | 51 | self._get_page_context(paginator, params, page) |
|
52 | 52 | |
|
53 | 53 | return render(request, TEMPLATE, params) |
|
54 | 54 | |
|
55 | 55 | def post(self, request, page=DEFAULT_PAGE): |
|
56 | 56 | form = ThreadForm(request.POST, request.FILES, |
|
57 | 57 | error_class=PlainErrorList) |
|
58 | 58 | form.session = request.session |
|
59 | 59 | |
|
60 | 60 | if form.is_valid(): |
|
61 | 61 | return self.create_thread(request, form) |
|
62 | 62 | if form.need_to_ban: |
|
63 | 63 | # Ban user because he is suspected to be a bot |
|
64 | 64 | self._ban_current_user(request) |
|
65 | 65 | |
|
66 | 66 | return self.get(request, page, form) |
|
67 | 67 | |
|
68 | 68 | def _get_page_context(self, paginator, params, page): |
|
69 | 69 | """ |
|
70 | 70 | Get pagination context variables |
|
71 | 71 | """ |
|
72 | 72 | |
|
73 | 73 | params[PARAMETER_PAGINATOR] = paginator |
|
74 | 74 | params[PARAMETER_CURRENT_PAGE] = paginator.page(int(page)) |
|
75 | 75 | |
|
76 | 76 | @staticmethod |
|
77 | 77 | def parse_tags_string(tag_strings): |
|
78 | 78 | """ |
|
79 | 79 | Parses tag list string and returns tag object list. |
|
80 | 80 | """ |
|
81 | 81 | |
|
82 | 82 | tags = [] |
|
83 | 83 | |
|
84 | 84 | if tag_strings: |
|
85 | 85 | tag_strings = tag_strings.split(TAG_DELIMITER) |
|
86 | 86 | for tag_name in tag_strings: |
|
87 | 87 | tag_name = tag_name.strip().lower() |
|
88 | 88 | if len(tag_name) > 0: |
|
89 | 89 | tag, created = Tag.objects.get_or_create(name=tag_name) |
|
90 | 90 | tags.append(tag) |
|
91 | 91 | |
|
92 | 92 | return tags |
|
93 | 93 | |
|
94 | 94 | @transaction.atomic |
|
95 | 95 | def create_thread(self, request, form, html_response=True): |
|
96 | 96 | """ |
|
97 | 97 | Creates a new thread with an opening post. |
|
98 | 98 | """ |
|
99 | 99 | |
|
100 | 100 | ip = utils.get_client_ip(request) |
|
101 | 101 | is_banned = Ban.objects.filter(ip=ip).exists() |
|
102 | 102 | |
|
103 | 103 | if is_banned: |
|
104 | 104 | if html_response: |
|
105 | 105 | return redirect(BannedView().as_view()) |
|
106 | 106 | else: |
|
107 | 107 | return |
|
108 | 108 | |
|
109 | 109 | data = form.cleaned_data |
|
110 | 110 | |
|
111 | 111 | title = data[FORM_TITLE] |
|
112 | 112 | text = data[FORM_TEXT] |
|
113 | 113 | image = data.get(FORM_IMAGE) |
|
114 | 114 | |
|
115 | 115 | text = self._remove_invalid_links(text) |
|
116 | 116 | |
|
117 | 117 | tag_strings = data[FORM_TAGS] |
|
118 | 118 | |
|
119 | 119 | tags = self.parse_tags_string(tag_strings) |
|
120 | 120 | |
|
121 | 121 | post = Post.objects.create_post(title=title, text=text, image=image, |
|
122 | 122 | ip=ip, tags=tags) |
|
123 | 123 | |
|
124 | 124 | # This is required to update the threads to which posts we have replied |
|
125 | 125 | # when creating this one |
|
126 | 126 | post.send_to_websocket(request) |
|
127 | 127 | |
|
128 | 128 | if html_response: |
|
129 | 129 | return redirect(post.get_url()) |
|
130 | 130 | |
|
131 | 131 | def get_threads(self): |
|
132 | 132 | """ |
|
133 | 133 | Gets list of threads that will be shown on a page. |
|
134 | 134 | """ |
|
135 | 135 | |
|
136 |
return Thread.objects. |
|
|
136 | return Thread.objects.order_by('-bump_time')\ | |
|
137 | 137 | .exclude(tags__in=self.settings_manager.get_hidden_tags()) |
General Comments 0
You need to be logged in to leave comments.
Login now