Class: FilesystemExplorer::ApplicationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/filesystem_explorer/application_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#routeObject (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_pathObject



23
# File 'app/controllers/filesystem_explorer/application_controller.rb', line 23

def current_filesystem_explorer_path ; return @path ; end

#downloadObject



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)
  options = as.nil? ? route : get_engine_configuration_options_by_as(as)

  return @filesystem_explorer_root_name ||= options.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)
  options = as.nil? ? route : get_engine_configuration_options_by_as(as)

  return @filesystem_explorer_root_path ||= Rails.application.routes.url_helpers.send("#{options.as}_path")
end

#indexObject



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