Skip to content

Commit 9b68cb1

Browse files
authored
Merge pull request #18 from mattip/comment-mix
tweak formatting when there are no static comments
2 parents d23f3d5 + ad01ffe commit 9b68cb1

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

themes/pypy/templates/index.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</a>
5151
</p>
5252
{# modified for static_comments only #}
53-
<p class="commentline">{{ static_comments.add_static_comment_count(post.comments, lang) }}</p>
53+
{{ static_comments.add_static_comment_count(post.comments, lang) }}
5454
</div>
5555
</header>
5656
{% if index_teasers %}

themes/pypy/templates/post.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{{ helper.html_pager(post) }}
4242
</nav>
4343
</aside>
44-
{% if post.comments|count >= 1 %}
44+
{% if post.comments|length >= 1 %}
4545
{# modified for static_comments only #}
4646
<section class="comments hidden-print">
4747
<h2>{{ messages("Comments") }}</h2>

themes/pypy/templates/post_header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</a>
5151
</p>
5252
{# modified for static_comments only #}
53-
<p class="commentline">{{ static_comments.add_static_comment_count(post.comments, lang) }}</p>
53+
{{ static_comments.add_static_comment_count(post.comments, lang) }}
5454
{% if not post.meta('nocomments') and site_has_comments %}
5555
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
5656
{% endif %}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{# -*- coding: utf-8 -*- #}
2+
3+
{% macro add_static_comments(static_comment_list, lang) %}
4+
{%if static_comment_list|length > 0 %}
5+
{%for comment in static_comment_list %}
6+
{%for i in range(comment.indent_change_before) %}
7+
<div class="comment-level comment-level-{{ comment.indent_levels|length + i }}">
8+
{% endfor %}
9+
<div class="comment comment-{{ comment.id }}">
10+
<div class="comment-header">
11+
<a name="comment-{{ comment.id }}"></a>
12+
{%if comment.author is not none %}
13+
{{ messages("{0} wrote on {1}:", lang).format(
14+
'<span class="author">' ~ ('<a href="{0}">{1}</a>'.format(comment.author_url|e, comment.author|e) if comment.author_url is not none else (comment.author|e)) ~ '</span>',
15+
'<span class="date">' + comment.formatted_date(date_format) + '</span>'
16+
) }}
17+
{% endif %}
18+
</div>
19+
<div class="comment-content">
20+
{{ comment.content }}
21+
</div>
22+
</div>
23+
{%for i in range(-comment.indent_change_after) %}
24+
</div>
25+
{% endfor %}
26+
{% endfor %}
27+
{% endif %}
28+
{% endmacro %}
29+
30+
{% macro add_static_comment_count(static_comment_list, lang) %}
31+
{% if static_comment_list|length > 0 %}
32+
<p class="commentline">{{ messages("{0} comments" if static_comment_list|length != 1 else "{0} comment", lang).format(static_comment_list|length) }}</p>
33+
{% endif %}
34+
{% endmacro %}

0 commit comments

Comments
 (0)