mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GR changes for mastheadImage
This commit is contained in:
parent
b9521c819d
commit
192e6a2f5d
@ -50,7 +50,7 @@ class MOBIOutput(OutputFormatPlugin):
|
|||||||
def check_for_masthead(self):
|
def check_for_masthead(self):
|
||||||
found = 'masthead' in self.oeb.guide
|
found = 'masthead' in self.oeb.guide
|
||||||
if not found:
|
if not found:
|
||||||
self.oeb.log.debug('No masthead found, generating default one...')
|
self.oeb.log.debug('No masthead found in manifest, generating default mastheadImage...')
|
||||||
try:
|
try:
|
||||||
from PIL import Image as PILImage
|
from PIL import Image as PILImage
|
||||||
PILImage
|
PILImage
|
||||||
@ -65,6 +65,9 @@ class MOBIOutput(OutputFormatPlugin):
|
|||||||
id, href = self.oeb.manifest.generate('masthead', 'masthead')
|
id, href = self.oeb.manifest.generate('masthead', 'masthead')
|
||||||
self.oeb.manifest.add(id, href, 'image/gif', data=raw)
|
self.oeb.manifest.add(id, href, 'image/gif', data=raw)
|
||||||
self.oeb.guide.add('masthead', 'Masthead Image', href)
|
self.oeb.guide.add('masthead', 'Masthead Image', href)
|
||||||
|
else:
|
||||||
|
self.oeb.log.debug('Using mastheadImage supplied in manifest...')
|
||||||
|
|
||||||
|
|
||||||
def dump_toc(self, toc) :
|
def dump_toc(self, toc) :
|
||||||
self.log( "\n >>> TOC contents <<<")
|
self.log( "\n >>> TOC contents <<<")
|
||||||
|
@ -32,13 +32,9 @@ class Clean(object):
|
|||||||
ref.type = 'cover'
|
ref.type = 'cover'
|
||||||
self.oeb.guide.refs['cover'] = ref
|
self.oeb.guide.refs['cover'] = ref
|
||||||
|
|
||||||
# Check for masthead in OPF, add to guide if present
|
|
||||||
for item in oeb.manifest.items:
|
|
||||||
if item.id == 'masthead-image':
|
|
||||||
self.oeb.guide.add('masthead', 'Masthead Image', item.href)
|
|
||||||
|
|
||||||
for x in list(self.oeb.guide):
|
for x in list(self.oeb.guide):
|
||||||
href = urldefrag(self.oeb.guide[x].href)[0]
|
href = urldefrag(self.oeb.guide[x].href)[0]
|
||||||
|
print "ebooks.oeb.transforms.guide:Clean(): checking x.lower(): %s" % x.lower()
|
||||||
if x.lower() not in ('cover', 'titlepage', 'masthead', 'toc',
|
if x.lower() not in ('cover', 'titlepage', 'masthead', 'toc',
|
||||||
'title-page', 'copyright-page', 'start'):
|
'title-page', 'copyright-page', 'start'):
|
||||||
self.oeb.guide.remove(x)
|
self.oeb.guide.remove(x)
|
||||||
|
@ -994,6 +994,14 @@ class BasicNewsRecipe(Recipe):
|
|||||||
mi.pubdate = datetime.now()
|
mi.pubdate = datetime.now()
|
||||||
opf_path = os.path.join(dir, 'index.opf')
|
opf_path = os.path.join(dir, 'index.opf')
|
||||||
ncx_path = os.path.join(dir, 'index.ncx')
|
ncx_path = os.path.join(dir, 'index.ncx')
|
||||||
|
|
||||||
|
# Add mastheadImage entry to <guide> section
|
||||||
|
from calibre.ebooks.metadata.opf2 import Guide
|
||||||
|
mi.guide = Guide()
|
||||||
|
ref = Guide.Reference('mastheadImage.jpg', os.getcwdu())
|
||||||
|
ref.type = 'masthead'
|
||||||
|
ref.title = 'Masthead Image'
|
||||||
|
mi.guide.append(ref)
|
||||||
opf = OPFCreator(dir, mi)
|
opf = OPFCreator(dir, mi)
|
||||||
|
|
||||||
manifest = [os.path.join(dir, 'feed_%d'%i) for i in range(len(feeds))]
|
manifest = [os.path.join(dir, 'feed_%d'%i) for i in range(len(feeds))]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user