##// END OF EJS Templates
Added a server-side gallery and mode switcher
neko259 -
r458:8937aaa9 1.5-dev
parent child Browse files
Show More
@@ -0,0 +1,58 b''
1 {% extends "boards/base.html" %}
2
3 {% load i18n %}
4 {% load cache %}
5 {% load static from staticfiles %}
6 {% load board %}
7
8 {% block head %}
9 <title>Neboard - {{ thread.get_opening_post.get_title }}</title>
10 {% endblock %}
11
12 {% block content %}
13 {% spaceless %}
14 {% get_current_language as LANGUAGE_CODE %}
15
16 <script src="{% static 'js/thread.js' %}"></script>
17
18 {% cache 600 thread_gallery_view thread.id thread.last_edit_time LANGUAGE_CODE %}
19 <div class="image-mode-tab">
20 <a href="{% url 'thread' thread.get_opening_post.id %}">{% trans 'Normal mode' %}</a>,
21 <a class="current_page" href="{% url 'thread_mode' thread.get_opening_post.id 'gallery' %}">{% trans 'Gallery mode' %}</a>
22 </div>
23
24 <div id="posts-table">
25 {% for post in thread.get_replies %}
26 {% if post.image %}
27 <a
28 class="thumb"
29 href="{{ post.image.url }}"><img
30 src="{{ post.image.url_200x150 }}"
31 alt="{{ post.id }}"
32 width="{{ post.image_pre_width }}"
33 height="{{ post.image_pre_height }}"
34 data-width="{{ post.image_width }}"
35 data-height="{{ post.image_height }}"/>
36 </a>
37 {% endif %}
38 {% endfor %}
39 </div>
40 {% endcache %}
41
42 {% endspaceless %}
43 {% endblock %}
44
45 {% block metapanel %}
46
47 {% get_current_language as LANGUAGE_CODE %}
48
49 <span class="metapanel" data-last-update="{{ last_update }}">
50 {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %}
51 <span id="reply-count">{{ thread.get_reply_count }}</span> {% trans 'replies' %},
52 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
53 {% trans 'Last update: ' %}{{ thread.last_edit_time }}
54 [<a href="rss/">RSS</a>]
55 {% endcache %}
56 </span>
57
58 {% endblock %}
@@ -23,33 +23,6 b''
23 for the JavaScript code in this page.
23 for the JavaScript code in this page.
24 */
24 */
25
25
26 function addGalleryPanel() {
27 var gallery = $('a[class="thumb"]').clone(true),
28 normal = $('.post').clone(true);
29
30 $('.navigation_panel').filter(':first').after(
31 '<div class="image-mode-tab" role="radiogroup" aria-label="Image mode2">' +
32 '<label><input type="radio" class="image-mode-normal" name="image-mode" value="0" checked="checked"/>'+ gettext('Normal') +'</label>' +
33 '<label><input type="radio" class="image-mode-table" name="image-mode" value="1"/>'+ gettext('Gallery') +'</label>' +
34 '</div>'
35 );
36
37 $('input[name="image-mode"]').change(function() {
38 //gallery mode
39 if($(this).val() === '1') {
40 $('.thread').replaceWith(
41 $('<div id="posts-table"></div>').append(gallery)
42 );
43 }
44 //normal mode
45 else {
46 $('#posts-table').replaceWith(
47 $('<div class="thread"></div>').append(normal)
48 );
49 }
50 });
51 }
52
53 function moveCaretToEnd(el) {
26 function moveCaretToEnd(el) {
54 if (typeof el.selectionStart == "number") {
27 if (typeof el.selectionStart == "number") {
55 el.selectionStart = el.selectionEnd = el.value.length;
28 el.selectionStart = el.selectionEnd = el.value.length;
@@ -72,10 +45,3 b' function addQuickReply(postId) {'
72
45
73 $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow");
46 $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow");
74 }
47 }
75
76
77
78 $(document).ready(function(){
79 addGalleryPanel();
80 initAutoupdate();
81 });
@@ -185,4 +185,8 b' function showNewPostsTitle() {'
185 document.removeEventListener('visibilitychange', null);
185 document.removeEventListener('visibilitychange', null);
186 });
186 });
187 }
187 }
188 } No newline at end of file
188 }
189
190 $(document).ready(function(){
191 initAutoupdate();
192 });
@@ -6,7 +6,7 b''
6 {% load board %}
6 {% load board %}
7
7
8 {% block head %}
8 {% block head %}
9 <title>Neboard - {{ thread.get_replies.0.get_title }}</title>
9 <title>Neboard - {{ thread.get_opening_post.get_title }}</title>
10 {% endblock %}
10 {% endblock %}
11
11
12 {% block content %}
12 {% block content %}
@@ -17,6 +17,12 b''
17 <script src="{% static 'js/thread.js' %}"></script>
17 <script src="{% static 'js/thread.js' %}"></script>
18
18
19 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
19 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
20
21 <div class="image-mode-tab">
22 <a class="current_page" href="{% url 'thread' thread.get_opening_post.id %}">{% trans 'Normal mode' %}</a>,
23 <a href="{% url 'thread_mode' thread.get_opening_post.id 'gallery' %}">{% trans 'Gallery mode' %}</a>
24 </div>
25
20 {% if bumpable %}
26 {% if bumpable %}
21 <div class="bar-bg">
27 <div class="bar-bg">
22 <div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
28 <div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
@@ -31,6 +31,7 b" urlpatterns = patterns('',"
31
31
32 # /boards/thread/
32 # /boards/thread/
33 url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'),
33 url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'),
34 url(r'^thread/(?P<post_id>\w+)/(?P<mode>\w+)/$', views.thread, name='thread_mode'),
34 url(r'^settings/$', views.settings, name='settings'),
35 url(r'^settings/$', views.settings, name='settings'),
35 url(r'^tags/$', views.all_tags, name='tags'),
36 url(r'^tags/$', views.all_tags, name='tags'),
36 url(r'^captcha/', include('captcha.urls')),
37 url(r'^captcha/', include('captcha.urls')),
@@ -171,7 +171,7 b' def tag(request, tag_name, page=0):'
171 context)
171 context)
172
172
173
173
174 def thread(request, post_id):
174 def thread(request, post_id, mode='normal'):
175 """Get all thread posts"""
175 """Get all thread posts"""
176
176
177 if utils.need_include_captcha(request):
177 if utils.need_include_captcha(request):
@@ -211,7 +211,15 b' def thread(request, post_id):'
211 context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time)
211 context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time)
212 context["thread"] = thread_to_show
212 context["thread"] = thread_to_show
213
213
214 return render(request, 'boards/thread.html', context)
214 if 'normal' == mode:
215 document = 'boards/thread.html'
216 elif 'gallery' == mode:
217 document = 'boards/thread_gallery.html'
218 else:
219 pass
220 # TODO raise 404 error
221
222 return render(request, document, context)
215
223
216
224
217 def login(request):
225 def login(request):
General Comments 0
You need to be logged in to leave comments. Login now