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