mirror of
https://github.com/neocities/neocities.git
synced 2025-08-05 09:11:28 +02:00
finishing up drag-n-drop code, use param for filename with site_file/text_editor
This commit is contained in:
parent
943271b509
commit
f6af2cbbcf
7 changed files with 196 additions and 399 deletions
|
@ -102,12 +102,12 @@ post '/api/upload' do
|
|||
end
|
||||
|
||||
if current_site.too_many_files?(files.length)
|
||||
api_error 400, 'too_many_files', "cannot exceed the maximum site files limit (#{current_site.plan_feature(:maximum_site_files)}), #{current_site.supporter? ? 'please contact support' : 'please upgrade to a supporter account'}"
|
||||
api_error 400, 'too_many_files', "cannot exceed the maximum site files limit (#{current_site.plan_feature(:maximum_site_files)})"
|
||||
end
|
||||
|
||||
files.each do |file|
|
||||
if !current_site.okay_to_upload?(file)
|
||||
api_error 400, 'invalid_file_type', "#{file[:filename]} is not a valid file type (or contains not allowed content) for this site, please upgrade to a supporter account to upload this file type"
|
||||
api_error 400, 'invalid_file_type', "#{file[:filename]} is not a allowed file type for free sites, supporter required"
|
||||
end
|
||||
|
||||
if File.directory? file[:filename]
|
||||
|
|
|
@ -8,7 +8,7 @@ get '/dashboard' do
|
|||
current_site.save_changes validate: false
|
||||
end
|
||||
|
||||
erb :'dashboard'
|
||||
erb :'dashboard/index'
|
||||
end
|
||||
|
||||
def dashboard_init
|
||||
|
@ -30,3 +30,11 @@ def dashboard_init
|
|||
@dir = params[:dir]
|
||||
@file_list = current_site.file_list @dir
|
||||
end
|
||||
|
||||
get '/dashboard/files' do
|
||||
require_login
|
||||
dashboard_init
|
||||
dont_browser_cache
|
||||
|
||||
erb :'dashboard/files', layout: false
|
||||
end
|
|
@ -177,7 +177,16 @@ get %r{\/site_files\/text_editor\/(.+)} do
|
|||
dont_browser_cache
|
||||
|
||||
@filename = params[:captures].first
|
||||
redirect '/site_files/text_editor?filename=' + Rack::Utils.escape(@filename)
|
||||
end
|
||||
|
||||
get '/site_files/text_editor' do
|
||||
require_login
|
||||
dont_browser_cache
|
||||
|
||||
@filename = params[:filename]
|
||||
extname = File.extname @filename
|
||||
|
||||
@ace_mode = case extname
|
||||
when /htm|html/ then 'html'
|
||||
when /js/ then 'javascript'
|
||||
|
@ -217,4 +226,4 @@ end
|
|||
get '/site_files/mount_info' do
|
||||
@title = 'Site Mount Information'
|
||||
erb :'site_files/mount_info'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue