From 8062c04b817d0193f7a597c874458aa468f43d1d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 03:38:16 -0600 Subject: [PATCH 1/8] EPUB Input: Ignore OPF files in the EPUB whose names start with a period --- src/calibre/ebooks/epub/input.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/epub/input.py b/src/calibre/ebooks/epub/input.py index 214511ae14..cdd69ea50f 100644 --- a/src/calibre/ebooks/epub/input.py +++ b/src/calibre/ebooks/epub/input.py @@ -117,7 +117,8 @@ class EPUBInput(InputFormatPlugin): encfile = os.path.abspath(os.path.join('META-INF', 'encryption.xml')) opf = None for f in walk(u'.'): - if f.lower().endswith('.opf') and '__MACOSX' not in f: + if f.lower().endswith('.opf') and '__MACOSX' not in f and \ + not os.path.basename(f).startswith('.'): opf = os.path.abspath(f) break path = getattr(stream, 'name', 'stream') From b95079ec8ccf7ab5b3b231d77a7ebf4e08ee31d4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 04:28:10 -0600 Subject: [PATCH 2/8] MOBI Input: Treat blockquote as having left margin of 1.0em instead of 1.25em --- src/calibre/ebooks/mobi/reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 6a44c2aa77..0cf31d64ec 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -234,7 +234,7 @@ class MobiReader(object): self.debug = debug self.embedded_mi = None self.base_css_rules = textwrap.dedent(''' - blockquote { margin: 0em 0em 0em 1.25em; text-align: justify } + blockquote { margin: 0em 0em 0em 1em; text-align: justify } p { margin: 0em; text-align: justify } From 5c3113afb0e5fb101c7be5fb9a0d97c7b5a29a00 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 09:53:41 -0600 Subject: [PATCH 3/8] ... --- src/calibre/gui2/dialogs/tweak_epub.ui | 2 +- src/calibre/gui2/preferences/plugboard.ui | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/dialogs/tweak_epub.ui b/src/calibre/gui2/dialogs/tweak_epub.ui index 063460aaae..fc6f24675f 100644 --- a/src/calibre/gui2/dialogs/tweak_epub.ui +++ b/src/calibre/gui2/dialogs/tweak_epub.ui @@ -10,7 +10,7 @@ 0 0 382 - 242 + 265 diff --git a/src/calibre/gui2/preferences/plugboard.ui b/src/calibre/gui2/preferences/plugboard.ui index 289518816f..b73c396481 100644 --- a/src/calibre/gui2/preferences/plugboard.ui +++ b/src/calibre/gui2/preferences/plugboard.ui @@ -19,7 +19,7 @@ Here you can change the metadata calibre uses to update a book when saving to disk or sending to device. -Use this dialog to define a 'plugboard' for a format (or all formats) and a device (or all devices). The plugboard spefies what template is connected to what field. The template is used to compute a value, and that value is assigned to the connected field. +Use this dialog to define a 'plugboard' for a format (or all formats) and a device (or all devices). The plugboard specifies what template is connected to what field. The template is used to compute a value, and that value is assigned to the connected field. Often templates will contain simple references to composite columns, but this is not necessary. You can use any template in a source box that you can use elsewhere in calibre. From 0ff8bd18635b68c463a59f08dcf6fea28dc361e2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 10:21:39 -0600 Subject: [PATCH 4/8] Conversion pipeline: When rescaling images, dont replace gif image data with jpeg data --- src/calibre/ebooks/oeb/transforms/rescale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/transforms/rescale.py b/src/calibre/ebooks/oeb/transforms/rescale.py index c3b4d6d40c..79d4c76487 100644 --- a/src/calibre/ebooks/oeb/transforms/rescale.py +++ b/src/calibre/ebooks/oeb/transforms/rescale.py @@ -39,7 +39,7 @@ class RescaleImages(object): if item.media_type.startswith('image'): ext = item.media_type.split('/')[-1].upper() if ext == 'JPG': ext = 'JPEG' - if ext not in ('PNG', 'JPEG'): + if ext not in ('PNG', 'JPEG', 'GIF'): ext = 'JPEG' raw = item.data From 5471913bbaabd011e313da0fe4e1dd8801797b65 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 10:30:21 -0600 Subject: [PATCH 5/8] MOBI Output: Remove transparencies from images. Fixes #6943 (lit conversion - problem with pictures) --- src/calibre/ebooks/mobi/output.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py index 49da18ea7b..d82704a0df 100644 --- a/src/calibre/ebooks/mobi/output.py +++ b/src/calibre/ebooks/mobi/output.py @@ -41,6 +41,24 @@ class MOBIOutput(OutputFormatPlugin): ), ]) + def remove_image_transparencies(self): + from calibre.utils.magick.draw import save_cover_data_to + for item in self.oeb.manifest: + if item.media_type.startswith('image'): + raw = item.data + ext = item.media_type.split('/')[-1].lower() + if ext not in ('png', 'gif') or not raw: + continue + try: + data = save_cover_data_to(raw, 'img.'+ext, return_data=True) + except: + self.log.exception('Failed to remove transparency from', + item.href) + data = None + if data is not None: + item.data = data + item.unload_data_from_memory() + def check_for_periodical(self): if self.oeb.metadata.publication_type and \ unicode(self.oeb.metadata.publication_type[0]).startswith('periodical:'): @@ -160,6 +178,7 @@ class MOBIOutput(OutputFormatPlugin): from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable from calibre.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder from calibre.customize.ui import plugin_for_input_format + self.remove_image_transparencies() imagemax = PALM_MAX_IMAGE_SIZE if opts.rescale_images else None if not opts.no_inline_toc: tocadder = HTMLTOCAdder(title=opts.toc_title) From 74a691134fbb024176dfab93212edb61283d22e2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 10:50:07 -0600 Subject: [PATCH 6/8] MOBI Output: Fix bug that could caused left margins in the MOBI file to have twice the size of the left margins in the input document --- src/calibre/customize/profiles.py | 5 +++++ src/calibre/ebooks/mobi/mobiml.py | 5 +++-- src/calibre/ebooks/mobi/reader.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index 0310f09242..1d879f0c5d 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -255,6 +255,9 @@ class OutputProfile(Plugin): #: Unsupported unicode characters to be replaced during preprocessing unsupported_unicode_chars = [] + #: Number of ems that the left margin of a blockquote is rendered as + mobi_ems_per_blockquote = 1.0 + @classmethod def tags_to_string(cls, tags): return escape(', '.join(tags)) @@ -564,6 +567,7 @@ class KindleOutput(OutputProfile): supports_mobi_indexing = True periodical_date_in_title = False ratings_char = u'\u2605' + mobi_ems_per_blockquote = 2.0 @classmethod def tags_to_string(cls, tags): @@ -582,6 +586,7 @@ class KindleDXOutput(OutputProfile): comic_screen_size = (741, 1022) supports_mobi_indexing = True periodical_date_in_title = False + mobi_ems_per_blockquote = 2.0 @classmethod def tags_to_string(cls, tags): diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 231ad51eee..a822e66758 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -184,13 +184,14 @@ class MobiMLizer(object): elif tag in NESTABLE_TAGS and istate.rendered: para = wrapper = bstate.nested[-1] elif left > 0 and indent >= 0: + ems = self.profile.mobi_ems_per_blockquote para = wrapper = etree.SubElement(parent, XHTML('blockquote')) para = wrapper - emleft = int(round(left / self.profile.fbase)) - 1 + emleft = int(round(left / self.profile.fbase)) - ems emleft = min((emleft, 10)) while emleft > 0: para = etree.SubElement(para, XHTML('blockquote')) - emleft -= 1 + emleft -= ems else: para = wrapper = etree.SubElement(parent, XHTML('p')) bstate.inline = bstate.para = para diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 0cf31d64ec..dbe6854006 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -234,7 +234,7 @@ class MobiReader(object): self.debug = debug self.embedded_mi = None self.base_css_rules = textwrap.dedent(''' - blockquote { margin: 0em 0em 0em 1em; text-align: justify } + blockquote { margin: 0em 0em 0em 2em; text-align: justify } p { margin: 0em; text-align: justify } From 9d676fbd9cb24fdec0eeef0fecbaed20b738b7ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 10:55:27 -0600 Subject: [PATCH 7/8] ... --- src/calibre/ebooks/metadata/fb2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/metadata/fb2.py b/src/calibre/ebooks/metadata/fb2.py index 576fbaa6fc..6e0d56dfa0 100644 --- a/src/calibre/ebooks/metadata/fb2.py +++ b/src/calibre/ebooks/metadata/fb2.py @@ -33,7 +33,10 @@ def get_metadata(stream): le = XPath('descendant::fb2:last-name')(au) if le: lname = tostring(le[0]) - author += ' '+lname + if author: + author += ' '+lname + else: + author = lname if author: authors.append(author) if len(authors) == 1 and author is not None: From 51809814e87e383c2633779fb7637372b9f3e74d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 11:08:57 -0600 Subject: [PATCH 8/8] Fix #6954 (New Recipe: Science News Recent Issues) --- .../news/science_news_recent_issues.png | Bin 0 -> 696 bytes .../recipes/science_news_recent_issues.recipe | 78 ++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 resources/images/news/science_news_recent_issues.png create mode 100644 resources/recipes/science_news_recent_issues.recipe diff --git a/resources/images/news/science_news_recent_issues.png b/resources/images/news/science_news_recent_issues.png new file mode 100644 index 0000000000000000000000000000000000000000..355fb8c3a6df665f91a888d12cf7c6b57ec72d19 GIT binary patch literal 696 zcmV;p0!RIcP)5r00004b3#c}2nYxW zdcp&e7dJN>}#) zcRma=K0ZxzAy0erLfQ%qy!u`uiap{(RRzHZ#aROg#fb_RAARKJ}8RyNkb3K$U-MV@>b)_d