diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2013-12-08 01:58:06 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2013-12-08 01:58:06 +0100 |
commit | 2bcde34af4707e2644be45ae9e1a075f445113f0 (patch) | |
tree | 938f1145a7574585bf5ed6b678e6251671b4c797 /pyaggr3g470r/views.py | |
parent | Updated README (diff) | |
download | newspipe-2bcde34af4707e2644be45ae9e1a075f445113f0.tar.gz newspipe-2bcde34af4707e2644be45ae9e1a075f445113f0.tar.bz2 newspipe-2bcde34af4707e2644be45ae9e1a075f445113f0.zip |
It is now possible to export all articles in a simple HTML site. The result is returned as a compressed tgz file.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r-- | pyaggr3g470r/views.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 48e0e49d..a458c3eb 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -28,7 +28,7 @@ __license__ = "GPLv3" import datetime -from flask import render_template, request, flash, session, url_for, redirect, g +from flask import render_template, request, make_response, flash, session, url_for, redirect, g from wtforms import TextField, PasswordField, SubmitField, validators from flask.ext.login import LoginManager, login_user, logout_user, login_required, current_user, AnonymousUserMixin from collections import defaultdict @@ -37,7 +37,9 @@ from forms import SigninForm, AddFeedForm, ProfileForm from pyaggr3g470r import app, db +import conf import utils +import export import feedgetter import models import search as fastsearch @@ -255,6 +257,21 @@ def index_database(): fastsearch.create_index(user.feeds) return redirect(url_for('home')) +@app.route('/export/', methods=['GET']) +@login_required +def export_articles(): + """ + Export all articles. + """ + user = models.User.objects(email=g.user.email).first() + export.export_html(user.feeds) + with open(conf.PATH + '/pyaggr3g470r/var/export.tar.gz', 'r') as export_file: + response = make_response(export_file.read()) + response.headers['Content-Type'] = 'application/x-compressed' + response.headers['Content-Disposition'] = 'attachment; filename=export.tar.gz' + return response + return redirect(url_for('management')) + @app.route('/search/', methods=['GET']) @login_required def search(): |