From ebcab0d2d32d3a95e385b9a63a87b24cee899f03 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Jul 2009 17:55:46 -0600 Subject: [PATCH 1/4] Fix searching by tag,author and format on devices. Fixes #2806 (Search interface does not work properly in the reader pane) --- src/calibre/gui2/library.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index c38af0cbf7..7d3f8c5742 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -844,14 +844,15 @@ class OnDeviceSearch(SearchQueryParser): def get_matches(self, location, query): location = location.lower().strip() query = query.lower().strip() - if location not in ('title', 'authors', 'tags', 'all'): + if location not in ('title', 'author', 'tag', 'all', 'format'): return set([]) matches = set([]) - locations = ['title', 'authors', 'tags'] if location == 'all' else [location] + locations = ['title', 'author', 'tag', 'format'] if location == 'all' else [location] q = { 'title' : lambda x : getattr(x, 'title').lower(), - 'authors': lambda x: getattr(x, 'authors').lower(), - 'tags':lambda x: ','.join(getattr(x, 'tags')).lower() + 'author': lambda x: getattr(x, 'authors').lower(), + 'tag':lambda x: ','.join(getattr(x, 'tags')).lower(), + 'format':lambda x: os.path.splitext(x.path)[1].lower() } for i, v in enumerate(locations): locations[i] = q[v] @@ -870,7 +871,7 @@ class DeviceBooksModel(BooksModel): self.db = [] self.map = [] self.sorted_map = [] - self.unknown = str(self.trUtf8('Unknown')) + self.unknown = _('Unknown') self.marked_for_deletion = {} self.search_engine = OnDeviceSearch(self) self.editable = True From 124fb1e67c6079fe3d762ec0e0096e37a0c5fff6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Jul 2009 22:06:59 -0600 Subject: [PATCH 2/4] Oops --- src/calibre/ebooks/oeb/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index ba4ebbc598..75a1ffb04d 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -790,7 +790,7 @@ class Manifest(object): data = first_pass(data) # Force into the XHTML namespace if barename(data.tag) != 'html': - self.log.warn('File %r does not appear to be (X)HTML'%self.href) + self.oeb.log.warn('File %r does not appear to be (X)HTML'%self.href) nroot = etree.fromstring('') for child in list(data): child.getparent.remove(child) From 05f02201fb42a55308842beaf3f45dedbdf87f80 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Jul 2009 22:13:43 -0600 Subject: [PATCH 3/4] More combobox related regressions --- src/calibre/gui2/dialogs/metadata_bulk.ui | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index f2bcc3cd93..05cb9cf12c 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -45,6 +45,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + authors + @@ -55,6 +58,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + author_sort + @@ -104,6 +110,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + publisher + @@ -262,6 +271,19 @@
widgets.h
+ + authors + auto_author_sort + author_sort + rating + publisher + tag_editor_button + tags + remove_tags + series + remove_format + button_box + From 3f60a90d94bb3c3076e47d0c0b6d9019487b76d9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 10 Jul 2009 14:05:28 -0600 Subject: [PATCH 4/4] HTML Input: Fix conversion when HTML files in different directories have the same name. Also ignore binary files. --- src/calibre/ebooks/html/input.py | 9 +++++++-- src/calibre/ebooks/oeb/base.py | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/html/input.py b/src/calibre/ebooks/html/input.py index fbcec7861c..6d3f5cde85 100644 --- a/src/calibre/ebooks/html/input.py +++ b/src/calibre/ebooks/html/input.py @@ -328,6 +328,7 @@ class HTMLInput(InputFormatPlugin): filelist = get_filelist(htmlpath, basedir, opts, log) + filelist = [f for f in filelist if not f.is_binary] htmlfile_map = {} for f in filelist: path = f.path @@ -336,6 +337,7 @@ class HTMLInput(InputFormatPlugin): id, href = oeb.manifest.generate(id='html', href=bname) htmlfile_map[path] = href item = oeb.manifest.add(id, href, 'text/html') + item.html_input_href = bname oeb.spine.add(item, True) self.added_resources = {} @@ -409,8 +411,9 @@ class HTMLInput(InputFormatPlugin): if not islinux: link = link.lower() if link not in self.added_resources: + bhref = os.path.basename(link) id, href = self.oeb.manifest.generate(id='added', - href=os.path.basename(link)) + href=bhref) self.oeb.log.debug('Added', link) self.oeb.container = self.DirContainer(os.path.dirname(link), self.oeb.log) @@ -418,7 +421,9 @@ class HTMLInput(InputFormatPlugin): guessed = self.guess_type(href)[0] media_type = guessed or self.BINARY_MIME - self.oeb.manifest.add(id, href, media_type).data + item = self.oeb.manifest.add(id, href, media_type) + item.html_input_href = bhref + item.data self.added_resources[link] = href nlink = self.added_resources[link] diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 75a1ffb04d..215e5a65ce 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -793,7 +793,7 @@ class Manifest(object): self.oeb.log.warn('File %r does not appear to be (X)HTML'%self.href) nroot = etree.fromstring('') for child in list(data): - child.getparent.remove(child) + child.getparent().remove(child) nroot.append(child) data = nroot elif not namespace(data.tag): @@ -927,7 +927,8 @@ class Manifest(object): if data is None: if self._loader is None: return None - data = self._loader(self.href) + data = self._loader(getattr(self, 'html_input_href', + self.href)) if not isinstance(data, basestring): pass # already parsed elif self.media_type.lower() in OEB_DOCS: