Show More
@@ -1,49 +1,49 b'' | |||
|
1 | 1 | [Version] |
|
2 |
Version = 4.4. |
|
|
2 | Version = 4.4.1 Kikyo | |
|
3 | 3 | SiteName = Neboard DEV |
|
4 | 4 | |
|
5 | 5 | [Cache] |
|
6 | 6 | # Timeout for caching, if cache is used |
|
7 | 7 | CacheTimeout = 600 |
|
8 | 8 | |
|
9 | 9 | [Forms] |
|
10 | 10 | # Max post length in characters |
|
11 | 11 | MaxTextLength = 30000 |
|
12 | 12 | MaxFileSize = 8000000 |
|
13 | 13 | LimitFirstPosting = true |
|
14 | 14 | LimitPostingSpeed = false |
|
15 | 15 | PowDifficulty = 0 |
|
16 | 16 | # Delay in seconds |
|
17 | 17 | PostingDelay = 30 |
|
18 | 18 | Autoban = false |
|
19 | 19 | DefaultTag = test |
|
20 | 20 | MaxFileCount = 1 |
|
21 | 21 | AdditionalSpoilerSpaces = false |
|
22 | 22 | |
|
23 | 23 | [Messages] |
|
24 | 24 | # Thread bumplimit |
|
25 | 25 | MaxPostsPerThread = 10 |
|
26 | 26 | ThreadArchiveDays = 300 |
|
27 | 27 | AnonymousMode = false |
|
28 | 28 | |
|
29 | 29 | [View] |
|
30 | 30 | DefaultTheme = md |
|
31 | 31 | DefaultImageViewer = simple |
|
32 | 32 | LastRepliesCount = 3 |
|
33 | 33 | ThreadsPerPage = 3 |
|
34 | 34 | PostsPerPage = 10 |
|
35 | 35 | ImagesPerPageGallery = 20 |
|
36 | 36 | MaxFavoriteThreads = 20 |
|
37 | 37 | MaxLandingThreads = 20 |
|
38 | 38 | Themes=md:Mystic Dark,md_centered:Mystic Dark (centered),sw:Snow White,pg:Photon Grey,ad:Amanita Dark,iw:Inocibe White |
|
39 | 39 | ImageViewers=simple:Simple,popup:Popup |
|
40 | 40 | |
|
41 | 41 | [Storage] |
|
42 | 42 | # Enable archiving threads instead of deletion when the thread limit is reached |
|
43 | 43 | ArchiveThreads = true |
|
44 | 44 | |
|
45 | 45 | [RSS] |
|
46 | 46 | MaxItems = 20 |
|
47 | 47 | |
|
48 | 48 | [External] |
|
49 | 49 | ImageSearchHost= |
@@ -1,165 +1,165 b'' | |||
|
1 | 1 | from django.contrib.auth.decorators import permission_required |
|
2 | 2 | |
|
3 | 3 | from django.core.exceptions import ObjectDoesNotExist |
|
4 | 4 | from django.core.urlresolvers import reverse |
|
5 | 5 | from django.http import Http404 |
|
6 | 6 | from django.shortcuts import get_object_or_404, render, redirect |
|
7 | 7 | from django.template.context_processors import csrf |
|
8 | 8 | from django.utils.decorators import method_decorator |
|
9 | 9 | from django.views.decorators.csrf import csrf_protect |
|
10 | 10 | from django.views.generic.edit import FormMixin |
|
11 | 11 | from django.utils import timezone |
|
12 | 12 | from django.utils.dateformat import format |
|
13 | 13 | |
|
14 | 14 | from boards import utils, settings |
|
15 | 15 | from boards.abstracts.settingsmanager import get_settings_manager |
|
16 | 16 | from boards.forms import PostForm, PlainErrorList |
|
17 | 17 | from boards.models import Post |
|
18 | 18 | from boards.views.base import BaseBoardView, CONTEXT_FORM |
|
19 | 19 | from boards.views.mixins import DispatcherMixin, PARAMETER_METHOD |
|
20 | 20 | from boards.views.posting_mixin import PostMixin |
|
21 | 21 | import neboard |
|
22 | 22 | |
|
23 | 23 | REQ_POST_ID = 'post_id' |
|
24 | 24 | |
|
25 | 25 | CONTEXT_LASTUPDATE = "last_update" |
|
26 | 26 | CONTEXT_THREAD = 'thread' |
|
27 | 27 | CONTEXT_MODE = 'mode' |
|
28 | 28 | CONTEXT_OP = 'opening_post' |
|
29 | 29 | CONTEXT_FAVORITE = 'is_favorite' |
|
30 | 30 | CONTEXT_RSS_URL = 'rss_url' |
|
31 | 31 | |
|
32 | 32 | FORM_TITLE = 'title' |
|
33 | 33 | FORM_TEXT = 'text' |
|
34 | 34 | FORM_IMAGE = 'image' |
|
35 | 35 | FORM_THREADS = 'threads' |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | class ThreadView(BaseBoardView, PostMixin, FormMixin, DispatcherMixin): |
|
39 | 39 | |
|
40 | 40 | @method_decorator(csrf_protect) |
|
41 | 41 | def get(self, request, post_id, form: PostForm=None): |
|
42 | 42 | try: |
|
43 | 43 | opening_post = Post.objects.get(id=post_id) |
|
44 | 44 | except ObjectDoesNotExist: |
|
45 | 45 | raise Http404 |
|
46 | 46 | |
|
47 | 47 | # If the tag is favorite, update the counter |
|
48 | 48 | settings_manager = get_settings_manager(request) |
|
49 | 49 | favorite = settings_manager.thread_is_fav(opening_post) |
|
50 | 50 | if favorite: |
|
51 | 51 | settings_manager.add_or_read_fav_thread(opening_post) |
|
52 | 52 | |
|
53 | 53 | # If this is not OP, don't show it as it is |
|
54 | 54 | if not opening_post.is_opening(): |
|
55 | 55 | return redirect('{}#{}'.format(opening_post.get_thread().get_opening_post() |
|
56 | 56 | .get_absolute_url(), opening_post.id)) |
|
57 | 57 | |
|
58 | 58 | if not form: |
|
59 | 59 | form = PostForm(error_class=PlainErrorList) |
|
60 | 60 | |
|
61 | 61 | thread_to_show = opening_post.get_thread() |
|
62 | 62 | |
|
63 | 63 | params = dict() |
|
64 | 64 | |
|
65 | 65 | params[CONTEXT_FORM] = form |
|
66 | 66 | params[CONTEXT_LASTUPDATE] = str(thread_to_show.last_edit_time) |
|
67 | 67 | params[CONTEXT_THREAD] = thread_to_show |
|
68 | 68 | params[CONTEXT_MODE] = self.get_mode() |
|
69 | 69 | params[CONTEXT_OP] = opening_post |
|
70 | 70 | params[CONTEXT_FAVORITE] = favorite |
|
71 | 71 | params[CONTEXT_RSS_URL] = self.get_rss_url(post_id) |
|
72 | 72 | |
|
73 | 73 | params.update(self.get_data(thread_to_show)) |
|
74 | 74 | |
|
75 | 75 | return render(request, self.get_template(), params) |
|
76 | 76 | |
|
77 | 77 | @method_decorator(csrf_protect) |
|
78 | 78 | def post(self, request, post_id): |
|
79 | 79 | opening_post = get_object_or_404(Post, id=post_id) |
|
80 | 80 | |
|
81 | 81 | # If this is not OP, don't show it as it is |
|
82 | 82 | if not opening_post.is_opening(): |
|
83 | 83 | raise Http404 |
|
84 | 84 | |
|
85 | 85 | if PARAMETER_METHOD in request.POST: |
|
86 | 86 | self.dispatch_method(request, opening_post) |
|
87 | 87 | |
|
88 | 88 | return redirect('thread', post_id) # FIXME Different for different modes |
|
89 | 89 | |
|
90 | 90 | if not opening_post.get_thread().is_archived(): |
|
91 | 91 | form = PostForm(request.POST, request.FILES, |
|
92 | 92 | error_class=PlainErrorList) |
|
93 | 93 | form.session = request.session |
|
94 | 94 | |
|
95 | 95 | if form.is_valid(): |
|
96 | 96 | return self.new_post(request, form, opening_post) |
|
97 | 97 | if form.need_to_ban: |
|
98 | 98 | # Ban user because he is suspected to be a bot |
|
99 | 99 | self._ban_current_user(request) |
|
100 | 100 | |
|
101 | 101 | return self.get(request, post_id, form) |
|
102 | 102 | |
|
103 | 103 | def new_post(self, request, form: PostForm, opening_post: Post=None, |
|
104 | 104 | html_response=True): |
|
105 | 105 | """ |
|
106 | 106 | Adds a new post (in thread or as a reply). |
|
107 | 107 | """ |
|
108 | 108 | |
|
109 | 109 | ip = utils.get_client_ip(request) |
|
110 | 110 | |
|
111 | 111 | data = form.cleaned_data |
|
112 | 112 | |
|
113 | 113 | title = form.get_title() |
|
114 | 114 | text = data[FORM_TEXT] |
|
115 | 115 | files = form.get_files() |
|
116 | 116 | file_urls = form.get_file_urls() |
|
117 | 117 | images = form.get_images() |
|
118 | 118 | |
|
119 | 119 | text = self._remove_invalid_links(text) |
|
120 | 120 | |
|
121 | 121 | post_thread = opening_post.get_thread() |
|
122 | 122 | |
|
123 | 123 | post = Post.objects.create_post(title=title, text=text, files=files, |
|
124 | 124 | thread=post_thread, ip=ip, |
|
125 | 125 | tripcode=form.get_tripcode(), |
|
126 |
|
|
|
126 | file_urls=file_urls) | |
|
127 | 127 | |
|
128 | 128 | if form.is_subscribe(): |
|
129 | 129 | settings_manager = get_settings_manager(request) |
|
130 | 130 | settings_manager.add_or_read_fav_thread( |
|
131 | 131 | post_thread.get_opening_post()) |
|
132 | 132 | |
|
133 | 133 | if html_response: |
|
134 | 134 | if opening_post: |
|
135 | 135 | return redirect(post.get_absolute_url()) |
|
136 | 136 | else: |
|
137 | 137 | return post |
|
138 | 138 | |
|
139 | 139 | def get_data(self, thread) -> dict: |
|
140 | 140 | """ |
|
141 | 141 | Returns context params for the view. |
|
142 | 142 | """ |
|
143 | 143 | |
|
144 | 144 | return dict() |
|
145 | 145 | |
|
146 | 146 | def get_template(self) -> str: |
|
147 | 147 | """ |
|
148 | 148 | Gets template to show the thread mode on. |
|
149 | 149 | """ |
|
150 | 150 | |
|
151 | 151 | pass |
|
152 | 152 | |
|
153 | 153 | def get_mode(self) -> str: |
|
154 | 154 | pass |
|
155 | 155 | |
|
156 | 156 | def subscribe(self, request, opening_post): |
|
157 | 157 | settings_manager = get_settings_manager(request) |
|
158 | 158 | settings_manager.add_or_read_fav_thread(opening_post) |
|
159 | 159 | |
|
160 | 160 | def unsubscribe(self, request, opening_post): |
|
161 | 161 | settings_manager = get_settings_manager(request) |
|
162 | 162 | settings_manager.del_fav_thread(opening_post) |
|
163 | 163 | |
|
164 | 164 | def get_rss_url(self, opening_id): |
|
165 | 165 | return reverse('thread', kwargs={'post_id': opening_id}) + 'rss/' |
General Comments 0
You need to be logged in to leave comments.
Login now