Method: Milkode#view

Defined in:
lib/milkode/cdweb/lib/command.rb

#view(record, params, before) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/milkode/cdweb/lib/command.rb', line 16

def view(record, params, before)
  @setting = WebSetting.new
  @title = record.shortpath
  @path = record.shortpath

  q = params[:query] && Query.new(params[:query]) 

  if (Util::larger_than_oneline(record.content) and q and !q.keywords.empty?)
    grep = Grep.new(record.content)
    match_lines = grep.match_lines_and(q.keywords)
    @record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines).to_html
  else
    @record_content = CodeRayWrapper.new(record.content, record.shortpath).to_html
  end
  
  @elapsed = Time.now - before
  haml :view
end