From 3ed8dcd289bf0ff31947ca0b53487963bb775c80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Paprota?= Date: Mon, 7 Jul 2008 02:12:19 +0200 Subject: [PATCH] Cleaned up item view. --- straw/ItemView.py | 15 +++++++++------ straw/model/__init__.py | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/straw/ItemView.py b/straw/ItemView.py index fd73253..0b88e84 100644 --- a/straw/ItemView.py +++ b/straw/ItemView.py @@ -328,6 +328,9 @@ class HTMLPresenter(MVP.BasicPresenter): html += "%s" % body return html + def _not_empty(self, text): + return text is not None and len(text) > 0 + def _htmlify_item(self, item, encoding): ret = [] @@ -348,11 +351,11 @@ class HTMLPresenter(MVP.BasicPresenter): ret.append('') # item body - if item.description is not None: + if self._not_empty(item.description): item.description.replace('\n', '
') ret.append('
%s
' % item.description) - if len(item.publication_name): + if self._not_empty(item.publication_name): ret.append('
') ret.append('%s: %s
' % (_("Publication"), item.publication_name)) @@ -425,8 +428,8 @@ class HTMLPresenter(MVP.BasicPresenter): imgsrc = "file://%s/%s" % (straw.defs.STRAW_DATA_DIR, 'image-missing.svg') dcret.append('
%s (%.2f %s - %s)
' % (enc['href'], imgsrc, link_text, size, unit, enc['type'])) dcret.append('') - - if item.creator is not None: + + if self._not_empty(item.creator): dcret.append('%s%s' % (_("Posted by"), item.creator)) if item.contributors is not None and len(item.contributors): for c in item.contributors: @@ -438,12 +441,12 @@ class HTMLPresenter(MVP.BasicPresenter): dcret.append('%s%s' % (_("Item Source"), url, text)) - if item.guid is not None and item.guid != "" and item.guidislink: + if self._not_empty(item.guid) and item.guidislink: dcret.append('%s%s' % (_("Permalink"), item.guid, item.guid)) # check for not guidislink for the case where there is guid but # isPermalink="false" and yet link is the same as guid (link is # always assumed to be a valid link) - if item.link != "" and item.link is not None and (item.link != item.guid or not item.guidislink): + if self._not_empty(item.link) and (item.link != item.guid or not item.guidislink): dcret.append('%s%s' % (_("Complete story"), item.link, item.link)) diff --git a/straw/model/__init__.py b/straw/model/__init__.py index 121c033..e00687e 100644 --- a/straw/model/__init__.py +++ b/straw/model/__init__.py @@ -299,23 +299,23 @@ class Item(GObject): self.feed_id = None self.is_read = False - self.link = "link" + self.link = "" self.pub_date = None - self.description = "description" + self.description = "" self.source = None - self.guid = "guid" + self.guid = "" self.guidislink = False - self.publication_name = "publication_name" - self.publication_volume = "publication_volume" - self.publication_number = "publication_number" - self.publication_section = "publication_section" - self.publication_starting_page = "publication_starting_page" + self.publication_name = "" + self.publication_volume = "" + self.publication_number = "" + self.publication_section = "" + self.publication_starting_page = "" - self.fm_license = "fm_license" - self.fm_changes = "fm_changes" + self.fm_license = "" + self.fm_changes = "" - self.creator = "creator" + self.creator = "" self.contributors = [] self.enclosures = [] -- 2.11.4.GIT