Class: FilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/files_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#initialize, #load_project

Constructor Details

This class inherits a constructor from ApplicationController

Instance Method Details

#listObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/files_controller.rb', line 5

def list
  load_project
  
  root = @project.checkout_dir
  relative_path = @params['path']
  absolute_path = relative_path ? "#{root}/#{relative_path}" : root
  if(File.file?(absolute_path))
    # TODO: use http://rubyforge.org/projects/syntax/
    # TODO: the file contents should be rendered within the regular layout
    render_text(File.open(absolute_path).read)
  else
    @relative_paths = Dir["#{absolute_path}/*"].collect {|f| f[root.length+1..-1]}
  end
end