Show More
@@ -29,7 +29,7 b' from boards.utils import validate_file_s' | |||||
29 | FILE_EXTENSION_DELIMITER, get_tripcode_from_text |
|
29 | FILE_EXTENSION_DELIMITER, get_tripcode_from_text | |
30 |
|
30 | |||
31 | FORMAT_PANEL_BUTTON = '<span class="mark_btn" ' \ |
|
31 | FORMAT_PANEL_BUTTON = '<span class="mark_btn" ' \ | |
32 | 'onClick="addMarkToMsg(\'{}\', \'{}\')">{}{}{}</span>' |
|
32 | 'onClick="addMarkToMsg(\'{}\', {}, \'{}\')">{}{}{}</span>' | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | REGEX_USERNAMES = re.compile(r'^[\w\s\d,]+$', re.UNICODE) |
|
35 | REGEX_USERNAMES = re.compile(r'^[\w\s\d,]+$', re.UNICODE) | |
@@ -110,8 +110,9 b' class FormatPanel(forms.Textarea):' | |||||
110 |
|
110 | |||
111 | def _get_button(self, formatter): |
|
111 | def _get_button(self, formatter): | |
112 | return FORMAT_PANEL_BUTTON.format( |
|
112 | return FORMAT_PANEL_BUTTON.format( | |
113 |
formatter. |
|
113 | formatter.tag_name, | |
114 |
formatter. |
|
114 | formatter.has_input, | |
|
115 | formatter.input_prompt, | |||
115 | formatter.preview_left, |
|
116 | formatter.preview_left, | |
116 | formatter.name, |
|
117 | formatter.name, | |
117 | formatter.preview_right) |
|
118 | formatter.preview_right) |
@@ -9,6 +9,7 b' from urllib.parse import unquote' | |||||
9 |
|
9 | |||
10 | from django.core.exceptions import ObjectDoesNotExist |
|
10 | from django.core.exceptions import ObjectDoesNotExist | |
11 | from django.urls import reverse |
|
11 | from django.urls import reverse | |
|
12 | from django.utils.translation import ugettext_lazy as _ | |||
12 |
|
13 | |||
13 | import boards |
|
14 | import boards | |
14 | from boards import settings |
|
15 | from boards import settings | |
@@ -44,9 +45,11 b' class TextFormatter:' | |||||
44 | preview_left = '' |
|
45 | preview_left = '' | |
45 | preview_right = '' |
|
46 | preview_right = '' | |
46 |
|
47 | |||
47 | # Left and right characters for the textarea input |
|
48 | # Tag name to enclose the text in the form | |
48 | format_left = '' |
|
49 | tag_name = '' | |
49 | format_right = '' |
|
50 | ||
|
51 | has_input = 'false' | |||
|
52 | input_prompt = '' | |||
50 |
|
53 | |||
51 |
|
54 | |||
52 | class AutolinkPattern: |
|
55 | class AutolinkPattern: | |
@@ -64,8 +67,7 b' class QuotePattern(TextFormatter):' | |||||
64 | preview_left = '<span class="quote">' |
|
67 | preview_left = '<span class="quote">' | |
65 | preview_right = '</span>' |
|
68 | preview_right = '</span>' | |
66 |
|
69 | |||
67 |
|
|
70 | tag_name = 'quote' | |
68 | format_right = '[/quote]' |
|
|||
69 |
|
71 | |||
70 |
|
72 | |||
71 | class SpoilerPattern(TextFormatter): |
|
73 | class SpoilerPattern(TextFormatter): | |
@@ -73,8 +75,7 b' class SpoilerPattern(TextFormatter):' | |||||
73 | preview_left = '<span class="spoiler">' |
|
75 | preview_left = '<span class="spoiler">' | |
74 | preview_right = '</span>' |
|
76 | preview_right = '</span>' | |
75 |
|
77 | |||
76 |
|
|
78 | tag_name = 'spoiler' | |
77 | format_right = '[/spoiler]' |
|
|||
78 |
|
79 | |||
79 |
|
80 | |||
80 | class CommentPattern(TextFormatter): |
|
81 | class CommentPattern(TextFormatter): | |
@@ -82,8 +83,7 b' class CommentPattern(TextFormatter):' | |||||
82 | preview_left = '<span class="comment">// ' |
|
83 | preview_left = '<span class="comment">// ' | |
83 | preview_right = '</span>' |
|
84 | preview_right = '</span>' | |
84 |
|
85 | |||
85 |
|
|
86 | tag_name = 'comment' | |
86 | format_right = '[/comment]' |
|
|||
87 |
|
87 | |||
88 |
|
88 | |||
89 | # TODO Use <s> tag here |
|
89 | # TODO Use <s> tag here | |
@@ -92,8 +92,7 b' class StrikeThroughPattern(TextFormatter' | |||||
92 | preview_left = '<span class="strikethrough">' |
|
92 | preview_left = '<span class="strikethrough">' | |
93 | preview_right = '</span>' |
|
93 | preview_right = '</span>' | |
94 |
|
94 | |||
95 | format_left = '[s]' |
|
95 | tag_name = 's' | |
96 | format_right = '[/s]' |
|
|||
97 |
|
96 | |||
98 |
|
97 | |||
99 | class ItalicPattern(TextFormatter): |
|
98 | class ItalicPattern(TextFormatter): | |
@@ -101,8 +100,7 b' class ItalicPattern(TextFormatter):' | |||||
101 | preview_left = '<i>' |
|
100 | preview_left = '<i>' | |
102 | preview_right = '</i>' |
|
101 | preview_right = '</i>' | |
103 |
|
102 | |||
104 | format_left = '[i]' |
|
103 | tag_name = 'i' | |
105 | format_right = '[/i]' |
|
|||
106 |
|
104 | |||
107 |
|
105 | |||
108 | class BoldPattern(TextFormatter): |
|
106 | class BoldPattern(TextFormatter): | |
@@ -110,8 +108,7 b' class BoldPattern(TextFormatter):' | |||||
110 | preview_left = '<b>' |
|
108 | preview_left = '<b>' | |
111 | preview_right = '</b>' |
|
109 | preview_right = '</b>' | |
112 |
|
110 | |||
113 | format_left = '[b]' |
|
111 | tag_name = 'b' | |
114 | format_right = '[/b]' |
|
|||
115 |
|
112 | |||
116 |
|
113 | |||
117 | class CodePattern(TextFormatter): |
|
114 | class CodePattern(TextFormatter): | |
@@ -119,8 +116,7 b' class CodePattern(TextFormatter):' | |||||
119 | preview_left = '<code>' |
|
116 | preview_left = '<code>' | |
120 | preview_right = '</code>' |
|
117 | preview_right = '</code>' | |
121 |
|
118 | |||
122 |
|
|
119 | tag_name = 'code' | |
123 | format_right = '[/code]' |
|
|||
124 |
|
120 | |||
125 |
|
121 | |||
126 | class HintPattern(TextFormatter): |
|
122 | class HintPattern(TextFormatter): | |
@@ -128,8 +124,18 b' class HintPattern(TextFormatter):' | |||||
128 | preview_left = '<span class="hint">' |
|
124 | preview_left = '<span class="hint">' | |
129 | preview_right = '</span>' |
|
125 | preview_right = '</span>' | |
130 |
|
126 | |||
131 |
|
|
127 | tag_name = 'hint' | |
132 | format_right = '[/hint]' |
|
128 | ||
|
129 | ||||
|
130 | class ColorPattern(TextFormatter): | |||
|
131 | name = 'color' | |||
|
132 | preview_left = '<span style="color:yellow;">' | |||
|
133 | preview_right = '</span>' | |||
|
134 | ||||
|
135 | tag_name = 'color' | |||
|
136 | ||||
|
137 | has_input = 'true' | |||
|
138 | input_prompt = _('Enter color (name or #ccc code)') | |||
133 |
|
139 | |||
134 |
|
140 | |||
135 | def render_reflink(tag_name, value, options, parent, context): |
|
141 | def render_reflink(tag_name, value, options, parent, context): | |
@@ -227,6 +233,7 b' formatters = [' | |||||
227 | StrikeThroughPattern, |
|
233 | StrikeThroughPattern, | |
228 | CodePattern, |
|
234 | CodePattern, | |
229 | HintPattern, |
|
235 | HintPattern, | |
|
236 | ColorPattern, | |||
230 | ] |
|
237 | ] | |
231 |
|
238 | |||
232 |
|
239 |
@@ -29,7 +29,21 b'' | |||||
29 | * @param start Start (left) text |
|
29 | * @param start Start (left) text | |
30 | * @param end End (right) text |
|
30 | * @param end End (right) text | |
31 | */ |
|
31 | */ | |
32 |
function addMarkToMsg( |
|
32 | function addMarkToMsg(tagName, hasInput, inputPrompt) { | |
|
33 | var startingTag = tagName; | |||
|
34 | ||||
|
35 | if (hasInput) { | |||
|
36 | var inputText = prompt(inputPrompt); | |||
|
37 | if (inputText) { | |||
|
38 | startingTag = startingTag + '=' + inputText; | |||
|
39 | } else { | |||
|
40 | return false; | |||
|
41 | } | |||
|
42 | } | |||
|
43 | ||||
|
44 | var start = '[' + startingTag + ']'; | |||
|
45 | var end = '[/' + tagName + ']'; | |||
|
46 | ||||
33 | var textareas = getPostTextarea(); |
|
47 | var textareas = getPostTextarea(); | |
34 |
|
48 | |||
35 | for (var i = 0; i < textareas.length; i++) { |
|
49 | for (var i = 0; i < textareas.length; i++) { |
General Comments 0
You need to be logged in to leave comments.
Login now