aboutsummaryrefslogtreecommitdiff
path: root/pyAggr3g470r.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2011-10-24 17:42:12 +0200
committercedricbonhomme <devnull@localhost>2011-10-24 17:42:12 +0200
commit6f57793c3e9c6cfacf0bfc539da48ae44ae947ce (patch)
treeee964f5b586b54e1fccccab596e810784034873e /pyAggr3g470r.py
parentUpdated CherryPy configuration. (diff)
downloadnewspipe-6f57793c3e9c6cfacf0bfc539da48ae44ae947ce.tar.gz
newspipe-6f57793c3e9c6cfacf0bfc539da48ae44ae947ce.tar.bz2
newspipe-6f57793c3e9c6cfacf0bfc539da48ae44ae947ce.zip
Added export.py. This file will gather all the export functions.
Diffstat (limited to 'pyAggr3g470r.py')
-rwxr-xr-xpyAggr3g470r.py51
1 files changed, 8 insertions, 43 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 8bc0a91d..25effe12 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -50,6 +50,7 @@ from collections import Counter
import datetime
import utils
+import export
import feedgetter
import PyQRNative
@@ -279,6 +280,7 @@ class Root:
# Export functions
html += "<h1>Export articles</h1>\n\n"
html += """<form method=get action="/export/"><select name="export_method">\n"""
+ html += """\t<option value="export_webzine" selected='selected'>Webzine</option>\n"""
html += """\t<option value="export_HTML" selected='selected'>HTML</option>\n"""
html += """\t<option value="export_TXT">Text</option>\n"""
html += """\t<option value="export_dokuwiki">DokuWiki</option>\n"""
@@ -1209,49 +1211,12 @@ class Root:
Export articles stored in the SQLite database in text
(raw or HTML) files.
"""
- for feed in self.feeds.values():
- # creates folder for each stream
- folder = utils.path + "/var/export/" + \
- utils.normalize_filename(feed.feed_title.strip().replace(':', '').lower())
- try:
- os.makedirs(folder)
- except OSError:
- # directories already exists (not a problem)
- pass
-
- for article in feed.articles.values():
- name = article.article_date.strip().replace(' ', '_')
-
- # Export all articles in HTML format
- if export_method == "export_HTML":
- name = os.path.normpath(folder + "/" + name + ".html")
- content = htmlheader()
- content += '\n<div style="width: 50%; overflow:hidden; text-align: justify; margin:0 auto">\n'
- content += """<h1><a href="%s">%s</a></h1><br />""" % \
- (article.article_link, article.article_title)
- content += article.article_description
- content += "</div>\n<hr />\n"
- content += htmlfooter
-
- # Export for dokuwiki
- # example: http://wiki.cedricbonhomme.org/doku.php/news-archives
- elif export_method == "export_dokuwiki":
- name = os.path.normpath(folder + "/" + name.replace(':', '-') + ".txt")
- content = "<html>"
- content += '\n<div style="width: 50%; overflow:hidden; text-align: justify; margin:0 auto">\n'
- content += """<h1><a href="%s">%s</a></h1><br />""" % \
- (article.article_link, article.article_title)
- content += article.article_description
- content += '</div>\n<hr />Generated with <a href="http://bitbucket.org/cedricbonhomme/pyaggr3g470r/">pyAggr3g470r</a>\n</html>'
-
- # Export all articles in raw text
- elif export_method == "export_TXT":
- content = "Title: " + article.article_title + "\n\n\n"
- content += utils.clear_string(article.article_description)
- name = os.path.normpath(folder + "/" + name + ".txt")
-
- with open(name, "w") as f:
- f.write(content)
+ if export_method == "export_webzine":
+ export.export_webzine(self.feeds)
+ return self.management()
+ else:
+ export.exports(self.feeds, export_method)
+
return self.management()
export.exposed = True
bgstack15