Add dates for feeds

This commit is contained in:
Guillaume Ayoub 2017-09-22 16:42:56 +02:00
parent 5c45209199
commit 5c6063f2ba
4 changed files with 19 additions and 0 deletions

10
afpy.py
View File

@ -1,9 +1,14 @@
import datetime
import locale
import docutils.core
import docutils.writers.html5_polyglot
import feedparser
from flask import Flask, abort, render_template
from jinja2 import TemplateNotFound
locale.setlocale(locale.LC_ALL, 'fr_FR')
app = Flask(__name__)
FEEDS = {
@ -69,6 +74,11 @@ def feed(name):
title=feed.feed.get('title'))
@app.template_filter('datetime')
def format_datetime(time_struct, format_):
return datetime.datetime(*time_struct[:6]).strftime(format_)
if __name__ == '__main__': # pragma: no cover
from sassutils.wsgi import SassMiddleware
app.wsgi_app = SassMiddleware(

View File

@ -126,6 +126,9 @@ dd
content: ''
display: inline
time
display: block
#planet main, #emplois main, #index-news
box-sizing: border-box
display: flex

View File

@ -111,6 +111,9 @@ dd {
content: '→ ';
display: inline; }
time {
display: block; }
#planet main, #emplois main, #index-news {
box-sizing: border-box;
display: flex;

View File

@ -8,6 +8,9 @@
{% for entry in entries %}
<article>
<h2>{{ entry.title }}</h2>
<time pubdate datetime="{{ entry.updated_parsed | datetime('%Y-%m-%d') }}">
{{ entry.updated_parsed | datetime('%x') }}
</time>
{{ entry.summary | safe }}
<p><a href="{{ entry.link }}">Lire la suite…</a></p>
</article>