# HG changeset patch # User neko259 # Date 2015-04-14 10:21:56 # Node ID 362f1a522c93d969bccd0b29ef18b190dd5b5a8f # Parent 0edfd683586252749abb3100b70bedb7370d3f90 Refactored post_view template tag diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py --- a/boards/templatetags/board.py +++ b/boards/templatetags/board.py @@ -2,13 +2,19 @@ import re from django.shortcuts import get_object_or_404 from django import template -ELLIPSIZER = '...' - -REGEX_LINES = re.compile(r'(
)', re.U | re.S) -REGEX_TAG = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S) IMG_ACTION_URL = '[{}]' +PARAM_POST = 'post' +PARAM_MODERATOR = 'moderator' +PARAM_OP = 'is_opening' +PARAM_THREAD = 'thread' +PARAM_CSS_CLASS = 'css_class' +PARAM_OPEN_LINK = 'need_open_link' +PARAM_TRUNCATED = 'truncated' +PARAM_OP_ID = 'opening_post_id' +PARAM_REPLY_LINK = 'reply_link' + register = template.Library() @@ -65,14 +71,14 @@ def post_view(post, moderator=False, nee css_class += ' dead_post' return { - 'post': post, - 'moderator': moderator, - 'is_opening': is_opening, - 'thread': thread, - 'css_class': css_class, - 'need_open_link': need_open_link, - 'truncated': truncated, - 'opening_post_id': opening_post_id, - 'reply_link': reply_link, + PARAM_POST: post, + PARAM_MODERATOR: moderator, + PARAM_OP: is_opening, + PARAM_THREAD: thread, + PARAM_CSS_CLASS: css_class, + PARAM_OPEN_LINK: need_open_link, + PARAM_TRUNCATED: truncated, + PARAM_OP_ID: opening_post_id, + PARAM_REPLY_LINK: reply_link, }