diff options
Diffstat (limited to 'app/figments/ebook.py')
-rw-r--r-- | app/figments/ebook.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/figments/ebook.py b/app/figments/ebook.py index 23e3fc5..81210a4 100644 --- a/app/figments/ebook.py +++ b/app/figments/ebook.py @@ -4,6 +4,7 @@ from ebooklib import epub from django.conf import settings from typogrify.filters import typogrify + def generate_epub_file(f): book = epub.EpubBook() @@ -16,17 +17,16 @@ def generate_epub_file(f): # intro chapter c1 = epub.EpubHtml(title='Introduction', file_name='intro.xhtml', lang='en') - c1.content=u'<html><head></head><body><h1>Forward</h1><p>Thank you for downloading my story <em>%s</em>. I hope you enjoy it and please feel free to email me if you have any questions or comments.</p> <p>If you enjoy this story and would like to read more, head on over to <a href="http://luxagraf.net/figments/">luxagraf.net</a>.</p><p>– Scott Gilbertson <br/> sng@luxagraf.net</p></body></html>' % f.title + c1.content = u'<html><head></head><body><h1>Forward</h1><p>Thank you for downloading my story <em>%s</em>. I hope you enjoy it and please feel free to email me if you have any questions or comments.</p> <p>If you enjoy this story and would like to read more, head on over to <a href="https://luxagraf.net/figments/">luxagraf.net</a>.</p><p>– Scott Gilbertson <br/> sng@luxagraf.net</p></body></html>' % f.title # chapter c2 = epub.EpubHtml(title=f.title, file_name='story.xhtml') - c2.content='<h1>%s</h1>' % f.title - c2.content+= typogrify(f.body_html) + c2.content = '<h1>%s</h1>' % f.title + c2.content += typogrify(f.body_html) # add chapters to the book book.add_item(c1) book.add_item(c2) - # create table of contents # - add section # - add auto created links to chapters @@ -48,7 +48,7 @@ body { h2 { text-align: left; text-transform: uppercase; - font-weight: 200; + font-weight: 200; } ol { list-style-type: none; @@ -71,9 +71,9 @@ nav[epub|type~='toc'] > ol > li > ol > li { # create spine book.spine = ['nav', c1, c2] path, filename = os.path.split(f.get_absolute_url()) - fpath = '%s%s/' %(settings.FLATFILES_ROOT, path) + fpath = '%s%s/' % (settings.FLATFILES_ROOT, path) if not os.path.isdir(fpath): os.makedirs(fpath) - bk = '%s%s.epub' %(fpath, f.slug) + bk = '%s%s.epub' % (fpath, f.slug) # create epub file epub.write_epub(bk, book, {}) |