- commit
- 6d199f7aaf7db5a83cc2826965cf40fdb4c537a2
- parent
- 758cdd81113b1444cbf66d8cbb513bea059f9810
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-07-30 12:25
fix comments in listings
Diffstat
M | neddit.py | 7 | +++++++ |
C | templates/_comments.html -> templates/_comment.html | 38 | ++++++++++++-------------------------- |
M | templates/_comments.html | 13 | +------------ |
M | templates/listing.html | 14 | +++++++++++++- |
4 files changed, 33 insertions, 39 deletions
diff --git a/neddit.py b/neddit.py
@@ -41,6 +41,13 @@ def format_number(value): 41 41 env.filters['k'] = format_number 42 42 43 43 -1 44 def normalize_link(value): -1 45 if value.startswith('https://www.reddit.com'): -1 46 value = value[22:] -1 47 return value -1 48 env.filters['link'] = normalize_link -1 49 -1 50 44 51 def fetch(url, **params): 45 52 app.logger.debug('fetch %s' % url) 46 53 r = requests.get(
diff --git a/templates/_comments.html b/templates/_comment.html
@@ -1,26 +1,12 @@1 -1 {% if comments %}2 -1 <ul class="comments">3 -1 {% for comment in comments.data.children %}4 -1 {% if comment.kind == 'more' %}5 -1 {% if parent %}6 -1 <li class="comment"><a href="{{ parent.data.permalink }}">Continue this thread</a></li>7 -1 {% endif %}8 -1 {% else %}9 -1 <li class="comment">10 -1 <header>11 -1 <a class="user" href="/u/{{ comment.data.author }}/">{{ comment.data.author }}</a>12 -1 <span class="meta">13 -1 {{ comment.data.score|k }} points14 -1 ·15 -1 <a href="{{ comment.data.permalink }}">{{ comment.data.created_utc|dt }}</a>16 -1 </span>17 -1 </header>18 -1 {{ comment.data.body_html|safe }}19 -1 {% with comments=comment.data.replies, parent=comment %}20 -1 {% include '_comments.html' %}21 -1 {% endwith %}22 -1 </li>23 -1 {% endif %}24 -1 {% endfor %}25 -1 </ul>26 -1 {% endif %}-1 1 <header> -1 2 <a class="user" href="/u/{{ comment.data.author }}/">{{ comment.data.author }}</a> -1 3 <span class="meta"> -1 4 {{ comment.data.score|k }} points -1 5 · -1 6 <a href="{{ comment.data.permalink }}">{{ comment.data.created_utc|dt }}</a> -1 7 </span> -1 8 </header> -1 9 {{ comment.data.body_html|safe }} -1 10 {% with comments=comment.data.replies, parent=comment %} -1 11 {% include '_comments.html' %} -1 12 {% endwith %}
diff --git a/templates/_comments.html b/templates/_comments.html
@@ -7,18 +7,7 @@ 7 7 {% endif %} 8 8 {% else %} 9 9 <li class="comment">10 -1 <header>11 -1 <a class="user" href="/u/{{ comment.data.author }}/">{{ comment.data.author }}</a>12 -1 <span class="meta">13 -1 {{ comment.data.score|k }} points14 -1 ·15 -1 <a href="{{ comment.data.permalink }}">{{ comment.data.created_utc|dt }}</a>16 -1 </span>17 -1 </header>18 -1 {{ comment.data.body_html|safe }}19 -1 {% with comments=comment.data.replies, parent=comment %}20 -1 {% include '_comments.html' %}21 -1 {% endwith %}-1 10 {% include '_comment.html' %} 22 11 </li> 23 12 {% endif %} 24 13 {% endfor %}
diff --git a/templates/listing.html b/templates/listing.html
@@ -36,7 +36,19 @@ 36 36 <ul class="posts"> 37 37 {% for post in data.children %} 38 38 <li class="post">39 -1 {% include '_post.html' %}-1 39 {% if post.kind == 't1' %} -1 40 <article> -1 41 <header> -1 42 <a class="u-bold" href="/r/{{ post.data.subreddit}}/">r/{{ post.data.subreddit }}</a> -1 43 <span class="meta">· Comment on <a class="u-bold" href="{{ post.data.link_permalink|link }}">{{ post.data.link_title }}</a></span> -1 44 </header> -1 45 {% with comment=post %} -1 46 {% include '_comment.html' %} -1 47 {% endwith %} -1 48 </article> -1 49 {% else %} -1 50 {% include '_post.html' %} -1 51 {% endif %} 40 52 </li> 41 53 {% endfor %} 42 54 </ul>