##// END OF EJS Templates
Fixed sticker autocompletions. Localized 'too many files' message and added max file count there
Fixed sticker autocompletions. Localized 'too many files' message and added max file count there

File last commit:

r1650:8a0acd9f default
r1766:8d73e763 default
Show More
board.py
51 lines | 1.2 KiB | 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.inclusion_tag('boards/post.html', name='post_view', takes_context=True)
def post_view(context, post, *args, **kwargs):
kwargs['perms'] = context['perms']
return post.get_view_params(*args, **kwargs)
@register.simple_tag(name='page_url')
def page_url(paginator, page_number, *args, **kwargs):
if paginator.supports_urls():
return paginator.get_page_url(page_number)