Show More
@@ -0,0 +1,33 b'' | |||||
|
1 | [Version] | |||
|
2 | Version = 2.7.0 Chani | |||
|
3 | SiteName = Neboard | |||
|
4 | ||||
|
5 | [Cache] | |||
|
6 | # Timeout for caching, if cache is used | |||
|
7 | CacheTimeout = 600 | |||
|
8 | ||||
|
9 | [Forms] | |||
|
10 | # Max post length in characters | |||
|
11 | MaxTextLength = 30000 | |||
|
12 | MaxImageSize = 8000000 | |||
|
13 | LimitPostingSpeed = false | |||
|
14 | ||||
|
15 | [Messages] | |||
|
16 | # Thread bumplimit | |||
|
17 | MaxPostsPerThread = 10 | |||
|
18 | # Old posts will be archived or deleted if this value is reached | |||
|
19 | MaxThreadCount = 5 | |||
|
20 | ||||
|
21 | [View] | |||
|
22 | DefaultTheme = md | |||
|
23 | DefaultImageViewer = simple | |||
|
24 | LastRepliesCount = 3 | |||
|
25 | ThreadsPerPage = 3 | |||
|
26 | ||||
|
27 | [Storage] | |||
|
28 | # Enable archiving threads instead of deletion when the thread limit is reached | |||
|
29 | ArchiveThreads = true | |||
|
30 | ||||
|
31 | [External] | |||
|
32 | # Thread update | |||
|
33 | WebsocketsEnabled = false |
@@ -51,11 +51,12 b' def user_and_ui_processor(request):' | |||||
51 | # This shows the moderator panel |
|
51 | # This shows the moderator panel | |
52 | context[CONTEXT_MODERATOR] = utils.is_moderator(request) |
|
52 | context[CONTEXT_MODERATOR] = utils.is_moderator(request) | |
53 |
|
53 | |||
54 |
context[CONTEXT_VERSION] = settings. |
|
54 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') | |
55 |
context[CONTEXT_SITE_NAME] = settings. |
|
55 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') | |
56 |
|
56 | |||
57 | context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting( |
|
57 | context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting( | |
58 | SETTING_IMAGE_VIEWER, default=settings.DEFAULT_IMAGE_VIEWER) |
|
58 | SETTING_IMAGE_VIEWER, | |
|
59 | default=settings.get('View', 'DefaultImageViewer')) | |||
59 |
|
60 | |||
60 | get_notifications(context, request) |
|
61 | get_notifications(context, request) | |
61 |
|
62 |
@@ -172,11 +172,10 b' class PostForm(NeboardForm):' | |||||
172 | def clean_text(self): |
|
172 | def clean_text(self): | |
173 | text = self.cleaned_data['text'].strip() |
|
173 | text = self.cleaned_data['text'].strip() | |
174 | if text: |
|
174 | if text: | |
175 | if len(text) > board_settings.MAX_TEXT_LENGTH: |
|
175 | max_length = board_settings.get_int('Forms', 'MaxTextLength') | |
|
176 | if len(text) > max_length: | |||
176 | raise forms.ValidationError(_('Text must have less than %s ' |
|
177 | raise forms.ValidationError(_('Text must have less than %s ' | |
177 | 'characters') % |
|
178 | 'characters') % str(max_length)) | |
178 | str(board_settings |
|
|||
179 | .MAX_TEXT_LENGTH)) |
|
|||
180 | return text |
|
179 | return text | |
181 |
|
180 | |||
182 | def clean_image(self): |
|
181 | def clean_image(self): | |
@@ -256,7 +255,7 b' class PostForm(NeboardForm):' | |||||
256 |
|
255 | |||
257 | posting_delay = settings.POSTING_DELAY |
|
256 | posting_delay = settings.POSTING_DELAY | |
258 |
|
257 | |||
259 | if board_settings.LIMIT_POSTING_SPEED: |
|
258 | if board_settings.get_bool('Forms', 'LimitPostingSpeed'): | |
260 | now = time.time() |
|
259 | now = time.time() | |
261 |
|
260 | |||
262 | current_delay = 0 |
|
261 | current_delay = 0 | |
@@ -283,10 +282,11 b' class PostForm(NeboardForm):' | |||||
283 | self.session[LAST_POST_TIME] = now |
|
282 | self.session[LAST_POST_TIME] = now | |
284 |
|
283 | |||
285 | def validate_image_size(self, size: int): |
|
284 | def validate_image_size(self, size: int): | |
286 | if size > board_settings.MAX_IMAGE_SIZE: |
|
285 | max_size = board_settings.get_int('Forms', 'MaxImageSize') | |
|
286 | if size > max_size: | |||
287 | raise forms.ValidationError( |
|
287 | raise forms.ValidationError( | |
288 | _('Image must be less than %s bytes') |
|
288 | _('Image must be less than %s bytes') | |
289 |
% str( |
|
289 | % str(max_size)) | |
290 |
|
290 | |||
291 | def _get_image_from_url(self, url: str) -> SimpleUploadedFile: |
|
291 | def _get_image_from_url(self, url: str) -> SimpleUploadedFile: | |
292 | """ |
|
292 | """ |
@@ -330,7 +330,7 b' class Post(models.Model, Viewable):' | |||||
330 | Sends post HTML data to the thread web socket. |
|
330 | Sends post HTML data to the thread web socket. | |
331 | """ |
|
331 | """ | |
332 |
|
332 | |||
333 | if not settings.WEBSOCKETS_ENABLED: |
|
333 | if not settings.get_bool('External', 'WebsocketsEnabled'): | |
334 | return |
|
334 | return | |
335 |
|
335 | |||
336 | thread_ids = list() |
|
336 | thread_ids = list() |
@@ -34,12 +34,13 b' class ThreadManager(models.Manager):' | |||||
34 | threads = Thread.objects.filter(archived=False).order_by('-bump_time') |
|
34 | threads = Thread.objects.filter(archived=False).order_by('-bump_time') | |
35 | thread_count = threads.count() |
|
35 | thread_count = threads.count() | |
36 |
|
36 | |||
37 | if thread_count > settings.MAX_THREAD_COUNT: |
|
37 | max_thread_count = settings.get_int('Messages', 'MaxThreadCount') | |
38 | num_threads_to_delete = thread_count - settings.MAX_THREAD_COUNT |
|
38 | if thread_count > max_thread_count: | |
|
39 | num_threads_to_delete = thread_count - max_thread_count | |||
39 | old_threads = threads[thread_count - num_threads_to_delete:] |
|
40 | old_threads = threads[thread_count - num_threads_to_delete:] | |
40 |
|
41 | |||
41 | for thread in old_threads: |
|
42 | for thread in old_threads: | |
42 | if settings.ARCHIVE_THREADS: |
|
43 | if settings.get_bool('Storage', 'ArchiveThreads'): | |
43 | self._archive_thread(thread) |
|
44 | self._archive_thread(thread) | |
44 | else: |
|
45 | else: | |
45 | thread.delete() |
|
46 | thread.delete() | |
@@ -55,7 +56,7 b' class ThreadManager(models.Manager):' | |||||
55 |
|
56 | |||
56 |
|
57 | |||
57 | def get_thread_max_posts(): |
|
58 | def get_thread_max_posts(): | |
58 | return settings.MAX_POSTS_PER_THREAD |
|
59 | return settings.get_int('Messages', 'MaxPostsPerThread') | |
59 |
|
60 | |||
60 |
|
61 | |||
61 | class Thread(models.Model): |
|
62 | class Thread(models.Model): | |
@@ -122,11 +123,13 b' class Thread(models.Model):' | |||||
122 | Gets several last replies, not including opening post |
|
123 | Gets several last replies, not including opening post | |
123 | """ |
|
124 | """ | |
124 |
|
125 | |||
125 | if settings.LAST_REPLIES_COUNT > 0: |
|
126 | last_replies_count = settings.get_int('View', 'LastRepliesCount') | |
|
127 | ||||
|
128 | if last_replies_count > 0: | |||
126 | reply_count = self.get_reply_count() |
|
129 | reply_count = self.get_reply_count() | |
127 |
|
130 | |||
128 | if reply_count > 0: |
|
131 | if reply_count > 0: | |
129 |
reply_count_to_show = min( |
|
132 | reply_count_to_show = min(last_replies_count, | |
130 | reply_count - 1) |
|
133 | reply_count - 1) | |
131 | replies = self.get_replies() |
|
134 | replies = self.get_replies() | |
132 | last_replies = replies[reply_count - reply_count_to_show:] |
|
135 | last_replies = replies[reply_count - reply_count_to_show:] | |
@@ -138,7 +141,7 b' class Thread(models.Model):' | |||||
138 | Gets number of posts between opening post and last replies. |
|
141 | Gets number of posts between opening post and last replies. | |
139 | """ |
|
142 | """ | |
140 | reply_count = self.get_reply_count() |
|
143 | reply_count = self.get_reply_count() | |
141 |
last_replies_count = min(settings. |
|
144 | last_replies_count = min(settings.get_int('View', 'LastRepliesCount'), | |
142 | reply_count - 1) |
|
145 | reply_count - 1) | |
143 | return reply_count - last_replies_count - 1 |
|
146 | return reply_count - last_replies_count - 1 | |
144 |
|
147 | |||
@@ -222,7 +225,7 b' class Thread(models.Model):' | |||||
222 | post.threads.update(last_edit_time=self.last_edit_time) |
|
225 | post.threads.update(last_edit_time=self.last_edit_time) | |
223 |
|
226 | |||
224 | def notify_clients(self): |
|
227 | def notify_clients(self): | |
225 | if not settings.WEBSOCKETS_ENABLED: |
|
228 | if not settings.get_bool('External', 'WebsocketsEnabled'): | |
226 | return |
|
229 | return | |
227 |
|
230 | |||
228 | client = Client() |
|
231 | client = Client() |
@@ -10,7 +10,7 b' from boards import settings' | |||||
10 | # TODO Make tests for all of these |
|
10 | # TODO Make tests for all of these | |
11 | class AllThreadsFeed(Feed): |
|
11 | class AllThreadsFeed(Feed): | |
12 |
|
12 | |||
13 |
title = settings. |
|
13 | title = settings.get('Version', 'SiteName') + ' - All threads' | |
14 | link = '/' |
|
14 | link = '/' | |
15 | description_template = 'boards/rss/post.html' |
|
15 | description_template = 'boards/rss/post.html' | |
16 |
|
16 |
@@ -1,2 +1,18 b'' | |||||
1 | from boards.default_settings import * |
|
1 | import configparser | |
|
2 | ||||
|
3 | ||||
|
4 | config = configparser.ConfigParser() | |||
|
5 | config.read('boards/config/default_settings.ini') | |||
|
6 | config.read('boards/config/settings.ini') | |||
|
7 | ||||
2 |
|
8 | |||
|
9 | def get(section, name): | |||
|
10 | return config[section][name] | |||
|
11 | ||||
|
12 | ||||
|
13 | def get_int(section, name): | |||
|
14 | return int(get(section, name)) | |||
|
15 | ||||
|
16 | ||||
|
17 | def get_bool(section, name): | |||
|
18 | return get(section, name) == 'true' |
@@ -51,7 +51,7 b' class AllThreadsView(PostMixin, BaseBoar' | |||||
51 |
|
51 | |||
52 | self.settings_manager = get_settings_manager(request) |
|
52 | self.settings_manager = get_settings_manager(request) | |
53 | paginator = get_paginator(self.get_threads(), |
|
53 | paginator = get_paginator(self.get_threads(), | |
54 |
settings. |
|
54 | settings.get_int('View', 'ThreadsPerPage')) | |
55 | paginator.current_page = int(page) |
|
55 | paginator.current_page = int(page) | |
56 |
|
56 | |||
57 | try: |
|
57 | try: |
@@ -32,7 +32,8 b' class SettingsView(BaseBoardView):' | |||||
32 | initial={ |
|
32 | initial={ | |
33 | FORM_THEME: selected_theme, |
|
33 | FORM_THEME: selected_theme, | |
34 | FORM_IMAGE_VIEWER: settings_manager.get_setting( |
|
34 | FORM_IMAGE_VIEWER: settings_manager.get_setting( | |
35 |
SETTING_IMAGE_VIEWER, |
|
35 | SETTING_IMAGE_VIEWER, | |
|
36 | default=settings.get('View', 'DefaultImageViewer')), | |||
36 | FORM_USERNAME: settings_manager.get_setting(SETTING_USERNAME), |
|
37 | FORM_USERNAME: settings_manager.get_setting(SETTING_USERNAME), | |
37 | FORM_TIMEZONE: request.session.get( |
|
38 | FORM_TIMEZONE: request.session.get( | |
38 | SESSION_TIMEZONE, timezone.get_current_timezone()), |
|
39 | SESSION_TIMEZONE, timezone.get_current_timezone()), |
@@ -51,7 +51,7 b' class ThreadView(BaseBoardView, PostMixi' | |||||
51 | params[CONTEXT_LASTUPDATE] = str(thread_to_show.last_edit_time) |
|
51 | params[CONTEXT_LASTUPDATE] = str(thread_to_show.last_edit_time) | |
52 | params[CONTEXT_THREAD] = thread_to_show |
|
52 | params[CONTEXT_THREAD] = thread_to_show | |
53 |
|
53 | |||
54 | if settings.WEBSOCKETS_ENABLED: |
|
54 | if settings.get_bool('External', 'WebsocketsEnabled'): | |
55 | token_time = format(timezone.now(), u'U') |
|
55 | token_time = format(timezone.now(), u'U') | |
56 |
|
56 | |||
57 | params[CONTEXT_WS_TIME] = token_time |
|
57 | params[CONTEXT_WS_TIME] = token_time |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now