Closes #1
This commit is contained in:
parent
57df913a2c
commit
00f7c1de33
3 changed files with 34 additions and 4 deletions
|
|
@ -66,6 +66,13 @@ def get_post(id, check_author=True):
|
|||
|
||||
return post
|
||||
|
||||
@bp.route('/<int:id>')
|
||||
def post(id):
|
||||
post = get_post(id, check_author=False)
|
||||
post = dict(post)
|
||||
post['body'] = markdown.markdown(post['body'])
|
||||
return render_template('blog/post.html', post=post)
|
||||
|
||||
@bp.route('/<int:id>/update', methods=('GET', 'POST'))
|
||||
@login_required
|
||||
def update(id):
|
||||
|
|
@ -101,3 +108,7 @@ def delete(id):
|
|||
db.execute('DELETE FROM post WHERE id = ?',(id,))
|
||||
db.commit()
|
||||
return redirect(url_for('blog.index'))
|
||||
|
||||
@bp.route('/temp')
|
||||
def temp():
|
||||
return render_template('temp.html')
|
||||
|
|
|
|||
|
|
@ -12,14 +12,13 @@
|
|||
<article class="post">
|
||||
<header>
|
||||
<div>
|
||||
<h1>{{ post['title'] }}</h1>
|
||||
<h1><a href="{{ url_for('blog.post', id=post['id']) }}">{{ post['title'] }}</a></h1>
|
||||
<div class="about">by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}</div>
|
||||
</div>
|
||||
{% if g.user['id'] == post['author_id'] %}
|
||||
<a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
|
||||
{% endif %}
|
||||
</header>
|
||||
<p class="body">{{ post['body']|safe }}</p>
|
||||
</article>
|
||||
{% if not loop.last %}
|
||||
<hr>
|
||||
|
|
|
|||
20
flaskr/templates/blog/post.html
Normal file
20
flaskr/templates/blog/post.html
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block header %}
|
||||
<h1>{% block title %}{{ post['title']}}{% endblock %}</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<article class="post">
|
||||
<header>
|
||||
<div>
|
||||
<h1>{{ post['title'] }}</h1>
|
||||
<div class="about">by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}</div>
|
||||
</div>
|
||||
{% if g.user['id'] == post['author_id'] %}
|
||||
<a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
|
||||
{% endif %}
|
||||
</header>
|
||||
<p class="body">{{ post['body']|safe }}</p>
|
||||
</article>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue