X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Writers%2Fbkmk_whtml.py;h=b4c4dab5c59ff3c0a28a7698376757e39efb542a;hb=4fd6d1f55e5e5dbcc0bdc1b933d6e14076316437;hp=eba924705dc00a72d0bc60f39c1cda9b49455f43;hpb=bcf579e3311f0d9f968338dc419e9a43b48414ba;p=bookmarks_db.git diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index eba9247..b4c4dab 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -1,25 +1,21 @@ """ Convert a bkmk database back to bookmarks.html - Written by BroytMann. Copyright (C) 2000-2004 PhiloSoft Design + Written by Broytman. Copyright (C) 2000-2010 PhiloSoft Design """ - -import os -NSFORMAT = os.environ.has_key("BKMK_NSFORMAT") +from bkmk_objects import Writer, BKMK_FORMAT, quote_title def dump_comment(comment): comment = comment.replace("
\n", "\n") - if NSFORMAT: + if BKMK_FORMAT == "NETSCAPE": comment = comment.replace("\n", "
\n") return comment ind_s = " "*4 -from bkmk_objects import Writer - class writer_html(Writer): filename = "bookmarks.html" @@ -30,14 +26,13 @@ class writer_html(Writer): def root_folder(self, f): self.outfile.write("\n") self.outfile.write(f.header + "\n") - self.outfile.write('

%s

\n\n' % f.name) + self.outfile.write('

%s

\n\n' % quote_title(f.name)) self._folder(f, 0) def start_folder(self, f, level): self.outfile.write(ind_s*level + '

%s

\n' % f.name) + if (BKMK_FORMAT == "MOZILLA") and f.last_modified: self.outfile.write(' LAST_MODIFIED="%s"' % f.last_modified) + self.outfile.write('>%s\n' % quote_title(f.name)) self._folder(f, level) def end_folder(self, f, level): @@ -45,8 +40,12 @@ class writer_html(Writer): def bookmark(self, b, level): self.outfile.write(ind_s*(level+1) + '
%s\n' % b.name) + 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\n' % quote_title(b.name)) if b.comment: self.outfile.write('
%s\n' % dump_comment(b.comment)) def ruler(self, r, level):