- opf = xslt(metadata, res('xsltContent.xsl'))
- manifest = opf.find('.//' + OPFNS('manifest'))
- spine = opf.find('.//' + OPFNS('spine'))
+ manifest.append(etree.fromstring(
+ '<item id="cover" href="cover.html" media-type="application/xhtml+xml" />'))
+ manifest.append(etree.fromstring(
+ '<item id="cover-image" href="%s" media-type="%s" />' % (c_name, c.mime_type())))
+ spine.insert(0, etree.fromstring('<itemref idref="cover" />'))
+ opf.getroot()[0].append(etree.fromstring('<meta name="cover" content="cover-image"/>'))
+ opf.getroot().append(etree.fromstring('<guide><reference href="cover.html" type="cover" title="Okładka"/></guide>'))
+
+ if flags and 'images' in flags:
+ for ilustr in input_xml.findall('//ilustr'):
+ src = ilustr.get('src')
+ mime = ImageCover(src)().mime_type()
+ zip.write(src, os.path.join('OPS', src))
+ manifest.append(etree.fromstring(
+ '<item id="%s" href="%s" media-type="%s" />' % (src, src, mime)))
+ # get it up to master
+ after = ilustr
+ while after.getparent().tag not in ['powiesc', 'opowiadanie', 'liryka_l', 'liryka_lp', 'dramat_wierszowany_l', 'dramat_wierszowany_lp', 'dramat_wspolczesny']:
+ after = after.getparent()
+ if not(after is ilustr):
+ moved = deepcopy(ilustr)
+ ilustr.tag = 'extra'
+ ilustr.text = None
+ moved.tail = None
+ after.addnext(moved)
+ else:
+ for ilustr in input_xml.findall('//ilustr'):
+ ilustr.tag = 'extra'