aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2012-11-09 00:35:28 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2012-11-09 00:35:28 -0500
commit867e8acae887638beb5107fb7a5c9f3e403d06e0 (patch)
tree8afbe0f128efe74236478133cf6b95e4178f4021
parentc21117dba95fd9d64c7f5120c752825080dc87d1 (diff)
downloadfamille-flask-867e8acae887638beb5107fb7a5c9f3e403d06e0.tar.gz
add rss flux
-rw-r--r--famille.py6
-rw-r--r--templates/news/list.html4
-rw-r--r--templates/rss.xml19
3 files changed, 27 insertions, 2 deletions
diff --git a/famille.py b/famille.py
index 0d2c498..0d2e7b9 100644
--- a/famille.py
+++ b/famille.py
@@ -204,5 +204,11 @@ def logout():
session.pop('user_id', None)
return redirect(url_for('login'))
+@app.route('/rss.xml')
+def rss():
+ news = query_db("SELECT * FROM news LEFT JOIN users ON "
+ "news.user_id=users.id ORDER BY news.date desc")
+ return render_template('rss.xml', news=news)
+
if __name__=="__main__":
app.run()
diff --git a/templates/news/list.html b/templates/news/list.html
index 61625c1..2f273e1 100644
--- a/templates/news/list.html
+++ b/templates/news/list.html
@@ -10,7 +10,7 @@
<table>
{% for user in users %}
<tr>
- <td><a href="{{url_for('view_user', user_id=user.id)}}">{{user.user_name}}</a></td>
+ <td><a href="{{url_for('view_user', user_id=user.id)}}">{{user.user_name}}</a></td>
<td>{{user.last_seen|format_date}}</td>
</tr>
{% endfor %}
@@ -24,7 +24,7 @@
{{comment.content_cache|shortify|safe}} <a href="{{url_for('show_news', news_id=comment.news_id)}}#comments">[…]</a>
</li>
{% else %}
- Pas de commentaires."
+ Pas de commentaires.
{% endfor %}
</ul>
</div>
diff --git a/templates/rss.xml b/templates/rss.xml
new file mode 100644
index 0000000..d0e7caa
--- /dev/null
+++ b/templates/rss.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0">
+<channel>
+<description>Actualités de la famille</description>
+<link>http://famille.horel.org</link>
+<title>Actualités de la la famille</title>
+
+{% for news in news %}
+<item>
+<title>{{news.title}}</title>
+<author>{{news.name}}</author>
+<link>http://famille.horel.org{{url_for('show_news', news_id=news.id)}}</link>
+<description>{{news.content_cache}}</description>
+<pubDate>{{news.date}}</pubDate>
+<guid>{{news.id}}</guid>
+</item>
+{% endfor %}
+</channel>
+</rss>