+ @staticmethod
+ def transform(wldoc, fieldfile):
+ # ugly, but we can't use wldoc.book_info here
+ from librarian import DCNS
+ url_elem = wldoc.edoc.getroot().find('.//' + DCNS('identifier.url'))
+ if url_elem is None:
+ gal_url = ''
+ gal_path = ''
+ else:
+ slug = url_elem.text.rstrip('/').rsplit('/', 1)[1]
+ gal_url = gallery_url(slug=slug)
+ gal_path = gallery_path(slug=slug)
+ return wldoc.as_html(gallery_path=gal_path, gallery_url=gal_url, base_url=absolute_url(gal_url))
+
+
+class BuildCover(BuildEbook):
+ def set_file_permissions(self, fieldfile):
+ pass
+
+
+@BuildEbook.register('cover_clean')
+@task(ignore_result=True)
+class BuildCoverClean(BuildCover):
+ @classmethod
+ def transform(cls, wldoc, fieldfile):
+ if wldoc.book_info.cover_box_position == 'none':
+ from librarian.cover import WLCover
+ return WLCover(wldoc.book_info, width=240).output_file()
+ from librarian.covers.marquise import MarquiseCover
+ return MarquiseCover(wldoc.book_info, width=240).output_file()
+
+