diff --git a/boards/static/js/thread.js b/boards/static/js/thread.js --- a/boards/static/js/thread.js +++ b/boards/static/js/thread.js @@ -23,33 +23,6 @@ for the JavaScript code in this page. */ -function addGalleryPanel() { - var gallery = $('a[class="thumb"]').clone(true), - normal = $('.post').clone(true); - - $('.navigation_panel').filter(':first').after( - '
' + - '' + - '' + - '
' - ); - - $('input[name="image-mode"]').change(function() { - //gallery mode - if($(this).val() === '1') { - $('.thread').replaceWith( - $('
').append(gallery) - ); - } - //normal mode - else { - $('#posts-table').replaceWith( - $('
').append(normal) - ); - } - }); -} - function moveCaretToEnd(el) { if (typeof el.selectionStart == "number") { el.selectionStart = el.selectionEnd = el.value.length; @@ -72,10 +45,3 @@ function addQuickReply(postId) { $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow"); } - - - -$(document).ready(function(){ - addGalleryPanel(); - initAutoupdate(); -}); diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -185,4 +185,8 @@ function showNewPostsTitle() { document.removeEventListener('visibilitychange', null); }); } -} \ No newline at end of file +} + +$(document).ready(function(){ + initAutoupdate(); +}); diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -6,7 +6,7 @@ {% load board %} {% block head %} - Neboard - {{ thread.get_replies.0.get_title }} + Neboard - {{ thread.get_opening_post.get_title }} {% endblock %} {% block content %} @@ -17,6 +17,12 @@ {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %} + +
+ {% trans 'Normal mode' %}, + {% trans 'Gallery mode' %} +
+ {% if bumpable %}
diff --git a/boards/templates/boards/thread_gallery.html b/boards/templates/boards/thread_gallery.html new file mode 100644 --- /dev/null +++ b/boards/templates/boards/thread_gallery.html @@ -0,0 +1,58 @@ +{% extends "boards/base.html" %} + +{% load i18n %} +{% load cache %} +{% load static from staticfiles %} +{% load board %} + +{% block head %} + Neboard - {{ thread.get_opening_post.get_title }} +{% endblock %} + +{% block content %} + {% spaceless %} + {% get_current_language as LANGUAGE_CODE %} + + + + {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE %} + + +
+ {% for post in thread.get_replies %} + {% if post.image %} + {{ post.id }} + + {% endif %} + {% endfor %} +
+ {% endcache %} + + {% endspaceless %} +{% endblock %} + +{% block metapanel %} + + {% get_current_language as LANGUAGE_CODE %} + + + {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %} + {{ thread.get_reply_count }} {% trans 'replies' %}, + {{ thread.get_images_count }} {% trans 'images' %}. + {% trans 'Last update: ' %}{{ thread.last_edit_time }} + [RSS] + {% endcache %} + + +{% endblock %} diff --git a/boards/urls.py b/boards/urls.py --- a/boards/urls.py +++ b/boards/urls.py @@ -31,6 +31,7 @@ urlpatterns = patterns('', # /boards/thread/ url(r'^thread/(?P\w+)/$', views.thread, name='thread'), + url(r'^thread/(?P\w+)/(?P\w+)/$', views.thread, name='thread_mode'), url(r'^settings/$', views.settings, name='settings'), url(r'^tags/$', views.all_tags, name='tags'), url(r'^captcha/', include('captcha.urls')), diff --git a/boards/views/__init__.py b/boards/views/__init__.py --- a/boards/views/__init__.py +++ b/boards/views/__init__.py @@ -171,7 +171,7 @@ def tag(request, tag_name, page=0): context) -def thread(request, post_id): +def thread(request, post_id, mode='normal'): """Get all thread posts""" if utils.need_include_captcha(request): @@ -211,7 +211,15 @@ def thread(request, post_id): context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time) context["thread"] = thread_to_show - return render(request, 'boards/thread.html', context) + if 'normal' == mode: + document = 'boards/thread.html' + elif 'gallery' == mode: + document = 'boards/thread_gallery.html' + else: + pass + # TODO raise 404 error + + return render(request, document, context) def login(request):