From 1843490897e2db9fecd3df669eb6d48082dd7574 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 May 2010 12:03:25 -0600 Subject: [PATCH 1/6] EPUB Output: Add a warning if the generated EPUB has no Table of Contents --- src/calibre/ebooks/epub/output.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/ebooks/epub/output.py b/src/calibre/ebooks/epub/output.py index fd96bfdb94..129a63ef3c 100644 --- a/src/calibre/ebooks/epub/output.py +++ b/src/calibre/ebooks/epub/output.py @@ -171,6 +171,10 @@ class EPUBOutput(OutputFormatPlugin): self.workaround_sony_quirks() + if self.oeb.toc.count() == 0: + self.log.warn('This EPUB file has no Table of Contents. It will ' + 'not validate via epubcheck') + from calibre.ebooks.oeb.base import OPF identifiers = oeb.metadata['identifier'] uuid = None From 56fc01dbacf3cacbc83275c025022365b77d7fbf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 May 2010 17:46:35 -0600 Subject: [PATCH 2/6] Don't popup an error message when adding books if the cover is not a valid image --- src/calibre/library/database2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 8f42107944..f375b3345a 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1050,7 +1050,10 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): mi.pubdate = utcnow() self.set_metadata(id, mi) if cover is not None: - self.set_cover(id, cover) + try: + self.set_cover(id, cover) + except: + traceback.print_exc() return id From f2f2996940740d5cfa9826ec9c8618829f993a35 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 May 2010 17:58:02 -0600 Subject: [PATCH 3/6] Allow users to set the content server port to < 1025 (system ports) witha warning. Fixes #5470 (You can only set the server port with the up and down arrows, not direct entry) --- src/calibre/gui2/dialogs/config/__init__.py | 11 +++++++++++ src/calibre/gui2/dialogs/config/config.ui | 3 --- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/dialogs/config/__init__.py b/src/calibre/gui2/dialogs/config/__init__.py index a1c65eaf03..5ce2a89a09 100644 --- a/src/calibre/gui2/dialogs/config/__init__.py +++ b/src/calibre/gui2/dialogs/config/__init__.py @@ -464,6 +464,17 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): self.opt_overwrite_author_title_metadata.setChecked(config['overwrite_author_title_metadata']) self.opt_enforce_cpu_limit.setChecked(config['enforce_cpu_limit']) self.device_detection_button.clicked.connect(self.debug_device_detection) + self.port.editingFinished.connect(self.check_port_value) + + def check_port_value(self, *args): + port = self.port.value() + if port < 1025: + warning_dialog(self, _('System port selected'), '

'+ + _('The value %d you have chosen for the content ' + 'server port is a system port. You operating ' + 'system may not allow the server to run on this ' + 'port. To be safe choose a port number larger than ' + '1024.')%port, show=True) def debug_device_detection(self): from calibre.gui2.dialogs.config.device_debug import DebugDevice diff --git a/src/calibre/gui2/dialogs/config/config.ui b/src/calibre/gui2/dialogs/config/config.ui index aff157bb08..dd6705f6a1 100644 --- a/src/calibre/gui2/dialogs/config/config.ui +++ b/src/calibre/gui2/dialogs/config/config.ui @@ -719,9 +719,6 @@ - - 1025 - 65535 From 5fa32e48500cd3d6754f312a6a22eedc89c862dc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 May 2010 18:19:00 -0600 Subject: [PATCH 4/6] Fix #5431 (AttributeError:'NoneType' object has no attribute 'db_id') --- src/calibre/devices/prs505/books.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/prs505/books.py b/src/calibre/devices/prs505/books.py index 9d943bd8e6..ee5209c563 100644 --- a/src/calibre/devices/prs505/books.py +++ b/src/calibre/devices/prs505/books.py @@ -384,7 +384,7 @@ class BookList(_BookList): if not pl: continue db_ids = [i.getAttribute('id') for i in pl.childNodes if hasattr(i, 'getAttribute')] - pl_book_ids = [self.book_by_id(i.getAttribute('id')).db_id for i in pl.childNodes if hasattr(i, 'getAttribute')] + pl_book_ids = [getattr(self.book_by_id(i), 'db_id', None) for i in db_ids] map = {} for i, j in zip(pl_book_ids, db_ids): map[i] = j From c54008869b60e6bdf39a4db7ea88b81e1f6db7ca Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 May 2010 18:48:57 -0600 Subject: [PATCH 5/6] Add entries to the welcome wizard for the Kobo and PocketBook readers --- src/calibre/customize/profiles.py | 14 +++++++++++++- src/calibre/gui2/wizard/__init__.py | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index f253b17c6e..242c7d8a91 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -261,6 +261,18 @@ class SonyReaderOutput(OutputProfile): fbase = 12 fsizes = [7.5, 9, 10, 12, 15.5, 20, 22, 24] +class KoboReaderOutput(OutputProfile): + + name = 'Kobo Reader' + short_name = 'kobo' + + description = _('This profile is intended for the Kobo Reader.') + + screen_size = (590, 775) + dpi = 168.451 + fbase = 12 + fsizes = [7.5, 9, 10, 12, 15.5, 20, 22, 24] + class SonyReader300Output(SonyReaderOutput): author = 'John Schember' @@ -461,7 +473,7 @@ class NookOutput(OutputProfile): output_profiles = [OutputProfile, SonyReaderOutput, SonyReader300Output, SonyReader900Output, MSReaderOutput, MobipocketOutput, HanlinV3Output, HanlinV5Output, CybookG3Output, CybookOpusOutput, KindleOutput, - iPadOutput, + iPadOutput, KoboReaderOutput, SonyReaderLandscapeOutput, KindleDXOutput, IlliadOutput, IRexDR1000Output, IRexDR800Output, JetBook5Output, NookOutput,] diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 6141494bbf..30127b7266 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -92,6 +92,14 @@ class Sony505(Sony500): name = 'SONY Reader 6" and Touch Edition' id = 'prs505' +class Kobo(Device): + name = 'Kobo Reader' + manufacturer = 'Kobo' + output_profile = 'kobo' + output_format = 'EPUB' + name = 'Kobo Reader' + id = 'kobo' + class Sony300(Sony505): name = 'SONY Reader Pocket Edition' @@ -125,6 +133,20 @@ class CybookOpus(CybookG3): output_profile = 'cybook_opus' id = 'cybook_opus' +class PocketBook360(CybookOpus): + + manufacturer = 'PocketBook' + name = 'PocketBook 360' + id = 'pocketbook360' + output_profile = 'cybook_opus' + +class PocketBook(CybookG3): + + manufacturer = 'PocketBook' + name = 'PocketBook 301/302' + id = 'pocketbook' + output_profile = 'cybookg3' + class iPhone(Device): name = 'iPad or iPhone/iTouch + Stanza' From 83343816b7f6779119776c95894edb2506f07c32 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 May 2010 08:53:56 -0600 Subject: [PATCH 6/6] EPUB Output: When rescaling PNG images, write out the rescaled data in PNG format as ADE cannot handle JPEG data in a PNG file --- src/calibre/ebooks/oeb/transforms/rescale.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/rescale.py b/src/calibre/ebooks/oeb/transforms/rescale.py index a217af853a..55aafded5c 100644 --- a/src/calibre/ebooks/oeb/transforms/rescale.py +++ b/src/calibre/ebooks/oeb/transforms/rescale.py @@ -37,6 +37,11 @@ class RescaleImages(object): page_height -= (self.opts.margin_top + self.opts.margin_bottom) * self.opts.dest.dpi/72. for item in self.oeb.manifest: if item.media_type.startswith('image'): + ext = item.media_type.split('/')[-1].upper() + if ext == 'JPG': ext = 'JPEG' + if ext not in ('PNG', 'JPEG'): + ext = 'JPEG' + raw = item.data if not raw: continue if qt: @@ -65,11 +70,11 @@ class RescaleImages(object): if qt: img = img.scaled(new_width, new_height, Qt.IgnoreAspectRatio, Qt.SmoothTransformation) - data = pixmap_to_data(img) + data = pixmap_to_data(img, format=ext) else: im = im.resize((int(new_width), int(new_height)), PILImage.ANTIALIAS) of = cStringIO.StringIO() - im.convert('RGB').save(of, 'JPEG') + im.convert('RGB').save(of, ext) data = of.getvalue() if data is not None: item.data = data