-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
41 lines (32 loc) · 780 Bytes
/
app.rb
File metadata and controls
41 lines (32 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'rubygems'
require 'sinatra'
require 'open-uri'
require 'dir_list'
require 'mongo_list'
enable :sessions
MongoList.connect('localhost')
# Set utf-8 for outgoing
before do
headers "Content-Type" => "text/html; charset=utf-8"
end
# Helpers
helpers do
def site_title
'Mongo Browser using JQueryTree running on Sinatra'
end
end
get '/*' do
erb :index
end
post '/jqueryfiletree/content' do
path = URI::decode( params[:dir] ).strip
puts " Post request: #{path}"
path << settings.split_char unless path[-1, 1] == settings.split_char
@results = []
begin
@results = MongoList.list_dir(settings.split_char, path)
rescue MongoList::MongoListError => e
puts "Error: couldn't open folder: #{e}"
end
erb :jquerytree, :layout => false
end