From 6d2208759ccc1ddac1ad6570c1bed406ed116e3f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jun 2011 00:11:15 -0600 Subject: [PATCH 1/5] Conversion: Convert
tags with text in them into as ADE cannot handle them. Fixes #794427 (Private bug) --- src/calibre/ebooks/oeb/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index db83fca496..a9c7664953 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1055,6 +1055,12 @@ class Manifest(object): and len(a) == 0 and not a.text: remove_elem(a) + # Convert
s with content into paragraphs as ADE can't handle + # them + for br in xpath(data, '//h:br'): + if len(br) > 0 or br.text: + br.tag = XHTML('div') + return data def _parse_txt(self, data): From 16560874daf9e8a5e83231928d4a647718e05766 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jun 2011 00:19:49 -0600 Subject: [PATCH 2/5] Fix restore database not working on some windows installs --- src/calibre/library/restore.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/library/restore.py b/src/calibre/library/restore.py index 20065309aa..8bd7174849 100644 --- a/src/calibre/library/restore.py +++ b/src/calibre/library/restore.py @@ -24,6 +24,7 @@ NON_EBOOK_EXTENSIONS = frozenset([ class RestoreDatabase(LibraryDatabase2): PATH_LIMIT = 10 + WINDOWS_LIBRARY_PATH_LIMIT = 180 def set_path(self, *args, **kwargs): pass From 5b207996292961d2adae3cd3883f6b571acf8825 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jun 2011 09:55:13 -0600 Subject: [PATCH 3/5] Make first-letter parition nodes in the tag browser click-searchable. Make regexp searching use unicode character classes. --- src/calibre/gui2/tag_view.py | 21 ++++++++++++++++++++- src/calibre/library/caches.py | 2 +- src/calibre/manual/faq.rst | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index a6a852fbdd..3b83e6d189 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -727,6 +727,15 @@ class TagTreeItem(object): # {{{ else: self.tag.state = set_to + def all_children(self): + res = [] + def recurse(nodes, res): + for t in nodes: + res.append(t) + recurse(t.children, res) + recurse(self.children, res) + return res + def child_tags(self): res = [] def recurse(nodes, res): @@ -1269,6 +1278,7 @@ class TagsModel(QAbstractItemModel): # {{{ category_icon = category_node.icon, category_key=category_node.category_key, icon_map=self.icon_state_map) + sub_cat.tag.is_searchable = False self.endInsertRows() else: # by 'first letter' cl = cl_list[idx] @@ -1651,7 +1661,16 @@ class TagsModel(QAbstractItemModel): # {{{ ans.append('%s:%s'%(node.category_key, node_searches[node.tag.state])) key = node.category_key - for tag_item in node.child_tags(): + for tag_item in node.all_children(): + if tag_item.type == TagTreeItem.CATEGORY: + if self.collapse_model == 'first letter' and \ + tag_item.temporary and not key.startswith('@') \ + and tag_item.tag.state: + if node_searches[tag_item.tag.state] == 'true': + ans.append('%s:~^%s'%(key, tag_item.py_name)) + else: + ans.append('(not %s:~^%s )'%(key, tag_item.py_name)) + continue tag = tag_item.tag if tag.state != TAG_SEARCH_STATES['clear']: if tag.state == TAG_SEARCH_STATES['mark_minus'] or \ diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 601071a2ce..b9dd2f3ed7 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -145,7 +145,7 @@ def _match(query, value, matchkind): return True elif query == t: return True - elif ((matchkind == REGEXP_MATCH and re.search(query, t, re.I)) or ### search unanchored + elif ((matchkind == REGEXP_MATCH and re.search(query, t, re.I|re.UNICODE)) or ### search unanchored (matchkind == CONTAINS_MATCH and query in t)): return True except re.error: diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index 4b527e169c..733adb65ee 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -131,7 +131,7 @@ Follow these steps to find the problem: * Make sure that you are connecting only a single device to your computer at a time. Do not have another |app| supported device like an iPhone/iPad etc. at the same time. * If you are connecting an Apple iDevice (iPad, iPod Touch, iPhone), use the 'Connect to iTunes' method in the 'Getting started' instructions in `Calibre + Apple iDevices: Start here `_. * Make sure you are running the latest version of |app|. The latest version can always be downloaded from `the calibre website `_. - * Ensure your operating system is seeing the device. That is, the device should be mounted as a disk that you can access using Windows explorer or whatever the file management program on your computer is. + * Ensure your operating system is seeing the device. That is, the device should be mounted as a disk, that you can access using Windows explorer or whatever the file management program on your computer is. On Windows your device **must have been assigned a drive letter**, like K:. * In calibre, go to Preferences->Plugins->Device Interface plugin and make sure the plugin for your device is enabled, the plugin icon next to it should be green when it is enabled. * If all the above steps fail, go to Preferences->Miscellaneous and click debug device detection with your device attached and post the output as a ticket on `the calibre bug tracker `_. From 954e04a52d98d5922abfeea24db813ae4a26914e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jun 2011 10:00:57 -0600 Subject: [PATCH 4/5] Fix #799171 (In 0.8.6 on Mac: Loading HTML pkg as ZIP file no longer picks up external style sheet from folder) --- src/calibre/ebooks/html/input.py | 2 +- src/calibre/ebooks/oeb/base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/html/input.py b/src/calibre/ebooks/html/input.py index ce6c46c6cf..69eb493c7d 100644 --- a/src/calibre/ebooks/html/input.py +++ b/src/calibre/ebooks/html/input.py @@ -457,7 +457,7 @@ class HTMLInput(InputFormatPlugin): href=bhref) guessed = self.guess_type(href)[0] media_type = guessed or self.BINARY_MIME - if 'text' in media_type: + if media_type == 'text/plain': self.log.warn('Ignoring link to text file %r'%link_) return None diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index a9c7664953..d75620adbd 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1162,7 +1162,7 @@ class Manifest(object): data = self._parse_xml(data) elif self.media_type.lower() in OEB_STYLES: data = self._parse_css(data) - elif 'text' in self.media_type.lower(): + elif self.media_type.lower() == 'text/plain': self.oeb.log.warn('%s contains data in TXT format'%self.href, 'converting to HTML') data = self._parse_txt(data) From 64d60aedc4f48a2100b081d145bf6f9342d45ea3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jun 2011 10:05:53 -0600 Subject: [PATCH 5/5] ... --- recipes/metro_uk.recipe | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/metro_uk.recipe b/recipes/metro_uk.recipe index 2d5155ef29..287af47f5c 100644 --- a/recipes/metro_uk.recipe +++ b/recipes/metro_uk.recipe @@ -1,3 +1,4 @@ +import re from calibre.web.feeds.news import BasicNewsRecipe class AdvancedUserRecipe1306097511(BasicNewsRecipe): title = u'Metro UK' @@ -10,6 +11,7 @@ class AdvancedUserRecipe1306097511(BasicNewsRecipe): remove_empty_feeds = True remove_javascript = True + preprocess_regexps = [(re.compile(r'Tweet'), lambda a : '')] language = 'en_GB'