Implement subcomment trees, replies to subcomments
This commit is contained in:
19
templates/comment.html
Normal file
19
templates/comment.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% macro render_comment(comment) %}
|
||||
<div style="margin-left:20px">
|
||||
<p><i>{{ comment.author }}</i></p>
|
||||
<p>{{ comment.text }}</p>
|
||||
<sup><a href="{{ url_for("comment", comment_id = comment.id) }}">reply</a></sup>
|
||||
{% for c in comment.children %}
|
||||
{{ render_comment(c) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro reply() %}
|
||||
{% if 'user_id' in session %}
|
||||
<form method="post" action="comment/">
|
||||
<textarea name="text"></textarea>
|
||||
<input type="submit" value="Post comment">
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
15
templates/comments.html
Normal file
15
templates/comments.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from 'comment.html' import render_comment, reply %}
|
||||
|
||||
{% block content %}
|
||||
<sup><a href="{{ url_for('thread', thread_id = thread_id) }}">thread</a></sup>
|
||||
{% if parent_id %}
|
||||
<sup><a href="../{{ parent_id }}">parent</a></sup>
|
||||
{% endif %}
|
||||
|
||||
{{ reply() }}
|
||||
|
||||
{% for c in comments %}
|
||||
{{ render_comment(c) }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
@@ -1,14 +1,5 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% macro render_comment(comment) %}
|
||||
<div style="margin-left:20px">
|
||||
<p><i>{{ comment.author }}</i></p>
|
||||
<p>{{ comment.text }}</p>
|
||||
{% for c in comment.children %}
|
||||
{{ render_comment(c) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
{% from 'comment.html' import render_comment, reply %}
|
||||
|
||||
{% block content %}
|
||||
{% if manage %}
|
||||
@@ -20,6 +11,9 @@
|
||||
{% endif %}
|
||||
<p>{{ author }} - rjgoire</p>
|
||||
<p>{{ text }}</p>
|
||||
|
||||
{{ reply() }}
|
||||
|
||||
{% for c in comments %}
|
||||
{{ render_comment(c) }}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user