Description:
[web] fixed tasks viewing, changed routes for it git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@261 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r131:e25d802c4aec - - 2 files changed: 13 inserted, 5 deleted

@@ -12,13 +12,19
12 end
12 end
13
13
14 def view
14 def view
15 - file_name = "#{RAILS_ROOT}/data/tasks/#{params[:file]}"
15 + base_filename = File.basename("#{params[:file]}.#{params[:ext]}")
16 - if !FileTest.exists?(file_name)
16 + filename = "#{RAILS_ROOT}/data/tasks/#{base_filename}"
17 + if !FileTest.exists?(filename)
17 redirect_to :action => 'index' and return
18 redirect_to :action => 'index' and return
18 end
19 end
19 - # ask Apache to send the file
20 + # ask Apache to send the file --- doesn't quite work...
20 - response.headers['X-Sendfile'] = file_name
21 + #response.headers['Content-Type'] = "application/force-download"
21 - render :nothing => true
22 + #response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\""
23 + #response.headers['Content-length'] = File.size(filename)
24 + #response.headers['X-Sendfile'] = filename
25 + #render :nothing => true
26 +
27 + send_file filename, :stream => false, :filename => base_filename
22 end
28 end
23
29
24 protected
30 protected
@@ -20,6 +20,8
20 # instead of a file named 'wsdl'
20 # instead of a file named 'wsdl'
21 map.connect ':controller/service.wsdl', :action => 'wsdl'
21 map.connect ':controller/service.wsdl', :action => 'wsdl'
22
22
23 + map.connect 'tasks/view/:file.:ext', :controller => 'tasks', :action => 'view'
24 +
23 # Install the default route as the lowest priority.
25 # Install the default route as the lowest priority.
24 map.connect ':controller/:action/:id.:format'
26 map.connect ':controller/:action/:id.:format'
25 map.connect ':controller/:action/:id'
27 map.connect ':controller/:action/:id'
You need to be logged in to leave comments. Login now