file-manager/config/routes.rb

54 lines
1.9 KiB
Ruby
Raw Normal View History

2024-05-12 06:22:01 +00:00
Rails.application.routes.draw do
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
count = FileManagerRoot.count
if count == 0
root = FileManagerRoot.create
else
if count > 1
FileManagerRoot.all[1..-1].each{|f| f.destroy}
end
root = FileManagerRoot.first
end
FileManagerUpload.create_indexes
FileManagerTrash.create_indexes
setting = root.file_manager_settings.first
if setting.nil?
setting = root.file_manager_settings.create
end
Thread.new do
setting.create_records
end
end
locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
resources :file_managers do
collection do
get :settings
patch :update_settings
end
member do
get :module
put :rename
post :recover
post :save
post :recover_all
post :clean_trashes
post :get_trash_count
post :upload_file
end
end
end
get '/xhr/file_manager_download', to: 'file_managers#download'
get '/xhr/file_manager', to: 'file_managers#index_backend'
post '/xhr/file_manager_upload', to: 'file_managers#upload_index'
post "/xhr/file_manager_create_folder/(:path)", to: 'file_managers#create_folder', constraints: { path: /.*/ }
post "/xhr/file_manager_save/(:path)", to: 'file_managers#save', constraints: { path: /.*/ }
get '/xhr/file_manager/:path', to: 'file_managers#path', constraints: { path: /.+/ }
put '/xhr/file_manager/(:path)', to: 'file_managers#rename', constraints: { path: /.+/ }
post '/xhr/file_manager_upload/:path', to: 'file_managers#upload', constraints: { path: /.+/ }
delete '/xhr/file_manager/(:path)', to: 'file_managers#delete', constraints: { path: /.+/ }
end
end