aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2014-02-10 08:58:05 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2014-02-10 08:58:05 +0100
commit1ce8d4a0653f2f3fb32c3157e447ad08c2b3aec9 (patch)
treef43e1a06dfd45720a692c0c33f2d85f6cbfd8af8
parentUpdated README? (diff)
downloadnewspipe-1ce8d4a0653f2f3fb32c3157e447ad08c2b3aec9.tar.gz
newspipe-1ce8d4a0653f2f3fb32c3157e447ad08c2b3aec9.tar.bz2
newspipe-1ce8d4a0653f2f3fb32c3157e447ad08c2b3aec9.zip
Export feeds to OPML.
-rw-r--r--pyaggr3g470r/templates/management.html6
-rw-r--r--pyaggr3g470r/templates/opml.xml14
-rw-r--r--pyaggr3g470r/views.py15
3 files changed, 31 insertions, 4 deletions
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 @@
<p>Update your <a href="/profile/">profile</a>.</p>
</div>
<div class="jumbotron">
- <h1>Import feeds</h1>
+ <h1>Import/export feeds</h1>
<form action="" method="post" id="formImportOPML" enctype="multipart/form-data">
- <span class="btn btn-default btn-file">Import OPML<input type="file" name="opmlfile" /></span>
+ <span class="btn btn-default btn-file">Batch import feeds from OPML<input type="file" name="opmlfile" /></span>
<button class="btn btn-default" type="submit">OK</button>
</form>
+ <br />
+ <a href="/export_opml/" class="btn btn-default">Export feeds to OPML</a>
</div>
<div class="jumbotron">
<h1>Export articles</h1>
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 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- OPML generated by pyAggr3g470r on {{ now.strftime('%A, %d %B %Y') }} -->
+<opml version="1.1">
+ <head>
+ <title>Feeds of {{ user.firstname }}</title>
+ <dateCreated>{{ now.strftime('%A, %d %B %Y') }}</dateCreated>
+ <dateModified>{{ now.strftime('%A, %d %B %Y') }}</dateModified>
+ <ownerName>{{ user.firstname }} {{ user.lastname }}</ownerName>
+ <ownerEmail>{{ user.email }}</ownerEmail>
+ </head>
+ <body>
+ {% for feed in user.feeds %} <outline title="{{ feed.title|escape }}" text="{{ feed.title|escape }}" description="{{ feed.description|escape }}" xmlUrl="{{ feed.link|escape }}" htmlUrl="{{ feed.site_link|escape }}" />
+ {% endfor %}</body>
+</opml> \ 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()
bgstack15