From ab8055b5cab2523d925f59c65bc38df103a26991 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 2 Dec 2020 15:02:12 -0500 Subject: deleted old apps and media --- app/unused_apps/figments/ebook.py | 79 --------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 app/unused_apps/figments/ebook.py (limited to 'app/unused_apps/figments/ebook.py') diff --git a/app/unused_apps/figments/ebook.py b/app/unused_apps/figments/ebook.py deleted file mode 100644 index 81210a4..0000000 --- a/app/unused_apps/figments/ebook.py +++ /dev/null @@ -1,79 +0,0 @@ -import os -from ebooklib import epub - -from django.conf import settings -from typogrify.filters import typogrify - - -def generate_epub_file(f): - book = epub.EpubBook() - - # add metadata - book.set_identifier('lux23') - book.set_title(f.title) - book.set_language('en') - - book.add_author('Scott Gilbertson') - - # intro chapter - c1 = epub.EpubHtml(title='Introduction', file_name='intro.xhtml', lang='en') - c1.content = u'

Forward

Thank you for downloading my story %s. I hope you enjoy it and please feel free to email me if you have any questions or comments.

If you enjoy this story and would like to read more, head on over to luxagraf.net.

– Scott Gilbertson
  sng@luxagraf.net

' % f.title - - # chapter - c2 = epub.EpubHtml(title=f.title, file_name='story.xhtml') - c2.content = '

%s

' % 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 - - book.toc = (epub.Link('intro.xhtml', 'Introduction', 'intro'), - epub.Link('story.xhtml', f.title, 'story'), - ) - - # add navigation files - book.add_item(epub.EpubNcx()) - book.add_item(epub.EpubNav()) - - # define css style - style = ''' -@namespace epub "http://www.idpf.org/2007/ops"; -body { - font-family: Georgia, Times, Times New Roman, serif; -} -h2 { - text-align: left; - text-transform: uppercase; - font-weight: 200; -} -ol { - list-style-type: none; -} -ol > li:first-child { - margin-top: 0.3em; -} -nav[epub|type~='toc'] > ol > li > ol { - list-style-type:square; -} -nav[epub|type~='toc'] > ol > li > ol > li { - margin-top: 0.3em; -} -''' - - # add css file - nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style) - book.add_item(nav_css) - - # create spine - book.spine = ['nav', c1, c2] - path, filename = os.path.split(f.get_absolute_url()) - fpath = '%s%s/' % (settings.FLATFILES_ROOT, path) - if not os.path.isdir(fpath): - os.makedirs(fpath) - bk = '%s%s.epub' % (fpath, f.slug) - # create epub file - epub.write_epub(bk, book, {}) -- cgit v1.2.3-70-g09d2