]> git.phdru.name Git - bookmarks_db.git/commitdiff
Store icon's URIs.
authorOleg Broytman <phd@phdru.name>
Wed, 11 Aug 2010 20:08:41 +0000 (20:08 +0000)
committerOleg Broytman <phd@phdru.name>
Wed, 11 Aug 2010 20:08:41 +0000 (20:08 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@264 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Robots/bkmk_rforking.py
Robots/bkmk_rsimple.py
Storage/bkmk_stflad.py
Writers/bkmk_whtml.py
bkmk_objects.py
check_url.py

index 4c4c098daae740d2278e6227ad86ca5b4457dc0b..f0e9354a0df4628fad5ef0093c08c652c43697ed 100644 (file)
@@ -55,7 +55,8 @@ class robot_forking(Robot):
             new_b = pickle.loads(subp_pipe.read_record())
             for attr in ("error", "no_error",
                   "moved", "size", "md5", "real_title",
-                  "last_tested", "last_modified", "test_time", "icon"):
+                  "last_tested", "last_modified", "test_time",
+                  "icon", "icon_href"):
                if hasattr(new_b, attr):
                   setattr(bookmark, attr, getattr(new_b, attr))
          else:
index 42975d29a729d26ad4838cd64791acef0ca34d9a..ba302943d175dd5e969adcf82cf564e0f2cb644b 100644 (file)
@@ -202,6 +202,7 @@ class robot_simple(Robot):
                   self.log("   looking for icon at: %s" % icon)
                   if icon in icons:
                      if icons[icon]:
+                        bookmark.icon_href = icon
                         content_type, bookmark.icon = icons[icon]
                         self.log("       cached icon: %s" % content_type)
                      else:
@@ -230,9 +231,10 @@ class robot_simple(Robot):
                         content_type = headers["Content-Type"]
                         if content_type.startswith("image/"):
                            icon_file = open(fname, "rb")
-                           icon = icon_file.read()
+                           icon_data = icon_file.read()
                            icon_file.close()
-                           bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon))
+                           bookmark.icon_href = icon
+                           bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon_data))
                            self.log("   got icon       : %s" % content_type)
                            icons[icon] = (content_type, bookmark.icon)
                         else:
index 6611d97aae5158e2c98c005c0e0f350339dd3c0e..9bd8751c278b9fa6becbee0d552455a43049c8de 100644 (file)
@@ -2,7 +2,7 @@
    Bookmarks storage module - FLAD (Flat ASCII Database)
       special version for compatibility with old (version 1) bkmk2db
 
-   Written by Broytman, Feb 2000 - Sep 2007. Copyright (C) 2000-2007 PhiloSoft Design
+   Written by Broytman. Copyright (C) 2000-2010 PhiloSoft Design
 """
 
 
@@ -45,10 +45,12 @@ LastVisit: %s
 LastModified: %s
 Keyword: %s
 Comment: %s
+IconURI: %s
 Icon: %s
 Charset: %s
 """ % (level+1, b.name, b.href, b.add_date, b.last_visit, b.last_modified,
-         b.keyword, b.comment.replace('\n', "\\n"), b.icon or '', b.charset or ''))
+         b.keyword, b.comment.replace('\n', "\\n"),
+         b.icon_href or '', b.icon or '', b.charset or ''))
 
 
    def ruler(self, r, level):
index 3597060b0f175fad48b62698d006aed59c085156..b4c4dab5c59ff3c0a28a7698376757e39efb542a 100644 (file)
@@ -1,7 +1,7 @@
 """
    Convert a bkmk database back to bookmarks.html
 
-   Written by Broytman. Copyright (C) 2000-2007 PhiloSoft Design
+   Written by Broytman. Copyright (C) 2000-2010 PhiloSoft Design
 """
 
 from bkmk_objects import Writer, BKMK_FORMAT, quote_title
@@ -42,6 +42,7 @@ class writer_html(Writer):
       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))
       if BKMK_FORMAT == "MOZILLA":
          if b.keyword: self.outfile.write(' SHORTCUTURL="%s"' % b.keyword)
+         if b.icon_href: self.outfile.write(' ICON_URI="%s"' % b.icon_href)
          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))
index 121f908b2971d2568dc49b9d2533a47c96125fd0..a9567e22134fd70b9adcefe788c2b2bb3a45746f 100644 (file)
@@ -44,13 +44,14 @@ class Bookmark:
    isBookmark = 1
 
    def __init__(self, href, add_date, last_visit=None, last_modified=None,
-         keyword=None, comment='', icon=None, charset=None):
+         keyword=None, comment='', icon_href=None, icon=None, charset=None):
       self.href = href
       self.add_date = add_date
       self.last_visit = last_visit
       self.last_modified = last_modified
       self.keyword = keyword
       self.comment = comment
+      self.icon_href = icon_href
       self.icon = icon
       self.charset = charset
 
index ebf9a20c827e3c1432cc90947ece19f06d7610f7..123f6a92182b89c9d66f7647024cef72d52a5f34 100755 (executable)
@@ -51,8 +51,9 @@ def run():
 URL: %s
 Title: %s
 LastModified: %s
+IconURI: %s
 Icon: %s
-""" % (bookmark.href, getattr(bookmark, 'real_title', ''), strftime(bookmark.last_modified), bookmark.icon)
+""" % (bookmark.href, getattr(bookmark, 'real_title', ''), strftime(bookmark.last_modified), bookmark.icon_href, bookmark.icon)
 
    robot.stop()
    log.close()