Cleaned up item view.origin/future
authorPaweł Paprota <ppawel@fastmail.fm>
Mon, 7 Jul 2008 00:12:19 +0000 (7 02:12 +0200)
committerPaweł Paprota <ppawel@fastmail.fm>
Mon, 7 Jul 2008 00:12:19 +0000 (7 02:12 +0200)
straw/ItemView.py
straw/model/__init__.py

index fd73253..0b88e84 100644 (file)
@@ -328,6 +328,9 @@ class HTMLPresenter(MVP.BasicPresenter):
         html += "</head><body>%s</body></html>" % 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('</div>')
 
         # item body
-        if item.description is not None:
+        if self._not_empty(item.description):
             item.description.replace('\n', '<br/>')
             ret.append('<div class="description">%s</div>' % item.description)
 
-        if len(item.publication_name):
+        if self._not_empty(item.publication_name):
             ret.append('<div class="description">')
             ret.append('<b>%s:</b> %s<br/>' % (_("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('<tr><td><div style="vertical-align: middle"><a class="dclink" href="%s" style="vertical-align: middle"><img style="padding: 0px 15px 5px 0px" src=%s /> %s</a> (%.2f %s - %s)</div></td></tr>' % (enc['href'], imgsrc, link_text, size, unit, enc['type']))
             dcret.append('</table></td></tr>')
-        
-        if item.creator is not None:
+
+        if self._not_empty(item.creator):
             dcret.append('<tr class="tr.dc"><td class="dcname"><span>%s</span></td><td class="dcvalue"><span>%s</span></td></tr>' % (_("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('<tr class="tr.dc"><td class="dcname"><span>%s</span></td><td class="dcvalue"><a class="dclink" href="%s"><span>%s</span></a></td></tr>' %
                          (_("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('<tr class="tr.dc"><td class="dcname"><span>%s</span></td><td class="dcvalue"><a class="dclink" href="%s"><span>%s</span></a></td></tr>' % (_("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('<tr class="tr.dc"><td class="dcname"><span>%s</span></td><td class="dcvalue"><a class="dclink" href="%s"><span>%s</span></a></td></tr>' %
                         (_("Complete story"), item.link, item.link))
 
index 121c033..e00687e 100644 (file)
@@ -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 = []