Add OPML export of subscriptions (#69)
It's nice to be able to export all your subscriptions if you want to move to a different reader. This patch adds a link to the subscription page where one can download the subscription list as OPML which is the standard way of importing/exporting between feed readers.
This commit is contained in:
parent
0d16b1ef88
commit
f0deb771e7
3 changed files with 28 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
<form action="{{ url_for('.update_all') }}" method="POST">
|
||||
<button type="submit">Poll All</button>
|
||||
<a href="{{ url_for('.subscriptions_opml')}}">Export as OPML</a>
|
||||
</form>
|
||||
</article>
|
||||
|
||||
|
|
10
woodwind/templates/subscriptions_opml.xml
Normal file
10
woodwind/templates/subscriptions_opml.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<opml version="2.0">
|
||||
<body>
|
||||
<outline text="Subscriptions" title="Woodwind">
|
||||
{% for s in subscriptions %}
|
||||
<outline xmlUrl="{{ s.feed.feed }}" />
|
||||
{% endfor %}
|
||||
</outline>
|
||||
</body>
|
||||
</opml>
|
|
@ -55,7 +55,8 @@ def index():
|
|||
.join(Subscription.user)\
|
||||
.filter(User.id == flask_login.current_user.id)\
|
||||
.filter(db.or_(Entry.deleted == None,
|
||||
Entry.deleted >= now))
|
||||
Entry.deleted >= now))\
|
||||
.order_by(Entry.published.desc())
|
||||
|
||||
if 'entry' in flask.request.args:
|
||||
entry_url = flask.request.args.get('entry')
|
||||
|
@ -126,6 +127,21 @@ def subscriptions():
|
|||
subscriptions=subscs)
|
||||
|
||||
|
||||
@views.route('/subscriptions_opml.xml')
|
||||
@flask_login.login_required
|
||||
def subscriptions_opml():
|
||||
subscs = Subscription\
|
||||
.query\
|
||||
.filter_by(user_id=flask_login.current_user.id)\
|
||||
.options(sqlalchemy.orm.subqueryload(Subscription.feed))\
|
||||
.order_by(db.func.lower(Subscription.name))\
|
||||
.all()
|
||||
template = flask.render_template('subscriptions_opml.xml',
|
||||
subscriptions=subscs)
|
||||
response = flask.make_response(template)
|
||||
response.headers['Content-Type'] = 'application/xml'
|
||||
return response
|
||||
|
||||
@views.route('/settings', methods=['GET', 'POST'])
|
||||
@flask_login.login_required
|
||||
def settings():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue