From f330c24f4f50c0c7db0d196db5da1b993235054f Mon Sep 17 00:00:00 2001 From: Yves Date: Mon, 22 Mar 2010 23:58:02 -0700 Subject: [PATCH] 0.5.3-4 image caching --- debian/changelog | 14 +++++++-- debian/control | 4 +-- src/FeedingIt.py | 23 ++++++++------- src/feedingitdbus.py | 4 +++ src/portrait.py | 9 +++++- src/rss.py | 79 ++++++++++++++++++++++++++++---------------------- 6 files changed, 82 insertions(+), 51 deletions(-) diff --git a/debian/changelog b/debian/changelog index f6b9233..1cd759d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,16 @@ -feedingit (0.5.3-0) unstable; urgency=low +feedingit (0.5.3-4) unstable; urgency=low + + * Fixed text selection when panning (#5103) + * Fixed re-layout of listing when orientation changes + + -- Yves Mon, 22 Mar 2010 22:02:19 -0800 + +feedingit (0.5.3-2) unstable; urgency=low * Enabled image caching for all articles - - -- Yves Wed, 21 Mar 2010 21:39:19 -0800 + * Added update dbus call + + -- Yves Mon, 22 Mar 2010 22:02:19 -0800 feedingit (0.5.2-4) unstable; urgency=low diff --git a/debian/control b/debian/control index 8b1fd87..15eb49e 100644 --- a/debian/control +++ b/debian/control @@ -9,8 +9,8 @@ XSBC-Bugtracker: https://garage.maemo.org/tracker/?func=browse&group_id=1202&ati Package: feedingit Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, python-gtkhtml2, python, python-hildon, - libgtkhtml2-0, python-dbus, python-osso, python-gconf, python-beautifulsoup, python2.5-webkit +Depends: ${shlibs:Depends}, ${misc:Depends}, python, python-hildon, + python-dbus, python-osso, python-gconf, python-beautifulsoup, python2.5-webkit Description: RSS Reader Its main features are: diff --git a/src/FeedingIt.py b/src/FeedingIt.py index 761ee54..217faee 100644 --- a/src/FeedingIt.py +++ b/src/FeedingIt.py @@ -370,11 +370,11 @@ class SortList(gtk.Dialog): class DisplayArticle(hildon.StackableWindow): - def __init__(self, feed, id, key, config): + def __init__(self, feed, id, key, config, listing): hildon.StackableWindow.__init__(self) #self.imageDownloader = ImageDownloader() self.feed = feed - #self.listing=listing + self.listing=listing self.key = key self.id = id self.set_title(feed.getTitle(id)) @@ -400,6 +400,8 @@ class DisplayArticle(hildon.StackableWindow): self.feed.setEntryRead(self.id) #if key=="ArchivedArticles": self.view.open("file://" + contentLink) + self.view.connect("motion-notify-event", lambda w,ev: True) + #else: #self.view.load_html_string(self.text, contentLink) # "text/html", "utf-8", self.link) self.view.set_zoom_level(float(config.getArtFontSize())/10.) @@ -497,10 +499,10 @@ class DisplayArticle(hildon.StackableWindow): # self.show_all() def _signal_link_clicked(self, object, link): - bus = dbus.SystemBus() + bus = dbus.SessionBus() proxy = bus.get_object("com.nokia.osso_browser", "/com/nokia/osso_browser/request") iface = dbus.Interface(proxy, 'com.nokia.osso_browser') - iface.load_url(link) + iface.open_new_window(link) #def _signal_request_url(self, object, url, stream): #print url @@ -585,11 +587,12 @@ class DisplayFeed(hildon.StackableWindow): self.show_all() def clear(self): - self.remove(self.pannableFeed) + self.pannableFeed.destroy() + #self.remove(self.pannableFeed) def button_clicked(self, button, index, previous=False, next=False): #newDisp = DisplayArticle(self.feedTitle, self.feed.getArticle(index), self.feed.getLink(index), index, self.key, self.listing, self.config) - newDisp = DisplayArticle(self.feed, index, self.key, self.config) + newDisp = DisplayArticle(self.feed, index, self.key, self.config, self.listing) stack = hildon.WindowStack.get_default() if previous: tmp = stack.peek() @@ -695,8 +698,8 @@ class FeedingIt: self.listing = Listing(CONFIGDIR) self.downloadDialog = False - #self.orientation = FremantleRotation("FeedingIt", main_window=self.window) - #self.orientation.set_mode(self.config.getOrientation()) + self.orientation = FremantleRotation("FeedingIt", main_window=self.window, app=self) + self.orientation.set_mode(self.config.getOrientation()) menu = hildon.AppMenu() # Create a button and add it to the menu @@ -843,8 +846,8 @@ class FeedingIt: break def buttonFeedClicked(widget, button, self, window, key): - disp = DisplayFeed(self.listing, self.listing.getFeed(key), self.listing.getFeedTitle(key), key, self.config) - disp.connect("feed-closed", self.onFeedClosed) + self.disp = DisplayFeed(self.listing, self.listing.getFeed(key), self.listing.getFeedTitle(key), key, self.config) + self.disp.connect("feed-closed", self.onFeedClosed) def onFeedClosed(self, object, key): #self.displayListing() diff --git a/src/feedingitdbus.py b/src/feedingitdbus.py index c6875e6..048d5b3 100644 --- a/src/feedingitdbus.py +++ b/src/feedingitdbus.py @@ -43,3 +43,7 @@ class ServerObject(dbus.service.Object): @dbus.service.method('org.maemo.feedingit') def GetStatus(self): return self.app.getStatus() + + def Update(self): + self.app.button_update_clicked(None, None) + return "Done" diff --git a/src/portrait.py b/src/portrait.py index 6782449..5fd1ec6 100644 --- a/src/portrait.py +++ b/src/portrait.py @@ -53,7 +53,7 @@ class FremantleRotation(object): _MCE_REQUEST_PATH = '/com/nokia/mce/request' _MCE_REQUEST_IF = 'com.nokia.mce.request' - def __init__(self, app_name, main_window=None, version='1.0', mode=0): + def __init__(self, app_name, main_window=None, version='1.0', mode=0, app=None): """Create a new rotation manager app_name ... The name of your application (for osso.Context) @@ -65,6 +65,7 @@ class FremantleRotation(object): self._main_window = main_window self._stack = hildon.WindowStack.get_default() self._mode = -1 + self.app = app app_id = '-'.join((app_name, self.__class__.__name__)) self._osso_context = osso.Context(app_id, version, False) self._last_dbus_orientation = self._get_current_orientation() @@ -170,6 +171,12 @@ class FremantleRotation(object): hildon.hildon_gtk_window_set_portrait_flags(window, flags) self._orientation = orientation + if orientation == self._PORTRAIT: + try: + self.app.disp.clear() + self.app.disp.displayFeed() + except: + pass def _on_orientation_signal(self, orientation, stand, face, x, y, z): if orientation in (self._PORTRAIT, self._LANDSCAPE): diff --git a/src/rss.py b/src/rss.py index 53c3892..5ccaefa 100644 --- a/src/rss.py +++ b/src/rss.py @@ -130,12 +130,14 @@ class Feed: tmp=feedparser.parse(self.url) else: tmp=feedparser.parse(self.url, handlers = [proxy]) + expiry = float(expiryTime) * 3600. # Check if the parse was succesful (number of entries > 0, else do nothing) if len(tmp["entries"])>0: #reversedEntries = self.getEntries() #reversedEntries.reverse() if not isdir(configdir+self.uniqueId+".d"): mkdir(configdir+self.uniqueId+".d") + currentTime = time.time() tmpEntries = {} tmpIds = [] for entry in tmp["entries"]: @@ -143,56 +145,63 @@ class Feed: tmpEntry = {"title":entry["title"], "content":self.extractContent(entry), "date":date, "dateTuple":dateTuple, "link":entry["link"], "images":[] } id = self.generateUniqueId(tmpEntry) + + #articleTime = time.mktime(self.entries[id]["dateTuple"]) if not id in self.ids: - - soup = BeautifulSoup(tmpEntry["content"]) + soup = BeautifulSoup(self.getArticle(tmpEntry)) #tmpEntry["content"]) images = soup('img') baseurl = ''.join(urlparse(tmpEntry["link"])[:-1]) if imageCache: - for img in images: + for img in images: + try: filename = self.imageHandler.addImage(self.uniqueId, baseurl, img['src']) img['src']=filename tmpEntry["images"].append(filename) + except: + print "Error downloading image %s" %img tmpEntry["contentLink"] = configdir+self.uniqueId+".d/"+id+".html" file = open(tmpEntry["contentLink"], "w") file.write(soup.prettify()) file.close() tmpEntries[id] = tmpEntry tmpIds.append(id) + if id not in self.readItems: + self.readItems[id] = False + else: + tmpEntries[id] = self.entries[id] + tmpIds.append(id) - for entryId in self.getIds()[:]: - currentTime = time.time() - expiry = float(expiryTime) * 3600. - try: - articleTime = time.mktime(self.entries[entryId]["dateTuple"]) - if currentTime - articleTime < expiry: - tmpEntries[entryId] = self.entries[entryId] - tmpIds.append(entryId) - else: - if (not self.isEntryRead(entryId)) and (currentTime - articleTime < 2*expiry): - tmpEntries[entryId] = self.entries[entryId] - tmpIds.append(entryId) - else: - self.removeEntry(id) - except: - self.removeEntry(id) - print "Error purging old articles %s" % id - - + oldIds = self.ids[:] + for entryId in oldIds: + if not entryId in tmpIds: + try: + articleTime = time.mktime(self.entries[entryId]["dateTuple"]) + if (currentTime - articleTime > 2*expiry): + self.removeEntry(entryId) + continue + if (currentTime - articleTime > expiry) and (self.isEntryRead(entryId)): + # Entry is over 24 hours, and already read + self.removeEntry(entryId) + continue + tmpEntries[entryId] = self.entries[entryId] + tmpIds.append(entryId) + except: + print "Error purging old articles %s" % entryId + self.removeEntry(entryId) + self.entries = tmpEntries self.ids = tmpIds - self.countUnread = 0 - # Initialize the new articles to unread - tmpReadItems = self.readItems - self.readItems = {} - for id in self.getIds(): - if not tmpReadItems.has_key(id): + tmpUnread = 0 + + + ids = self.ids[:] + for id in ids: + if not self.readItems.has_key(id): self.readItems[id] = False - else: - self.readItems[id] = tmpReadItems[id] if self.readItems[id]==False: - self.countUnread = self.countUnread + 1 + tmpUnread = tmpUnread + 1 del tmp + self.countUnread = tmpUnread self.updateTime = time.asctime() self.saveFeed(configdir) @@ -320,9 +329,9 @@ class Feed: #except: # print "Error removing entry %s" %id - def getArticle(self, id): - self.setEntryRead(id) - entry = self.entries[id] + def getArticle(self, entry): + #self.setEntryRead(id) + #entry = self.entries[id] title = entry['title'] #content = entry.get('content', entry.get('summary_detail', {})) content = entry["content"] @@ -465,7 +474,7 @@ class Listing: def addArchivedArticle(self, key, index): feed = self.getFeed(key) title = feed.getTitle(index) - link = feed.getLink(index) + link = feed.getExternalLink(index) date = feed.getDateTuple(index) if not self.listOfFeeds.has_key("ArchivedArticles"): self.listOfFeeds["ArchivedArticles"] = {"title":"Archived Articles", "url":"", "unread":0, "updateTime":"Never"} -- 1.7.9.5