Browse Source

Chapter 11: Permanent links to posts (11g)

master
T. Meissner 6 years ago
parent
commit
0dff7d0fb8
4 changed files with 22 additions and 1 deletions
  1. +6
    -0
      app/main/views.py
  2. +3
    -1
      app/static/styles.css
  3. +5
    -0
      app/templates/_posts.html
  4. +8
    -0
      app/templates/post.html

+ 6
- 0
app/main/views.py View File

@ -82,3 +82,9 @@ def edit_profile_admin(id):
form.location.data = user.location form.location.data = user.location
form.about_me.data = user.about_me form.about_me.data = user.about_me
return render_template('edit_profile.html', form=form, user=user) return render_template('edit_profile.html', form=form, user=user)
@main.route('/post/<int:id>')
def post(id):
post = Post.query.get_or_404(id)
return render_template('post.html', posts=[post])

+ 3
- 1
app/static/styles.css View File

@ -31,6 +31,9 @@ div.post-content {
margin-left: 48px; margin-left: 48px;
min-height: 48px; min-height: 48px;
} }
div.post-footer {
text-align: right;
}
div.pagination { div.pagination {
width: 100%; width: 100%;
text-align: center; text-align: center;
@ -60,4 +63,3 @@ div.flask-pagedown-preview {
.post-body h3 { .post-body h3 {
font-size: 120%; font-size: 120%;
} }

+ 5
- 0
app/templates/_posts.html View File

@ -16,6 +16,11 @@
{{ post.body }} {{ post.body }}
{% endif %} {% endif %}
</div> </div>
<div class="post-footer">
<a href="{{ url_for('.post', id=post.id) }}">
<span class="label label-default">Permalink</span>
</a>
</div>
</div> </div>
</li> </li>
{% endfor %} {% endfor %}


+ 8
- 0
app/templates/post.html View File

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% import "_macros.html" as macros %}
{% block title %}Flasky{% endblock %}
{% block page_content %}
{% include '_posts.html' %}
{% endblock %}

Loading…
Cancel
Save