##// END OF EJS Templates
Added metadata to the gallery. Added links to search the image by the online search engines
neko259 -
r460:dce9cedd 1.5-dev
parent child Browse files
Show More
@@ -27,3 +27,7 b''
27 z-index: 300;
27 z-index: 300;
28 position:absolute;
28 position:absolute;
29 }
29 }
30
31 .gallery_image {
32 display: inline-block;
33 } No newline at end of file
@@ -358,4 +358,11 b' li {'
358 .current_page, .current_mode {
358 .current_page, .current_mode {
359 border: solid 1px #afdcec;
359 border: solid 1px #afdcec;
360 padding: 2px;
360 padding: 2px;
361 }
362
363 .gallery_image {
364 border: solid 1px;
365 padding: 0.5ex;
366 margin: 0.5ex;
367 text-align: center;
361 } No newline at end of file
368 }
@@ -350,4 +350,8 b' li {'
350 padding: 0 .5ex 0 0;
350 padding: 0 .5ex 0 0;
351 color: #182F6F;
351 color: #182F6F;
352 background: #FFF;
352 background: #FFF;
353 }
354
355 .gallery_image_metadata {
356 margin-bottom: 1em;
353 } No newline at end of file
357 }
@@ -24,16 +24,24 b''
24 <div id="posts-table">
24 <div id="posts-table">
25 {% for post in thread.get_replies %}
25 {% for post in thread.get_replies %}
26 {% if post.image %}
26 {% if post.image %}
27 <a
27 <div class="gallery_image">
28 class="thumb"
28 <div>
29 href="{{ post.image.url }}"><img
29 <a
30 src="{{ post.image.url_200x150 }}"
30 class="thumb"
31 alt="{{ post.id }}"
31 href="{{ post.image.url }}"><img
32 width="{{ post.image_pre_width }}"
32 src="{{ post.image.url_200x150 }}"
33 height="{{ post.image_pre_height }}"
33 alt="{{ post.id }}"
34 data-width="{{ post.image_width }}"
34 width="{{ post.image_pre_width }}"
35 data-height="{{ post.image_height }}"/>
35 height="{{ post.image_pre_height }}"
36 </a>
36 data-width="{{ post.image_width }}"
37 data-height="{{ post.image_height }}"/>
38 </a>
39 </div>
40 <div class="gallery_image_metadata">
41 {{ post.image_width }}x{{ post.image_height }}
42 {% image_actions post.image.url request.get_host %}
43 </div>
44 </div>
37 {% endif %}
45 {% endif %}
38 {% endfor %}
46 {% endfor %}
39 </div>
47 </div>
@@ -6,6 +6,17 b' from django import template'
6
6
7 register = template.Library()
7 register = template.Library()
8
8
9 actions = [
10 {
11 'name': 'google',
12 'link': 'http://google.com/searchbyimage?image_url=%s',
13 },
14 {
15 'name': 'iqdb',
16 'link': 'http://iqdb.org/?url=%s',
17 },
18 ]
19
9
20
10 @register.simple_tag(name='post_url')
21 @register.simple_tag(name='post_url')
11 def post_url(*args, **kwargs):
22 def post_url(*args, **kwargs):
@@ -21,3 +32,18 b' def post_url(*args, **kwargs):'
21 link = reverse(thread, kwargs={'post_id': post_id})
32 link = reverse(thread, kwargs={'post_id': post_id})
22
33
23 return link
34 return link
35
36
37 @register.simple_tag(name='image_actions')
38 def image_actions(*args, **kwargs):
39 image_link = args[0]
40 if len(args) > 1:
41 image_link = 'http://' + args[1] + image_link # TODO https?
42
43 result = ''
44
45 for action in actions:
46 result += '[<a href="' + action['link'] % image_link + '">' + \
47 action['name'] + '</a>]'
48
49 return result
@@ -7,7 +7,7 b' import re'
7
7
8 from django.core import serializers
8 from django.core import serializers
9 from django.core.urlresolvers import reverse
9 from django.core.urlresolvers import reverse
10 from django.http import HttpResponseRedirect
10 from django.http import HttpResponseRedirect, Http404
11 from django.http.response import HttpResponse
11 from django.http.response import HttpResponse
12 from django.template import RequestContext
12 from django.template import RequestContext
13 from django.shortcuts import render, redirect, get_object_or_404
13 from django.shortcuts import render, redirect, get_object_or_404
@@ -30,6 +30,8 b' import neboard'
30
30
31
31
32 BAN_REASON_SPAM = 'Autoban: spam bot'
32 BAN_REASON_SPAM = 'Autoban: spam bot'
33 MODE_GALLERY = 'gallery'
34 MODE_NORMAL = 'normal'
33
35
34
36
35 def index(request, page=0):
37 def index(request, page=0):
@@ -171,7 +173,7 b' def tag(request, tag_name, page=0):'
171 context)
173 context)
172
174
173
175
174 def thread(request, post_id, mode='normal'):
176 def thread(request, post_id, mode=MODE_NORMAL):
175 """Get all thread posts"""
177 """Get all thread posts"""
176
178
177 if utils.need_include_captcha(request):
179 if utils.need_include_captcha(request):
@@ -211,13 +213,12 b" def thread(request, post_id, mode='norma"
211 context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time)
213 context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time)
212 context["thread"] = thread_to_show
214 context["thread"] = thread_to_show
213
215
214 if 'normal' == mode:
216 if MODE_NORMAL == mode:
215 document = 'boards/thread.html'
217 document = 'boards/thread.html'
216 elif 'gallery' == mode:
218 elif MODE_GALLERY == mode:
217 document = 'boards/thread_gallery.html'
219 document = 'boards/thread_gallery.html'
218 else:
220 else:
219 pass
221 raise Http404
220 # TODO raise 404 error
221
222
222 return render(request, document, context)
223 return render(request, document, context)
223
224
General Comments 0
You need to be logged in to leave comments. Login now