Add a news app, and enable commenting

This commit is contained in:
Trever Fischer
2012-02-25 11:57:44 -05:00
parent 44fb472f22
commit 5284eafaa9
9 changed files with 144 additions and 0 deletions

16
templates/news/index.html Normal file
View File

@@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% load markup %}
{% load comments %}
{% block title %}News{% endblock %}
{% block content %}
{% for post in items.object_list %}
<h2><a href="{{post.get_absolute_url}}">{{post.title}}</a></h2>
<div class="byline">By {{post.author}}</div>
<div class="content">
{{post.body|markdown}}
</div>
<div class="commentcount">{% get_comment_count for post as comment_count %}{{comment_count}} comments.</div>
{% endfor %}
{% endblock %}

34
templates/news/view.html Normal file
View File

@@ -0,0 +1,34 @@
{% extends 'base.html' %}
{% load markup %}
{% load comments %}
{% block title %}News - {{item.title}}{% endblock %}
{% block content %}
<h2><a href="{{post.get_absolute_url}}">{{post.title}}</a></h2>
<div class="byline">By {{item.author}}</div>
<div class="content">
{{item.body|markdown}}
</div>
<div class="commentcount">{% get_comment_count for item as comment_count %}{{comment_count}} comments.</div>
<div class="comments">
{% if comment_count > 0 %}
<h3>Comments</h3>
{% get_comment_list for item as comment_list %}
{% for comment in comment_list %}
<a name="c{{ comment.id }}" href="{% get_comment_permalink comment %}">#{{comment.id}}</a> by {{comment.user}}
<div class="comment">
{{comment.comment|markdown:"safe"}}
</div>
{% endfor %}
{% endif %}
{% get_comment_form for item as form %}
<h4>Add a comment</h4>
<form action="{% comment_form_target %}" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="Post">
<input type="submit" name="preview" value="Preview">
<input type="hidden" name="next" value="{{post.get_absolute_url}}" />
</form>
</div>
{% endblock %}