##// END OF EJS Templates
Added error 404 page
neko259 -
r130:2cca92a8 default
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,182 +1,189 b''
1 1 # SOME DESCRIPTIVE TITLE.
2 2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3 3 # This file is distributed under the same license as the PACKAGE package.
4 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 5 #
6 6 msgid ""
7 7 msgstr ""
8 8 "Project-Id-Version: PACKAGE VERSION\n"
9 9 "Report-Msgid-Bugs-To: \n"
10 "POT-Creation-Date: 2013-08-27 23:51+0300\n"
10 "POT-Creation-Date: 2013-08-30 18:54+0300\n"
11 11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 13 "Language-Team: LANGUAGE <LL@li.org>\n"
14 14 "Language: ru\n"
15 15 "MIME-Version: 1.0\n"
16 16 "Content-Type: text/plain; charset=UTF-8\n"
17 17 "Content-Transfer-Encoding: 8bit\n"
18 18 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
19 19 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
20 20
21 #: templates/boards/404.html:6
22 msgid "Not found"
23 msgstr "Не найдено"
24
25 #: templates/boards/404.html:12
26 msgid "This page does not exist"
27 msgstr "Этой страницы не существует"
28
21 29 #: templates/boards/authors.html:6
22 30 msgid "Authors"
23 31 msgstr "Авторы"
24 32
25 33 #: templates/boards/authors.html:24
26 34 msgid "Distributed under the"
27 35 msgstr "Распространяется под"
28 36
29 37 #: templates/boards/authors.html:26
30 38 msgid "license"
31 39 msgstr "лицензией"
32 40
33 41 #: templates/boards/authors.html:28
34 42 msgid "Repository"
35 43 msgstr "Репозиторий"
36 44
37 45 #: templates/boards/banned.html:6
38 46 msgid "Banned"
39 msgstr ""
47 msgstr "Заблокирован"
40 48
41 49 #: templates/boards/banned.html:11
42 50 msgid "Your IP address has been banned. Contact the administrator"
43 msgstr ""
51 msgstr "Ваш IP адрес был заблокирован. Свяжитесь с администратором"
44 52
45 53 #: templates/boards/base.html:12
46 54 msgid "Feed"
47 55 msgstr "Лента"
48 56
49 #: templates/boards/base.html:35
57 #: templates/boards/base.html:36
50 58 msgid "All threads"
51 59 msgstr "Все темы"
52 60
53 #: templates/boards/base.html:41
61 #: templates/boards/base.html:42
54 62 msgid "Settings"
55 63 msgstr "Настройки"
56 64
57 #: templates/boards/base.html:49
65 #: templates/boards/base.html:50
58 66 msgid "Up"
59 67 msgstr "Вверх"
60 68
61 69 #: templates/boards/posting_general.html:18
62 70 msgid "Tag: "
63 71 msgstr "Тег: "
64 72
65 73 #: templates/boards/posting_general.html:35
66 #: templates/boards/posting_general.html:79 templates/boards/thread.html:27
74 #: templates/boards/posting_general.html:81 templates/boards/thread.html:27
67 75 #: templates/boards/rss/post.html:5
68 76 msgid "Post image"
69 77 msgstr "Изображение сообщения"
70 78
71 #: templates/boards/posting_general.html:46
79 #: templates/boards/posting_general.html:48
72 80 msgid "Reply"
73 81 msgstr "Ответ"
74 82
75 #: templates/boards/posting_general.html:53 templates/boards/thread.html:111
83 #: templates/boards/posting_general.html:55 templates/boards/thread.html:108
76 84 msgid "replies"
77 85 msgstr "ответов"
78 86
79 #: templates/boards/posting_general.html:54 templates/boards/thread.html:112
87 #: templates/boards/posting_general.html:56 templates/boards/thread.html:109
80 88 msgid "images"
81 89 msgstr "изображений"
82 90
83 #: templates/boards/posting_general.html:56
84 #: templates/boards/posting_general.html:127 templates/boards/thread.html:51
91 #: templates/boards/posting_general.html:58
92 #: templates/boards/posting_general.html:131 templates/boards/thread.html:48
85 93 #: templates/boards/rss/post.html:10
86 94 msgid "Tags"
87 95 msgstr "Теги"
88 96
89 #: templates/boards/posting_general.html:109
97 #: templates/boards/posting_general.html:113
90 98 msgid "Create new thread"
91 99 msgstr "Создать новую тему"
92 100
93 #: templates/boards/posting_general.html:112 templates/boards/thread.html:73
101 #: templates/boards/posting_general.html:116 templates/boards/thread.html:70
94 102 msgid "Title"
95 103 msgstr "Заголовок"
96 104
97 #: templates/boards/posting_general.html:117 templates/boards/thread.html:78
105 #: templates/boards/posting_general.html:121 templates/boards/thread.html:75
98 106 msgid "Text"
99 107 msgstr "Текст"
100 108
101 #: templates/boards/posting_general.html:122 templates/boards/thread.html:83
109 #: templates/boards/posting_general.html:126 templates/boards/thread.html:80
102 110 msgid "Image"
103 111 msgstr "Изображение"
104 112
105 #: templates/boards/posting_general.html:137 templates/boards/thread.html:94
113 #: templates/boards/posting_general.html:141 templates/boards/thread.html:91
106 114 msgid "Post"
107 115 msgstr "Отправить"
108 116
109 #: templates/boards/posting_general.html:139
117 #: templates/boards/posting_general.html:143
110 118 msgid "Tags must be delimited by spaces. Text or image is required."
111 119 msgstr ""
112 120 "Теги должны быть разделены пробелами. Текст или изображение обязательны."
113 121
114 #: templates/boards/posting_general.html:142 templates/boards/thread.html:96
122 #: templates/boards/posting_general.html:146 templates/boards/thread.html:93
115 123 msgid "Basic markdown syntax."
116 124 msgstr "Базовый синтаксис markdown."
117 125
118 #: templates/boards/posting_general.html:152
126 #: templates/boards/posting_general.html:156
119 127 msgid "Pages:"
120 128 msgstr "Страницы: "
121 129
122 130 #: templates/boards/settings.html:13
123 131 msgid "Theme"
124 132 msgstr "Тема"
125 133
126 134 #: templates/boards/settings.html:29
127 135 msgid "Save"
128 136 msgstr "Сохранить"
129 137
130 138 #: templates/boards/tags.html:7
131 139 msgid "tags"
132 140 msgstr "тегов"
133 141
134 #: templates/boards/thread.html:39
135 msgid "Get!"
136 msgstr "Гет!"
137
138 #: templates/boards/thread.html:70
142 #: templates/boards/thread.html:67
139 143 msgid "Reply to thread"
140 144 msgstr "Ответить в тему"
141 145
142 #: templates/boards/thread.html:97
146 #: templates/boards/thread.html:94
143 147 msgid "Example: "
144 148 msgstr "Пример: "
145 149
146 #: templates/boards/thread.html:97
150 #: templates/boards/thread.html:94
147 151 msgid "italic"
148 152 msgstr "курсив"
149 153
150 #: templates/boards/thread.html:98
154 #: templates/boards/thread.html:95
151 155 msgid "bold"
152 156 msgstr "полужирный"
153 157
154 #: templates/boards/thread.html:99
158 #: templates/boards/thread.html:96
155 159 msgid "Quotes can be inserted with"
156 160 msgstr "Цитаты могут быть вставлены при помощи"
157 161
158 #: templates/boards/thread.html:100
162 #: templates/boards/thread.html:97
159 163 msgid "Links to answers can be inserted with"
160 164 msgstr "Ссылки на ответы могут быть вставлены с помощью"
161 165
162 #: templates/boards/thread.html:113
166 #: templates/boards/thread.html:110
163 167 msgid "Last update: "
164 168 msgstr "Последнее обновление: "
165 169
170 #~ msgid "Get!"
171 #~ msgstr "Гет!"
172
166 173 #~ msgid "View"
167 174 #~ msgstr "Просмотр"
168 175
169 176 #~ msgid "gets"
170 177 #~ msgstr "гетов"
171 178
172 179 #~ msgid "author"
173 180 #~ msgstr "автор"
174 181
175 182 #~ msgid "developer"
176 183 #~ msgstr "разработчик"
177 184
178 185 #~ msgid "javascript developer"
179 186 #~ msgstr "разработчик javascript"
180 187
181 188 #~ msgid "designer"
182 189 #~ msgstr "дизайнер"
@@ -1,30 +1,14 b''
1 1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4
5 5 {% block head %}
6 <title>{% trans "Authors" %}</title>
6 <title>{% trans "Not found" %}</title>
7 7 {% endblock %}
8 8
9 9 {% block content %}
10 10 <div class="post">
11 <h2>Authors</h2>
12 {% for nick, values in authors.items %}
13 <p>
14 <b>{{ nick }}</b> ({{ values.name }}):
15 {% for value in values.contacts %}
16 <a href="mailto:{{ value }}">{{ value }}</a>
17 {% endfor %} -
18 {% for role in values.roles %}
19 {% trans role %}
20 {% endfor %}
21 </p>
22 {% endfor %}
23 <br />
24 <p>{% trans "Distributed under the" %}
25 <a href="http://www.gnu.org/licenses/gpl.html" >GNU GPLv3</a>
26 {% trans "license" %}</p>
27 <p><a href="https://bitbucket.org/neko259/neboard">
28 {% trans "Repository" %}</a></p>
11 <p><img src="{{ STATIC_URL }}images/404.png" width="200" /></p>
12 <p>{% trans 'This page does not exist' %}</p>
29 13 </div>
30 14 {% endblock %} No newline at end of file
@@ -1,256 +1,261 b''
1 1 from django.core.urlresolvers import reverse
2 2 from django.template import RequestContext
3 3 from django.shortcuts import render, redirect, get_object_or_404
4 4 from django.http import HttpResponseRedirect
5 5
6 6 from boards import forms
7 7 import boards
8 8 from boards import utils
9 9 from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \
10 10 ThreadCaptchaForm, PostCaptchaForm
11 11
12 12 from boards.models import Post, Admin, Tag, Ban
13 13 from boards import authors
14 14 import neboard
15 15
16 16
17 17 def index(request, page=0):
18 18 context = _init_default_context(request)
19 19
20 20 if utils.need_include_captcha(request):
21 21 threadFormClass = ThreadCaptchaForm
22 22 kwargs = {'request': request}
23 23 else:
24 24 threadFormClass = ThreadForm
25 25 kwargs = {}
26 26
27 27 if request.method == 'POST':
28 28 form = threadFormClass(request.POST, request.FILES,
29 29 error_class=PlainErrorList, **kwargs)
30 30
31 31 if form.is_valid():
32 32 return _new_post(request, form)
33 33 else:
34 34 form = threadFormClass(error_class=PlainErrorList, **kwargs)
35 35
36 36 threads = Post.objects.get_threads(page=int(page))
37 37
38 38 context['threads'] = None if len(threads) == 0 else threads
39 39 context['form'] = form
40 40 context['pages'] = range(Post.objects.get_thread_page_count())
41 41
42 42 return render(request, 'boards/posting_general.html',
43 43 context)
44 44
45 45
46 46 def _new_post(request, form, thread_id=boards.models.NO_PARENT):
47 47 """Add a new post (in thread or as a reply)."""
48 48
49 49 ip = _get_client_ip(request)
50 50 is_banned = Ban.objects.filter(ip=ip).count() > 0
51 51
52 52 if is_banned:
53 53 return redirect(you_are_banned)
54 54
55 55 data = form.cleaned_data
56 56
57 57 title = data['title']
58 58 text = data['text']
59 59
60 60 if 'image' in data.keys():
61 61 image = data['image']
62 62 else:
63 63 image = None
64 64
65 65 tags = []
66 66
67 67 new_thread = thread_id == boards.models.NO_PARENT
68 68 if new_thread:
69 69 tag_strings = data['tags']
70 70
71 71 if tag_strings:
72 72 tag_strings = tag_strings.split(' ')
73 73 for tag_name in tag_strings:
74 74 tag_name = tag_name.strip()
75 75 if len(tag_name) > 0:
76 76 tag, created = Tag.objects.get_or_create(name=tag_name)
77 77 tags.append(tag)
78 78
79 79 # TODO Add a possibility to define a link image instead of an image file.
80 80 # If a link is given, download the image automatically.
81 81
82 82 post = Post.objects.create_post(title=title, text=text, ip=ip,
83 83 parent_id=thread_id, image=image,
84 84 tags=tags)
85 85
86 86 thread_to_show = (post.id if new_thread else thread_id)
87 87
88 88 if new_thread:
89 89 return redirect(thread, post_id=thread_to_show)
90 90 else:
91 91 return redirect(reverse(thread,
92 92 kwargs={'post_id': thread_to_show}) + '#'
93 93 + str(post.id))
94 94
95 95
96 96 def tag(request, tag_name, page=0):
97 97 """Get all tag threads (posts without a parent)."""
98 98
99 99 tag = get_object_or_404(Tag, name=tag_name)
100 100 threads = Post.objects.get_threads(tag=tag, page=int(page))
101 101
102 102 if request.method == 'POST':
103 103 form = ThreadForm(request.POST, request.FILES,
104 104 error_class=PlainErrorList)
105 105 if form.is_valid():
106 106 return _new_post(request, form)
107 107 else:
108 108 form = forms.ThreadForm(initial={'tags': tag_name},
109 109 error_class=PlainErrorList)
110 110
111 111 context = _init_default_context(request)
112 112 context['threads'] = None if len(threads) == 0 else threads
113 113 context['tag'] = tag_name
114 114 context['pages'] = range(Post.objects.get_thread_page_count(tag=tag))
115 115
116 116 context['form'] = form
117 117
118 118 return render(request, 'boards/posting_general.html',
119 119 context)
120 120
121 121
122 122 def thread(request, post_id):
123 123 """Get all thread posts"""
124 124
125 125 if utils.need_include_captcha(request):
126 126 postFormClass = PostCaptchaForm
127 127 kwargs = {'request': request}
128 128 else:
129 129 postFormClass = PostForm
130 130 kwargs = {}
131 131
132 132 if request.method == 'POST':
133 133 form = postFormClass(request.POST, request.FILES,
134 134 error_class=PlainErrorList, **kwargs)
135 135 if form.is_valid():
136 136 return _new_post(request, form, post_id)
137 137 else:
138 138 form = postFormClass(error_class=PlainErrorList, **kwargs)
139 139
140 140 posts = Post.objects.get_thread(post_id)
141 141
142 142 context = _init_default_context(request)
143 143
144 144 context['posts'] = posts
145 145 context['form'] = form
146 146
147 147 return render(request, 'boards/thread.html', context)
148 148
149 149
150 150 def login(request):
151 151 """Log in as admin"""
152 152
153 153 if 'name' in request.POST and 'password' in request.POST:
154 154 request.session['admin'] = False
155 155
156 156 isAdmin = len(Admin.objects.filter(name=request.POST['name'],
157 157 password=request.POST[
158 158 'password'])) > 0
159 159
160 160 if isAdmin:
161 161 request.session['admin'] = True
162 162
163 163 response = HttpResponseRedirect('/')
164 164
165 165 else:
166 166 response = render(request, 'boards/login.html', {'error': 'Login error'})
167 167 else:
168 168 response = render(request, 'boards/login.html', {})
169 169
170 170 return response
171 171
172 172
173 173 def logout(request):
174 174 request.session['admin'] = False
175 175 return HttpResponseRedirect('/')
176 176
177 177
178 178 def settings(request):
179 179 """User's settings"""
180 180
181 181 context = RequestContext(request)
182 182
183 183 if request.method == 'POST':
184 184 form = SettingsForm(request.POST)
185 185 if form.is_valid():
186 186 selected_theme = form.cleaned_data['theme']
187 187 request.session['theme'] = selected_theme
188 188
189 189 return redirect(settings)
190 190 else:
191 191 selected_theme = _get_theme(request)
192 192 form = SettingsForm(initial={'theme': selected_theme})
193 193 context['form'] = form
194 194 context['tags'] = Tag.objects.get_popular_tags()
195 195 context['theme'] = _get_theme(request)
196 196
197 197 return render(request, 'boards/settings.html', context)
198 198
199 199
200 200 def all_tags(request):
201 201 """All tags list"""
202 202
203 203 context = _init_default_context(request)
204 204 context['all_tags'] = Tag.objects.get_not_empty_tags()
205 205
206 206 return render(request, 'boards/tags.html', context)
207 207
208 208
209 209 def jump_to_post(request, post_id):
210 210 """Determine thread in which the requested post is and open it's page"""
211 211
212 212 post = get_object_or_404(Post, id=post_id)
213 213
214 214 if boards.models.NO_PARENT == post.parent:
215 215 return redirect(thread, post_id=post.id)
216 216 else:
217 217 parent_thread = get_object_or_404(Post, id=post.parent)
218 218 return redirect(reverse(thread, kwargs={'post_id': parent_thread.id})
219 219 + '#' + str(post.id))
220 220
221 221
222 222 def authors(request):
223 223 context = _init_default_context(request)
224 224 context['authors'] = boards.authors.authors
225 225
226 226 return render(request, 'boards/authors.html', context)
227 227
228 228
229 229 def you_are_banned(request):
230 230 context = _init_default_context(request)
231 231 return render(request, 'boards/banned.html', context)
232 232
233 233
234 def page_404(request):
235 context = _init_default_context(request)
236 return render(request, 'boards/404.html', context)
237
238
234 239 def _get_theme(request):
235 240 """Get user's CSS theme"""
236 241
237 242 return request.session.get('theme', neboard.settings.DEFAULT_THEME)
238 243
239 244
240 245 def _get_client_ip(request):
241 246 x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
242 247 if x_forwarded_for:
243 248 ip = x_forwarded_for.split(',')[-1].strip()
244 249 else:
245 250 ip = request.META.get('REMOTE_ADDR')
246 251 return ip
247 252
248 253
249 254 def _init_default_context(request):
250 255 """Create context with default values that are used in most views"""
251 256
252 257 context = RequestContext(request)
253 258 context['tags'] = Tag.objects.get_popular_tags()
254 259 context['theme'] = _get_theme(request)
255 260
256 261 return context
@@ -1,23 +1,23 b''
1 1 from django.conf.urls import patterns, include, url
2 2
3 3 # Uncomment the next two lines to enable the admin:
4 4 from django.conf.urls.static import static
5 5 from django.contrib import admin
6 6 from neboard import settings
7 7
8 8 admin.autodiscover()
9 9
10 10 urlpatterns = patterns('',
11 11 # Examples:
12 12 # url(r'^$', 'neboard.views.home', name='home'),
13 13 # url(r'^neboard/', include('neboard.foo.urls')),
14 14
15 15 # Uncomment the admin/doc line below to enable admin documentation:
16 16 # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
17 17
18 18 # Uncomment the next line to enable the admin:
19 19 url(r'^admin/', include(admin.site.urls)),
20 20 url(r'^', include('boards.urls')),
21 21 ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
22 22
23
23 handler404 = 'boards.views.page_404'
General Comments 0
You need to be logged in to leave comments. Login now