Esempio n. 1
0
def ask_epub(epub_file, context):
    output = EPUB(epub_file, "a")
    part = StringIO(unicode(render_to_string('epub/ask.xhtml', context)))
    output.addpart(part, "ask.xhtml", "application/xhtml+xml",
                   1)  #after title, we hope
    asking_epub = StringIO()
    output.writetodisk(asking_epub)
    return asking_epub
Esempio n. 2
0
def personalize(epub_file, acq):
    output = EPUB(epub_file, "a")
    context = {'acq': acq}
    part = StringIO(
        unicode(render_to_string('epub/datedcc_license.xhtml', context)))
    output.addpart(part, "datedcc_license.xhtml", "application/xhtml+xml",
                   1)  #after title, we hope
    output.addmetadata(
        'rights', '%s after %s' % (acq.work.last_campaign().license_url,
                                   acq.work.last_campaign().cc_date))
    personalized_epub = StringIO()
    output.writetodisk(personalized_epub)
    #logger.info("personalized")
    return personalized_epub