Fix for zip files, status in epub.

This commit is contained in:
Jim Miller 2011-05-05 20:47:39 -05:00
parent 94669a2179
commit 0e28d86a7b
5 changed files with 28 additions and 13 deletions

View file

@ -81,6 +81,10 @@ def main():
outputepub = ZipFile(outputopt, "w", compression=ZIP_STORED)
outputepub.debug = 3
outputepub.writestr("mimetype", "application/epub+zip")
# declares all the files created by Windows. otherwise, when
# it runs in appengine, windows unzips the files as 000 perms.
for zf in outputepub.filelist:
zf.create_system = 0
outputepub.close()
## Re-open file for content.
@ -277,6 +281,10 @@ def main():
outputepub.writestr("content.opf",contentdom.toxml('utf-8'))
outputepub.writestr("toc.ncx",tocncxdom.toxml('utf-8'))
# declares all the files created by Windows. otherwise, when
# it runs in appengine, windows unzips the files as 000 perms.
for zf in outputepub.filelist:
zf.create_system = 0
outputepub.close()
## Utility method for creating new tags.

View file

@ -159,6 +159,10 @@ class BaseStoryWriter(Configurable):
self.writeStoryImpl(out)
zipout = ZipFile(outstream, 'w', compression=ZIP_DEFLATED)
zipout.writestr(filename,out.getvalue())
# declares all the files created by Windows. otherwise, when
# it runs in appengine, windows unzips the files as 000 perms.
for zf in zipout.filelist:
zf.create_system = 0
zipout.close()
out.close()
else:

View file

@ -153,11 +153,13 @@ h6 { text-align: center; }
## ZipFile can't change compression type file-by-file, so we
## have to close and re-open
outputepub = ZipFile(zipio, 'w', compression=ZIP_STORED)
outputepub.debug=3
outputepub.writestr('mimetype','application/epub+zip')
outputepub.close()
## Re-open file for content.
outputepub = ZipFile(zipio, 'a', compression=ZIP_DEFLATED)
outputepub.debug=3
## Create META-INF/container.xml file. The only thing it does is
## point to content.opf
@ -238,6 +240,8 @@ h6 { text-align: center; }
metadata.appendChild(newTag(contentdom,"dc:description",text=
self.getMetadata('description')))
metadata.appendChild(newTag(contentdom,"dc:subject",text=
self.getMetadata('status')))
# listables all go into dc:suject tags, but only if they are configured.
for (name,lst) in self.story.getLists().iteritems():
if name in self.getConfigList("include_subject_tags"):
@ -387,7 +391,12 @@ h6 { text-align: center; }
fullhtml = fullhtml.replace('</p>','</p>\n').replace('<br />','<br />\n')
outputepub.writestr("OEBPS/file%04d.xhtml"%(index+1),fullhtml.encode('utf-8'))
del fullhtml
# declares all the files created by Windows. otherwise, when
# it runs in appengine, windows unzips the files as 000 perms.
logging.debug("outputepub create_system")
for zf in outputepub.filelist:
zf.create_system = 0
outputepub.close()
out.write(zipio.getvalue())
zipio.close()

View file

@ -35,23 +35,17 @@ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
<div id='greeting'>
<p>Hi, {{ nickname }}! This is a fan fiction downloader, which makes reading stories from various websites
much easier. </p>
<p>For Amazon Kindle use Mobi output(see notice below), for Sony Reader, Nook and iPad use ePub</p>
<p>Or see your personal list of <a href="/recent">previously downloaded fanfics</a>.</p>
</div>
<h3>Experimental New Feature</h3>
<h3>Experimental New Version!</h3>
<p>
If you select EPub format, when it's done you will also be given a 'Convert' link.
This version is a new re-org/re-write of the code
</p>
<p>
That link will take you to <a href="http://convertfiles.com">convertfiles.com</a> where you can
directly convert your new story to FictionBook (fb2), Mobipocket (mobi), MS Reader (lit) or Adobe Portable
Document Format(pdf).
There's also a 'Convert' link for EPubs on your <a href="/recent">recent downloads</a>
page. We'd really like to hear from users about this in our <a href="http://groups.google.com/group/fanfic-downloader">Google Group</a>.
So far, only a few sites are supported: fanfiction.net, twilighted.net and whofic.com.
</p>
<p>
We'd especially like Kindle and other Mobi users to try it. The <a href="http://convertfiles.com">convertfiles.com</a> Mobi file
appears to be more correct than our Mobi output.
Mobi support (for Kindle) is only via EPub conversion in this version.
</p>
<div id='error'>
@ -66,7 +60,7 @@ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
<input type='radio' name='format' value='epub' checked>EPub</input>
<input type='radio' name='format' value='html'>HTML</input>
<input type='radio' name='format' value='txt'>Plain Text</input>
<p><i>For Mobi (Kindle) select EPub and Convert it.</i></p>
<p><i>For Mobi (Kindle) select EPub and use the Convert link when it's finished.</i></p>
</div>
</div>

View file

@ -21,7 +21,7 @@ class Remover(webapp.RequestHandler):
logging.debug("Starting r3m0v3r")
user = users.get_current_user()
logging.debug("Working as user %s" % user)
theDate = datetime.date.today() - datetime.timedelta(days=5)
theDate = datetime.date.today() - datetime.timedelta(days=7)
logging.debug("Will delete stuff older than %s" % theDate)
fics = DownloadMeta.all()