From f53453069d81989670586ef54130b026dd31a1e1 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 31 Oct 2018 22:18:19 +0100 Subject: Improved the import/export functions for data liberation. It is now possible to export all feeds to OPML with ou without enabled and private feeds. --- src/web/views/article.py | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'src/web/views/article.py') diff --git a/src/web/views/article.py b/src/web/views/article.py index 640de8b4..bf39795d 100644 --- a/src/web/views/article.py +++ b/src/web/views/article.py @@ -139,30 +139,16 @@ def expire(): @login_required def export(): """ - Export to OPML or JSON. + Export articles to JSON. """ user = UserController(current_user.id).get(id=current_user.id) - if request.args.get('format') == "JSON": - # Export to JSON for the export of account. - try: - json_result = export_json(user) - except Exception as e: - flash(gettext("Error when exporting articles."), 'danger') - return redirect(redirect_url()) - response = make_response(json_result) - response.mimetype = 'application/json' - response.headers["Content-Disposition"] \ - = 'attachment; filename=account.json' - elif request.args.get('format') == "OPML": - # Export to the OPML format. - categories = {cat.id: cat.dump() - for cat in CategoryController(user.id).read()} - response = make_response(render_template('opml.xml', user=user, - categories=categories, - now=datetime.now())) - response.headers['Content-Type'] = 'application/xml' - response.headers['Content-Disposition'] = 'attachment; filename=feeds.opml' - else: - flash(gettext('Export format not supported.'), 'warning') + try: + json_result = export_json(user) + except Exception as e: + flash(gettext("Error when exporting articles."), 'danger') return redirect(redirect_url()) + response = make_response(json_result) + response.mimetype = 'application/json' + response.headers["Content-Disposition"] \ + = 'attachment; filename=account.json' return response -- cgit