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:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r131:e25d802c4aec - - 2 files changed: 13 inserted, 5 deleted
@@ -12,13 +12,19 | |||
|
12 | 12 | end |
|
13 | 13 | |
|
14 | 14 | def view |
|
15 | - file_name = "#{RAILS_ROOT}/data/tasks/#{params[:file]}" | |
|
16 | - if !FileTest.exists?(file_name) | |
|
15 | + base_filename = File.basename("#{params[:file]}.#{params[:ext]}") | |
|
16 | + filename = "#{RAILS_ROOT}/data/tasks/#{base_filename}" | |
|
17 | + if !FileTest.exists?(filename) | |
|
17 | 18 | redirect_to :action => 'index' and return |
|
18 | 19 | end |
|
19 | - # ask Apache to send the file | |
|
20 | - response.headers['X-Sendfile'] = file_name | |
|
21 | - render :nothing => true | |
|
20 | + # ask Apache to send the file --- doesn't quite work... | |
|
21 | + #response.headers['Content-Type'] = "application/force-download" | |
|
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 | 28 | end |
|
23 | 29 | |
|
24 | 30 | protected |
@@ -20,6 +20,8 | |||
|
20 | 20 | # instead of a file named 'wsdl' |
|
21 | 21 | map.connect ':controller/service.wsdl', :action => 'wsdl' |
|
22 | 22 | |
|
23 | + map.connect 'tasks/view/:file.:ext', :controller => 'tasks', :action => 'view' | |
|
24 | + | |
|
23 | 25 | # Install the default route as the lowest priority. |
|
24 | 26 | map.connect ':controller/:action/:id.:format' |
|
25 | 27 | map.connect ':controller/:action/:id' |
You need to be logged in to leave comments.
Login now