##// END OF EJS Templates
Refactored post view, added a hint of how to add new tags to favorites
Refactored post view, added a hint of how to add new tags to favorites

File last commit:

r1093:0edfd683 default
r1093:0edfd683 default
Show More
board.py
78 lines | 1.8 KiB | text/x-python | PythonLexer
neko259
Truncate posts by lines
r1000 import re
neko259
Added a template tag to get post link instead of using jumper
r320 from django.shortcuts import get_object_or_404
from django import template
neko259
Truncate posts by lines
r1000 ELLIPSIZER = '...'
REGEX_LINES = re.compile(r'(<div class="br"></div>)', re.U | re.S)
REGEX_TAG = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S)
neko259
Refactoring
r1027 IMG_ACTION_URL = '[<a href="{}">{}</a>]'
neko259
Added tag search. Refactored search to show any model results in a list.
r692
neko259
Added a template tag to get post link instead of using jumper
r320 register = template.Library()
neko259
Added metadata to the gallery. Added links to search the image by the online search engines
r460 actions = [
{
'name': 'google',
'link': 'http://google.com/searchbyimage?image_url=%s',
},
{
'name': 'iqdb',
'link': 'http://iqdb.org/?url=%s',
},
]
neko259
Added a template tag to get post link instead of using jumper
r320
@register.simple_tag(name='post_url')
def post_url(*args, **kwargs):
post_id = args[0]
neko259
Added tag search. Refactored search to show any model results in a list.
r692 post = get_object_or_404('Post', id=post_id)
neko259
Added a template tag to get post link instead of using jumper
r320
neko259
Using opening post ID from cache, not passing it to the post view
r621 return post.get_url()
neko259
Speed up thread loading
r614
neko259
Added metadata to the gallery. Added links to search the image by the online search engines
r460 @register.simple_tag(name='image_actions')
def image_actions(*args, **kwargs):
image_link = args[0]
if len(args) > 1:
neko259
Refactoring
r1027 image_link = 'http://' + args[1] + image_link # TODO https?
neko259
Added metadata to the gallery. Added links to search the image by the online search engines
r460
neko259
Refactoring
r1027 return ', '.join([IMG_ACTION_URL.format(
action['link'] % image_link, action['name'])for action in actions])
neko259
Added template tag to render post the same way in all places (threads list, thread view, post view)
r537
@register.inclusion_tag('boards/post.html', name='post_view')
neko259
Removed truncated post view, using an argument for this mode. Fixed bumpable argument in thread
r594 def post_view(post, moderator=False, need_open_link=False, truncated=False,
neko259
Close form by default, open it under the post that is replied
r1056 reply_link=False, **kwargs):
neko259
Show images count in OP
r538 """
Get post
"""
neko259
Removed obsolete parameter from post view tag
r988 thread = post.get_thread()
neko259
Removed unnecessary params from post_view template tag
r1032 is_opening = post.is_opening()
neko259
Added debug suffix to the site name when DEBUG is set to true. Optimized post...
r583
neko259
Removed unnecessary params from post_view template tag
r1032 if is_opening:
opening_post_id = post.id
neko259
Backed out changeset a37f5ca1da43
r949 else:
neko259
Removed unnecessary params from post_view template tag
r1032 opening_post_id = thread.get_opening_post_id()
neko259
Speed up thread loading
r614
neko259
Refactored post view, added a hint of how to add new tags to favorites
r1093 css_class = 'post'
if thread.archived:
css_class += ' archive_post'
elif not thread.can_bump():
css_class += ' dead_post'
neko259
Added template tag to render post the same way in all places (threads list, thread view, post view)
r537 return {
'post': post,
neko259
Fixed moderator panel
r540 'moderator': moderator,
neko259
Added debug suffix to the site name when DEBUG is set to true. Optimized post...
r583 'is_opening': is_opening,
'thread': thread,
neko259
Refactored post view, added a hint of how to add new tags to favorites
r1093 'css_class': css_class,
neko259
Removed truncated post view, using an argument for this mode. Fixed bumpable argument in thread
r594 'need_open_link': need_open_link,
'truncated': truncated,
neko259
Speed up thread loading
r614 'opening_post_id': opening_post_id,
neko259
Close form by default, open it under the post that is replied
r1056 'reply_link': reply_link,
neko259
Speed up thread loading
r614 }
neko259
Truncate posts by lines
r1000