From 5d0c774c14c4f13361a178819229d6bcbb1d9091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Sun, 4 Jun 2023 11:30:31 +0200 Subject: [PATCH] Chapter 12 --- app.db | Bin 36864 -> 36864 bytes app/__init__.py | 2 ++ app/templates/_post.html | 12 ++++++------ app/templates/base.html | 5 +++++ app/templates/user.html | 4 +++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app.db b/app.db index 8ba4b97641810242c815701c57eeb83381e208d9..2b7c11bb2a62295722e14df376e430d10b281002 100644 GIT binary patch delta 37 rcmZozz|^pSX@WH4fr&ECj0ZL*Y_sJtHn1`@)-y3M27=8>cJ~4S@6QYq delta 37 tcmZozz|^pSX@WH4-ib2KjC(gGY_sJtGO{u;&@(nLwKOo>tYmjD5CHFd3>5$X diff --git a/app/__init__.py b/app/__init__.py index 7fe7ba8..42cdefd 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -7,6 +7,7 @@ from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager from flask_bootstrap import Bootstrap +from flask_moment import Moment app = Flask(__name__) app.config.from_object(Config) @@ -20,6 +21,7 @@ login = LoginManager(app) # sets de default login view login.login_view = "login" bootstrap = Bootstrap(app) +moment = Moment(app) if not app.debug: if app.config["MAIL_SERVER"]: diff --git a/app/templates/_post.html b/app/templates/_post.html index 30d18db..aac3058 100644 --- a/app/templates/_post.html +++ b/app/templates/_post.html @@ -6,12 +6,12 @@ - - {{ post.author.username }} - - says: -
- {{ post.body }} + + {{ post.author.username }} + + said {{ moment(post.timestamp).fromNow() }}: +
+ {{ post.body }} diff --git a/app/templates/base.html b/app/templates/base.html index 01b8d2a..645241e 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -47,4 +47,9 @@ {# application content needs to be provided in the app_content block #} {% block app_content %}{% endblock %} +{% endblock %} + +{% block scripts %} + {{ super() }} + {{ moment.include_moment() }} {% endblock %} \ No newline at end of file diff --git a/app/templates/user.html b/app/templates/user.html index 0658a3d..09e0990 100644 --- a/app/templates/user.html +++ b/app/templates/user.html @@ -7,7 +7,9 @@

User: {{ user.username }}

{% if user.about_me %}

{{ user.about_me }}

{% endif %} - {% if user.last_seen %}

Last seen on: {{ user.last_seen }}

{% endif %} + {% if user.last_seen %} +

Last seen on: {{ moment(user.last_seen).format('LLL') }}

+ {% endif %}

{{ user.followers.count() }} followers, {{ user.followed.count() }} following.

{% if user == current_user %}

Edit your profile