diff --git a/Changelog.yaml b/Changelog.yaml index f2eee7dbef..727c717bd6 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -4,7 +4,7 @@ # for important features/bug fixes. # Also, each release can have new and improved recipes. -- version: 0.6.25 +- version: 0.6.26 date: 2009-12-04 new features: diff --git a/resources/recipes/economist.recipe b/resources/recipes/economist.recipe index 75cb86863a..cadf2964ed 100644 --- a/resources/recipes/economist.recipe +++ b/resources/recipes/economist.recipe @@ -22,7 +22,8 @@ class Economist(BasicNewsRecipe): oldest_article = 7.0 cover_url = 'http://www.economist.com/images/covers/currentcovereu_large.jpg' - remove_tags = [dict(name=['script', 'noscript', 'title'])] + remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']), + dict(attrs={'class':['dblClkTrk']})] remove_tags_before = dict(name=lambda tag: tag.name=='title' and tag.parent.name=='body') needs_subscription = True diff --git a/resources/recipes/economist_free.recipe b/resources/recipes/economist_free.recipe index effda489c9..7c27764b8d 100644 --- a/resources/recipes/economist_free.recipe +++ b/resources/recipes/economist_free.recipe @@ -3,7 +3,6 @@ from calibre.utils.threadpool import ThreadPool, makeRequests import time from datetime import datetime from lxml import html -from urllib2 import urlopen class Economist(BasicNewsRecipe): @@ -16,7 +15,8 @@ class Economist(BasicNewsRecipe): oldest_article = 6.5 cover_url = 'http://www.economist.com/images/covers/currentcovereu_large.jpg' - remove_tags = [dict(name=['script', 'noscript', 'title'])] + remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']), + dict(attrs={'class':['dblClkTrk']})] remove_tags_before = dict(name=lambda tag: tag.name=='title' and tag.parent.name=='body') def parse_index(self): @@ -44,10 +44,12 @@ class Economist(BasicNewsRecipe): return [(t, a) for t, a in self.feed_dict.items()] def process_eco_feed_article(self, args): + from calibre import browser i, url, title, description, author, published = args - ret = urlopen(url) + br = browser() + ret = br.open(url) raw = ret.read() - url = ret.geturl().replace('displaystory', 'PrinterFriendly').strip() + url = br.geturl().replace('displaystory', 'PrinterFriendly').strip() root = html.fromstring(raw) matches = root.xpath('//*[@class = "article-section"]') feedtitle = 'Miscellaneous' diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 5bb00f0bb5..a25d4b2718 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -870,7 +870,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): from a book file. ''' num, ok = QInputDialog.getInt(self, _('How many empty books?'), - _('How many empty boks should be added?'), 1, 1, 100) + _('How many empty books should be added?'), 1, 1, 100) if ok: from calibre.ebooks.metadata import MetaInformation for x in xrange(num): diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 1cabe310a1..348b1232ee 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en' ''' ''' import os, math, re, glob -from PyQt4.Qt import QWidget, QSize, QSizePolicy, QUrl, SIGNAL, Qt, QTimer, \ +from PyQt4.Qt import QSize, QSizePolicy, QUrl, SIGNAL, Qt, QTimer, \ QPainter, QPalette, QBrush, QFontDatabase, QDialog, \ QColor, QPoint, QImage, QRegion, QVariant, \ QFont, QObject, QApplication, pyqtSignature @@ -343,6 +343,9 @@ class Document(QWebPage): def width(self): return self.mainFrame().contentsSize().width() # offsetWidth gives inaccurate results + def set_bottom_padding(self, amount): + self.javascript('$("body").css("padding-bottom", "%dpx")' % amount) + class EntityDeclarationProcessor(object): @@ -361,7 +364,7 @@ class DocumentView(QWebView): DISABLED_BRUSH = QBrush(Qt.lightGray, Qt.Dense5Pattern) def __init__(self, *args): - QWidget.__init__(self, *args) + QWebView.__init__(self, *args) self.debug_javascript = False self.self_closing_pat = re.compile(r'<([a-z]+)\s+([^>]+)/>', re.IGNORECASE) @@ -374,8 +377,8 @@ class DocumentView(QWebView): self.manager = None self._reference_mode = False self._ignore_scrollbar_signals = False - self.connect(self.document, SIGNAL('loadStarted()'), self.load_started) - self.connect(self.document, SIGNAL('loadFinished(bool)'), self.load_finished) + self.loading_url = None + self.loadFinished.connect(self.load_finished) self.connect(self.document, SIGNAL('linkClicked(QUrl)'), self.link_clicked) self.connect(self.document, SIGNAL('linkHovered(QString,QString,QString)'), self.link_hovered) self.connect(self.document, SIGNAL('selectionChanged()'), self.selection_changed) @@ -473,13 +476,12 @@ class DocumentView(QWebView): html = EntityDeclarationProcessor(html).processed_html if 'xhtml' in mt: html = self.self_closing_pat.sub(self.self_closing_sub, html) - #self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path)) - self.setHtml(html, QUrl.fromLocalFile(path)) - self.turn_off_internal_scrollbars() - - def load_started(self): if self.manager is not None: self.manager.load_started() + self.loading_url = QUrl.fromLocalFile(path) + #self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path)) + self.setHtml(html, self.loading_url) + self.turn_off_internal_scrollbars() def initialize_scrollbar(self): if getattr(self, 'scrollbar', None) is not None: @@ -497,6 +499,11 @@ class DocumentView(QWebView): def load_finished(self, ok): + if self.loading_url is None: + # An