Class: FilesystemExplorer::ApplicationController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- FilesystemExplorer::ApplicationController
- Defined in:
- app/controllers/filesystem_explorer/application_controller.rb
Instance Attribute Summary collapse
-
#route ⇒ Object
readonly
Returns the value of attribute route.
Instance Method Summary collapse
- #current_filesystem_explorer_path ⇒ Object
- #download ⇒ Object
- #filesystem_explorer_root_name(as = nil) ⇒ Object
- #filesystem_explorer_root_path(as = nil) ⇒ Object
- #index ⇒ Object
Instance Attribute Details
#route ⇒ Object (readonly)
Returns the value of attribute route.
5 6 7 |
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 5 def route @route end |
Instance Method Details
#current_filesystem_explorer_path ⇒ Object
23 |
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 23 def current_filesystem_explorer_path ; return @path ; end |
#download ⇒ Object
18 19 20 21 |
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 18 def download @path = FilesystemExplorer::FilesystemItem.new(File.join('/', %Q[#{params[:path]}#{".#{params[:format]}" if params[:format]}]), root: route.path) send_file @path.full_path, disposition: :attachment, x_sendfile: true end |
#filesystem_explorer_root_name(as = nil) ⇒ Object
31 32 33 34 35 |
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 31 def filesystem_explorer_root_name(as = nil) = as.nil? ? route : (as) return @filesystem_explorer_root_name ||= .as.to_s.humanize end |
#filesystem_explorer_root_path(as = nil) ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 25 def filesystem_explorer_root_path(as = nil) = as.nil? ? route : (as) return @filesystem_explorer_root_path ||= Rails.application.routes.url_helpers.send("#{.as}_path") end |
#index ⇒ Object
11 12 13 14 15 16 |
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 11 def index @path = FilesystemExplorer::FilesystemItem.new(route.path, %Q[#{params[:path]}#{".#{params[:format]}" if params[:format]}]) @path.parent.instance_exec { @is_parent = true } if @path.parent render @path.exists? ? :index : :not_found end |