]> git.phdru.name Git - bookmarks_db.git/blobdiff - Writers/bkmk_whtml.py
Fix: convert unicode icon URLs to utf-8
[bookmarks_db.git] / Writers / bkmk_whtml.py
index 3597060b0f175fad48b62698d006aed59c085156..707b52a68becf5bb00db6181fa3645bf2f247aa9 100644 (file)
@@ -1,9 +1,16 @@
-"""
-   Convert a bkmk database back to bookmarks.html
+"""Convert a bkmk database back to bookmarks.html
 
-   Written by Broytman. Copyright (C) 2000-2007 PhiloSoft Design
+This file is a part of Bookmarks database and Internet robot.
 """
 
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2000-2012 PhiloSoft Design"
+__license__ = "GNU GPL"
+
+__all__ = ['writer_html']
+
+
+from m_lib.defenc import default_encoding
 from bkmk_objects import Writer, BKMK_FORMAT, quote_title
 
 
@@ -13,7 +20,6 @@ def dump_comment(comment):
       comment = comment.replace("\n", "<BR>\n")
    return comment
 
-
 ind_s = " "*4
 
 class writer_html(Writer):
@@ -39,9 +45,17 @@ class writer_html(Writer):
       self.outfile.write(ind_s*level + "</DL><p>\n")
 
    def bookmark(self, b, level):
-      self.outfile.write(ind_s*(level+1) + '<DT><A HREF="%s" ADD_DATE="%s" LAST_VISIT="%s" LAST_MODIFIED="%s"' % (b.href, b.add_date, b.last_visit, b.last_modified))
+      self.outfile.write(ind_s*(level+1) + '<DT><A HREF="%s" ADD_DATE="%s"' % (b.href, b.add_date))
+      if b.last_visit: self.outfile.write(' LAST_VISIT="%s"' % b.last_visit)
+      if b.last_modified:
+         self.outfile.write(' LAST_MODIFIED="%s"' % b.last_modified)
       if BKMK_FORMAT == "MOZILLA":
          if b.keyword: self.outfile.write(' SHORTCUTURL="%s"' % b.keyword)
+         if b.icon_href:
+            value = b.icon_href
+            if isinstance(value, unicode):
+               value = value.encode('utf-8')
+            self.outfile.write(' ICON_URI="%s"' % value)
          if b.icon: self.outfile.write(' ICON="%s"' % b.icon)
          if b.charset: self.outfile.write(' LAST_CHARSET="%s"' % b.charset)
       self.outfile.write('>%s</A>\n' % quote_title(b.name))