From 8f0af30946cf5412f6d0c189c4ebffbd32949e18 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sat, 1 Jan 2011 15:17:11 -0700 Subject: [PATCH 01/26] GwR patch losing last author of divRunningTag --- src/calibre/library/catalog.py | 62 +++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 5f771a8a6d..4cc3cdbabb 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -11,7 +11,7 @@ from xml.sax.saxutils import escape from lxml import etree from calibre import prints, prepare_string_for_xml, strftime -from calibre.constants import preferred_encoding +from calibre.constants import preferred_encoding, DEBUG from calibre.customize import CatalogPlugin from calibre.customize.conversion import OptionRecommendation, DummyReporter from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString @@ -1917,34 +1917,36 @@ class EPUB_MOBI(CatalogPlugin): aTag['name'] = anchor_name.replace(" ","") body.insert(btc, aTag) btc += 1 - ''' - # We don't need this because the kindle inserts section titles - #

By Author

- h2Tag = Tag(soup, "h2") - aTag = Tag(soup, "a") - anchor_name = friendly_name.lower() - aTag['name'] = anchor_name.replace(" ","") - h2Tag.insert(0,aTag) - h2Tag.insert(1,NavigableString('%s' % friendly_name)) - body.insert(btc,h2Tag) - btc += 1 - ''' #

#

divTag = Tag(soup, "div") dtc = 0 - current_letter = "" - current_author = "" - current_series = None + divOpeningTag = None + dotc = 0 + divRunningTag = None + drtc = 0 # Loop through booksByAuthor book_count = 0 - divRunningTag = None + current_author = '' + previous_author = '' + current_letter = '' + current_series = None for book in self.booksByAuthor: book_count += 1 if self.letter_or_symbol(book['author_sort'][0].upper()) != current_letter : # Start a new letter with Index letter + if divOpeningTag is not None: + divTag.insert(dtc, divOpeningTag) + dtc += 1 + dotc = 0 + if divRunningTag is not None: + divTag.insert(dtc, divRunningTag) + dtc += 1 + drtc = 0 + divRunningTag = None + current_letter = self.letter_or_symbol(book['author_sort'][0].upper()) author_count = 0 divOpeningTag = Tag(soup, 'div') @@ -1964,16 +1966,16 @@ class EPUB_MOBI(CatalogPlugin): current_author = book['author'] author_count += 1 if author_count == 2: - # Add divOpeningTag to divTag + # Add divOpeningTag to divTag, kill divOpeningTag divTag.insert(dtc, divOpeningTag) dtc += 1 - elif author_count > 2 and divRunningTag is not None: - divTag.insert(dtc, divRunningTag) - dtc += 1 + divOpeningTag = None + dotc = 0 - divRunningTag = Tag(soup, 'div') - divRunningTag['style'] = 'display:inline-block;width:100%' - drtc = 0 + # Create a divRunningTag for the rest of the authors in this letter + divRunningTag = Tag(soup, 'div') + divRunningTag['style'] = 'display:inline-block;width:100%' + drtc = 0 non_series_books = 0 current_series = None @@ -1986,7 +1988,7 @@ class EPUB_MOBI(CatalogPlugin): if author_count == 1: divOpeningTag.insert(dotc, pAuthorTag) dotc += 1 - elif divRunningTag is not None: + else: divRunningTag.insert(drtc,pAuthorTag) drtc += 1 @@ -2059,10 +2061,12 @@ class EPUB_MOBI(CatalogPlugin): if author_count == 1: divOpeningTag.insert(dotc, pBookTag) dotc += 1 - elif divRunningTag is not None: + else: divRunningTag.insert(drtc,pBookTag) drtc += 1 + # Loop ends here + if not self.__generateForKindle: # Insert the

tag with book_count at the head #

By Author

@@ -2080,6 +2084,9 @@ class EPUB_MOBI(CatalogPlugin): if author_count == 1: divTag.insert(dtc, divOpeningTag) dtc += 1 + elif divRunningTag is not None: + divTag.insert(dtc, divRunningTag) + dtc += 1 # Add the divTag to the body body.insert(btc, divTag) @@ -5027,7 +5034,8 @@ class EPUB_MOBI(CatalogPlugin): if catalog_source_built: recommendations = [] - recommendations.append(('comments', '\n'.join(line for line in build_log), + if DEBUG: + recommendations.append(('comments', '\n'.join(line for line in build_log), OptionRecommendation.HIGH)) dp = getattr(opts, 'debug_pipeline', None) From 2e7a4c9d4eb5c3a3fb5faea4a29a6a748bad827a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 1 Jan 2011 16:36:06 -0700 Subject: [PATCH 02/26] Fix #8149 (getting this error message when i try to open up book details in new 0.7.36version) --- src/calibre/gui2/dialogs/book_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/book_info.py b/src/calibre/gui2/dialogs/book_info.py index eac8461299..4da897920c 100644 --- a/src/calibre/gui2/dialogs/book_info.py +++ b/src/calibre/gui2/dialogs/book_info.py @@ -23,7 +23,7 @@ class BookInfo(QDialog, Ui_BookInfo): self.cover_pixmap = None self.comments.sizeHint = self.comments_size_hint self.comments.page().setLinkDelegationPolicy(self.comments.page().DelegateAllLinks) - self.comments.linkClicked(self.link_clicked) + self.comments.linkClicked.connect(self.link_clicked) self.view_func = view_func From 00136022865693e9106eaf9c4ca29d7dbeeda275 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sat, 1 Jan 2011 18:09:42 -0700 Subject: [PATCH 03/26] GwR patch catalog.py --- src/calibre/library/catalog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 4cc3cdbabb..f013477308 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -5037,6 +5037,8 @@ class EPUB_MOBI(CatalogPlugin): if DEBUG: recommendations.append(('comments', '\n'.join(line for line in build_log), OptionRecommendation.HIGH)) + else: + recommendations.append(('comments', '', OptionRecommendation.HIGH)) dp = getattr(opts, 'debug_pipeline', None) if dp is not None: From 02d68b83a1c4cdf7ccbde71965b5cbc10042d13b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 09:42:45 -0700 Subject: [PATCH 04/26] Fix regression in 0.7.36 that broke PDF Output when specifying a cover --- src/calibre/ebooks/pdf/writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdf/writer.py b/src/calibre/ebooks/pdf/writer.py index 4ff10290c9..b0884417f6 100644 --- a/src/calibre/ebooks/pdf/writer.py +++ b/src/calibre/ebooks/pdf/writer.py @@ -175,7 +175,7 @@ class PDFWriter(QObject): # {{{ if self.cover_data is None: return item_path = os.path.join(self.tmp_path, 'cover.pdf') - printer = self.get_printer() + printer = get_pdf_printer(self.opts) printer.setOutputFileName(item_path) self.combine_queue.insert(0, item_path) p = QPixmap() From bcfbe8188888dcd85a85a8c590dad43d8a22bc67 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 10:34:09 -0700 Subject: [PATCH 05/26] Windows device detection: If the driver order detection assigns the same drive order to disks on the device, use the drive letter when sorting. --- src/calibre/devices/scanner.py | 6 ++++++ src/calibre/devices/usbms/device.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/scanner.py b/src/calibre/devices/scanner.py index 380dcb7440..ab06db1af0 100644 --- a/src/calibre/devices/scanner.py +++ b/src/calibre/devices/scanner.py @@ -30,6 +30,12 @@ class Drive(str): typ.order = order return typ +def drivecmp(a, b): + ans = cmp(getattr(a, 'order', 0), getattr(b, 'order', 0)) + if ans == 0: + ans = cmp(a, b) + return ans + class WinPNPScanner(object): diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 2c095d6f7b..4711a8eec4 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -11,7 +11,7 @@ intended to be subclassed with the relevant parts implemented for a particular device. This class handles device detection. ''' -import os, subprocess, time, re, sys, glob, operator +import os, subprocess, time, re, sys, glob from itertools import repeat from calibre.devices.interface import DevicePlugin @@ -225,7 +225,7 @@ class Device(DeviceConfig, DevicePlugin): return False def open_windows(self): - from calibre.devices.scanner import win_pnp_drives + from calibre.devices.scanner import win_pnp_drives, drivecmp time.sleep(5) drives = {} @@ -263,7 +263,7 @@ class Device(DeviceConfig, DevicePlugin): if self.WINDOWS_MAIN_MEM in (self.WINDOWS_CARD_A_MEM, self.WINDOWS_CARD_B_MEM) or \ self.WINDOWS_CARD_A_MEM == self.WINDOWS_CARD_B_MEM: - letters = sorted(drives.values(), key=operator.attrgetter('order')) + letters = sorted(drives.values(), cmp=drivecmp) drives = {} for which, letter in zip(['main', 'carda', 'cardb'], letters): drives[which] = letter From 206d4982ab36cf7cbf7275b92b08316f4d4036e6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 10:47:12 -0700 Subject: [PATCH 06/26] Fix #8159 (Calibre thinks that the Memory Card is Main Memory.) --- src/calibre/devices/scanner.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/scanner.py b/src/calibre/devices/scanner.py index ab06db1af0..241d503c14 100644 --- a/src/calibre/devices/scanner.py +++ b/src/calibre/devices/scanner.py @@ -63,7 +63,13 @@ class WinPNPScanner(object): order = 0 match = re.search(r'REV_.*?&(\d+)#', pnp_id) if match is None: - match = re.search(r'REV_.*?&(\d+)', pnp_id) + # Windows XP + # On the Nook Color this is the last digit + # + # USBSTOR\DISK&VEN_B&N&PROD_EBOOK_DISK&REV_0100\7&13EAFDB8&0&2004760017462009&1 + # USBSTOR\DISK&VEN_B&N&PROD_EBOOK_DISK&REV_0100\7&13EAFDB8&0&2004760017462009&0 + # + match = re.search(r'REV_.*&(\d+)', pnp_id) if match is not None: order = int(match.group(1)) return order From ccd7d1c25347589a35cc87477a0366ab98981e68 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 10:56:40 -0700 Subject: [PATCH 07/26] ... --- src/calibre/gui2/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 371c4df701..c8b5cb001e 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -303,7 +303,7 @@ def run_gui(opts, args, actions, listener, app, gui_debug=None): runner.main.system_tray_icon.hide() except: pass - if runner.main.gui_debug is not None: + if getattr(runner.main, 'gui_debug', None) is not None: e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0] import subprocess creationflags = 0 From 9f7bdcdc0ba6dd4bf57ff9fee0ae9581159b0d87 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 11:00:18 -0700 Subject: [PATCH 08/26] Tag browser: Fix grouping by name for authors --- resources/default_tweaks.py | 2 +- src/calibre/gui2/tag_view.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index 9726ed3b09..b2133ed331 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -77,7 +77,7 @@ categories_use_field_for_author_name = 'author' # sort: the sort value. For authors, this is the author_sort for that author # category: the category (e.g., authors, series) that the item is in. categories_collapse_more_than = 50 -categories_collapsed_name_template = '{first.name:shorten(4,'',0)} - {last.name::shorten(4,'',0)}' +categories_collapsed_name_template = '{first.sort:shorten(4,'',0)} - {last.sort:shorten(4,'',0)}' categories_collapsed_rating_template = '{first.avg_rating:4.2f:ifempty(0)} - {last.avg_rating:4.2f:ifempty(0)}' categories_collapsed_popularity_template = '{first.count:d} - {last.count:d}' categories_collapse_model = 'first letter' diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index f04902283e..d6a7a6d604 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -738,7 +738,7 @@ class TagsModel(QAbstractItemModel): # {{{ category_key=category_node.category_key) else: if upper(tag.sort[0]) != collapse_letter: - collapse_letter = upper(tag.name[0]) + collapse_letter = upper(tag.sort[0]) sub_cat = TagTreeItem(parent=category, data = collapse_letter, category_icon = category_node.icon, From 21daa3c72ab507c8f03cc27cbe1d9619d7a92aea Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 11:01:56 -0700 Subject: [PATCH 09/26] Tag Browser: Fix the Manage X items in the right click menu --- src/calibre/gui2/tag_view.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index d6a7a6d604..b89b756da2 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -216,6 +216,8 @@ class TagsView(QTreeView): # {{{ item = item.parent if item.type == TagTreeItem.CATEGORY: + while item.parent != self._model.root_item: + item = item.parent category = unicode(item.name.toString()) key = item.category_key # Verify that we are working with a field that we know something about From 59b476a8b205d7bbf12b96023c519b754ec06824 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 11:09:57 -0700 Subject: [PATCH 10/26] Tag browser: Allow changing the sub-categorization scheme from the context menu --- resources/default_tweaks.py | 9 ++++-- src/calibre/gui2/tag_view.py | 58 ++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index b2133ed331..e3a606327a 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -61,7 +61,7 @@ categories_use_field_for_author_name = 'author' # first letter (categories_collapse_model = 'first letter') or into equal-sized # groups (categories_collapse_model = 'partition'). If sorting by average rating # or by popularity, then 'partition' is always used. The addition of -# subcategories can be disabled by setting categories_collapse_more_than = 0. +# subcategories can be disabled by setting categories_collapse_model='disable'. # When using partition, the format of the subcategory label is controlled by a # template: categories_collapsed_name_template if sorting by name, # categories_collapsed_rating_template if sorting by average rating, and @@ -76,11 +76,16 @@ categories_use_field_for_author_name = 'author' # avg_rating: the averate rating of all the books referencing this item # sort: the sort value. For authors, this is the author_sort for that author # category: the category (e.g., authors, series) that the item is in. +# Possible values: +# category_collapse_model: 'disable', 'first letter', 'partition' +# categories_collapse_more_than: a number greater than or equal to 0 +# the templates: any valid template using only 'first' and 'last' +categories_collapse_model = 'first letter' categories_collapse_more_than = 50 categories_collapsed_name_template = '{first.sort:shorten(4,'',0)} - {last.sort:shorten(4,'',0)}' categories_collapsed_rating_template = '{first.avg_rating:4.2f:ifempty(0)} - {last.avg_rating:4.2f:ifempty(0)}' categories_collapsed_popularity_template = '{first.count:d} - {last.count:d}' -categories_collapse_model = 'first letter' + # Set whether boolean custom columns are two- or three-valued. # Two-values for true booleans diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index b89b756da2..538d16cd85 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -94,6 +94,10 @@ class TagsView(QTreeView): # {{{ self.setDropIndicatorShown(True) self.setAutoExpandDelay(500) self.pane_is_visible = False + if tweaks['categories_collapse_more_than'] == 0: + self.collapse_model = 'disable' + else: + self.collapse_model = tweaks['categories_collapse_model'] def set_pane_is_visible(self, to_what): pv = self.pane_is_visible @@ -106,7 +110,8 @@ class TagsView(QTreeView): # {{{ self._model = TagsModel(db, parent=self, hidden_categories=self.hidden_categories, search_restriction=None, - drag_drop_finished=self.drag_drop_finished) + drag_drop_finished=self.drag_drop_finished, + collapse_model=self.collapse_model) self.pane_is_visible = True # because TagsModel.init did a recount self.sort_by = sort_by self.tag_match = tag_match @@ -194,6 +199,11 @@ class TagsView(QTreeView): # {{{ self.hidden_categories.add(category) elif action == 'show': self.hidden_categories.discard(category) + elif action == 'categorization': + changed = self.collapse_model != category + self.collapse_model = category + if changed: + self.set_new_model(self._model.get_filter_categories_by()) elif action == 'defaults': self.hidden_categories.clear() config.set('tag_browser_hidden_categories', self.hidden_categories) @@ -279,6 +289,23 @@ class TagsView(QTreeView): # {{{ self.context_menu.addAction(_('Show all categories'), partial(self.context_menu_handler, action='defaults')) + m = self.context_menu.addMenu(_('Change sub-categorization scheme')) + da = m.addAction('Disable', + partial(self.context_menu_handler, action='categorization', category='disable')) + fla = m.addAction('By first letter', + partial(self.context_menu_handler, action='categorization', category='first letter')) + pa = m.addAction('Partition', + partial(self.context_menu_handler, action='categorization', category='partition')) + if self.collapse_model == 'disable': + da.setCheckable(True) + da.setChecked(True) + elif self.collapse_model == 'first letter': + fla.setCheckable(True) + fla.setChecked(True) + else: + pa.setCheckable(True) + pa.setChecked(True) + if not self.context_menu.isEmpty(): self.context_menu.popup(self.mapToGlobal(point)) return True @@ -340,7 +367,8 @@ class TagsView(QTreeView): # {{{ hidden_categories=self.hidden_categories, search_restriction=self.search_restriction, drag_drop_finished=self.drag_drop_finished, - filter_categories_by=filter_categories_by) + filter_categories_by=filter_categories_by, + collapse_model=self.collapse_model) self.setModel(self._model) except: # The DB must be gone. Set the model to None and hope that someone @@ -469,7 +497,7 @@ class TagsModel(QAbstractItemModel): # {{{ def __init__(self, db, parent, hidden_categories=None, search_restriction=None, drag_drop_finished=None, - filter_categories_by=None): + filter_categories_by=None, collapse_model='disable'): QAbstractItemModel.__init__(self, parent) # must do this here because 'QPixmap: Must construct a QApplication @@ -490,6 +518,7 @@ class TagsModel(QAbstractItemModel): # {{{ self.search_restriction = search_restriction self.row_map = [] self.filter_categories_by = filter_categories_by + self.collapse_model = collapse_model # get_node_tree cannot return None here, because row_map is empty data = self.get_node_tree(config['sort_tags_by']) @@ -681,15 +710,18 @@ class TagsModel(QAbstractItemModel): # {{{ return False row_index = -1 collapse = tweaks['categories_collapse_more_than'] - collapse_model = tweaks['categories_collapse_model'] - if sort_by == 'name': - collapse_template = tweaks['categories_collapsed_name_template'] - elif sort_by == 'rating': - collapse_model = 'partition' - collapse_template = tweaks['categories_collapsed_rating_template'] - else: - collapse_model = 'partition' - collapse_template = tweaks['categories_collapsed_popularity_template'] + collapse_model = self.collapse_model + if collapse == 0: + collapse_model = 'disable' + elif collapse_model != 'disable': + if sort_by == 'name': + collapse_template = tweaks['categories_collapsed_name_template'] + elif sort_by == 'rating': + collapse_model = 'partition' + collapse_template = tweaks['categories_collapsed_rating_template'] + else: + collapse_model = 'partition' + collapse_template = tweaks['categories_collapsed_popularity_template'] collapse_letter = None for i, r in enumerate(self.row_map): @@ -724,7 +756,7 @@ class TagsModel(QAbstractItemModel): # {{{ tag.avg_rating = None tag.state = state_map.get(tag.name, 0) - if collapse > 0 and cat_len > collapse: + if collapse_model != 'disable' and cat_len > collapse: if collapse_model == 'partition': if (idx % collapse) == 0: d = {'first': tag} From bd4f65258dd66ab6383c582ac4b61274ebba86d5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 11:14:48 -0700 Subject: [PATCH 11/26] Fix regression that broke sort_columns_at_startup twek in 0.7.36 --- src/calibre/gui2/library/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 322199a4f9..c1dd5b3766 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -386,7 +386,12 @@ class BooksView(QTableView): # {{{ old_state = self.get_default_state() if tweaks['sort_columns_at_startup'] is not None: - old_state['sort_history'] = tweaks['sort_columns_at_startup'] + sh = [] + for c,d in tweaks['sort_columns_at_startup']: + if not isinstance(d, bool): + d = True if d == 0 else False + sh.append((c, d)) + old_state['sort_history'] = sh self.apply_state(old_state) From d99b2e97fba8029856c35210281c92cacc286688 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 11:17:33 -0700 Subject: [PATCH 12/26] ... --- Changelog.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.yaml b/Changelog.yaml index 79ef8f249c..e46d937411 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -5,7 +5,7 @@ # Also, each release can have new and improved recipes. - version: 0.7.36 - date: 2010-01-01 + date: 2011-01-01 new features: - title: "Tag browser: Add subcategories and search" From 40b5755934363fd51288b9d3285867a60e59e60c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 11:31:56 -0700 Subject: [PATCH 13/26] Tag browser: Move the configuration of the sub-category grouping from tweaks to the Preferences dialog --- resources/default_tweaks.py | 19 ++--------- src/calibre/gui2/__init__.py | 2 ++ src/calibre/gui2/preferences/look_feel.py | 6 ++++ src/calibre/gui2/preferences/look_feel.ui | 40 ++++++++++++++++++++--- src/calibre/gui2/tag_view.py | 16 ++++++--- 5 files changed, 58 insertions(+), 25 deletions(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index e3a606327a..4ae0278133 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -55,16 +55,9 @@ author_sort_copy_method = 'invert' # categories_use_field_for_author_name = 'author_sort' categories_use_field_for_author_name = 'author' -# Control how the tags pane displays categories containing many items. If the -# number of items is larger than categories_collapse_more_than, a sub-category -# will be added. If sorting by name, then the subcategories can be organized by -# first letter (categories_collapse_model = 'first letter') or into equal-sized -# groups (categories_collapse_model = 'partition'). If sorting by average rating -# or by popularity, then 'partition' is always used. The addition of -# subcategories can be disabled by setting categories_collapse_model='disable'. -# When using partition, the format of the subcategory label is controlled by a -# template: categories_collapsed_name_template if sorting by name, -# categories_collapsed_rating_template if sorting by average rating, and +# When partitioning the tags browser, the format of the subcategory label is +# controlled by a template: categories_collapsed_name_template if sorting by +# name, categories_collapsed_rating_template if sorting by average rating, and # categories_collapsed_popularity_template if sorting by popularity. There are # two variables available to the template: first and last. The variable 'first' # is the initial item in the subcategory, and the variable 'last' is the final @@ -76,12 +69,6 @@ categories_use_field_for_author_name = 'author' # avg_rating: the averate rating of all the books referencing this item # sort: the sort value. For authors, this is the author_sort for that author # category: the category (e.g., authors, series) that the item is in. -# Possible values: -# category_collapse_model: 'disable', 'first letter', 'partition' -# categories_collapse_more_than: a number greater than or equal to 0 -# the templates: any valid template using only 'first' and 'last' -categories_collapse_model = 'first letter' -categories_collapse_more_than = 50 categories_collapsed_name_template = '{first.sort:shorten(4,'',0)} - {last.sort:shorten(4,'',0)}' categories_collapsed_rating_template = '{first.avg_rating:4.2f:ifempty(0)} - {last.avg_rating:4.2f:ifempty(0)}' categories_collapsed_popularity_template = '{first.count:d} - {last.count:d}' diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 1c99d9d9d5..8c62304f09 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -53,6 +53,8 @@ gprefs.defaults['toolbar_icon_size'] = 'medium' gprefs.defaults['toolbar_text'] = 'auto' gprefs.defaults['show_child_bar'] = False gprefs.defaults['font'] = None +gprefs.defaults['tags_browser_partition_method'] = 'first letter' +gprefs.defaults['tags_browser_collapse_at'] = 50 # }}} diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index de1116c231..263d19325d 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -57,6 +57,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): (_('Never'), 'never')] r('toolbar_text', gprefs, choices=choices) + choices = [(_('Disabled'), 'disabled'), (_('By first letter'), 'first letter'), + (_('Partitioned'), 'partition')] + r('tags_browser_partition_method', gprefs, choices=choices) + r('tags_browser_collapse_at', gprefs) + self.current_font = None self.change_font_button.clicked.connect(self.change_font) @@ -113,6 +118,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def refresh_gui(self, gui): gui.search.search_as_you_type(config['search_as_you_type']) self.update_font_display() + gui.tags_view.reread_collapse_parameters() if __name__ == '__main__': app = QApplication([]) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 8e57f8c17e..36a45b8dce 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -7,7 +7,7 @@ 0 0 670 - 385 + 420 @@ -141,7 +141,37 @@ - + + + + Tags browser: partitioning method: + + + opt_tags_browser_partition_method + + + + + + + + + + Tags browser - collapse when more items than: + + + opt_tags_browser_collapse_at + + + + + + + 1000000 + + + + &Toolbar @@ -183,7 +213,7 @@ - + @@ -204,14 +234,14 @@ - + Change &font (needs restart) - + Qt::Vertical diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index 538d16cd85..8d42e51dfc 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -17,7 +17,7 @@ from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, QFont, QSize, \ QShortcut, QKeySequence, SIGNAL from calibre.ebooks.metadata import title_sort -from calibre.gui2 import config, NONE +from calibre.gui2 import config, NONE, gprefs from calibre.library.field_metadata import TagsIcons, category_icon_map from calibre.utils.config import tweaks from calibre.utils.icu import sort_key, upper, lower, strcmp @@ -94,10 +94,10 @@ class TagsView(QTreeView): # {{{ self.setDropIndicatorShown(True) self.setAutoExpandDelay(500) self.pane_is_visible = False - if tweaks['categories_collapse_more_than'] == 0: + if gprefs['tags_browser_collapse_at'] == 0: self.collapse_model = 'disable' else: - self.collapse_model = tweaks['categories_collapse_model'] + self.collapse_model = gprefs['tags_browser_partition_method'] def set_pane_is_visible(self, to_what): pv = self.pane_is_visible @@ -105,6 +105,13 @@ class TagsView(QTreeView): # {{{ if to_what and not pv: self.recount() + def reread_collapse_parameters(self): + if gprefs['tags_browser_collapse_at'] == 0: + self.collapse_model = 'disable' + else: + self.collapse_model = gprefs['tags_browser_partition_method'] + self.set_new_model(self._model.get_filter_categories_by()) + def set_database(self, db, tag_match, sort_by): self.hidden_categories = config['tag_browser_hidden_categories'] self._model = TagsModel(db, parent=self, @@ -204,6 +211,7 @@ class TagsView(QTreeView): # {{{ self.collapse_model = category if changed: self.set_new_model(self._model.get_filter_categories_by()) + gprefs['tags_browser_partition_method'] = category elif action == 'defaults': self.hidden_categories.clear() config.set('tag_browser_hidden_categories', self.hidden_categories) @@ -709,7 +717,7 @@ class TagsModel(QAbstractItemModel): # {{{ if data is None: return False row_index = -1 - collapse = tweaks['categories_collapse_more_than'] + collapse = gprefs['tags_browser_collapse_at'] collapse_model = self.collapse_model if collapse == 0: collapse_model = 'disable' From 01469303ab53ff49026d0c9c26aa1e9c5c87d437 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sun, 2 Jan 2011 11:53:03 -0700 Subject: [PATCH 14/26] GwR patch for empty merge field --- src/calibre/library/catalog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index f013477308..c91c6bca88 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -4829,6 +4829,8 @@ class EPUB_MOBI(CatalogPlugin): addendum = self.__db.get_field(record['id'], self.__merge_comments['field'], index_is_id=True) + if addendum is None: + addendum = '' include_hr = eval(self.__merge_comments['hr']) if self.__merge_comments['position'] == 'before': merged = addendum From 9515a4d5e16149deb678f1dddbc1ab8871a1dc9b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 12:00:34 -0700 Subject: [PATCH 15/26] Clean up use of ZipFile in catalog.py --- src/calibre/library/catalog.py | 26 ++++++++++++-------------- src/calibre/utils/zipfile.py | 6 ++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index dab715dfa4..73a1a7372e 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -4,7 +4,6 @@ __license__ = 'GPL v3' __copyright__ = '2010, Greg Riker' import codecs, datetime, htmlentitydefs, os, re, shutil, time, zlib -from contextlib import closing from collections import namedtuple from copy import deepcopy from xml.sax.saxutils import escape @@ -33,7 +32,7 @@ FIELDS = ['all', 'author_sort', 'authors', 'comments', TEMPLATE_ALLOWED_FIELDS = [ 'author_sort', 'authors', 'id', 'isbn', 'pubdate', 'publisher', 'series_index', 'series', 'tags', 'timestamp', 'title', 'uuid' ] -class CSV_XML(CatalogPlugin): +class CSV_XML(CatalogPlugin): # {{{ 'CSV/XML catalog generator' Option = namedtuple('Option', 'option, default, dest, action, help') @@ -209,8 +208,9 @@ class CSV_XML(CatalogPlugin): with open(path_to_output, 'w') as f: f.write(etree.tostring(root, encoding='utf-8', xml_declaration=True, pretty_print=True)) +# }}} -class BIBTEX(CatalogPlugin): +class BIBTEX(CatalogPlugin): # {{{ 'BIBTEX catalog generator' Option = namedtuple('Option', 'option, default, dest, action, help') @@ -535,6 +535,7 @@ class BIBTEX(CatalogPlugin): bibtexc, citation_bibtex)) outfile.close() +# }}} class EPUB_MOBI(CatalogPlugin): 'ePub catalog generator' @@ -991,12 +992,10 @@ class EPUB_MOBI(CatalogPlugin): if not os.path.exists(self.__archive_path): self.opts.log.info(' creating thumbnail archive, thumb_width: %1.2f"' % float(self.opts.thumb_width)) - zfw = ZipFile(self.__archive_path, mode='w') - zfw.writestr("Catalog Thumbs Archive",'') - #zfw.comment = "thumb_width: %1.2f" % float(self.opts.thumb_width) - zfw.close() + with ZipFile(self.__archive_path, mode='w') as zfw: + zfw.writestr("Catalog Thumbs Archive",'') else: - with closing(ZipFile(self.__archive_path, mode='r')) as zfr: + with ZipFile(self.__archive_path, mode='r') as zfr: try: cached_thumb_width = zfr.read('thumb_width') except: @@ -1007,7 +1006,7 @@ class EPUB_MOBI(CatalogPlugin): self.opts.log.warning(' thumb_width changed: %1.2f" => %1.2f"' % (float(cached_thumb_width),float(self.opts.thumb_width))) os.remove(self.__archive_path) - with closing(ZipFile(self.__archive_path, mode='w')) as zfw: + with ZipFile(self.__archive_path, mode='w') as zfw: zfw.writestr("Catalog Thumbs Archive",'') else: self.opts.log.info(' existing thumb cache at %s, cached_thumb_width: %1.2f"' % @@ -2913,7 +2912,7 @@ class EPUB_MOBI(CatalogPlugin): # Write the thumb_width to the file validating cache contents # Allows detection of aborted catalog builds - with closing(ZipFile(self.__archive_path, mode='a'))as zfw: + with ZipFile(self.__archive_path, mode='a') as zfw: zfw.writestr('thumb_width', self.opts.thumb_width) self.thumbs = thumbs @@ -4659,7 +4658,7 @@ class EPUB_MOBI(CatalogPlugin): cover_crc = hex(zlib.crc32(data)) # Test cache for uuid - with closing(ZipFile(self.__archive_path, mode='r')) as zfr: + with ZipFile(self.__archive_path, mode='r') as zfr: try: t_info = zfr.getinfo(title['uuid']) except: @@ -4683,9 +4682,8 @@ class EPUB_MOBI(CatalogPlugin): # Save thumb to archive t_info = ZipInfo(title['uuid'],time.localtime()[0:6]) t_info.comment = cover_crc - zfw = ZipFile(self.__archive_path, mode='a') - zfw.writestr(t_info, thumb_data) - zfw.close() + with ZipFile(self.__archive_path, mode='a') as zfw: + zfw.writestr(t_info, thumb_data) def getFriendlyGenreTag(self, genre): # Find the first instance of friendly_tag matching genre diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index 7f6e97f7d2..ff290abd25 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -1258,6 +1258,12 @@ class ZipFile: """Call the "close()" method in case the user forgot.""" self.close() + def __enter__(self): + return self + + def __exit__(self, typ, value, traceback): + self.close() + def close(self): """Close the file, and for mode "w" and "a" write the ending records.""" From 77b4d61c5298d54f626bd819a27cb9d8a75bf3a4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 12:18:19 -0700 Subject: [PATCH 16/26] ... --- src/calibre/gui2/__init__.py | 2 +- src/calibre/gui2/preferences/look_feel.ui | 88 +++++++++++++++-------- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 8c62304f09..df6ac45e5b 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -54,7 +54,7 @@ gprefs.defaults['toolbar_text'] = 'auto' gprefs.defaults['show_child_bar'] = False gprefs.defaults['font'] = None gprefs.defaults['tags_browser_partition_method'] = 'first letter' -gprefs.defaults['tags_browser_collapse_at'] = 50 +gprefs.defaults['tags_browser_collapse_at'] = 100 # }}} diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 36a45b8dce..3b6bbb63ab 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -7,7 +7,7 @@ 0 0 670 - 420 + 392 @@ -141,35 +141,63 @@ - - - - Tags browser: partitioning method: - - - opt_tags_browser_partition_method - - - - - - - - - - Tags browser - collapse when more items than: - - - opt_tags_browser_collapse_at - - - - - - - 1000000 - - + + + + + + Tags browser category partitioning method: + + + opt_tags_browser_partition_method + + + + + + + Choose how tag browser subcategories are displayed when +there are more items than the limit. Select by first +letter to see an A, B, C list. Choose partitioned to +have a list of fixed-sized groups. Set to disabled +if you never want subcategories + + + + + + + Collapse when more items than: + + + opt_tags_browser_collapse_at + + + + + + + If a Tag Browser category has more than this number of items, it is divided up into sub-categories. Set to zero to disable. + + + 10000 + + + + + + + Qt::Horizontal + + + + 20 + 5 + + + + + From 547cee660cd07715eb64d537c7d5c86537a9ff27 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 12:30:10 -0700 Subject: [PATCH 17/26] ... --- src/calibre/gui2/wizard/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 4f418d34d5..4e5e79bbdf 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -174,7 +174,7 @@ class CybookOrizon(CybookOpus): class PocketBook360(CybookOpus): manufacturer = 'PocketBook' - name = 'PocketBook 360' + name = 'PocketBook 360 and newer models' id = 'pocketbook360' output_profile = 'cybook_opus' From 7c084b0630e4b5021fe96e3f93d0a5dae34b6e62 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 12:59:33 -0700 Subject: [PATCH 18/26] Catalog generation: Work on a copy of the library database so as not to lock it --- src/calibre/gui2/convert/gui_conversion.py | 2 +- src/calibre/library/__init__.py | 5 +++-- src/calibre/library/database2.py | 9 ++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/convert/gui_conversion.py b/src/calibre/gui2/convert/gui_conversion.py index 116f09e429..d1e1270924 100644 --- a/src/calibre/gui2/convert/gui_conversion.py +++ b/src/calibre/gui2/convert/gui_conversion.py @@ -30,7 +30,7 @@ def gui_catalog(fmt, title, dbspec, ids, out_file_name, sync, fmt_options, conne from calibre.library import db from calibre.utils.config import prefs prefs.refresh() - db = db() + db = db(read_only=True) db.catalog_plugin_on_device_temp_mapping = dbspec # Create a minimal OptionParser that we can append to diff --git a/src/calibre/library/__init__.py b/src/calibre/library/__init__.py index d08ca0b44f..2e00db32c4 100644 --- a/src/calibre/library/__init__.py +++ b/src/calibre/library/__init__.py @@ -2,10 +2,11 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' ''' Code to manage ebook library''' -def db(path=None): +def db(path=None, read_only=False): from calibre.library.database2 import LibraryDatabase2 from calibre.utils.config import prefs - return LibraryDatabase2(path if path else prefs['library_path']) + return LibraryDatabase2(path if path else prefs['library_path'], + read_only=read_only) def generate_test_db(library_path, # {{{ diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index cbda615677..9f6712f22a 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -113,7 +113,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): def exists_at(cls, path): return path and os.path.exists(os.path.join(path, 'metadata.db')) - def __init__(self, library_path, row_factory=False, default_prefs=None): + def __init__(self, library_path, row_factory=False, default_prefs=None, + read_only=False): self.field_metadata = FieldMetadata() self.dirtied_queue = Queue() if not os.path.exists(library_path): @@ -124,6 +125,12 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): self.dbpath = os.path.join(library_path, 'metadata.db') self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', self.dbpath) + if read_only and os.path.exists(self.dbpath): + pt = PersistentTemporaryFile('_ro.db') + pt.close() + shutil.copyfile(self.dbpath, pt.name) + self.dbpath = pt.name + if isinstance(self.dbpath, unicode) and not iswindows: self.dbpath = self.dbpath.encode(filesystem_encoding) From 559ecdaf249de9f6fa4f0bd40701542c07d8d235 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 13:11:40 -0700 Subject: [PATCH 19/26] ... --- src/calibre/library/database2.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 9f6712f22a..521f688251 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -125,15 +125,17 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): self.dbpath = os.path.join(library_path, 'metadata.db') self.dbpath = os.environ.get('CALIBRE_OVERRIDE_DATABASE_PATH', self.dbpath) + if isinstance(self.dbpath, unicode) and not iswindows: + self.dbpath = self.dbpath.encode(filesystem_encoding) + if read_only and os.path.exists(self.dbpath): - pt = PersistentTemporaryFile('_ro.db') + # Work on only a copy of metadata.db to ensure that + # metadata.db is not changed + pt = PersistentTemporaryFile('_metadata_ro.db') pt.close() shutil.copyfile(self.dbpath, pt.name) self.dbpath = pt.name - if isinstance(self.dbpath, unicode) and not iswindows: - self.dbpath = self.dbpath.encode(filesystem_encoding) - apply_default_prefs = not os.path.exists(self.dbpath) self.connect() From a8d9f7aaa0bac02c2f4f1548658ab577936057e4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 13:37:22 -0700 Subject: [PATCH 20/26] Fix database integrity check breaking after a catalog generation. Fix thumbs.zip in use error when generating catalog on some windows machines. Apparently, os.remove is broken on windows --- src/calibre/library/catalog.py | 1 - src/calibre/library/database2.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index f21f4278a4..6b34b7f08c 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -1005,7 +1005,6 @@ class EPUB_MOBI(CatalogPlugin): self.opts.log.warning(" invalidating cache at '%s'" % self.__archive_path) self.opts.log.warning(' thumb_width changed: %1.2f" => %1.2f"' % (float(cached_thumb_width),float(self.opts.thumb_width))) - os.remove(self.__archive_path) with ZipFile(self.__archive_path, mode='w') as zfw: zfw.writestr("Catalog Thumbs Archive",'') else: diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 521f688251..611aa1cc89 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -102,7 +102,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if self.user_version == 0: self.initialize_database() # remember to add any filter to the connect method in sqlite.py as well - # so that various code taht connects directly will not complain about + # so that various code that connects directly will not complain about # missing functions self.books_list_filter = self.conn.create_dynamic_filter('books_list_filter') # Store temporary tables in memory @@ -2778,7 +2778,6 @@ books_series_link feeds os.remove(dest) raise else: - os.remove(self.dbpath) shutil.copyfile(dest, self.dbpath) self.connect() self.initialize_dynamic() From 2a8af11efd957bbb1e4c4201e8e5cf1079c9df7a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 13:43:48 -0700 Subject: [PATCH 21/26] Fix #8158 (Latest version of calibre: tag search doesn't work, error on shutting down) --- src/calibre/gui2/tag_view.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index 8d42e51dfc..beedad4757 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -779,8 +779,11 @@ class TagsModel(QAbstractItemModel): # {{{ category_icon = category_node.icon, category_key=category_node.category_key) else: - if upper(tag.sort[0]) != collapse_letter: - collapse_letter = upper(tag.sort[0]) + ts = tag.sort + if not ts: + ts = 'Z' + if upper(ts[0]) != collapse_letter: + collapse_letter = upper(ts[0]) sub_cat = TagTreeItem(parent=category, data = collapse_letter, category_icon = category_node.icon, From 32a2993c761636fab25b32b104a6cd4f5d9c6b07 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sun, 2 Jan 2011 14:14:29 -0700 Subject: [PATCH 22/26] GwR fix for ratings --- resources/catalog/template.xhtml | 6 +++--- src/calibre/library/catalog.py | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/resources/catalog/template.xhtml b/resources/catalog/template.xhtml index 409086d343..4df2a11c84 100644 --- a/resources/catalog/template.xhtml +++ b/resources/catalog/template.xhtml @@ -14,10 +14,10 @@ - + - + @@ -32,7 +32,7 @@ - +
 
 
{publisher}{note_source}: {note_content}
 

diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index 6b34b7f08c..dd1a9e2e7d 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -4393,21 +4393,21 @@ class EPUB_MOBI(CatalogPlugin): ''' # Publisher - publisher = NBSP + publisher = '' if 'publisher' in book: publisher = book['publisher'] # Rating stars = int(book['rating']) / 2 - rating = NBSP + rating = '' if stars: star_string = self.FULL_RATING_SYMBOL * stars empty_stars = self.EMPTY_RATING_SYMBOL * (5 - stars) rating = '%s%s
' % (star_string,empty_stars) # Notes - note_source = NBSP - note_content = NBSP + note_source = '' + note_content = '' if 'notes' in book: note_source = book['notes']['source'] note_content = book['notes']['content'] @@ -4449,7 +4449,7 @@ class EPUB_MOBI(CatalogPlugin): formatsTag = body.find('p',attrs={'class':'formats'}) formatsTag.extract() - if note_content == NBSP: + if note_content == '': tdTag = body.find('td', attrs={'class':'notes'}) tdTag.contents[0].replaceWith(NBSP) @@ -4463,6 +4463,18 @@ class EPUB_MOBI(CatalogPlugin): imgTag['alt'] = "cover thumbnail" tdTag.insert(0,imgTag) + ''' + # Rating + stars = int(book['rating']) / 2 + rating = '' + if stars: + star_string = self.FULL_RATING_SYMBOL * stars + empty_stars = self.EMPTY_RATING_SYMBOL * (5 - stars) + rating = '%s%s
' % (star_string,empty_stars) + ratingTag = body.find('td',attrs={'class':'rating'}) + ratingTag.insert(0,NavigableString(rating)) + ''' + # The Blurb if 'description' in book and book['description'] > '': blurbTag = body.find(attrs={'class':'description'}) From 1c14eac4557ac4788750c0dce1690ecaffbba7dd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 14:25:33 -0700 Subject: [PATCH 23/26] ... --- src/calibre/gui2/preferences/look_feel.ui | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 3b6bbb63ab..a9a664f2f3 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -177,7 +177,8 @@ if you never want subcategories - If a Tag Browser category has more than this number of items, it is divided up into sub-categories. Set to zero to disable. + If a Tag Browser category has more than this number of items, it is divided + up into sub-categories. If the partition method is set to disable, this value is ignored. 10000 From a7c0bb2092354c4baca9d318cd477cf1b77b7633 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 14:27:51 -0700 Subject: [PATCH 24/26] ... --- src/calibre/gui2/preferences/look_feel.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index a9a664f2f3..2223167068 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -178,7 +178,7 @@ if you never want subcategories If a Tag Browser category has more than this number of items, it is divided - up into sub-categories. If the partition method is set to disable, this value is ignored. +up into sub-categories. If the partition method is set to disable, this value is ignored. 10000 From 8ed09851287265ffab9942cba33a6aaf8ab9f623 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 14:52:32 -0700 Subject: [PATCH 25/26] ... --- src/calibre/gui2/tag_view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index beedad4757..90d7ce698a 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -781,7 +781,7 @@ class TagsModel(QAbstractItemModel): # {{{ else: ts = tag.sort if not ts: - ts = 'Z' + ts = ' ' if upper(ts[0]) != collapse_letter: collapse_letter = upper(ts[0]) sub_cat = TagTreeItem(parent=category, From 45cd9f4708fa783a71f094570261755707e46435 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 2 Jan 2011 15:20:20 -0700 Subject: [PATCH 26/26] Fix La Republica --- resources/recipes/la_republica.recipe | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/recipes/la_republica.recipe b/resources/recipes/la_republica.recipe index c74f2d7b05..14dc0d0aef 100644 --- a/resources/recipes/la_republica.recipe +++ b/resources/recipes/la_republica.recipe @@ -28,6 +28,8 @@ class LaRepubblica(BasicNewsRecipe): recursion = 10 remove_javascript = True + no_stylesheets = True + def get_article_url(self, article): link = article.get('id', article.get('guid', None)) if link is None: