Skip to content

Instantly share code, notes, and snippets.

@miketierney
Created May 15, 2009 02:05
Show Gist options
  • Save miketierney/112022 to your computer and use it in GitHub Desktop.
Save miketierney/112022 to your computer and use it in GitHub Desktop.
def list_directories path, response
dir_list = Dir.new(path).entries.reject{ |f| f =~ /^\./ }
response.body = "<html><head></head><body><ul style=\"list-style-type:none;margin:0;padding:0;\">"
dir_list.each do |d|
response.body += "<li>"
response.body += File.directory?(d) ? "<strong>#{d}/</strong>" : "#{d}"
response.body += "</li>"
end
response.body += "</ul></body></html>"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment