Created
April 6, 2011 08:11
-
-
Save gglanzani/905312 to your computer and use it in GitHub Desktop.
Adapted from Brett Terpstra https://gist.github.com/raw/899757/47eef9c26f3027277adb93b30c0e70ec83796b37/gistfile1.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
%w[fileutils ftools set zlib].each do |filename| | |
require filename | |
end | |
# Load the Marshal dump to a hash | |
def load file_name | |
begin | |
file = Zlib::GzipReader.open(file_name) | |
rescue Zlib::GzipFile::Error | |
file = File.open(file_name, 'r') | |
ensure | |
obj = Marshal.load file.read | |
file.close | |
return obj | |
end | |
end | |
HOME_DIR = ENV['HOME'] | |
DB_LOCATION = "#{HOME_DIR}/Dropbox/appsupport/Bookmark" | |
obj = load(DB_LOCATION + "/bookmarks.stash") | |
tag = '' | |
bookmarks = [] | |
obj.each {|bookmark| | |
if bookmark['tag'] =~ /\b#{tag}\b/i | |
bookmarks << { | |
'title' => bookmark['description'], | |
'url' => bookmark['href'] | |
} | |
end unless bookmark['tag'].nil? | |
} | |
puts "<!DOCTYPE NETSCAPE-Bookmark-file-1><!-- This is an automatically generated file. It will be read and overwritten. DO NOT EDIT! --> <TITLE>Bookmarks</TITLE> <H1>Bookmarks</H1>" | |
puts "<DL><p>" | |
bookmarks.each{|bookmark| | |
puts %Q{<DT><A HREF="#{bookmark['url']}">#{bookmark['title']}</A>} | |
} | |
puts "</DL><p>" | |
# wanted_keys = %w[presentation] | |
# p bookmarks.reject { |bookmark| !wanted_keys.include? bookmark['tag'] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment