Skip to content

Instantly share code, notes, and snippets.

@pogin503
Created October 29, 2013 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pogin503/7213150 to your computer and use it in GitHub Desktop.
Save pogin503/7213150 to your computer and use it in GitHub Desktop.
root_dir = '/Users/Username/Dropbox/Documents/Study/'
res = Dir.glob(root_dir + "**/*.mm")
res1 = res.map do |e|
"file://" + e
end
# puts res1
File::delete("index.html")
# File::open("index.html","a")
File::open("index.html", "a") do |file|
file.puts("<html>")
file.puts("<head>")
file.puts('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">')
file.puts("</head>")
file.puts("<body>")
puts root_dir
sub_res = root_dir.gsub(/\//, "\\\\/")
puts sub_res
res1.map do |e|
# filename = File.basename(e)
file.puts('<a href="' + e + '">' + e.gsub(/file:\/\/#{sub_res}/, "") + '</a><br />')
end
file.puts("</body>")
file.puts("</html>")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment