From 1ce8d4a0653f2f3fb32c3157e447ad08c2b3aec9 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 10 Feb 2014 08:58:05 +0100 Subject: Export feeds to OPML. --- pyaggr3g470r/templates/management.html | 6 ++++-- pyaggr3g470r/templates/opml.xml | 14 ++++++++++++++ pyaggr3g470r/views.py | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 pyaggr3g470r/templates/opml.xml (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/templates/management.html b/pyaggr3g470r/templates/management.html index 0f01acdb..41dbd4e9 100644 --- a/pyaggr3g470r/templates/management.html +++ b/pyaggr3g470r/templates/management.html @@ -12,11 +12,13 @@

Update your profile.

-

Import feeds

+

Import/export feeds

- Import OPML + Batch import feeds from OPML
+
+ Export feeds to OPML

Export articles

diff --git a/pyaggr3g470r/templates/opml.xml b/pyaggr3g470r/templates/opml.xml new file mode 100644 index 00000000..8918bb88 --- /dev/null +++ b/pyaggr3g470r/templates/opml.xml @@ -0,0 +1,14 @@ + + + + + Feeds of {{ user.firstname }} + {{ now.strftime('%A, %d %B %Y') }} + {{ now.strftime('%A, %d %B %Y') }} + {{ user.firstname }} {{ user.lastname }} + {{ user.email }} + + + {% for feed in user.feeds %} + {% endfor %} + \ No newline at end of file diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 65e2459f..d09ff8f4 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -335,7 +335,7 @@ def index_database(): fastsearch.create_index(user.feeds) flash('Database indexed.', 'success') return redirect(url_for('home')) - + @app.route('/export/', methods=['GET']) @login_required def export_articles(): @@ -353,6 +353,17 @@ def export_articles(): response.headers['Content-Disposition'] = 'attachment; filename='+archive_file_name return response +@app.route('/export_opml/', methods=['GET']) +def export_opml(): + """ + Export all feeds to OPML. + """ + user = models.User.objects(email=g.user.email).first() + response = make_response(render_template('opml.xml', user=user, now=datetime.datetime.now())) + response.headers['Content-Type'] = 'application/xml' + response.headers['Content-Disposition'] = 'attachment; filename=feeds.opml' + return response + @app.route('/search/', methods=['GET']) @login_required def search(): @@ -391,7 +402,7 @@ def management(): flash(str(nb) + " feeds imported.", "success") except Exception as e: flash("Impossible to import the new feeds.", "danger") - + form = AddFeedForm() user = models.User.objects(email=g.user.email).first() -- cgit