mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
improve file type message, fix missing directory for drag-n-drop
This commit is contained in:
parent
7dc4179bf8
commit
d2e2dd3482
2 changed files with 8 additions and 13 deletions
|
@ -39,16 +39,11 @@ end
|
|||
|
||||
def file_upload_response(error=nil)
|
||||
http_error_code = 406
|
||||
flash[:error] = error if error
|
||||
|
||||
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]) : ''
|
||||
redirect "/dashboard#{query_string}"
|
||||
end
|
||||
else
|
||||
halt http_error_code, error if error
|
||||
halt 200, 'File(s) successfully uploaded.'
|
||||
|
@ -67,12 +62,10 @@ post '/site_files/upload' do
|
|||
params[:files].each do |file|
|
||||
file[:filename] = "#{params[:dir]}/#{file[:filename]}" if params[:dir]
|
||||
if current_site.file_size_too_large? file[:tempfile].size
|
||||
file_upload_response "#{params[:dir]}/#{file[:filename]} is too large, upload cancelled."
|
||||
file_upload_response "#{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 only supported by supporter accounts.}
|
||||
# TODO: Better explanation and link.
|
||||
#<a href="/plan">supporter accounts</a>. <a href="/site_files/allowed_types">Why We Do This</a>}
|
||||
file_upload_response %{#{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
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
<form action="/site_files/upload" class="dropzone" id="uploads">
|
||||
<div class="dz-message" style="display: none"></div>
|
||||
<input name="csrf_token" type="hidden" value="<%= csrf_token %>">
|
||||
<input name="dir" type="hidden" value="<%= @dir %>">
|
||||
<div class="upload-Boundary <%= @file_list.length <= 5 ? 'with-instruction' : '' %>">
|
||||
<% @file_list.each do |file| %>
|
||||
<div class="file filehover">
|
||||
|
@ -240,7 +241,8 @@
|
|||
|
||||
this.on("error", function(file, errorMessage) {
|
||||
hideUploadProgress()
|
||||
alert('Failed: '+errorMessage)
|
||||
location.href = '/dashboard<%= @dir ? "?dir=#{@dir}" : "" %>'
|
||||
// alert('Failed: '+errorMessage)
|
||||
})
|
||||
|
||||
this.on("totaluploadprogress", function(progress, totalBytes, totalBytesSent) {
|
||||
|
|
Loading…
Add table
Reference in a new issue