aboutsummaryrefslogtreecommitdiff
path: root/source/epub/ez_epub.py
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2012-04-15 18:59:50 +0200
committercedricbonhomme <devnull@localhost>2012-04-15 18:59:50 +0200
commite6472738b5253aa328f8b2a4f4f2a23abc8582c2 (patch)
treec61704deed1d3cb37f5e3961794896c6dd115ba5 /source/epub/ez_epub.py
parentBetter use of datetime. (diff)
downloadnewspipe-e6472738b5253aa328f8b2a4f4f2a23abc8582c2.tar.gz
newspipe-e6472738b5253aa328f8b2a4f4f2a23abc8582c2.tar.bz2
newspipe-e6472738b5253aa328f8b2a4f4f2a23abc8582c2.zip
Reorganization of folders.
Diffstat (limited to 'source/epub/ez_epub.py')
-rw-r--r--source/epub/ez_epub.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/epub/ez_epub.py b/source/epub/ez_epub.py
new file mode 100644
index 00000000..ecfd4f5a
--- /dev/null
+++ b/source/epub/ez_epub.py
@@ -0,0 +1,36 @@
+#! /usr/local/bin/python
+#-*- coding: utf-8 -*-
+
+import epub
+from genshi.template import TemplateLoader
+
+class Section:
+ def __init__(self):
+ self.title = ''
+ self.paragraphs = []
+ self.tocDepth = 1
+
+def makeBook(title, authors, sections, outputDir, lang='en-US', cover=None):
+ book = epub.EpubBook()
+ book.setLang(lang)
+ book.setTitle(title)
+ for author in authors:
+ book.addCreator(author)
+ #book.addTitlePage()
+ #book.addTocPage()
+ #if cover:
+ #book.addCover(cover)
+
+ loader = TemplateLoader('./epub/templates')
+ tmpl = loader.load('ez-section.html')
+
+ for i, section in enumerate(sections):
+ stream = tmpl.generate(section = section)
+ html = stream.render('xhtml', doctype='xhtml11', drop_xml_decl=False)
+ item = book.addHtml('', 's%d.html' % (i + 1), html)
+ book.addSpineItem(item)
+ book.addTocMapNode(item.destPath, section.title, section.tocDepth)
+
+ outputFile = outputDir + 'article.epub'
+ book.createBook(outputDir)
+ book.createArchive(outputDir, outputFile) \ No newline at end of file
bgstack15