From 91626094db204c6cbad1a41a0e06dce59a64dc38 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 3 Jun 2011 17:38:47 +0100 Subject: [PATCH 01/11] Make the formatter and other users of mi.format_field respect the use_roman series number config item. --- src/calibre/ebooks/metadata/book/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index 378d4ab5f0..690b54183f 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -18,6 +18,7 @@ from calibre.library.field_metadata import FieldMetadata from calibre.utils.date import isoformat, format_date from calibre.utils.icu import sort_key from calibre.utils.formatter import TemplateFormatter +from calibre.utils.config import config def human_readable(size, precision=2): """ Convert a size in bytes into megabytes """ @@ -557,12 +558,13 @@ class Metadata(object): def format_series_index(self, val=None): from calibre.ebooks.metadata import fmt_sidx + use_roman=config['use_roman_numerals_for_series_number'] v = self.series_index if val is None else val try: x = float(v) except (ValueError, TypeError): x = 1 - return fmt_sidx(x) + return fmt_sidx(x, use_roman=use_roman) def authors_from_string(self, raw): from calibre.ebooks.metadata import string_to_authors From 62cd0e33f9475ea3756ce95b941991fccbbd7259 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 3 Jun 2011 17:44:21 +0100 Subject: [PATCH 02/11] Back out the fix. It was broken --- src/calibre/ebooks/metadata/book/base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index 690b54183f..378d4ab5f0 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -18,7 +18,6 @@ from calibre.library.field_metadata import FieldMetadata from calibre.utils.date import isoformat, format_date from calibre.utils.icu import sort_key from calibre.utils.formatter import TemplateFormatter -from calibre.utils.config import config def human_readable(size, precision=2): """ Convert a size in bytes into megabytes """ @@ -558,13 +557,12 @@ class Metadata(object): def format_series_index(self, val=None): from calibre.ebooks.metadata import fmt_sidx - use_roman=config['use_roman_numerals_for_series_number'] v = self.series_index if val is None else val try: x = float(v) except (ValueError, TypeError): x = 1 - return fmt_sidx(x, use_roman=use_roman) + return fmt_sidx(x) def authors_from_string(self, raw): from calibre.ebooks.metadata import string_to_authors From 3548babcd9d3d7b365bf4ecff57cbf8eeaaaaece Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 14:35:30 -0600 Subject: [PATCH 03/11] User Manual: Use google custom search --- src/calibre/manual/gui.rst | 5 +-- src/calibre/manual/portable.rst | 2 +- src/calibre/manual/templates/search.html | 49 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/calibre/manual/templates/search.html diff --git a/src/calibre/manual/gui.rst b/src/calibre/manual/gui.rst index e2758bc257..752c9c4881 100644 --- a/src/calibre/manual/gui.rst +++ b/src/calibre/manual/gui.rst @@ -74,10 +74,7 @@ Edit metadata 1. **Edit metadata individually**: This allows you to edit the metadata of books one-by-one, with the option of fetching metadata, including covers from the internet. It also allows you to add/remove particular ebook formats from a book. 2. **Edit metadata in bulk**: This allows you to edit common metadata fields for large numbers of books simulataneously. It operates on all the books you have selected in the :ref:`Library view `. 3. **Download metadata and covers**: Downloads metadata and covers (if available), for the books that are selected in the book list. - 4. **Download only metadata**: Downloads only metadata (if available), for the books that are selected in the book list. - 5. **Download only covers**: Downloads only covers (if available), for the books that are selected in the book list. - 6. **Download only social metadata**: Downloads only social metadata such as tags and reviews (if available), for the books that are selected in the book list. - 7. **Merge Book Records**: Gives you the capability of merging the metadata and formats of two or more book records together. You can choose to either delete or keep the records that were not clicked first. + 4. **Merge Book Records**: Gives you the capability of merging the metadata and formats of two or more book records together. You can choose to either delete or keep the records that were not clicked first. For more details see :ref:`metadata`. diff --git a/src/calibre/manual/portable.rst b/src/calibre/manual/portable.rst index a9c9679512..7381617209 100644 --- a/src/calibre/manual/portable.rst +++ b/src/calibre/manual/portable.rst @@ -11,7 +11,7 @@ You can "install" calibre onto a USB stick that you can take with you and use on * Run a Mobile Calibre installation with both the Calibre binaries and your ebook library resident on a USB disk or other portable media. In particular it is not necessary to have Calibre installed on the Windows PC that is to run Calibre. This batch file also does not care what drive letter is assigned when you plug in the USB device. It also will not affect any settings on the host machine being a completely self-contained Calibre installation. * Run a networked Calibre installation optimised for performance when the ebook files are located on a networked share. -If you find setting up the bat file too challenging, there is a third party portable calibre build available at `portableapps.com http://portableapps.com`_. +If you find setting up the bat file too challenging, there is a third party portable calibre build available at `portableapps.com `_. This calibre-portable.bat file is intended for use on Windows based systems, but the principles are easily adapted for use on Linux or OS X based systems. Note that calibre requires the Microsoft Visual C++ 2008 runtimes to run. Most windows computers have them installed already, but it may be a good idea to have the installer for installing them on your USB stick. The installer is available from `Microsoft `_. diff --git a/src/calibre/manual/templates/search.html b/src/calibre/manual/templates/search.html new file mode 100644 index 0000000000..58901c8fb4 --- /dev/null +++ b/src/calibre/manual/templates/search.html @@ -0,0 +1,49 @@ +{# + basic/search.html + ~~~~~~~~~~~~~~~~~ + + Template for the search page, using google adsense search + + :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{% extends "layout.html" %} +{% set title = _('Search') %} +{% block extrahead %} + + {{ super() }} +{% endblock %} +{% block body %} +

{{ _('Search') }}

+
+ +

+ {% trans %}Please activate JavaScript to enable the search + functionality.{% endtrans %} +

+
+

+ {% trans %}From here you can search these documents. Enter your search + words into the box below and click "search". Note that the search + function will automatically search for all of the words. Pages + containing fewer words won't appear in the result list.{% endtrans %} +

+
Loading
+ + +{% endblock %} From d407876d74fecc2c4e9fd7b9bb6ac79e25dcd119 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 3 Jun 2011 21:37:29 +0100 Subject: [PATCH 04/11] Add composite columns to conditionable_columns --- src/calibre/library/coloring.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index c8cafcf9eb..8cfa085919 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -85,7 +85,7 @@ class Rule(object): # {{{ if dt == 'datetime': return self.date_condition(col, action, val) - if dt in ('comments', 'series', 'text', 'enumeration'): + if dt in ('comments', 'series', 'text', 'enumeration', 'composite'): ism = m.get('is_multiple', False) if ism: return self.multiple_condition(col, action, val, ism) @@ -181,9 +181,7 @@ def rule_from_template(fm, template): def conditionable_columns(fm): for key in fm: m = fm[key] - dt = m['datatype'] - if m.get('name', False) and dt in ('bool', 'int', 'float', 'rating', 'series', - 'comments', 'text', 'enumeration', 'datetime'): + if m.get('name', False) and m['kind'] == 'field': if key == 'sort': yield 'title_sort' else: From d38c3a9fd938d236301acd851af70b624414fac5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 14:49:14 -0600 Subject: [PATCH 05/11] Fix is set and is not set coloring conditions for test columns --- src/calibre/library/coloring.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index c8cafcf9eb..0102f8f977 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -128,9 +128,9 @@ class Rule(object): # {{{ def multiple_condition(self, col, action, val, sep): if action == 'is set': - return "test('%s', '1', '')"%col + return "test(field('%s'), '1', '')"%col if action == 'is not set': - return "test('%s', '', '1')"%col + return "test(field('%s'), '', '1')"%col if action == 'has': return "str_in_list(field('%s'), '%s', \"%s\", '1', '')"%(col, sep, val) if action == 'does not have': @@ -142,9 +142,9 @@ class Rule(object): # {{{ def text_condition(self, col, action, val): if action == 'is set': - return "test('%s', '1', '')"%col + return "test(field('%s'), '1', '')"%col if action == 'is not set': - return "test('%s', '', '1')"%col + return "test(field('%s'), '', '1')"%col if action == 'is': return "strcmp(field('%s'), \"%s\", '', '1', '')"%(col, val) if action == 'is not': From b4593fb818d94ac559ea085478a6c8ddaedc309f Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 3 Jun 2011 21:55:02 +0100 Subject: [PATCH 06/11] Fix is_multiple problem in templates for custom columns. --- src/calibre/library/coloring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index 8cfa085919..31798d7000 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -88,7 +88,7 @@ class Rule(object): # {{{ if dt in ('comments', 'series', 'text', 'enumeration', 'composite'): ism = m.get('is_multiple', False) if ism: - return self.multiple_condition(col, action, val, ism) + return self.multiple_condition(col, action, val, ',' if ism == '|' else ism) return self.text_condition(col, action, val) def identifiers_condition(self, col, action, val): From 191c68189c0bd8ca0578513d4251bb68807dcb38 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 14:58:28 -0600 Subject: [PATCH 07/11] Fix coloring broken for tags like columns --- src/calibre/library/coloring.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index 0102f8f977..fc14ef1efd 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -127,6 +127,8 @@ class Rule(object): # {{{ val, lt, eq, gt) def multiple_condition(self, col, action, val, sep): + if sep == '|': + sep = ',' if action == 'is set': return "test(field('%s'), '1', '')"%col if action == 'is not set': From 19db6649c37e8ce2c27acfcca8c40e6515f81bba Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 14:59:20 -0600 Subject: [PATCH 08/11] ... --- src/calibre/library/coloring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index fc14ef1efd..26d709a321 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -127,7 +127,7 @@ class Rule(object): # {{{ val, lt, eq, gt) def multiple_condition(self, col, action, val, sep): - if sep == '|': + if not sep or sep == '|': sep = ',' if action == 'is set': return "test(field('%s'), '1', '')"%col From 11d0915aea3f52bd401b7fcc5db529f8582fd605 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 15:05:26 -0600 Subject: [PATCH 09/11] Support composite columns as condionable columns for coloring --- src/calibre/library/coloring.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index 26d709a321..408f6ff58e 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -85,7 +85,7 @@ class Rule(object): # {{{ if dt == 'datetime': return self.date_condition(col, action, val) - if dt in ('comments', 'series', 'text', 'enumeration'): + if dt in ('comments', 'series', 'text', 'enumeration', 'composite'): ism = m.get('is_multiple', False) if ism: return self.multiple_condition(col, action, val, ism) @@ -185,7 +185,7 @@ def conditionable_columns(fm): m = fm[key] dt = m['datatype'] if m.get('name', False) and dt in ('bool', 'int', 'float', 'rating', 'series', - 'comments', 'text', 'enumeration', 'datetime'): + 'comments', 'text', 'enumeration', 'datetime', 'composite'): if key == 'sort': yield 'title_sort' else: From 5738b0453ce6d15286489e4e7cd8858ad6064b32 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 15:34:41 -0600 Subject: [PATCH 10/11] Escape color templates when redering rules list --- src/calibre/gui2/preferences/coloring.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index 695adabed8..0fca30695b 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -12,6 +12,7 @@ from PyQt4.Qt import (QWidget, QDialog, QLabel, QGridLayout, QComboBox, QSize, QScrollArea, QPushButton, QVBoxLayout, QDialogButtonBox, QToolButton, QListView, QAbstractListModel, pyqtSignal, QSizePolicy, QSpacerItem) +from calibre import prepare_string_for_xml from calibre.utils.icu import sort_key from calibre.gui2 import error_dialog from calibre.gui2.dialogs.template_dialog import TemplateDialog @@ -430,7 +431,7 @@ class RulesModel(QAbstractListModel): # {{{ return _('''

Advanced Rule for column %s:

%s
- ''')%(col, rule) + ''')%(col, prepare_string_for_xml(rule)) conditions = [self.condition_to_html(c) for c in rule.conditions] return _('''\

Set the color of %s to %s if the following @@ -439,9 +440,10 @@ class RulesModel(QAbstractListModel): # {{{ ''') % (col, rule.color, ''.join(conditions)) def condition_to_html(self, condition): + c, a, v = condition return ( _('

  • If the %s column %s value: %s') % - tuple(condition)) + (c, a, prepare_string_for_xml(v))) # }}} From 66f98e8ee20dbcc3a228709bcd8b6a9aaf23fc90 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2011 15:42:15 -0600 Subject: [PATCH 11/11] Nook TSR driver: Do not upload separate cover thumbnails --- src/calibre/devices/nook/driver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/devices/nook/driver.py b/src/calibre/devices/nook/driver.py index aaa68891ba..22264c3458 100644 --- a/src/calibre/devices/nook/driver.py +++ b/src/calibre/devices/nook/driver.py @@ -117,4 +117,6 @@ class NOOK_TSR(NOOK): EBOOK_DIR_MAIN = EBOOK_DIR_CARD_A = 'My Files/Books' WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'EBOOK_DISK' + def upload_cover(self, path, filename, metadata, filepath): + pass