Skip to content

Instantly share code, notes, and snippets.

@june29
Created January 17, 2009 16:55
Show Gist options
  • Save june29/48387 to your computer and use it in GitHub Desktop.
Save june29/48387 to your computer and use it in GitHub Desktop.
extensions = ["png", "gif", "ico", "bmp", "jpg"]
pattern = Regexp.new("(\." + extensions.join("$|\.") + "$)")
target = ARGV[0] || "."
puts "<html>"
puts " <head>"
puts " <title>Images</title>"
puts " <style>"
puts " * {margin:0;padding:5px;}"
puts " h4 { font-family: 'Georgia'; color: #fff; background-color: #000; }"
puts " </style>"
puts "</head>"
puts "<body>"
Dir.glob("#{target}/**/*") { |filename|
puts " <h4>#{filename}</h4>" if File.directory? filename
puts " <img src='#{filename}' alt='#{File.basename(filename)}' />" if pattern =~ filename
}
puts "</body>"
puts "</html>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment