Show More
@@ -1,6 +1,10 b'' | |||||
|
1 | __author__ = 'neko259' | |||
|
2 | ||||
1 | from django.utils.translation import ugettext_lazy as _ |
|
3 | from django.utils.translation import ugettext_lazy as _ | |
2 |
|
4 | |||
3 | __author__ = 'neko259' |
|
5 | ATTR_ROLES = 'roles' | |
|
6 | ATTR_CONTACTS = 'contacts' | |||
|
7 | ATTR_NAME = 'name' | |||
4 |
|
8 | |||
5 | ROLE_AUTHOR = _('author') |
|
9 | ROLE_AUTHOR = _('author') | |
6 | ROLE_DEVELOPER = _('developer') |
|
10 | ROLE_DEVELOPER = _('developer') | |
@@ -9,23 +13,23 b" ROLE_DESIGNER = _('designer')" | |||||
9 |
|
13 | |||
10 | authors = { |
|
14 | authors = { | |
11 | 'neko259': { |
|
15 | 'neko259': { | |
12 |
|
|
16 | ATTR_NAME: 'Pavel Ryapolov', | |
13 |
|
|
17 | ATTR_CONTACTS: ['neko259@gmail.com'], | |
14 |
|
|
18 | ATTR_ROLES: [ROLE_AUTHOR, ROLE_DEVELOPER], | |
15 | }, |
|
19 | }, | |
16 | 'ilyas': { |
|
20 | 'ilyas': { | |
17 |
|
|
21 | ATTR_NAME: 'Ilyas Babayev', | |
18 |
|
|
22 | ATTR_CONTACTS: ['zamesilyasa@gmail.com'], | |
19 |
|
|
23 | ATTR_ROLES: [ROLE_AUTHOR, ROLE_DEVELOPER], | |
20 | }, |
|
24 | }, | |
21 | 'ritsufag': { |
|
25 | 'ritsufag': { | |
22 |
|
|
26 | ATTR_NAME: 'Aiko Kirino', | |
23 |
|
|
27 | ATTR_CONTACTS: ['ritsufag@gmail.com'], | |
24 |
|
|
28 | ATTR_ROLES: [ROLE_JS_DEV, ROLE_DESIGNER], | |
25 | }, |
|
29 | }, | |
26 | 'Tenno Seremel': { |
|
30 | 'Tenno Seremel': { | |
27 |
|
|
31 | ATTR_NAME: 'anonymous', | |
28 |
|
|
32 | ATTR_CONTACTS: ['html@serenareem.net'], | |
29 |
|
|
33 | ATTR_ROLES: [ROLE_JS_DEV, ROLE_DESIGNER], | |
30 | }, |
|
34 | }, | |
31 | } No newline at end of file |
|
35 | } |
@@ -1,30 +1,39 b'' | |||||
|
1 | __author__ = 'neko259' | |||
|
2 | ||||
1 | from boards import utils, settings |
|
3 | from boards import utils, settings | |
2 | from boards.models import Post |
|
4 | from boards.models import Post | |
3 | from boards.models.post import SETTING_MODERATE |
|
5 | from boards.models.post import SETTING_MODERATE | |
4 |
|
6 | |||
5 | __author__ = 'neko259' |
|
7 | CONTEXT_SITE_NAME = 'site_name' | |
|
8 | CONTEXT_VERSION = 'version' | |||
|
9 | CONTEXT_MODERATOR = 'moderator' | |||
|
10 | CONTEXT_THEME_CSS = 'theme_css' | |||
|
11 | CONTEXT_THEME = 'theme' | |||
|
12 | CONTEXT_PPD = 'posts_per_day' | |||
|
13 | CONTEXT_TAGS = 'tags' | |||
|
14 | CONTEXT_USER = 'user' | |||
6 |
|
15 | |||
7 |
|
16 | |||
8 | def user_and_ui_processor(request): |
|
17 | def user_and_ui_processor(request): | |
9 | context = {} |
|
18 | context = {} | |
10 |
|
19 | |||
11 | user = utils.get_user(request) |
|
20 | user = utils.get_user(request) | |
12 |
context[ |
|
21 | context[CONTEXT_USER] = user | |
13 |
context[ |
|
22 | context[CONTEXT_TAGS] = user.fav_tags.all() | |
14 |
context[ |
|
23 | context[CONTEXT_PPD] = float(Post.objects.get_posts_per_day()) | |
15 |
|
24 | |||
16 | theme = utils.get_theme(request, user) |
|
25 | theme = utils.get_theme(request, user) | |
17 |
context[ |
|
26 | context[CONTEXT_THEME] = theme | |
18 |
context[ |
|
27 | context[CONTEXT_THEME_CSS] = 'css/' + theme + '/base_page.css' | |
19 |
|
28 | |||
20 | # This shows the moderator panel |
|
29 | # This shows the moderator panel | |
21 | moderate = user.get_setting(SETTING_MODERATE) |
|
30 | moderate = user.get_setting(SETTING_MODERATE) | |
22 | if moderate == 'True': |
|
31 | if moderate == 'True': | |
23 |
context[ |
|
32 | context[CONTEXT_MODERATOR] = user.is_moderator() | |
24 | else: |
|
33 | else: | |
25 |
context[ |
|
34 | context[CONTEXT_MODERATOR] = False | |
26 |
|
35 | |||
27 |
context[ |
|
36 | context[CONTEXT_VERSION] = settings.VERSION | |
28 |
context[ |
|
37 | context[CONTEXT_SITE_NAME] = settings.SITE_NAME | |
29 |
|
38 | |||
30 | return context No newline at end of file |
|
39 | return context |
@@ -107,7 +107,8 b' class PostForm(NeboardForm):' | |||||
107 | widget=FormatPanel(attrs={ATTRIBUTE_PLACEHOLDER: TEXT_PLACEHOLDER}), |
|
107 | widget=FormatPanel(attrs={ATTRIBUTE_PLACEHOLDER: TEXT_PLACEHOLDER}), | |
108 | required=False, label=LABEL_TEXT) |
|
108 | required=False, label=LABEL_TEXT) | |
109 | image = forms.ImageField(required=False, label=_('Image'), |
|
109 | image = forms.ImageField(required=False, label=_('Image'), | |
110 |
widget=forms.ClearableFileInput( |
|
110 | widget=forms.ClearableFileInput( | |
|
111 | attrs={'accept': 'image/*'})) | |||
111 |
|
112 | |||
112 | # This field is for spam prevention only |
|
113 | # This field is for spam prevention only | |
113 | email = forms.CharField(max_length=100, required=False, label=_('e-mail'), |
|
114 | email = forms.CharField(max_length=100, required=False, label=_('e-mail'), | |
@@ -139,7 +140,7 b' class PostForm(NeboardForm):' | |||||
139 | def clean_image(self): |
|
140 | def clean_image(self): | |
140 | image = self.cleaned_data['image'] |
|
141 | image = self.cleaned_data['image'] | |
141 | if image: |
|
142 | if image: | |
142 |
if image. |
|
143 | if image.size > board_settings.MAX_IMAGE_SIZE: | |
143 | raise forms.ValidationError( |
|
144 | raise forms.ValidationError( | |
144 | _('Image must be less than %s bytes') |
|
145 | _('Image must be less than %s bytes') | |
145 | % str(board_settings.MAX_IMAGE_SIZE)) |
|
146 | % str(board_settings.MAX_IMAGE_SIZE)) |
@@ -1,10 +1,12 b'' | |||||
1 | # coding=utf-8 |
|
1 | # coding=utf-8 | |
2 |
|
2 | |||
3 | import markdown |
|
3 | import markdown | |
4 |
from markdown.inlinepatterns import Pattern |
|
4 | from markdown.inlinepatterns import Pattern | |
5 | from markdown.util import etree |
|
5 | from markdown.util import etree | |
|
6 | ||||
6 | import boards |
|
7 | import boards | |
7 |
|
8 | |||
|
9 | ||||
8 | __author__ = 'neko259' |
|
10 | __author__ = 'neko259' | |
9 |
|
11 | |||
10 |
|
12 | |||
@@ -22,6 +24,9 b' class TextFormatter():' | |||||
22 | An interface for formatter that can be used in the text format panel |
|
24 | An interface for formatter that can be used in the text format panel | |
23 | """ |
|
25 | """ | |
24 |
|
26 | |||
|
27 | def __init__(self): | |||
|
28 | pass | |||
|
29 | ||||
25 | name = '' |
|
30 | name = '' | |
26 |
|
31 | |||
27 | # Left and right tags for the button preview |
|
32 | # Left and right tags for the button preview |
@@ -16,6 +16,9 b' class BanMiddleware:' | |||||
16 | anything |
|
16 | anything | |
17 | """ |
|
17 | """ | |
18 |
|
18 | |||
|
19 | def __init__(self): | |||
|
20 | pass | |||
|
21 | ||||
19 | def process_view(self, request, view_func, view_args, view_kwargs): |
|
22 | def process_view(self, request, view_func, view_args, view_kwargs): | |
20 |
|
23 | |||
21 | if view_func != BannedView.as_view: |
|
24 | if view_func != BannedView.as_view: | |
@@ -36,7 +39,8 b' class MinifyHTMLMiddleware(object):' | |||||
36 | compress_html = False |
|
39 | compress_html = False | |
37 |
|
40 | |||
38 | if RESPONSE_CONTENT_TYPE in response\ |
|
41 | if RESPONSE_CONTENT_TYPE in response\ | |
39 |
and TYPE_HTML in response[RESPONSE_CONTENT_TYPE] |
|
42 | and TYPE_HTML in response[RESPONSE_CONTENT_TYPE]\ | |
|
43 | and compress_html: | |||
40 | response.content = strip_spaces_between_tags( |
|
44 | response.content = strip_spaces_between_tags( | |
41 | response.content.strip()) |
|
45 | response.content.strip()) | |
42 | return response No newline at end of file |
|
46 | return response |
@@ -4,7 +4,10 b' from django.conf import settings' | |||||
4 | import line_profiler |
|
4 | import line_profiler | |
5 |
|
5 | |||
6 |
|
6 | |||
7 |
class ProfilerMiddleware( |
|
7 | class ProfilerMiddleware(): | |
|
8 | def __init__(self): | |||
|
9 | self.profiler = None | |||
|
10 | ||||
8 | def process_view(self, request, callback, callback_args, callback_kwargs): |
|
11 | def process_view(self, request, callback, callback_args, callback_kwargs): | |
9 | if settings.DEBUG and 'prof' in request.GET: |
|
12 | if settings.DEBUG and 'prof' in request.GET: | |
10 | self.profiler = line_profiler.LineProfiler() |
|
13 | self.profiler = line_profiler.LineProfiler() |
@@ -5,6 +5,14 b' from haystack.query import SearchQuerySe' | |||||
5 | from boards.abstracts.paginator import get_paginator |
|
5 | from boards.abstracts.paginator import get_paginator | |
6 | from boards.forms import SearchForm, PlainErrorList |
|
6 | from boards.forms import SearchForm, PlainErrorList | |
7 |
|
7 | |||
|
8 | FORM_QUERY = 'query' | |||
|
9 | ||||
|
10 | CONTEXT_QUERY = 'query' | |||
|
11 | CONTEXT_FORM = 'form' | |||
|
12 | CONTEXT_PAGE = 'page' | |||
|
13 | ||||
|
14 | REQUEST_PAGE = 'page' | |||
|
15 | ||||
8 | __author__ = 'neko259' |
|
16 | __author__ = 'neko259' | |
9 |
|
17 | |||
10 | TEMPLATE = 'search/search.html' |
|
18 | TEMPLATE = 'search/search.html' | |
@@ -14,20 +22,20 b' class BoardSearchView(View):' | |||||
14 | def get(self, request): |
|
22 | def get(self, request): | |
15 | context = RequestContext(request) |
|
23 | context = RequestContext(request) | |
16 | form = SearchForm(request.GET, error_class=PlainErrorList) |
|
24 | form = SearchForm(request.GET, error_class=PlainErrorList) | |
17 |
context[ |
|
25 | context[CONTEXT_FORM] = form | |
18 |
|
26 | |||
19 | if form.is_valid(): |
|
27 | if form.is_valid(): | |
20 |
query = form.cleaned_data[ |
|
28 | query = form.cleaned_data[FORM_QUERY] | |
21 | if len(query) >= 3: |
|
29 | if len(query) >= 3: | |
22 | results = SearchQuerySet().auto_query(query).order_by('-id') \ |
|
30 | results = SearchQuerySet().auto_query(query).order_by('-id') \ | |
23 | .highlight() |
|
31 | .highlight() | |
24 | paginator = get_paginator(results, 10) |
|
32 | paginator = get_paginator(results, 10) | |
25 |
|
33 | |||
26 |
if |
|
34 | if REQUEST_PAGE in request.GET: | |
27 |
page = int(request.GET[ |
|
35 | page = int(request.GET[REQUEST_PAGE]) | |
28 | else: |
|
36 | else: | |
29 | page = 1 |
|
37 | page = 1 | |
30 |
context[ |
|
38 | context[CONTEXT_PAGE] = paginator.page(page) | |
31 |
context[ |
|
39 | context[CONTEXT_QUERY] = query | |
32 |
|
40 | |||
33 | return render(request, TEMPLATE, context) No newline at end of file |
|
41 | return render(request, TEMPLATE, context) |
General Comments 0
You need to be logged in to leave comments.
Login now