From bebe2467cc95162f745ef2b94202b63e5a54a484 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 25 Sep 2011 13:17:40 -0600 Subject: [PATCH 1/3] News download: Add list of articles in the downloaded issue to the comments metadata of the generated ebook. Makes it possible to search for a particular article in the calibre library. Fixes #851717 ([enhancement] News downloading options for search) --- src/calibre/web/feeds/news.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index da037ca43b..d50cd632f0 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -13,7 +13,7 @@ from functools import partial from contextlib import nested, closing -from calibre import (browser, __appname__, iswindows, +from calibre import (browser, __appname__, iswindows, force_unicode, strftime, preferred_encoding, as_unicode) from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag from calibre.ebooks.metadata.opf2 import OPFCreator @@ -49,7 +49,7 @@ class BasicNewsRecipe(Recipe): #: A couple of lines that describe the content this recipe downloads. #: This will be used primarily in a GUI that presents a list of recipes. - description = '' + description = u'' #: The author of this recipe __author__ = __appname__ @@ -112,8 +112,6 @@ class BasicNewsRecipe(Recipe): #: If set to "optional" the use of a username and password becomes optional needs_subscription = False - #: - #: If True the navigation bar is center aligned, otherwise it is left aligned center_navbar = True @@ -1205,12 +1203,22 @@ class BasicNewsRecipe(Recipe): mi.author_sort = __appname__ mi.publication_type = 'periodical:'+self.publication_type+':'+self.short_title() mi.timestamp = nowf() + article_titles, aseen = [], set() + for f in feeds: + for a in f: + if a.title and a.title not in aseen: + aseen.add(a.title) + article_titles.append(force_unicode(a.title, 'utf-8')) + mi.comments = self.description + if not isinstance(mi.comments, unicode): + mi.comments = mi.comments.decode('utf-8', 'replace') + mi.comments += ('\n\n' + _('Articles in this issue: ') + '\n' + + '\n\n'.join(article_titles)) + language = canonicalize_lang(self.language) if language is not None: mi.language = language - if not isinstance(mi.comments, unicode): - mi.comments = mi.comments.decode('utf-8', 'replace') mi.pubdate = nowf() opf_path = os.path.join(dir, 'index.opf') ncx_path = os.path.join(dir, 'index.ncx') @@ -1256,6 +1264,7 @@ class BasicNewsRecipe(Recipe): self.play_order_counter = 0 self.play_order_map = {} + def feed_index(num, parent): f = feeds[num] for j, a in enumerate(f): From dc9b181dae236b86e28bb30b9242c2faca1d1786 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Sep 2011 12:07:20 -0600 Subject: [PATCH 2/3] Fix #855587 (Doesn't build with poppler 0.17/0.18) --- src/calibre/ebooks/pdf/images.cpp | 2 +- src/calibre/ebooks/pdf/reflow.cpp | 5 +++++ src/calibre/ebooks/pdf/reflow.h | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdf/images.cpp b/src/calibre/ebooks/pdf/images.cpp index 8ca7448001..466c69af4b 100644 --- a/src/calibre/ebooks/pdf/images.cpp +++ b/src/calibre/ebooks/pdf/images.cpp @@ -126,7 +126,7 @@ void XMLImages::add(GfxState *state, Object *ref, Stream *str, if (img->type == jpeg) { int c; - str = ((DCTStream *)str)->getRawStream(); + str = str->getNextStream(); str->reset(); // copy the stream diff --git a/src/calibre/ebooks/pdf/reflow.cpp b/src/calibre/ebooks/pdf/reflow.cpp index 65b5de6ae0..8103e1a03d 100644 --- a/src/calibre/ebooks/pdf/reflow.cpp +++ b/src/calibre/ebooks/pdf/reflow.cpp @@ -625,7 +625,12 @@ static string get_link_dest(LinkAction *link, PDFDoc *doc) { return oss.str(); } +#if (POPPLER_MAJOR_VERSION == 0) && (POPPLER_MINOR_VERSION < 17) void XMLOutputDev::process_link(Link* link){ +#else +void XMLOutputDev::process_link(AnnotLink* link){ +#endif + double _x1, _y1, _x2, _y2; int x1, y1, x2, y2; diff --git a/src/calibre/ebooks/pdf/reflow.h b/src/calibre/ebooks/pdf/reflow.h index 768799f004..d99137d376 100644 --- a/src/calibre/ebooks/pdf/reflow.h +++ b/src/calibre/ebooks/pdf/reflow.h @@ -244,6 +244,11 @@ class XMLOutputDev : public OutputDev { XMLImages *images; PDFDoc *doc; +#if (POPPLER_MAJOR_VERSION == 0) && (POPPLER_MINOR_VERSION < 17) void process_link(Link* link); +#else + void process_link(AnnotLink* link); +#endif + }; } From 589ca8b572786050cb993d5c386f8ec8c4bb96cf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Sep 2011 17:04:26 -0600 Subject: [PATCH 3/3] ... --- src/calibre/db/__init__.py | 1 + src/calibre/db/backend.py | 3 ++- src/calibre/gui2/metadata/basic_widgets.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/__init__.py b/src/calibre/db/__init__.py index 3c7c86b932..826b7a99fd 100644 --- a/src/calibre/db/__init__.py +++ b/src/calibre/db/__init__.py @@ -7,6 +7,7 @@ __license__ = 'GPL v3' __copyright__ = '2011, Kovid Goyal ' __docformat__ = 'restructuredtext en' +SPOOL_SIZE = 30*1024*1024 ''' Rewrite of the calibre database backend. diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py index 7dd6e052ea..d7bb251506 100644 --- a/src/calibre/db/backend.py +++ b/src/calibre/db/backend.py @@ -17,6 +17,7 @@ from calibre import isbytestring, force_unicode, prints from calibre.constants import (iswindows, filesystem_encoding, preferred_encoding) from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile +from calibre.db import SPOOL_SIZE from calibre.db.schema_upgrades import SchemaUpgrade from calibre.library.field_metadata import FieldMetadata from calibre.ebooks.metadata import title_sort, author_to_author_sort @@ -38,7 +39,7 @@ Differences in semantics from pysqlite: ''' -SPOOL_SIZE = 30*1024*1024 + class DynamicFilter(object): # {{{ diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index fbde89b7b7..267462bd5e 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -35,7 +35,7 @@ from calibre.gui2.dialogs.tag_editor import TagEditor from calibre.utils.icu import strcmp from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile from calibre.gui2.languages import LanguagesEdit as LE -from calibre.db.backend import SPOOL_SIZE +from calibre.db import SPOOL_SIZE def save_dialog(parent, title, msg, det_msg=''): d = QMessageBox(parent)