Show More
@@ -30,7 +30,6 b" urlpatterns = patterns(''," | |||||
30 |
|
30 | |||
31 | # /boards/thread/ |
|
31 | # /boards/thread/ | |
32 | url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'), |
|
32 | url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'), | |
33 | # /boards/theme/theme_name/ |
|
|||
34 | url(r'^settings/$', views.settings, name='settings'), |
|
33 | url(r'^settings/$', views.settings, name='settings'), | |
35 | url(r'^tags/$', views.all_tags, name='tags'), |
|
34 | url(r'^tags/$', views.all_tags, name='tags'), | |
36 | url(r'^captcha/', include('captcha.urls')), |
|
35 | url(r'^captcha/', include('captcha.urls')), | |
@@ -49,5 +48,9 b" urlpatterns = patterns(''," | |||||
49 | url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/rss/$', TagThreadsFeed()), |
|
48 | url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/rss/$', TagThreadsFeed()), | |
50 | url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()), |
|
49 | url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()), | |
51 |
|
50 | |||
|
51 | # i18n | |||
52 | url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), |
|
52 | url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), | |
|
53 | ||||
|
54 | # API | |||
|
55 | url(r'^get_post/(?P<post_id>\w+)/$', views.get_post, name="get_post"), | |||
53 | ) |
|
56 | ) |
@@ -1,7 +1,9 b'' | |||||
1 | import hashlib |
|
1 | import hashlib | |
2 | import string |
|
2 | import string | |
|
3 | from django.core import serializers | |||
3 | from django.core.urlresolvers import reverse |
|
4 | from django.core.urlresolvers import reverse | |
4 | from django.http import HttpResponseRedirect |
|
5 | from django.http import HttpResponseRedirect | |
|
6 | from django.http.response import HttpResponse | |||
5 | from django.template import RequestContext |
|
7 | from django.template import RequestContext | |
6 | from django.shortcuts import render, redirect, get_object_or_404 |
|
8 | from django.shortcuts import render, redirect, get_object_or_404 | |
7 | from django.utils import timezone |
|
9 | from django.utils import timezone | |
@@ -244,6 +246,8 b' def jump_to_post(request, post_id):' | |||||
244 |
|
246 | |||
245 |
|
247 | |||
246 | def authors(request): |
|
248 | def authors(request): | |
|
249 | """Show authors list""" | |||
|
250 | ||||
247 | context = _init_default_context(request) |
|
251 | context = _init_default_context(request) | |
248 | context['authors'] = boards.authors.authors |
|
252 | context['authors'] = boards.authors.authors | |
249 |
|
253 | |||
@@ -251,6 +255,8 b' def authors(request):' | |||||
251 |
|
255 | |||
252 |
|
256 | |||
253 | def delete(request, post_id): |
|
257 | def delete(request, post_id): | |
|
258 | """Delete post""" | |||
|
259 | ||||
254 | user = _get_user(request) |
|
260 | user = _get_user(request) | |
255 | post = get_object_or_404(Post, id=post_id) |
|
261 | post = get_object_or_404(Post, id=post_id) | |
256 |
|
262 | |||
@@ -265,6 +271,8 b' def delete(request, post_id):' | |||||
265 |
|
271 | |||
266 |
|
272 | |||
267 | def ban(request, post_id): |
|
273 | def ban(request, post_id): | |
|
274 | """Ban user""" | |||
|
275 | ||||
268 | user = _get_user(request) |
|
276 | user = _get_user(request) | |
269 | post = get_object_or_404(Post, id=post_id) |
|
277 | post = get_object_or_404(Post, id=post_id) | |
270 |
|
278 | |||
@@ -276,16 +284,22 b' def ban(request, post_id):' | |||||
276 |
|
284 | |||
277 |
|
285 | |||
278 | def you_are_banned(request): |
|
286 | def you_are_banned(request): | |
|
287 | """Show the page that notifies that user is banned""" | |||
|
288 | ||||
279 | context = _init_default_context(request) |
|
289 | context = _init_default_context(request) | |
280 | return render(request, 'boards/staticpages/banned.html', context) |
|
290 | return render(request, 'boards/staticpages/banned.html', context) | |
281 |
|
291 | |||
282 |
|
292 | |||
283 | def page_404(request): |
|
293 | def page_404(request): | |
|
294 | """Show page 404 (not found error)""" | |||
|
295 | ||||
284 | context = _init_default_context(request) |
|
296 | context = _init_default_context(request) | |
285 | return render(request, 'boards/404.html', context) |
|
297 | return render(request, 'boards/404.html', context) | |
286 |
|
298 | |||
287 |
|
299 | |||
288 | def tag_subscribe(request, tag_name): |
|
300 | def tag_subscribe(request, tag_name): | |
|
301 | """Add tag to favorites""" | |||
|
302 | ||||
289 | user = _get_user(request) |
|
303 | user = _get_user(request) | |
290 | tag = get_object_or_404(Tag, name=tag_name) |
|
304 | tag = get_object_or_404(Tag, name=tag_name) | |
291 |
|
305 | |||
@@ -296,6 +310,8 b' def tag_subscribe(request, tag_name):' | |||||
296 |
|
310 | |||
297 |
|
311 | |||
298 | def tag_unsubscribe(request, tag_name): |
|
312 | def tag_unsubscribe(request, tag_name): | |
|
313 | """Remove tag from favorites""" | |||
|
314 | ||||
299 | user = _get_user(request) |
|
315 | user = _get_user(request) | |
300 | tag = get_object_or_404(Tag, name=tag_name) |
|
316 | tag = get_object_or_404(Tag, name=tag_name) | |
301 |
|
317 | |||
@@ -306,10 +322,29 b' def tag_unsubscribe(request, tag_name):' | |||||
306 |
|
322 | |||
307 |
|
323 | |||
308 | def static_page(request, name): |
|
324 | def static_page(request, name): | |
|
325 | """Show a static page that needs only tags list and a CSS""" | |||
|
326 | ||||
309 | context = _init_default_context(request) |
|
327 | context = _init_default_context(request) | |
310 | return render(request, 'boards/staticpages/' + name + '.html', context) |
|
328 | return render(request, 'boards/staticpages/' + name + '.html', context) | |
311 |
|
329 | |||
312 |
|
330 | |||
|
331 | def get_post(request, post_id): | |||
|
332 | """ | |||
|
333 | Get the JSON of a post. | |||
|
334 | This is used for replies preview and new posts loading. Also this can be | |||
|
335 | used as and API for external clients. | |||
|
336 | """ | |||
|
337 | ||||
|
338 | post = get_object_or_404(Post, id=post_id) | |||
|
339 | ||||
|
340 | json = serializers.serialize("json", [post], fields=( | |||
|
341 | "pub_time", "_text_rendered", "title", "text", "image", | |||
|
342 | "image_width", "image_height", "replies", "tags" | |||
|
343 | )) | |||
|
344 | ||||
|
345 | return HttpResponse(content=json) | |||
|
346 | ||||
|
347 | ||||
313 | def _get_theme(request, user=None): |
|
348 | def _get_theme(request, user=None): | |
314 | """Get user's CSS theme""" |
|
349 | """Get user's CSS theme""" | |
315 |
|
350 |
General Comments 0
You need to be logged in to leave comments.
Login now