Class: SourceBrowser::SourceController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
# File 'app/controllers/source_browser/source_controller.rb', line 5

def index
  @files = git.ls_files
end

#showObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/source_browser/source_controller.rb', line 9

def show
  @path = params[:id]
  @object = git.object(@path)
  @files = git.ls_files

  @formatter = Rouge::Formatters::HTML.new
  @formatter = Rouge::Formatters::HTMLLineTable.new(@formatter, line_id: "L%i", line_format: "<a href='?line=%i'>%i</a>")
  @lexer = Rouge::Lexer.guess(filename: @path, source: @object.contents)
  @source = @formatter.format(@lexer.lex(@object.contents))
end