From ba22e309d0143aa39427d130cb85a604a810a8a7 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 11 Jan 2011 17:46:08 +0000 Subject: [PATCH 1/4] Fix tags_older_than --- src/calibre/library/database2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index dc82825607..495cd9b685 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1373,7 +1373,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if r is not None: if (now - r[self.FIELD_MAP['timestamp']]) > delta: tags = r[self.FIELD_MAP['tags']] - if tags and tag in tags.lower(): + tags = tags.lower().split() if tags else [] + tags = [tag.strip() for tag in tags if tag.strip()] + if tag in tags: yield r[self.FIELD_MAP['id']] def get_next_series_num_for(self, series): From 5dcdfefceda2c4a39baf2dca2a8509a58de6c869 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 11 Jan 2011 17:49:36 +0000 Subject: [PATCH 2/4] ... --- src/calibre/library/database2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 495cd9b685..48c62efffe 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1373,7 +1373,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if r is not None: if (now - r[self.FIELD_MAP['timestamp']]) > delta: tags = r[self.FIELD_MAP['tags']] - tags = tags.lower().split() if tags else [] + tags = tags.lower().split(',') if tags else [] tags = [tag.strip() for tag in tags if tag.strip()] if tag in tags: yield r[self.FIELD_MAP['id']] From b61fdf0eac17b578c73ce68c344ec8efe952239a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jan 2011 13:15:29 -0700 Subject: [PATCH 3/4] Updated NYTimes --- resources/recipes/nytimes.recipe | 25 +++++++++++++++++++++++++ resources/recipes/nytimes_sub.recipe | 23 +++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/resources/recipes/nytimes.recipe b/resources/recipes/nytimes.recipe index eaa428e731..6f80f4f85f 100644 --- a/resources/recipes/nytimes.recipe +++ b/resources/recipes/nytimes.recipe @@ -685,3 +685,28 @@ class NYTimes(BasicNewsRecipe): divTag.replaceWith(tag) return soup + + def populate_article_metadata(self, article, soup, first): + shortparagraph = "" + try: + if len(article.text_summary.strip()) == 0: + articlebodies = soup.findAll('div',attrs={'class':'articleBody'}) + if articlebodies: + for articlebody in articlebodies: + if articlebody: + paras = articlebody.findAll('p') + for p in paras: + refparagraph = self.massageNCXText(self.tag_to_string(p,use_alt=False)).strip() + #account for blank paragraphs and short paragraphs by appending them to longer ones + if len(refparagraph) > 0: + if len(refparagraph) > 70: #approximately one line of text + article.summary = article.text_summary = shortparagraph + refparagraph + return + else: + shortparagraph = refparagraph + " " + if shortparagraph.strip().find(" ") == -1 and not shortparagraph.strip().endswith(":"): + shortparagraph = shortparagraph + "- " + except: + self.log("Error creating article descriptions") + return + diff --git a/resources/recipes/nytimes_sub.recipe b/resources/recipes/nytimes_sub.recipe index e56fd9cdec..8ac7c735f7 100644 --- a/resources/recipes/nytimes_sub.recipe +++ b/resources/recipes/nytimes_sub.recipe @@ -685,4 +685,27 @@ class NYTimes(BasicNewsRecipe): divTag.replaceWith(tag) return soup + def populate_article_metadata(self, article, soup, first): + shortparagraph = "" + try: + if len(article.text_summary.strip()) == 0: + articlebodies = soup.findAll('div',attrs={'class':'articleBody'}) + if articlebodies: + for articlebody in articlebodies: + if articlebody: + paras = articlebody.findAll('p') + for p in paras: + refparagraph = self.massageNCXText(self.tag_to_string(p,use_alt=False)).strip() + #account for blank paragraphs and short paragraphs by appending them to longer ones + if len(refparagraph) > 0: + if len(refparagraph) > 70: #approximately one line of text + article.summary = article.text_summary = shortparagraph + refparagraph + return + else: + shortparagraph = refparagraph + " " + if shortparagraph.strip().find(" ") == -1 and not shortparagraph.strip().endswith(":"): + shortparagraph = shortparagraph + "- " + except: + self.log("Error creating article descriptions") + return From bfa79729a27f6f2bb504d2137f0bc89d192e5f68 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jan 2011 13:34:18 -0700 Subject: [PATCH 4/4] ... --- src/calibre/gui2/preferences/plugins.ui | 4 ++++ src/calibre/gui2/shortcuts.py | 7 ++++++- src/calibre/gui2/viewer/documentview.py | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/preferences/plugins.ui b/src/calibre/gui2/preferences/plugins.ui index 18f0786a66..83a904eb08 100644 --- a/src/calibre/gui2/preferences/plugins.ui +++ b/src/calibre/gui2/preferences/plugins.ui @@ -76,6 +76,10 @@ &Add a new plugin + + + :/images/plugins.png:/images/plugins.png + diff --git a/src/calibre/gui2/shortcuts.py b/src/calibre/gui2/shortcuts.py index bdd699a69d..5e56435e10 100644 --- a/src/calibre/gui2/shortcuts.py +++ b/src/calibre/gui2/shortcuts.py @@ -150,7 +150,7 @@ class Delegate(QStyledItemDelegate): custom = [] if editor.custom.isChecked(): for x in ('1', '2'): - sc = getattr(editor, 'shortcut'+x) + sc = getattr(editor, 'shortcut'+x, None) if sc is not None: custom.append(sc) @@ -266,6 +266,11 @@ class ShortcutConfig(QWidget): self.view.scrollTo(index) + @property + def is_editing(self): + return self.view.state() == self.view.EditingState + + if __name__ == '__main__': from calibre.gui2 import is_ok_to_use_qt from calibre.gui2.viewer.keys import SHORTCUTS diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 55abae0392..4485e63373 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -120,6 +120,13 @@ class ConfigDialog(QDialog, Ui_Dialog): def accept(self, *args): + if self.shortcut_config.is_editing: + from calibre.gui2 import info_dialog + info_dialog(self, _('Still editing'), + _('You are in the middle of editing a keyboard shortcut' + ' first complete that, by clicking outside the ' + ' shortcut editing box.'), show=True) + return c = config() c.set('serif_family', unicode(self.serif_family.currentFont().family())) c.set('sans_family', unicode(self.sans_family.currentFont().family()))