From 0dff7d0fb84c89b8177c19d18b5f5debf0f3451e Mon Sep 17 00:00:00 2001 From: tmeissner Date: Tue, 20 Nov 2018 23:20:08 +0100 Subject: [PATCH] Chapter 11: Permanent links to posts (11g) --- app/main/views.py | 6 ++++++ app/static/styles.css | 4 +++- app/templates/_posts.html | 5 +++++ app/templates/post.html | 8 ++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/templates/post.html diff --git a/app/main/views.py b/app/main/views.py index bd5c694..b805a32 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -82,3 +82,9 @@ def edit_profile_admin(id): form.location.data = user.location form.about_me.data = user.about_me return render_template('edit_profile.html', form=form, user=user) + + +@main.route('/post/') +def post(id): + post = Post.query.get_or_404(id) + return render_template('post.html', posts=[post]) diff --git a/app/static/styles.css b/app/static/styles.css index 86f4b5e..32fd714 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -31,6 +31,9 @@ div.post-content { margin-left: 48px; min-height: 48px; } +div.post-footer { + text-align: right; +} div.pagination { width: 100%; text-align: center; @@ -60,4 +63,3 @@ div.flask-pagedown-preview { .post-body h3 { font-size: 120%; } - \ No newline at end of file diff --git a/app/templates/_posts.html b/app/templates/_posts.html index 0f7deec..f6c149d 100644 --- a/app/templates/_posts.html +++ b/app/templates/_posts.html @@ -16,6 +16,11 @@ {{ post.body }} {% endif %} + {% endfor %} diff --git a/app/templates/post.html b/app/templates/post.html new file mode 100644 index 0000000..e4cb256 --- /dev/null +++ b/app/templates/post.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} +{% import "_macros.html" as macros %} + +{% block title %}Flasky{% endblock %} + +{% block page_content %} +{% include '_posts.html' %} +{% endblock %}