Show More
@@ -18,6 +18,7 b' PostingDelay = 30' | |||||
18 | Autoban = false |
|
18 | Autoban = false | |
19 | DefaultTag = test |
|
19 | DefaultTag = test | |
20 | MaxFileCount = 1 |
|
20 | MaxFileCount = 1 | |
|
21 | AdditionalSpoilerSpaces = false | |||
21 |
|
22 | |||
22 | [Messages] |
|
23 | [Messages] | |
23 | # Thread bumplimit |
|
24 | # Thread bumplimit |
@@ -10,6 +10,7 b' from django.core.exceptions import Objec' | |||||
10 | from django.core.urlresolvers import reverse |
|
10 | from django.core.urlresolvers import reverse | |
11 |
|
11 | |||
12 | import boards |
|
12 | import boards | |
|
13 | from boards import settings | |||
13 |
|
14 | |||
14 |
|
15 | |||
15 | __author__ = 'neko259' |
|
16 | __author__ = 'neko259' | |
@@ -24,6 +25,7 b' LINE_BREAK_HTML = \'<div class="br"></div' | |||||
24 | SPOILER_SPACE = ' ' |
|
25 | SPOILER_SPACE = ' ' | |
25 |
|
26 | |||
26 | MAX_SPOILER_MULTIPLIER = 2 |
|
27 | MAX_SPOILER_MULTIPLIER = 2 | |
|
28 | MAX_SPOILER_SPACE_COUNT = 20 | |||
27 |
|
29 | |||
28 |
|
30 | |||
29 | class TextFormatter(): |
|
31 | class TextFormatter(): | |
@@ -202,11 +204,15 b' def render_tag(tag_name, value, options,' | |||||
202 |
|
204 | |||
203 |
|
205 | |||
204 | def render_spoiler(tag_name, value, options, parent, context): |
|
206 | def render_spoiler(tag_name, value, options, parent, context): | |
205 | text_len = len(value) |
|
207 | if settings.get_bool('Forms', 'AdditionalSpoilerSpaces'): | |
206 | space_count = random.randint(0, text_len * MAX_SPOILER_MULTIPLIER) |
|
208 | text_len = len(value) | |
207 | side_spaces = SPOILER_SPACE * (space_count // 2) |
|
209 | space_count = min(random.randint(0, text_len * MAX_SPOILER_MULTIPLIER), | |
208 | return '<span class="spoiler">{}{}{}</span>'.format(side_spaces, value, |
|
210 | MAX_SPOILER_SPACE_COUNT) | |
209 | side_spaces) |
|
211 | side_spaces = SPOILER_SPACE * (space_count // 2) | |
|
212 | else: | |||
|
213 | side_spaces = '' | |||
|
214 | return '<span class="spoiler">{}{}{}</span>'.format(side_spaces, | |||
|
215 | value, side_spaces) | |||
210 |
|
216 | |||
211 |
|
217 | |||
212 | formatters = [ |
|
218 | formatters = [ |
General Comments 0
You need to be logged in to leave comments.
Login now