##// END OF EJS Templates
Updated sync method for requesting and getting a post
Updated sync method for requesting and getting a post

File last commit:

r1160:e92b66f8 default
r1177:a55da940 decentral
Show More
board.py
45 lines | 978 B | text/x-python | PythonLexer
import re
from django.shortcuts import get_object_or_404
from django import template
IMG_ACTION_URL = '[<a href="{}">{}</a>]'
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):
post_id = args[0]
post = get_object_or_404('Post', id=post_id)
return post.get_absolute_url()
@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?
return ', '.join([IMG_ACTION_URL.format(
action['link'] % image_link, action['name'])for action in actions])
@register.simple_tag(name='post_view')
def post_view(post, *args, **kwargs):
return post.get_view(*args, **kwargs)