From e762c6b0a257dbbc90f51e069f708bbf037fac57 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 29 Apr 2014 23:08:36 +0200 Subject: Added export to JSON. --- pyaggr3g470r/export.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'pyaggr3g470r/export.py') diff --git a/pyaggr3g470r/export.py b/pyaggr3g470r/export.py index 243b6843..502c82db 100644 --- a/pyaggr3g470r/export.py +++ b/pyaggr3g470r/export.py @@ -39,6 +39,8 @@ import time import tarfile from datetime import datetime +from flask import jsonify + import conf import models @@ -197,4 +199,25 @@ def export_html(user): shutil.rmtree(webzine_root) with open(conf.WEBZINE_ROOT + archive_file_name, 'r') as export_file: - return export_file.read(), archive_file_name \ No newline at end of file + return export_file.read(), archive_file_name + +def export_json(user): + """ + """ + result = [] + for feed in user.feeds: + result.append({ + "title": feed.title, + "description": feed.description, + "link": feed.link, + "site_link": feed.site_link, + "articles": [ { + "title": article.title, + "link": article.link, + "content": article.content + } + for article in feed.articles + ] + }) + + return jsonify(result=result) -- cgit