Skip to content

Instantly share code, notes, and snippets.

@navinpai
Created December 26, 2011 19:20
Show Gist options
  • Save navinpai/1521963 to your computer and use it in GitHub Desktop.
Save navinpai/1521963 to your computer and use it in GitHub Desktop.
Sinatra :: Get Dropbox public folder contents as JSON file
#Basically the heart of the Publicbox (https://github.com/hmans/publicbox) code
# See whole file at: https://github.com/hmans/publicbox/blob/master/config.ru
get '/*' do |path|
doc = Nokogiri::HTML(open("https://www.dropbox.com/#{path}").read)
files = []
doc.css('#list-view div.filerow').each do |row|
files << {
filename: row.css('div.filename a').first.content.strip,
size: row.css('div.filesize span.hidden').first.content.to_i,
modified: row.css('div.modified span.hidden').first.content.to_i,
url: row.css('div.filename a').first['href']
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment