Compare commits

..

3 commits

Author SHA1 Message Date
44a49e5aee Add link to individual post in index 2026-03-11 20:27:32 +05:30
89622db6c9 End individual post url in / 2026-03-11 20:27:06 +05:30
13bdcaef9e Fix bad test 2026-03-11 20:25:52 +05:30
3 changed files with 7 additions and 5 deletions

View file

@ -86,9 +86,10 @@ def get_post(id, check_author=True):
return post return post
@bp.route('/<int:id>') @bp.route('/<int:id>/')
def individual_post(id): def individual_post(id):
post = get_post(id, False) post = dict(get_post(id, False))
post['body'] = markdown.markdown(post['body'])
return render_template('blog/post.html', post=post) return render_template('blog/post.html', post=post)
@bp.route('/<int:id>/update', methods=('GET', 'POST')) @bp.route('/<int:id>/update', methods=('GET', 'POST'))

View file

@ -12,7 +12,7 @@
<article class="post"> <article class="post">
<header> <header>
<div> <div>
<h1>{{ post['title'] }}</h1> <h1><a class="action" href="{{ url_for('blog.individual_post', id=post['id']) }}">{{ post['title'] }}</a></h1>
<div class="about">by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}</div> <div class="about">by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}</div>
</div> </div>
{% if g.user['id'] == post['author_id'] %} {% if g.user['id'] == post['author_id'] %}

View file

@ -13,6 +13,7 @@ def test_index(client, auth):
assert b'by test on 2018-01-01' in response.data assert b'by test on 2018-01-01' in response.data
assert b'test\nbody' not in response.data assert b'test\nbody' not in response.data
assert b'href="/1/update"' in response.data assert b'href="/1/update"' in response.data
assert b'href="/1/"' in response.data
def test_firehose(client, auth): def test_firehose(client, auth):
response = client.get('/') response = client.get('/')
@ -20,7 +21,7 @@ def test_firehose(client, auth):
assert b"Register" not in response.data assert b"Register" not in response.data
auth.login() auth.login()
response = client.get('/') response = client.get('/firehose')
assert b'Log Out' in response.data assert b'Log Out' in response.data
assert b'test title' in response.data assert b'test title' in response.data
assert b'by test on 2018-01-01' in response.data assert b'by test on 2018-01-01' in response.data
@ -28,7 +29,7 @@ def test_firehose(client, auth):
assert b'href="/1/update"' in response.data assert b'href="/1/update"' in response.data
def test_individual_page(client, auth): def test_individual_page(client, auth):
response = client.get('/1') response = client.get('/1/')
assert b'test title' in response.data assert b'test title' in response.data
assert b'by test on 2018-01-01' in response.data assert b'by test on 2018-01-01' in response.data
assert b'test\nbody' in response.data assert b'test\nbody' in response.data