##// 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 27 z-index: 300;
28 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 358 .current_page, .current_mode {
359 359 border: solid 1px #afdcec;
360 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 368 } No newline at end of file
@@ -350,4 +350,8 b' li {'
350 350 padding: 0 .5ex 0 0;
351 351 color: #182F6F;
352 352 background: #FFF;
353 }
354
355 .gallery_image_metadata {
356 margin-bottom: 1em;
353 357 } No newline at end of file
@@ -24,16 +24,24 b''
24 24 <div id="posts-table">
25 25 {% for post in thread.get_replies %}
26 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>
27 <div class="gallery_image">
28 <div>
29 <a
30 class="thumb"
31 href="{{ post.image.url }}"><img
32 src="{{ post.image.url_200x150 }}"
33 alt="{{ post.id }}"
34 width="{{ post.image_pre_width }}"
35 height="{{ post.image_pre_height }}"
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 45 {% endif %}
38 46 {% endfor %}
39 47 </div>
@@ -6,6 +6,17 b' from django import template'
6 6
7 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 21 @register.simple_tag(name='post_url')
11 22 def post_url(*args, **kwargs):
@@ -21,3 +32,18 b' def post_url(*args, **kwargs):'
21 32 link = reverse(thread, kwargs={'post_id': post_id})
22 33
23 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 8 from django.core import serializers
9 9 from django.core.urlresolvers import reverse
10 from django.http import HttpResponseRedirect
10 from django.http import HttpResponseRedirect, Http404
11 11 from django.http.response import HttpResponse
12 12 from django.template import RequestContext
13 13 from django.shortcuts import render, redirect, get_object_or_404
@@ -30,6 +30,8 b' import neboard'
30 30
31 31
32 32 BAN_REASON_SPAM = 'Autoban: spam bot'
33 MODE_GALLERY = 'gallery'
34 MODE_NORMAL = 'normal'
33 35
34 36
35 37 def index(request, page=0):
@@ -171,7 +173,7 b' def tag(request, tag_name, page=0):'
171 173 context)
172 174
173 175
174 def thread(request, post_id, mode='normal'):
176 def thread(request, post_id, mode=MODE_NORMAL):
175 177 """Get all thread posts"""
176 178
177 179 if utils.need_include_captcha(request):
@@ -211,13 +213,12 b" def thread(request, post_id, mode='norma"
211 213 context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time)
212 214 context["thread"] = thread_to_show
213 215
214 if 'normal' == mode:
216 if MODE_NORMAL == mode:
215 217 document = 'boards/thread.html'
216 elif 'gallery' == mode:
218 elif MODE_GALLERY == mode:
217 219 document = 'boards/thread_gallery.html'
218 220 else:
219 pass
220 # TODO raise 404 error
221 raise Http404
221 222
222 223 return render(request, document, context)
223 224
General Comments 0
You need to be logged in to leave comments. Login now