File tree Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from blog import db
6
6
7
-
8
7
class User (db .Model ):
9
8
id = db .Column (db .Integer , primary_key = True )
10
9
created_at = db .Column (db .DateTime , default = datetime .now )
Original file line number Diff line number Diff line change 1
1
from flask import render_template
2
2
from blog import app
3
+ from blog .models import Post
3
4
4
5
5
6
@app .route ("/" )
6
7
def homepage ():
7
- posts = [{"title" : "primo post" , "body" : "random body" },
8
- {"title" : "secondo post" , "body" : "more random content" }]
9
- some_boolean_flag = False
10
- return render_template ("homepage.html" ,
11
- posts = posts , boolean_flag = some_boolean_flag )
8
+ posts = Post .query .order_by (Post .created_at .desc ()).all ()
9
+ return render_template ("homepage.html" , posts = posts )
12
10
13
11
14
12
@app .route ("/about" )
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ html, body {
44
44
margin-bottom : 30px ;
45
45
}
46
46
47
+ .p-small-one {
48
+ font-size : 0.875rem ;
49
+ }
50
+
51
+ .p-small-two {
52
+ font-size : 0.800rem ;
53
+ }
54
+
47
55
@media (min-width : 768px ) {
48
56
.single-post-home {
49
57
margin-left : 30px ;
Original file line number Diff line number Diff line change 4
4
5
5
{% block content %}
6
6
< div class ="container content-container ">
7
-
8
7
< div class ="row no-gutters ">
9
8
10
9
< div class ="col-md-9 order-md-2 ">
11
10
{% for post in posts %}
12
11
< div class ="single-post-home ">
13
12
< h5 > {{ post.title }}</ h5 >
14
- < p > {{ post.body }}</ p >
13
+ < p class ="p-small-two text-muted "> {{ post.created_at.strftime('%d.%m.%Y') }}</ p >
14
+
15
+ {% if post.description %}
16
+ < p class ="p-small-one text-muted mb-0 ">
17
+ {{ post.description }}
18
+ </ p >
19
+ {% endif %}
15
20
</ div >
16
21
{% endfor %}
17
22
</ div >
@@ -20,7 +25,6 @@ <h5>{{ post.title }}</h5>
20
25
{% include 'about_me_snippet.html' %}
21
26
</ div >
22
27
23
- </ div >
24
-
28
+ </ div >
25
29
</ div >
26
30
{% endblock %}
You can’t perform that action at this time.
0 commit comments