# HG changeset patch # User neko259 # Date 2014-01-23 12:44:17 # Node ID cf14ad325ad9e24827d0a95909683be7a327e06f # Parent 6c2489dfaebabca7bf10a1eca05790680014b343 Added debug suffix to the site name when DEBUG is set to true. Optimized post template tag if additional parameters are provided diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -4,11 +4,8 @@ {% get_current_language as LANGUAGE_CODE %} -{% with thread=post.thread_new %} -{% with bumpable=thread.can_bump %} {% cache 600 post post.id post.last_edit_time thread.archived bumpable truncated moderator LANGUAGE_CODE need_open_link %} - {% with is_opening=post.is_opening %} {% spaceless %} {% if thread.archived %}
@@ -97,7 +94,4 @@ {% endif %}
{% endspaceless %} - {% endwith %} {% endcache %} -{% endwith %} -{% endwith %} diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -74,23 +74,25 @@ {% for thread in threads %} {% cache 600 thread_short thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
- {% post_view_truncated thread.get_opening_post True moderator %} - {% if not thread.archived %} - {% if thread.get_last_replies.exists %} - {% if thread.get_skipped_replies_count %} -
- - {% blocktrans with count=thread.get_skipped_replies_count %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %} - + {% with can_bump=thread.can_bump %} + {% post_view_truncated thread.get_opening_post True moderator is_opening=True thread=thread can_bump=can_bump %} + {% if not thread.archived %} + {% if thread.get_last_replies.exists %} + {% if thread.get_skipped_replies_count %} + + {% endif %} +
+ {% for post in thread.get_last_replies %} + {% post_view_truncated post moderator=moderator is_opening=False thread=thread can_bump=can_bump %} + {% endfor %}
{% endif %} -
- {% for post in thread.get_last_replies %} - {% post_view_truncated post moderator=moderator%} - {% endfor %} -
- {% endif %} - {% endif %} + {% endif %} + {% endwith %}
{% endcache %} {% endfor %} diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -32,9 +32,15 @@ {% endif %}
+ {% with can_bump=thread.can_bump %} {% for post in thread.get_replies %} - {% post_view post moderator=moderator %} + {% if forloop.first %} + {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump %} + {% else %} + {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump %} + {% endif %} {% endfor %} + {% endwith %}
{% if not thread.archived %} diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py --- a/boards/templatetags/board.py +++ b/boards/templatetags/board.py @@ -50,27 +50,63 @@ def image_actions(*args, **kwargs): @register.inclusion_tag('boards/post.html', name='post_view') -def post_view(post, moderator=False): +def post_view(post, moderator=False, **kwargs): """ Get post """ + if 'is_opening' in kwargs: + is_opening = kwargs['is_opening'] + else: + is_opening = post.is_opening() + + if 'thread' in kwargs: + thread = kwargs['thread'] + else: + thread = post.thread_new + + if 'can_bump' in kwargs: + can_bump = kwargs['can_bump'] + else: + can_bump = thread.can_bump() + return { 'post': post, 'moderator': moderator, + 'is_opening': is_opening, + 'thread': thread, + 'bumpable': can_bump, } @register.inclusion_tag('boards/post.html', name='post_view_truncated') -def post_view_truncated(post, need_open_link=False, moderator=False): +def post_view_truncated(post, need_open_link=False, moderator=False, **kwargs): """ Get post with truncated text. If the 'open' or 'reply' link is needed, pass the second parameter as True. """ + if 'is_opening' in kwargs: + is_opening = kwargs['is_opening'] + else: + is_opening = post.is_opening() + + if 'thread' in kwargs: + thread = kwargs['thread'] + else: + thread = post.thread_new + + if 'can_bump' in kwargs: + can_bump = kwargs['can_bump'] + else: + can_bump = thread.can_bump() + return { 'post': post, 'truncated': True, 'need_open_link': need_open_link, 'moderator': moderator, + 'is_opening': is_opening, + 'thread': thread, + 'bumpable': can_bump, } diff --git a/neboard/settings.py b/neboard/settings.py --- a/neboard/settings.py +++ b/neboard/settings.py @@ -227,6 +227,9 @@ VERSION = '1.7 Anubis' # Debug mode middlewares if DEBUG: + + SITE_NAME += '_debug' + MIDDLEWARE_CLASSES += ( 'boards.profiler.ProfilerMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware',