16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/helpers/webgit/application_helper.rb', line 16
def preview(blob, format)
f = format_to_sym(format)
case f
when :html, :htm then
"<div>#{blob.content}</div>"
when :ruby, :java, :js, :python, :scss, :php, :lua, :html, :json, :go, :sql, :yaml, :text, :coffee then
CodeRay.scan(blob.content.force_encoding('UTF-8'), f).div(:line_numbers => :table, :css => :class)
when :png, :jpg, :gif then
"<img src=\"#{preview_path(params[:branch], params[:path])}.#{params[:format]}\" />"
when '.pdf' then
"<iframe src=\"#{preview_path(params[:branch], params[:path])}.#{params[:format]}\" width='860' height='800' border='0' style='border:none'></iframe>"
else
"Binary File [#{params[:path]}]"
end
end
|