18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/milkode/cdweb/lib/command.rb', line 18
def view(record, params, before)
@setting = WebSetting.new
@title = record.shortpath
@path = record.shortpath
is_sensitive = params[:sensitive] == 'on'
q = params[:query] && Query.new(params[:query])
if (Util::larger_than_oneline(record.content) && q && !q.keywords.empty?)
if Util::gotoline_keyword?(q.keywords[0])
gotolines = Util::parse_gotoline(q.keywords)
match_lines = []
gotolines.each do |v|
if v[0][0][1..-1] == record.shortpath
match_lines << Grep::MatchLineResult.new(v[1] - 1, nil)
end
end
@record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines, q.keywords).to_html
else
grep = Grep.new(record.content)
match_lines = grep.match_lines_and(q.keywords, is_sensitive, q.wide_match_range)
if match_lines.empty? && q.wide_match_range_empty?
match_lines = grep.match_lines_and(q.keywords, is_sensitive, 7)
end
@record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines, q.keywords).to_html
end
else
@record_content = CodeRayWrapper.new(record.content, record.shortpath).to_html
end
Database.instance.touch_viewtime(@path)
@elapsed = Time.now - before
haml :view
end
|