Webs that Don't Allow File Uploads
... should still allow you to manually upload files and have them render. Fixed.
This commit is contained in:
parent
5d15e3f39d
commit
34fd7b425f
|
@ -7,12 +7,13 @@ class FileController < ApplicationController
|
|||
|
||||
layout 'default'
|
||||
|
||||
before_filter :dnsbl_check, :check_allow_uploads
|
||||
before_filter :dnsbl_check
|
||||
before_filter :check_allow_uploads, :except => :file
|
||||
|
||||
def file
|
||||
@file_name = params['id']
|
||||
if params['file']
|
||||
return unless is_post
|
||||
return unless is_post and check_allow_uploads
|
||||
# form supplied
|
||||
new_file = @web.wiki_files.create(params['file'])
|
||||
if new_file.valid?
|
||||
|
@ -25,10 +26,11 @@ class FileController < ApplicationController
|
|||
end
|
||||
else
|
||||
# no form supplied, this is a request to download the file
|
||||
file = WikiFile.find_by_file_name(@file_name)
|
||||
if file
|
||||
send_data(file.content, determine_file_options_for(@file_name, :filename => @file_name))
|
||||
file = @web.files_path + '/' + @file_name
|
||||
if File.exists?(file)
|
||||
send_file(file)
|
||||
else
|
||||
return unless check_allow_uploads
|
||||
@file = WikiFile.new(:file_name => @file_name)
|
||||
render
|
||||
end
|
||||
|
|
|
@ -117,6 +117,14 @@ class Web < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def files_path
|
||||
if default_web?
|
||||
"#{RAILS_ROOT}/webs/files"
|
||||
else
|
||||
"#{RAILS_ROOT}/webs/#{self.address}/files"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns an array of all the wiki words in any current revision
|
||||
|
@ -150,12 +158,4 @@ class Web < ActiveRecord::Base
|
|||
def default_web?
|
||||
defined? DEFAULT_WEB and self.address == DEFAULT_WEB
|
||||
end
|
||||
|
||||
def files_path
|
||||
if default_web?
|
||||
"#{RAILS_ROOT}/webs/files"
|
||||
else
|
||||
"#{RAILS_ROOT}/webs/#{self.address}/files"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue