From f104f1e07db22b94a212e69cebfd97cae70f02c0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 8 Jul 2009 11:05:44 -0600 Subject: [PATCH 1/3] Removethumbnails instead of larger images in WSJ recipe --- src/calibre/web/feeds/recipes/recipe_wsj.py | 146 ++++++++++---------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/src/calibre/web/feeds/recipes/recipe_wsj.py b/src/calibre/web/feeds/recipes/recipe_wsj.py index 962f7cb30b..0037b919b5 100644 --- a/src/calibre/web/feeds/recipes/recipe_wsj.py +++ b/src/calibre/web/feeds/recipes/recipe_wsj.py @@ -7,19 +7,19 @@ from calibre.web.feeds.news import BasicNewsRecipe # http://online.wsj.com/page/us_in_todays_paper.html -class WallStreetJournal(BasicNewsRecipe): - - title = 'The Wall Street Journal' - __author__ = 'Kovid Goyal and Sujata Raman' +class WallStreetJournal(BasicNewsRecipe): + + title = 'The Wall Street Journal' + __author__ = 'Kovid Goyal' description = 'News and current affairs.' needs_subscription = True language = _('English') max_articles_per_feed = 10 - timefmt = ' [%a, %b %d, %Y]' + timefmt = ' [%a, %b %d, %Y]' no_stylesheets = True - + extra_css = '''h1{color:#093D72 ; font-size:large ; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; } - h2{color:gray; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small; font-style:italic;} + h2{color:#474537; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small; font-style:italic;} .subhead{color:gray; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small; font-style:italic;} .insettipUnit {color:#666666; font-family:Arial,Sans-serif;font-size:xx-small } .targetCaption{ font-size:x-small; color:#333333; font-family:Arial,Helvetica,sans-serif} @@ -30,89 +30,89 @@ class WallStreetJournal(BasicNewsRecipe): .byline{color:blue;font-family:Arial,Helvetica,sans-serif; font-size:xx-small} h6{color:#333333; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small;font-style:italic; } .paperLocation{color:#666666; font-size:xx-small}''' - + remove_tags_before = dict(name='h1') remove_tags = [ dict(id=["articleTabs_tab_article", "articleTabs_tab_comments", "articleTabs_tab_interactive","articleTabs_tab_video","articleTabs_tab_map","articleTabs_tab_slideshow"]), - {'class':['footer_columns','network','insetCol3wide','interactive','video','slideshow','map','insettip','more_in', "insetContent", 'articleTools_bottom', 'aTools', "tooltip", "adSummary", "nav-inline"]}, + {'class':['footer_columns','network','insetCol3wide','interactive','video','slideshow','map','insettip','insetClose','more_in', "insetContent", 'articleTools_bottom', 'aTools', "tooltip", "adSummary", "nav-inline"]}, dict(rel='shortcut icon'), ] remove_tags_after = [dict(id="article_story_body"), {'class':"article story"},] - - def get_browser(self): - br = BasicNewsRecipe.get_browser() - if self.username is not None and self.password is not None: - br.open('http://commerce.wsj.com/auth/login') - br.select_form(nr=0) - br['user'] = self.username - br['password'] = self.password - br.submit() + + def get_browser(self): + br = BasicNewsRecipe.get_browser() + if self.username is not None and self.password is not None: + br.open('http://commerce.wsj.com/auth/login') + br.select_form(nr=0) + br['user'] = self.username + br['password'] = self.password + br.submit() return br - + def postprocess_html(self, soup, first): for tag in soup.findAll(name=['table', 'tr', 'td']): tag.name = 'div' - - for tag in soup.findAll('div', dict(id=["articleImage_1", "articleImage_2", "articleImage_3", "articleImage_4", "articleImage_5", "articleImage_6", "articleImage_7"])): + + for tag in soup.findAll('div', dict(id=["articleThumbnail_1", "articleThumbnail_2", "articleThumbnail_3", "articleThumbnail_4", "articleThumbnail_5", "articleThumbnail_6", "articleThumbnail_7"])): tag.extract() - + return soup - + def get_article_url(self, article): try: return article.feedburner_origlink.split('?')[0] except AttributeError: return article.link.split('?')[0] - - def cleanup(self): - self.browser.open('http://online.wsj.com/logout?url=http://online.wsj.com') - - feeds = [ - #('Most Emailed - Day', 'http://online.wsj.com/xml/rss/3_7030.xml'), - #('Most Emailed - Week', 'http://online.wsj.com/xml/rss/3_7253.xml'), - #('Most Emailed - Month', 'http://online.wsj.com/xml/rss/3_7254.xml'), - (' Most Viewed - Day', 'http://online.wsj.com/xml/rss/3_7198.xml'), - (' Most Viewed - Week', 'http://online.wsj.com/xml/rss/3_7251.xml'), - #('Most Viewed - Month', 'http://online.wsj.com/xml/rss/3_7252.xml'), - ('Today\'s Newspaper - Page One', 'http://online.wsj.com/xml/rss/3_7205.xml'), - ('Today\'s Newspaper - Marketplace', 'http://online.wsj.com/xml/rss/3_7206.xml'), - ('Today\'s Newspaper - Money & Investing', 'http://online.wsj.com/xml/rss/3_7207.xml'), - ('Today\'s Newspaper - Personal Journal', 'http://online.wsj.com/xml/rss/3_7208.xml'), - ('Today\'s Newspaper - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7209.xml'), - ('Opinion', 'http://online.wsj.com/xml/rss/3_7041.xml'), - ('News - U.S.: What\'s News', 'http://online.wsj.com/xml/rss/3_7011.xml'), - ('News - U.S. Business', 'http://online.wsj.com/xml/rss/3_7014.xml'), - ('News - Europe: What\'s News', 'http://online.wsj.com/xml/rss/3_7012.xml'), - ('News - Asia: What\'s News', 'http://online.wsj.com/xml/rss/3_7013.xml'), - ('News - World News', 'http://online.wsj.com/xml/rss/3_7085.xml'), - ('News - Economy', 'http://online.wsj.com/xml/rss/3_7086.xml'), - ('News - Earnings', 'http://online.wsj.com/xml/rss/3_7088.xml'), - ('News - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), - ('News - Law', 'http://online.wsj.com/xml/rss/3_7091.xml'), - ('News - Media & Marketing', 'http://online.wsj.com/xml/rss/3_7020.xml'), - ('Technology - What\'s News', 'http://online.wsj.com/xml/rss/3_7015.xml'), - ('Technology - Gadgets', 'http://online.wsj.com/xml/rss/3_7094.xml'), - ('Technology - Telecommunications', 'http://online.wsj.com/xml/rss/3_7095.xml'), - ('Technology - E-commerce/Media', 'http://online.wsj.com/xml/rss/3_7096.xml'), - ('Technology - Asia', 'http://online.wsj.com/xml/rss/3_7097.xml'), - ('Technology - Europe', 'http://online.wsj.com/xml/rss/3_7098.xml'), - ('Markets - News', 'http://online.wsj.com/xml/rss/3_7031.xml'), - ('Markets - Europe News', 'http://online.wsj.com/xml/rss/3_7101.xml'), - ('Markets - Asia News', 'http://online.wsj.com/xml/rss/3_7102.xml'), - ('Markets - Deals & Deal Makers', 'http://online.wsj.com/xml/rss/3_7099.xml'), - ('Markets - Hedge Funds', 'http://online.wsj.com/xml/rss/3_7199.xml'), - ('Personal Journal', 'http://online.wsj.com/xml/rss/3_7200.xml'), - ('Personal Journal - Money', 'http://online.wsj.com/xml/rss/3_7104.xml'), - ('Personal Journal - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), - ('Personal Journal - Autos', 'http://online.wsj.com/xml/rss/3_7092.xml'), - ('Personal Journal - Homes', 'http://online.wsj.com/xml/rss/3_7105.xml'), - ('Personal Journal - Travel', 'http://online.wsj.com/xml/rss/3_7106.xml'), - ('Personal Journal - Careers', 'http://online.wsj.com/xml/rss/3_7107.xml'), - ('Weekend & Leisure', 'http://online.wsj.com/xml/rss/3_7201.xml'), - ('Weekend & Leisure - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7202.xml'), - ('Weekend & Leisure - Arts & Entertainment', 'http://online.wsj.com/xml/rss/3_7177.xml'), - ('Weekend & Leisure - Books', 'http://online.wsj.com/xml/rss/3_7203.xml'), - ('Weekend & Leisure - Sports', 'http://online.wsj.com/xml/rss/3_7204.xml'), + + def cleanup(self): + self.browser.open('http://online.wsj.com/logout?url=http://online.wsj.com') + + feeds = [ + #('Most Emailed - Day', 'http://online.wsj.com/xml/rss/3_7030.xml'), + #('Most Emailed - Week', 'http://online.wsj.com/xml/rss/3_7253.xml'), + #('Most Emailed - Month', 'http://online.wsj.com/xml/rss/3_7254.xml'), + (' Most Viewed - Day', 'http://online.wsj.com/xml/rss/3_7198.xml'), + (' Most Viewed - Week', 'http://online.wsj.com/xml/rss/3_7251.xml'), + #('Most Viewed - Month', 'http://online.wsj.com/xml/rss/3_7252.xml'), + ('Today\'s Newspaper - Page One', 'http://online.wsj.com/xml/rss/3_7205.xml'), + ('Today\'s Newspaper - Marketplace', 'http://online.wsj.com/xml/rss/3_7206.xml'), + ('Today\'s Newspaper - Money & Investing', 'http://online.wsj.com/xml/rss/3_7207.xml'), + ('Today\'s Newspaper - Personal Journal', 'http://online.wsj.com/xml/rss/3_7208.xml'), + ('Today\'s Newspaper - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7209.xml'), + ('Opinion', 'http://online.wsj.com/xml/rss/3_7041.xml'), + ('News - U.S.: What\'s News', 'http://online.wsj.com/xml/rss/3_7011.xml'), + ('News - U.S. Business', 'http://online.wsj.com/xml/rss/3_7014.xml'), + ('News - Europe: What\'s News', 'http://online.wsj.com/xml/rss/3_7012.xml'), + ('News - Asia: What\'s News', 'http://online.wsj.com/xml/rss/3_7013.xml'), + ('News - World News', 'http://online.wsj.com/xml/rss/3_7085.xml'), + ('News - Economy', 'http://online.wsj.com/xml/rss/3_7086.xml'), + ('News - Earnings', 'http://online.wsj.com/xml/rss/3_7088.xml'), + ('News - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), + ('News - Law', 'http://online.wsj.com/xml/rss/3_7091.xml'), + ('News - Media & Marketing', 'http://online.wsj.com/xml/rss/3_7020.xml'), + ('Technology - What\'s News', 'http://online.wsj.com/xml/rss/3_7015.xml'), + ('Technology - Gadgets', 'http://online.wsj.com/xml/rss/3_7094.xml'), + ('Technology - Telecommunications', 'http://online.wsj.com/xml/rss/3_7095.xml'), + ('Technology - E-commerce/Media', 'http://online.wsj.com/xml/rss/3_7096.xml'), + ('Technology - Asia', 'http://online.wsj.com/xml/rss/3_7097.xml'), + ('Technology - Europe', 'http://online.wsj.com/xml/rss/3_7098.xml'), + ('Markets - News', 'http://online.wsj.com/xml/rss/3_7031.xml'), + ('Markets - Europe News', 'http://online.wsj.com/xml/rss/3_7101.xml'), + ('Markets - Asia News', 'http://online.wsj.com/xml/rss/3_7102.xml'), + ('Markets - Deals & Deal Makers', 'http://online.wsj.com/xml/rss/3_7099.xml'), + ('Markets - Hedge Funds', 'http://online.wsj.com/xml/rss/3_7199.xml'), + ('Personal Journal', 'http://online.wsj.com/xml/rss/3_7200.xml'), + ('Personal Journal - Money', 'http://online.wsj.com/xml/rss/3_7104.xml'), + ('Personal Journal - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), + ('Personal Journal - Autos', 'http://online.wsj.com/xml/rss/3_7092.xml'), + ('Personal Journal - Homes', 'http://online.wsj.com/xml/rss/3_7105.xml'), + ('Personal Journal - Travel', 'http://online.wsj.com/xml/rss/3_7106.xml'), + ('Personal Journal - Careers', 'http://online.wsj.com/xml/rss/3_7107.xml'), + ('Weekend & Leisure', 'http://online.wsj.com/xml/rss/3_7201.xml'), + ('Weekend & Leisure - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7202.xml'), + ('Weekend & Leisure - Arts & Entertainment', 'http://online.wsj.com/xml/rss/3_7177.xml'), + ('Weekend & Leisure - Books', 'http://online.wsj.com/xml/rss/3_7203.xml'), + ('Weekend & Leisure - Sports', 'http://online.wsj.com/xml/rss/3_7204.xml'), ] From 8443a11abec4f3e5b85bf8b6508c7f0b94b270a2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 8 Jul 2009 11:06:21 -0600 Subject: [PATCH 2/3] ... --- src/calibre/web/feeds/recipes/recipe_wsj.py | 140 ++++++++++---------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/calibre/web/feeds/recipes/recipe_wsj.py b/src/calibre/web/feeds/recipes/recipe_wsj.py index 0037b919b5..a206b6cc50 100644 --- a/src/calibre/web/feeds/recipes/recipe_wsj.py +++ b/src/calibre/web/feeds/recipes/recipe_wsj.py @@ -7,17 +7,17 @@ from calibre.web.feeds.news import BasicNewsRecipe # http://online.wsj.com/page/us_in_todays_paper.html -class WallStreetJournal(BasicNewsRecipe): - - title = 'The Wall Street Journal' - __author__ = 'Kovid Goyal' +class WallStreetJournal(BasicNewsRecipe): + + title = 'The Wall Street Journal' + __author__ = 'Kovid Goyal and Sujata Raman' description = 'News and current affairs.' needs_subscription = True language = _('English') max_articles_per_feed = 10 - timefmt = ' [%a, %b %d, %Y]' + timefmt = ' [%a, %b %d, %Y]' no_stylesheets = True - + extra_css = '''h1{color:#093D72 ; font-size:large ; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; } h2{color:#474537; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small; font-style:italic;} .subhead{color:gray; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small; font-style:italic;} @@ -30,7 +30,7 @@ class WallStreetJournal(BasicNewsRecipe): .byline{color:blue;font-family:Arial,Helvetica,sans-serif; font-size:xx-small} h6{color:#333333; font-family:Georgia,"Century Schoolbook","Times New Roman",Times,serif; font-size:small;font-style:italic; } .paperLocation{color:#666666; font-size:xx-small}''' - + remove_tags_before = dict(name='h1') remove_tags = [ dict(id=["articleTabs_tab_article", "articleTabs_tab_comments", "articleTabs_tab_interactive","articleTabs_tab_video","articleTabs_tab_map","articleTabs_tab_slideshow"]), @@ -39,80 +39,80 @@ class WallStreetJournal(BasicNewsRecipe): ] remove_tags_after = [dict(id="article_story_body"), {'class':"article story"},] - - def get_browser(self): - br = BasicNewsRecipe.get_browser() - if self.username is not None and self.password is not None: - br.open('http://commerce.wsj.com/auth/login') - br.select_form(nr=0) - br['user'] = self.username - br['password'] = self.password - br.submit() + + def get_browser(self): + br = BasicNewsRecipe.get_browser() + if self.username is not None and self.password is not None: + br.open('http://commerce.wsj.com/auth/login') + br.select_form(nr=0) + br['user'] = self.username + br['password'] = self.password + br.submit() return br - + def postprocess_html(self, soup, first): for tag in soup.findAll(name=['table', 'tr', 'td']): tag.name = 'div' - + for tag in soup.findAll('div', dict(id=["articleThumbnail_1", "articleThumbnail_2", "articleThumbnail_3", "articleThumbnail_4", "articleThumbnail_5", "articleThumbnail_6", "articleThumbnail_7"])): tag.extract() - + return soup - + def get_article_url(self, article): try: return article.feedburner_origlink.split('?')[0] except AttributeError: return article.link.split('?')[0] - - def cleanup(self): - self.browser.open('http://online.wsj.com/logout?url=http://online.wsj.com') - - feeds = [ - #('Most Emailed - Day', 'http://online.wsj.com/xml/rss/3_7030.xml'), - #('Most Emailed - Week', 'http://online.wsj.com/xml/rss/3_7253.xml'), - #('Most Emailed - Month', 'http://online.wsj.com/xml/rss/3_7254.xml'), - (' Most Viewed - Day', 'http://online.wsj.com/xml/rss/3_7198.xml'), - (' Most Viewed - Week', 'http://online.wsj.com/xml/rss/3_7251.xml'), - #('Most Viewed - Month', 'http://online.wsj.com/xml/rss/3_7252.xml'), - ('Today\'s Newspaper - Page One', 'http://online.wsj.com/xml/rss/3_7205.xml'), - ('Today\'s Newspaper - Marketplace', 'http://online.wsj.com/xml/rss/3_7206.xml'), - ('Today\'s Newspaper - Money & Investing', 'http://online.wsj.com/xml/rss/3_7207.xml'), - ('Today\'s Newspaper - Personal Journal', 'http://online.wsj.com/xml/rss/3_7208.xml'), - ('Today\'s Newspaper - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7209.xml'), - ('Opinion', 'http://online.wsj.com/xml/rss/3_7041.xml'), - ('News - U.S.: What\'s News', 'http://online.wsj.com/xml/rss/3_7011.xml'), - ('News - U.S. Business', 'http://online.wsj.com/xml/rss/3_7014.xml'), - ('News - Europe: What\'s News', 'http://online.wsj.com/xml/rss/3_7012.xml'), - ('News - Asia: What\'s News', 'http://online.wsj.com/xml/rss/3_7013.xml'), - ('News - World News', 'http://online.wsj.com/xml/rss/3_7085.xml'), - ('News - Economy', 'http://online.wsj.com/xml/rss/3_7086.xml'), - ('News - Earnings', 'http://online.wsj.com/xml/rss/3_7088.xml'), - ('News - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), - ('News - Law', 'http://online.wsj.com/xml/rss/3_7091.xml'), - ('News - Media & Marketing', 'http://online.wsj.com/xml/rss/3_7020.xml'), - ('Technology - What\'s News', 'http://online.wsj.com/xml/rss/3_7015.xml'), - ('Technology - Gadgets', 'http://online.wsj.com/xml/rss/3_7094.xml'), - ('Technology - Telecommunications', 'http://online.wsj.com/xml/rss/3_7095.xml'), - ('Technology - E-commerce/Media', 'http://online.wsj.com/xml/rss/3_7096.xml'), - ('Technology - Asia', 'http://online.wsj.com/xml/rss/3_7097.xml'), - ('Technology - Europe', 'http://online.wsj.com/xml/rss/3_7098.xml'), - ('Markets - News', 'http://online.wsj.com/xml/rss/3_7031.xml'), - ('Markets - Europe News', 'http://online.wsj.com/xml/rss/3_7101.xml'), - ('Markets - Asia News', 'http://online.wsj.com/xml/rss/3_7102.xml'), - ('Markets - Deals & Deal Makers', 'http://online.wsj.com/xml/rss/3_7099.xml'), - ('Markets - Hedge Funds', 'http://online.wsj.com/xml/rss/3_7199.xml'), - ('Personal Journal', 'http://online.wsj.com/xml/rss/3_7200.xml'), - ('Personal Journal - Money', 'http://online.wsj.com/xml/rss/3_7104.xml'), - ('Personal Journal - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), - ('Personal Journal - Autos', 'http://online.wsj.com/xml/rss/3_7092.xml'), - ('Personal Journal - Homes', 'http://online.wsj.com/xml/rss/3_7105.xml'), - ('Personal Journal - Travel', 'http://online.wsj.com/xml/rss/3_7106.xml'), - ('Personal Journal - Careers', 'http://online.wsj.com/xml/rss/3_7107.xml'), - ('Weekend & Leisure', 'http://online.wsj.com/xml/rss/3_7201.xml'), - ('Weekend & Leisure - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7202.xml'), - ('Weekend & Leisure - Arts & Entertainment', 'http://online.wsj.com/xml/rss/3_7177.xml'), - ('Weekend & Leisure - Books', 'http://online.wsj.com/xml/rss/3_7203.xml'), - ('Weekend & Leisure - Sports', 'http://online.wsj.com/xml/rss/3_7204.xml'), + + def cleanup(self): + self.browser.open('http://online.wsj.com/logout?url=http://online.wsj.com') + + feeds = [ + #('Most Emailed - Day', 'http://online.wsj.com/xml/rss/3_7030.xml'), + #('Most Emailed - Week', 'http://online.wsj.com/xml/rss/3_7253.xml'), + #('Most Emailed - Month', 'http://online.wsj.com/xml/rss/3_7254.xml'), + (' Most Viewed - Day', 'http://online.wsj.com/xml/rss/3_7198.xml'), + (' Most Viewed - Week', 'http://online.wsj.com/xml/rss/3_7251.xml'), + #('Most Viewed - Month', 'http://online.wsj.com/xml/rss/3_7252.xml'), + ('Today\'s Newspaper - Page One', 'http://online.wsj.com/xml/rss/3_7205.xml'), + ('Today\'s Newspaper - Marketplace', 'http://online.wsj.com/xml/rss/3_7206.xml'), + ('Today\'s Newspaper - Money & Investing', 'http://online.wsj.com/xml/rss/3_7207.xml'), + ('Today\'s Newspaper - Personal Journal', 'http://online.wsj.com/xml/rss/3_7208.xml'), + ('Today\'s Newspaper - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7209.xml'), + ('Opinion', 'http://online.wsj.com/xml/rss/3_7041.xml'), + ('News - U.S.: What\'s News', 'http://online.wsj.com/xml/rss/3_7011.xml'), + ('News - U.S. Business', 'http://online.wsj.com/xml/rss/3_7014.xml'), + ('News - Europe: What\'s News', 'http://online.wsj.com/xml/rss/3_7012.xml'), + ('News - Asia: What\'s News', 'http://online.wsj.com/xml/rss/3_7013.xml'), + ('News - World News', 'http://online.wsj.com/xml/rss/3_7085.xml'), + ('News - Economy', 'http://online.wsj.com/xml/rss/3_7086.xml'), + ('News - Earnings', 'http://online.wsj.com/xml/rss/3_7088.xml'), + ('News - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), + ('News - Law', 'http://online.wsj.com/xml/rss/3_7091.xml'), + ('News - Media & Marketing', 'http://online.wsj.com/xml/rss/3_7020.xml'), + ('Technology - What\'s News', 'http://online.wsj.com/xml/rss/3_7015.xml'), + ('Technology - Gadgets', 'http://online.wsj.com/xml/rss/3_7094.xml'), + ('Technology - Telecommunications', 'http://online.wsj.com/xml/rss/3_7095.xml'), + ('Technology - E-commerce/Media', 'http://online.wsj.com/xml/rss/3_7096.xml'), + ('Technology - Asia', 'http://online.wsj.com/xml/rss/3_7097.xml'), + ('Technology - Europe', 'http://online.wsj.com/xml/rss/3_7098.xml'), + ('Markets - News', 'http://online.wsj.com/xml/rss/3_7031.xml'), + ('Markets - Europe News', 'http://online.wsj.com/xml/rss/3_7101.xml'), + ('Markets - Asia News', 'http://online.wsj.com/xml/rss/3_7102.xml'), + ('Markets - Deals & Deal Makers', 'http://online.wsj.com/xml/rss/3_7099.xml'), + ('Markets - Hedge Funds', 'http://online.wsj.com/xml/rss/3_7199.xml'), + ('Personal Journal', 'http://online.wsj.com/xml/rss/3_7200.xml'), + ('Personal Journal - Money', 'http://online.wsj.com/xml/rss/3_7104.xml'), + ('Personal Journal - Health', 'http://online.wsj.com/xml/rss/3_7089.xml'), + ('Personal Journal - Autos', 'http://online.wsj.com/xml/rss/3_7092.xml'), + ('Personal Journal - Homes', 'http://online.wsj.com/xml/rss/3_7105.xml'), + ('Personal Journal - Travel', 'http://online.wsj.com/xml/rss/3_7106.xml'), + ('Personal Journal - Careers', 'http://online.wsj.com/xml/rss/3_7107.xml'), + ('Weekend & Leisure', 'http://online.wsj.com/xml/rss/3_7201.xml'), + ('Weekend & Leisure - Weekend Journal', 'http://online.wsj.com/xml/rss/3_7202.xml'), + ('Weekend & Leisure - Arts & Entertainment', 'http://online.wsj.com/xml/rss/3_7177.xml'), + ('Weekend & Leisure - Books', 'http://online.wsj.com/xml/rss/3_7203.xml'), + ('Weekend & Leisure - Sports', 'http://online.wsj.com/xml/rss/3_7204.xml'), ] From 6ac009886c19acae72ea8c49054f532ba9d99a62 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 8 Jul 2009 13:27:26 -0600 Subject: [PATCH 3/3] Search box now indicates successfully parsed queries --- src/calibre/gui2/library.py | 22 +++++++++++++++++++--- src/calibre/gui2/main.py | 13 +++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index 79ecbc082b..c1705cb420 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -244,12 +244,15 @@ class BooksModel(QAbstractTableModel): try: self.db.search(text) except ParseException: - self.emit(SIGNAL('parse_exception()')) + self.emit(SIGNAL('searched(PyQt_PyObject)'), False) return self.last_search = text if reset: self.clear_caches() self.reset() + if self.last_search: + self.emit(SIGNAL('searched(PyQt_PyObject)'), True) + def sort(self, col, order, reset=True): if not self.db: @@ -743,14 +746,20 @@ class BooksView(TableView): def set_editable(self, editable): self._model.set_editable(editable) - def connect_to_search_box(self, sb): + def connect_to_search_box(self, sb, search_done): QObject.connect(sb, SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'), self._model.search) + self._search_done = search_done + self.connect(self._model, SIGNAL('searched(PyQt_PyObject)'), + self.search_done) def connect_to_book_display(self, bd): QObject.connect(self._model, SIGNAL('new_bookdisplay_data(PyQt_PyObject)'), bd) + def search_done(self, ok): + self._search_done(self, ok) + class DeviceBooksView(BooksView): @@ -864,7 +873,7 @@ class DeviceBooksModel(BooksModel): try: matches = self.search_engine.parse(text) except ParseException: - self.emit(SIGNAL('parse_exception()')) + self.emit(SIGNAL('searched(PyQt_PyObject)'), False) return self.map = [] @@ -875,6 +884,9 @@ class DeviceBooksModel(BooksModel): if reset: self.reset() self.last_search = text + if self.last_search: + self.emit(SIGNAL('searched(PyQt_PyObject)'), True) + def resort(self, reset): self.sort(self.sorted_on[0], self.sorted_on[1], reset=reset) @@ -1068,11 +1080,15 @@ class SearchBox(QLineEdit): self.setText(self.help_text) self.home(False) self.initial_state = True + self.setStyleSheet("background-color: white") def clear(self): self.clear_to_help() self.emit(SIGNAL('search(PyQt_PyObject, PyQt_PyObject)'), '', False) + def search_done(self, ok): + col = 'rgba(0,255,0,25%)' if ok else 'rgb(255,0,0,25%)' + self.setStyleSheet('background-color: '+col) def keyPressEvent(self, event): if self.initial_state: diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index e3aa0e6b8c..c1597c5979 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -394,13 +394,14 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): QObject.connect(self.library_view, SIGNAL('files_dropped(PyQt_PyObject)'), self.files_dropped, Qt.QueuedConnection) - for func, target in [ - ('connect_to_search_box', self.search), + for func, args in [ + ('connect_to_search_box', (self.search, + self.search_done)), ('connect_to_book_display', - self.status_bar.book_info.show_data), + (self.status_bar.book_info.show_data,)), ]: for view in (self.library_view, self.memory_view, self.card_a_view, self.card_b_view): - getattr(view, func)(target) + getattr(view, func)(*args) self.memory_view.connect_dirtied_signal(self.upload_booklists) self.card_a_view.connect_dirtied_signal(self.upload_booklists) @@ -631,6 +632,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): self.match_any.setVisible(False) self.popularity.setVisible(False) + def search_done(self, view, ok): + if view is self.current_view(): + self.search.search_done(ok) + def sync_cf_to_listview(self, index, *args): if not hasattr(index, 'row') and \ self.library_view.currentIndex().row() != index: