EOS
end
def footer_home(package, files)
<
EOS
end
def result_record(record, patterns, nth=1)
if (patterns.size > 0)
<
#{record.shortpath}
#{result_record_match_line(record, patterns, nth)}
EOS
else
<#{record.shortpath}
EOS
end
end
def result_record_match_line(record, patterns, nth)
str = ""
grep = Grep.new(record.content)
lines = grep.match_lines_or(patterns)
unless (lines.empty?)
index = lines[0].index
(index - nth..index + nth).each do |i|
if (0 <= i && i < grep.content.size)
match_datas = (i == index) ? lines[0].match_datas : []
str << line(i + 1, grep.content[i], match_datas) + "\n"
end
end
end
str
end
def record_content(record)
<
#{record_content_line(record)}
EOS
end
def record_content_line(record)
str = ""
grep = Grep.new(record.content)
grep.content.each_with_index do |l, index|
str << line(index + 1, l, []) + "\n"
end
str
end
def line(lineno, line, match_datas)
sprintf("%5d: %s", lineno, match_strong(Rack::Utils::escape_html(line), match_datas))
end
def match_strong(line, match_datas)
match_datas.each do |m|
line = line.split(m[0]).join('' + m[0] + '') unless (m.nil?)
end
line
end
def pagination_link(page, label)
href = "?page=#{page}"
pagination_span("#{label}")
end
def pagination_span(content)
"\n"
end
def empty_summary()
<
gren web検索
EOS
end
def search_summary(keyword, total_records, range, elapsed)
<