aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/export.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-29 23:08:36 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-29 23:08:36 +0200
commite762c6b0a257dbbc90f51e069f708bbf037fac57 (patch)
tree6ed6a400d2e359cc97a090b50d7469982da15fed /pyaggr3g470r/export.py
parentadded templates for emails (diff)
downloadnewspipe-e762c6b0a257dbbc90f51e069f708bbf037fac57.tar.gz
newspipe-e762c6b0a257dbbc90f51e069f708bbf037fac57.tar.bz2
newspipe-e762c6b0a257dbbc90f51e069f708bbf037fac57.zip
Added export to JSON.
Diffstat (limited to 'pyaggr3g470r/export.py')
-rw-r--r--pyaggr3g470r/export.py25
1 files changed, 24 insertions, 1 deletions
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)
bgstack15