fixes for file upload response

This commit is contained in:
Kyle Drake 2014-12-26 02:18:19 -06:00
parent f4c812d0df
commit badfc671d9
5 changed files with 19 additions and 15 deletions

View file

@ -1,15 +1,5 @@
get '/dashboard' do
require_login
if params[:dir] && params[:dir][0] != '/'
params[:dir] = '/'+params[:dir]
end
if !File.directory?(current_site.files_path(params[:dir]))
redirect '/dashboard'
end
@dir = params[:dir]
@file_list = current_site.file_list @dir
dashboard_init
erb :'dashboard'
end

View file

@ -43,6 +43,7 @@ def file_upload_response(error=nil)
if params[:from_button]
if error
@error = error
dashboard_init
halt 200, erb(:'dashboard')
else
query_string = params[:dir] ? "?"+Rack::Utils.build_query(dir: params[:dir]) : ''
@ -69,7 +70,7 @@ post '/site_files/upload' do
file_upload_response "#{params[:dir]}/#{file[:filename]} is too large, upload cancelled."
end
if !current_site.okay_to_upload? file
file_upload_response "#{params[:dir]}/#{file[:filename]}: file type (or content in file) is not allowed on this site, upload cancelled. You can upgrade your account to remove the file type restrictions."
file_upload_response %{#{params[:dir]}#{file[:filename]}: file type (or content in file) is only supported by <a href="/plan">supporter accounts</a>. <a href="/site_files/allowed_types">Why We Do This</a>}
end
end

View file

@ -14,6 +14,19 @@ def dashboard_if_signed_in
redirect '/dashboard' if signed_in?
end
def dashboard_init
if params[:dir] && params[:dir][0] != '/'
params[:dir] = '/'+params[:dir]
end
if !File.directory?(current_site.files_path(params[:dir]))
redirect '/dashboard'
end
@dir = params[:dir]
@file_list = current_site.file_list @dir
end
def require_login_ajax
halt 'You are not logged in!' unless signed_in?
halt 'You are banned.' if current_site.is_banned? || parent_site.is_banned?

View file

@ -58,7 +58,7 @@
<% if @error %>
<div class="alert alert-block alert-error">
<p><%= @error %></p>
<p><%== @error %></p>
</div>
<% end %>

View file

@ -37,9 +37,9 @@
<h2>Is there a way to remove the whitelist?</h2>
<p>
<strong>Yes!</strong> If you <a href="/plan">become a supporter</a> at the <strong>Cat Bus</strong> or higher level, we will remove the whitelist for your file uploads, and you can upload anything you want (except illegal/copyrighted content, of course)! Becoming a supporter reduces the "file dump" risk, which makes it a lot safer for us to allow file uploads of any kind.
<strong>Yes!</strong> If you <a href="/plan">become a supporter</a>, we will remove the whitelist for your file uploads, and you can upload anything you want (except illegal/copyrighted content, of course)! Becoming a supporter reduces the "file dump" risk, which makes it a lot safer for us to allow file uploads of any kind.
</p>
<p>
Keep in mind that it's still better to host things like videos on Youtube. They've spent a lot of time and invested a lot of money into building a platform for sharing high-bandwidth video very efficiently all over the world, which is not something we have the capital to perfect. And they don't charge you for bandwith, even if your video becomes very popular (infact, you can make money by sharing their advertising revenue with them).
Keep in mind that it's still better to host things like videos on Youtube. They've spent a lot of time and invested a lot of money into building a platform for sharing high-bandwidth video very efficiently all over the world. And they don't charge you for bandwith, even if your video becomes very popular (infact, you can make money by sharing their advertising revenue with them).
</p>
</div>