4 enable :inline_templates
6 def uploaded_file(file)
7 "#{options.root}/files/#{file}"
11 content_type 'text/css', :charset => 'utf-8'
19 get '/ready/:name' do |name|
20 path = uploaded_file(name)
21 unless File.exists? path then
24 base = request.url.gsub(/\/ready\/[^\/]*$/, '')
25 @url = "#{base}/#{name}"
29 get '/:name' do |name|
30 path = uploaded_file(name)
31 unless File.exists? path then
39 tmpfile = params[:file][:tempfile]
40 name = params[:file][:filename]
42 if tmpfile.nil? || name.nil? then
43 @error = "No file selected"
46 FileUtils::cp(tmpfile.path, uploaded_file(name))
47 redirect "ready/#{name}"
56 %link{ :rel => 'stylesheet', :href => "#{request.script_name}/style.css", :type => 'text/css',
57 :media => "screen, projection" }
66 %form#upload{ :enctype => 'multipart/form-data',
67 :action => 'upload', :method => 'post' }
69 %input{ :type => 'file', :name => 'file' }
71 %input{ :type => 'submit', :value => 'Send file' }
76 %a{ :href => @url }= @url
82 background-color: $green
87 text-decoration: underline
93 border: black solid 1px