Show More
@@ -0,0 +1,44 b'' | |||||
|
1 | {% load i18n %} | |||
|
2 | {% load board %} | |||
|
3 | {% load static %} | |||
|
4 | ||||
|
5 | <div class="post-form-w"> | |||
|
6 | <script src="{% static 'js/panel.js' %}"></script> | |||
|
7 | ||||
|
8 | <div class="post-form" data-hasher="{% static 'js/3party/sha256.js' %}" | |||
|
9 | data-pow-script="{% static 'js/proof_of_work.js' %}"> | |||
|
10 | {% if new_thread %} | |||
|
11 | <div class="form-title">{% trans "Create new thread" %}</div> | |||
|
12 | {% else %} | |||
|
13 | <div class="form-title">{% trans "Reply to thread" %} #{{ opening_post_id }}<span class="reply-to-message"> {% trans "to message " %} #<span id="reply-to-message-id"></span></span></div> | |||
|
14 | {% endif %} | |||
|
15 | ||||
|
16 | <div class="swappable-form-full"> | |||
|
17 | <form enctype="multipart/form-data" method="post" id="form">{% csrf_token %} | |||
|
18 | {{ form.as_div }} | |||
|
19 | <div class="form-submit"> | |||
|
20 | <input type="submit" value="{% trans "Post" %}"/> | |||
|
21 | <button id="preview-button" type="button" onclick="return false;">{% trans 'Preview' %}</button> | |||
|
22 | </div> | |||
|
23 | </form> | |||
|
24 | </div> | |||
|
25 | ||||
|
26 | <div> | |||
|
27 | {% if new_thread %} | |||
|
28 | {% trans 'Tags must be delimited by spaces. Text or image is required.' %}<br /> | |||
|
29 | {% endif %} | |||
|
30 | {% with size=max_file_size|filesizeformat %} | |||
|
31 | {% blocktrans %}Max total file size is {{ size }}.{% endblocktrans %}<br /> | |||
|
32 | {% endwith %} | |||
|
33 | {% blocktrans %}Max file number is {{ max_files }}.{% endblocktrans %} | |||
|
34 | </div> | |||
|
35 | ||||
|
36 | <div id="preview-text"></div> | |||
|
37 | <div><a href="{% url "staticpage" name="help" %}">{% trans 'Help' %}</a></div> | |||
|
38 | </div> | |||
|
39 | </div> | |||
|
40 | ||||
|
41 | <script src="{% static 'js/form.js' %}"></script> | |||
|
42 | <script src="{% static 'js/jquery.form.min.js' %}"></script> | |||
|
43 | <script src="{% static 'js/3party/jquery.blockUI.js' %}"></script> | |||
|
44 |
@@ -155,35 +155,8 b'' | |||||
155 | {% trans 'No threads exist. Create the first one!' %}</div> |
|
155 | {% trans 'No threads exist. Create the first one!' %}</div> | |
156 | {% endif %} |
|
156 | {% endif %} | |
157 |
|
157 | |||
158 | <div class="post-form-w"> |
|
158 | {% form_view form=form new_thread=True %} | |
159 | <script src="{% static 'js/panel.js' %}"></script> |
|
|||
160 | <div class="post-form" data-hasher="{% static 'js/3party/sha256.js' %}" |
|
|||
161 | data-pow-script="{% static 'js/proof_of_work.js' %}"> |
|
|||
162 | <div class="form-title">{% trans "Create new thread" %}</div> |
|
|||
163 | <div class="swappable-form-full"> |
|
|||
164 | <form enctype="multipart/form-data" method="post" id="form">{% csrf_token %} |
|
|||
165 | {{ form.as_div }} |
|
|||
166 | <div class="form-submit"> |
|
|||
167 | <input type="submit" value="{% trans "Post" %}"/> |
|
|||
168 | <button id="preview-button" type="button" onclick="return false;">{% trans 'Preview' %}</button> |
|
|||
169 | </div> |
|
|||
170 | </form> |
|
|||
171 | </div> |
|
|||
172 | <div> |
|
|||
173 | {% trans 'Tags must be delimited by spaces. Text or image is required.' %} |
|
|||
174 | {% with size=max_file_size|filesizeformat %} |
|
|||
175 | {% blocktrans %}Max total file size is {{ size }}.{% endblocktrans %} |
|
|||
176 | {% endwith %} |
|
|||
177 | {% blocktrans %}Max file number is {{ max_files }}.{% endblocktrans %} |
|
|||
178 | </div> |
|
|||
179 | <div id="preview-text"></div> |
|
|||
180 | <div><a href="{% url "staticpage" name="help" %}">{% trans 'Help' %}</a></div> |
|
|||
181 | </div> |
|
|||
182 | </div> |
|
|||
183 |
|
159 | |||
184 | <script src="{% static 'js/form.js' %}"></script> |
|
|||
185 | <script src="{% static 'js/jquery.form.min.js' %}"></script> |
|
|||
186 | <script src="{% static 'js/3party/jquery.blockUI.js' %}"></script> |
|
|||
187 | <script src="{% static 'js/thread_create.js' %}"></script> |
|
160 | <script src="{% static 'js/thread_create.js' %}"></script> | |
188 |
|
161 | |||
189 | {% endblock %} |
|
162 | {% endblock %} |
@@ -42,37 +42,8 b'' | |||||
42 | </div> |
|
42 | </div> | |
43 |
|
43 | |||
44 | {% if not thread.is_archived %} |
|
44 | {% if not thread.is_archived %} | |
45 | <div class="post-form-w"> |
|
45 | {% form_view form=form new_thread=False opening_post_id=opening_post.id %} | |
46 | <script src="{% static 'js/panel.js' %}"></script> |
|
|||
47 | <div class="form-title">{% trans "Reply to thread" %} #{{ opening_post.id }}<span class="reply-to-message"> {% trans "to message " %} #<span id="reply-to-message-id"></span></span></div> |
|
|||
48 | <div class="post-form" id="compact-form" data-hasher="{% static 'js/3party/sha256.js' %}" |
|
|||
49 | data-pow-script="{% static 'js/proof_of_work.js' %}"> |
|
|||
50 | <div class="swappable-form-full"> |
|
|||
51 | <form enctype="multipart/form-data" method="post" id="form">{% csrf_token %} |
|
|||
52 | <div class="compact-form-text"></div> |
|
|||
53 | {{ form.as_div }} |
|
|||
54 | <div class="form-submit"> |
|
|||
55 | <input type="submit" value="{% trans "Post" %}"/> |
|
|||
56 | <button id="preview-button" type="button" onclick="return false;">{% trans 'Preview' %}</button> |
|
|||
57 | </div> |
|
|||
58 | </form> |
|
|||
59 | </div> |
|
|||
60 | <div id="preview-text"></div> |
|
|||
61 | <div> |
|
|||
62 | {% with size=max_file_size|filesizeformat %} |
|
|||
63 | {% blocktrans %}Max total file size is {{ size }}.{% endblocktrans %} |
|
|||
64 | {% endwith %} |
|
|||
65 | {% blocktrans %}Max file number is {{ max_files }}.{% endblocktrans %} |
|
|||
66 | </div> |
|
|||
67 | <div><a href="{% url "staticpage" name="help" %}"> |
|
|||
68 | {% trans 'Help' %}</a></div> |
|
|||
69 | <div><a href="#" onClick="resetForm(); return false;">{% trans 'Reset form' %}</a></div> |
|
|||
70 | </div> |
|
|||
71 | </div> |
|
|||
72 |
|
46 | |||
73 | <script src="{% static 'js/form.js' %}"></script> |
|
|||
74 | <script src="{% static 'js/jquery.form.min.js' %}"></script> |
|
|||
75 | <script src="{% static 'js/3party/jquery.blockUI.js' %}"></script> |
|
|||
76 | <script src="{% static 'js/thread.js' %}"></script> |
|
47 | <script src="{% static 'js/thread.js' %}"></script> | |
77 | <script src="{% static 'js/thread_update.js' %}"></script> |
|
48 | <script src="{% static 'js/thread_update.js' %}"></script> | |
78 | {% endif %} |
|
49 | {% endif %} |
@@ -4,6 +4,8 b' from django.shortcuts import get_object_' | |||||
4 | from django.utils.text import re_tag |
|
4 | from django.utils.text import re_tag | |
5 |
|
5 | |||
6 | from boards.mdx_neboard import LINE_BREAK_HTML |
|
6 | from boards.mdx_neboard import LINE_BREAK_HTML | |
|
7 | from boards import settings | |||
|
8 | from boards.settings import SECTION_FORMS | |||
7 |
|
9 | |||
8 | IMG_ACTION_URL = '[<a href="{}">{}</a>]' |
|
10 | IMG_ACTION_URL = '[<a href="{}">{}</a>]' | |
9 | REGEX_NEWLINE = re.compile(LINE_BREAK_HTML) |
|
11 | REGEX_NEWLINE = re.compile(LINE_BREAK_HTML) | |
@@ -11,6 +13,8 b" TRUNCATOR = '...'" | |||||
11 | HTML4_SINGLETS =( |
|
13 | HTML4_SINGLETS =( | |
12 | 'br', 'col', 'link', 'base', 'img', 'param', 'area', 'hr', 'input' |
|
14 | 'br', 'col', 'link', 'base', 'img', 'param', 'area', 'hr', 'input' | |
13 | ) |
|
15 | ) | |
|
16 | PARAM_MAX_FILE_SIZE = 'max_file_size' | |||
|
17 | PARAM_MAX_FILES = 'max_files' | |||
14 |
|
18 | |||
15 |
|
19 | |||
16 | register = template.Library() |
|
20 | register = template.Library() | |
@@ -94,3 +98,11 b' def truncatenewlines_html(value, arg):' | |||||
94 |
|
98 | |||
95 | return text |
|
99 | return text | |
96 |
|
100 | |||
|
101 | ||||
|
102 | @register.inclusion_tag('boards/form.html', name='form_view', takes_context=True) | |||
|
103 | def form_view(context, *args, **kwargs): | |||
|
104 | kwargs['perms'] = context['perms'] | |||
|
105 | kwargs[PARAM_MAX_FILE_SIZE] = settings.get_int(SECTION_FORMS, 'MaxFileSize') | |||
|
106 | kwargs[PARAM_MAX_FILES] = settings.get_int(SECTION_FORMS, 'MaxFileCount') | |||
|
107 | return kwargs | |||
|
108 |
@@ -33,16 +33,13 b" PARAMETER_CURRENT_PAGE = 'current_page'" | |||||
33 | PARAMETER_PAGINATOR = 'paginator' |
|
33 | PARAMETER_PAGINATOR = 'paginator' | |
34 | PARAMETER_THREADS = 'threads' |
|
34 | PARAMETER_THREADS = 'threads' | |
35 | PARAMETER_ADDITIONAL = 'additional_params' |
|
35 | PARAMETER_ADDITIONAL = 'additional_params' | |
36 | PARAMETER_MAX_FILE_SIZE = 'max_file_size' |
|
|||
37 | PARAMETER_RSS_URL = 'rss_url' |
|
36 | PARAMETER_RSS_URL = 'rss_url' | |
38 | PARAMETER_MAX_FILES = 'max_files' |
|
|||
39 |
|
37 | |||
40 | TEMPLATE = 'boards/all_threads.html' |
|
38 | TEMPLATE = 'boards/all_threads.html' | |
41 | DEFAULT_PAGE = 1 |
|
39 | DEFAULT_PAGE = 1 | |
42 |
|
40 | |||
43 |
|
41 | |||
44 |
class AllThreadsView( |
|
42 | class AllThreadsView(BaseBoardView, PaginatedMixin, DispatcherMixin): | |
45 | DispatcherMixin): |
|
|||
46 |
|
43 | |||
47 | tag_name = '' |
|
44 | tag_name = '' | |
48 |
|
45 | |||
@@ -83,9 +80,7 b' class AllThreadsView(FileUploadMixin, Ba' | |||||
83 |
|
80 | |||
84 | params[PARAMETER_THREADS] = threads |
|
81 | params[PARAMETER_THREADS] = threads | |
85 | params[CONTEXT_FORM] = form |
|
82 | params[CONTEXT_FORM] = form | |
86 | params[PARAMETER_MAX_FILE_SIZE] = self.get_max_upload_size() |
|
|||
87 | params[PARAMETER_RSS_URL] = self.get_rss_url() |
|
83 | params[PARAMETER_RSS_URL] = self.get_rss_url() | |
88 | params[PARAMETER_MAX_FILES] = settings.get_int(SECTION_FORMS, 'MaxFileCount') |
|
|||
89 |
|
84 | |||
90 | paginator.set_url(self.get_reverse_url(), request.GET.dict()) |
|
85 | paginator.set_url(self.get_reverse_url(), request.GET.dict()) | |
91 | params.update(self.get_page_context(paginator, page)) |
|
86 | params.update(self.get_page_context(paginator, page)) |
@@ -35,6 +35,7 b' class DispatcherMixin:' | |||||
35 | return getattr(self, method_name)(*args, **kwargs) |
|
35 | return getattr(self, method_name)(*args, **kwargs) | |
36 |
|
36 | |||
37 |
|
37 | |||
|
38 | # TODO Check if it is still used anywhere and safely remove | |||
38 | class FileUploadMixin: |
|
39 | class FileUploadMixin: | |
39 | def get_max_upload_size(self): |
|
40 | def get_max_upload_size(self): | |
40 | return boards.settings.get_int(SECTION_FORMS, 'MaxFileSize') |
|
41 | return boards.settings.get_int(SECTION_FORMS, 'MaxFileSize') |
@@ -8,11 +8,9 b" TEMPLATE_NORMAL = 'boards/thread_normal." | |||||
8 | CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress' |
|
8 | CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress' | |
9 | CONTEXT_POSTS_LEFT = 'posts_left' |
|
9 | CONTEXT_POSTS_LEFT = 'posts_left' | |
10 | CONTEXT_BUMPABLE = 'bumpable' |
|
10 | CONTEXT_BUMPABLE = 'bumpable' | |
11 | PARAM_MAX_FILE_SIZE = 'max_file_size' |
|
|||
12 | PARAM_MAX_FILES = 'max_files' |
|
|||
13 |
|
11 | |||
14 |
|
12 | |||
15 |
class NormalThreadView(ThreadView |
|
13 | class NormalThreadView(ThreadView): | |
16 |
|
14 | |||
17 | def get_template(self): |
|
15 | def get_template(self): | |
18 | return TEMPLATE_NORMAL |
|
16 | return TEMPLATE_NORMAL | |
@@ -31,7 +29,5 b' class NormalThreadView(ThreadView, FileU' | |||||
31 | params[CONTEXT_POSTS_LEFT] = left_posts |
|
29 | params[CONTEXT_POSTS_LEFT] = left_posts | |
32 | params[CONTEXT_BUMPLIMIT_PRG] = str( |
|
30 | params[CONTEXT_BUMPLIMIT_PRG] = str( | |
33 | float(left_posts) / max_posts * 100) |
|
31 | float(left_posts) / max_posts * 100) | |
34 | params[PARAM_MAX_FILE_SIZE] = self.get_max_upload_size() |
|
|||
35 | params[PARAM_MAX_FILES] = settings.get_int(SECTION_FORMS, 'MaxFileCount') |
|
|||
36 |
|
32 | |||
37 | return params |
|
33 | return params |
General Comments 0
You need to be logged in to leave comments.
Login now