diff --git a/boards/static/css/base.css b/boards/static/css/base.css --- a/boards/static/css/base.css +++ b/boards/static/css/base.css @@ -27,3 +27,7 @@ z-index: 300; position:absolute; } + +.gallery_image { + display: inline-block; +} \ No newline at end of file diff --git a/boards/static/css/md/base_page.css b/boards/static/css/md/base_page.css --- a/boards/static/css/md/base_page.css +++ b/boards/static/css/md/base_page.css @@ -358,4 +358,11 @@ li { .current_page, .current_mode { border: solid 1px #afdcec; padding: 2px; +} + +.gallery_image { + border: solid 1px; + padding: 0.5ex; + margin: 0.5ex; + text-align: center; } \ No newline at end of file diff --git a/boards/static/css/sw/base_page.css b/boards/static/css/sw/base_page.css --- a/boards/static/css/sw/base_page.css +++ b/boards/static/css/sw/base_page.css @@ -350,4 +350,8 @@ li { padding: 0 .5ex 0 0; color: #182F6F; background: #FFF; +} + +.gallery_image_metadata { + margin-bottom: 1em; } \ No newline at end of file diff --git a/boards/templates/boards/thread_gallery.html b/boards/templates/boards/thread_gallery.html --- a/boards/templates/boards/thread_gallery.html +++ b/boards/templates/boards/thread_gallery.html @@ -24,16 +24,24 @@
{% for post in thread.get_replies %} {% if post.image %} - {{ post.id }} - + {% endif %} {% endfor %}
diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py --- a/boards/templatetags/board.py +++ b/boards/templatetags/board.py @@ -6,6 +6,17 @@ from django import template register = template.Library() +actions = [ + { + 'name': 'google', + 'link': 'http://google.com/searchbyimage?image_url=%s', + }, + { + 'name': 'iqdb', + 'link': 'http://iqdb.org/?url=%s', + }, +] + @register.simple_tag(name='post_url') def post_url(*args, **kwargs): @@ -21,3 +32,18 @@ def post_url(*args, **kwargs): link = reverse(thread, kwargs={'post_id': post_id}) return link + + +@register.simple_tag(name='image_actions') +def image_actions(*args, **kwargs): + image_link = args[0] + if len(args) > 1: + image_link = 'http://' + args[1] + image_link # TODO https? + + result = '' + + for action in actions: + result += '[' + \ + action['name'] + ']' + + return result diff --git a/boards/views/__init__.py b/boards/views/__init__.py --- a/boards/views/__init__.py +++ b/boards/views/__init__.py @@ -7,7 +7,7 @@ import re from django.core import serializers from django.core.urlresolvers import reverse -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, Http404 from django.http.response import HttpResponse from django.template import RequestContext from django.shortcuts import render, redirect, get_object_or_404 @@ -30,6 +30,8 @@ import neboard BAN_REASON_SPAM = 'Autoban: spam bot' +MODE_GALLERY = 'gallery' +MODE_NORMAL = 'normal' def index(request, page=0): @@ -171,7 +173,7 @@ def tag(request, tag_name, page=0): context) -def thread(request, post_id, mode='normal'): +def thread(request, post_id, mode=MODE_NORMAL): """Get all thread posts""" if utils.need_include_captcha(request): @@ -211,13 +213,12 @@ def thread(request, post_id, mode='norma context["last_update"] = _datetime_to_epoch(thread_to_show.last_edit_time) context["thread"] = thread_to_show - if 'normal' == mode: + if MODE_NORMAL == mode: document = 'boards/thread.html' - elif 'gallery' == mode: + elif MODE_GALLERY == mode: document = 'boards/thread_gallery.html' else: - pass - # TODO raise 404 error + raise Http404 return render(request, document, context)