Skip to content

Commit

Permalink
Chapter 12: Dates and Times (v0.12)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Nov 11, 2022
1 parent 542fa42 commit a650e6f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from flask_login import LoginManager
from flask_mail import Mail
from flask_bootstrap import Bootstrap
from flask_moment import Moment
from config import Config

app = Flask(__name__)
Expand All @@ -17,6 +18,7 @@
login.login_view = 'login'
mail = Mail(app)
bootstrap = Bootstrap(app)
moment = Moment(app)

if not app.debug:
if app.config['MAIL_SERVER']:
Expand Down
2 changes: 1 addition & 1 deletion app/templates/_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a href="{{ url_for('user', username=post.author.username) }}">
{{ post.author.username }}
</a>
says:
said {{ moment(post.timestamp).fromNow() }}:
<br>
{{ post.body }}
</td>
Expand Down
5 changes: 5 additions & 0 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@
{% block app_content %}{% endblock %}
</div>
{% endblock %}

{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
{% endblock %}
4 changes: 3 additions & 1 deletion app/templates/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<td>
<h1>User: {{ user.username }}</h1>
{% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
{% if user.last_seen %}<p>Last seen on: {{ user.last_seen }}</p>{% endif %}
{% if user.last_seen %}
<p>Last seen on: {{ moment(user.last_seen).format('LLL') }}</p>
{% endif %}
<p>{{ user.followers.count() }} followers, {{ user.followed.count() }} following.</p>
{% if user == current_user %}
<p><a href="{{ url_for('edit_profile') }}">Edit your profile</a></p>
Expand Down

0 comments on commit a650e6f

Please sign in to comment.