aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/article.py32
-rw-r--r--src/web/views/feed.py35
2 files changed, 41 insertions, 26 deletions
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
diff --git a/src/web/views/feed.py b/src/web/views/feed.py
index 873e1eb6..dcc3aa3e 100644
--- a/src/web/views/feed.py
+++ b/src/web/views/feed.py
@@ -5,7 +5,7 @@ from sqlalchemy import desc
from werkzeug.exceptions import BadRequest
from flask import Blueprint, render_template, flash, \
- redirect, request, url_for
+ redirect, request, url_for, make_response
from flask_babel import gettext
from flask_login import login_required, current_user
@@ -14,8 +14,8 @@ from lib import misc_utils, utils
from lib.feed_utils import construct_feed_from
from web.lib.view_utils import etag_match
from web.forms import AddFeedForm
-from web.controllers import (CategoryController, FeedController,
- ArticleController)
+from web.controllers import (UserController, CategoryController,
+ FeedController, ArticleController)
logger = logging.getLogger(__name__)
feeds_bp = Blueprint('feeds', __name__, url_prefix='/feeds')
@@ -261,3 +261,32 @@ def duplicates(feed_id):
'info')
return redirect(url_for('home'))
return render_template('duplicates.html', duplicates=duplicates, feed=feed)
+
+
+@feeds_bp.route('/export', methods=['GET'])
+@login_required
+def export():
+ """
+ Export feeds to OPML.
+ """
+ include_disabled = request.args.get('includedisabled', '') == 'on'
+ include_private = request.args.get('includeprivate', '') == 'on'
+
+ filter = {}
+ if not include_disabled:
+ filter['enabled'] = True
+ if not include_private:
+ filter['private'] = False
+
+ user = UserController(current_user.id).get(id=current_user.id)
+ feeds = FeedController(current_user.id).read(**filter)
+ categories = {cat.id: cat.dump()
+ for cat in CategoryController(user.id).read()}
+
+ response = make_response(render_template('opml.xml',
+ user=user, feeds=feeds,
+ categories=categories,
+ now=datetime.now()))
+ response.headers['Content-Type'] = 'application/xml'
+ response.headers['Content-Disposition'] = 'attachment; filename=feeds.opml'
+ return response
bgstack15