Merge branch 'master' of github.com:warpc/rosa-build
This commit is contained in:
commit
c47f8ae495
|
@ -5,6 +5,16 @@ class Git::BlobsController < Git::BaseController
|
|||
|
||||
def show
|
||||
@blob = @tree / @path
|
||||
|
||||
if params[:raw]
|
||||
image_url = Rails.root.to_s + "/" + @path
|
||||
|
||||
response.headers['Cache-Control'] = "public, max-age=#{12.hours.to_i}"
|
||||
response.headers['Content-Type'] = @blob.mime_type
|
||||
response.headers['Content-Disposition'] = 'inline'
|
||||
|
||||
render(:text => open(image_url).read) and return
|
||||
end
|
||||
end
|
||||
|
||||
def blame
|
||||
|
@ -42,4 +52,4 @@ class Git::BlobsController < Git::BaseController
|
|||
@commit = @git_repository.log(@treeish, @path).first # TODO WTF nil ?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,4 +40,9 @@ module GitHelper
|
|||
blob.data.split("\n").collect{|line| "<div>#{line.present? ? h(line) : "<br>"}</div>"}.join
|
||||
end
|
||||
|
||||
end
|
||||
def choose_render_way(blob)
|
||||
return :image if blob.mime_type.match(/image/)
|
||||
return :text if blob.mime_type.match(/text|xml|json/)
|
||||
:binary
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
.content
|
||||
.inner
|
||||
%h3= render_path
|
||||
%h3= @blob.mime_type
|
||||
|
||||
.blob_header
|
||||
.size #{(@blob.size / 1024.0).round(3)} Kb
|
||||
|
@ -22,13 +23,33 @@
|
|||
- else
|
||||
#{link_to "Raw", raw_path(@project, @treeish, @path)} #{link_to "Blame", blame_path(@project, @treeish, @path)} #{link_to "History", commits_path(@project, @treeish, @path)}
|
||||
.clear
|
||||
%table.table.blob
|
||||
%tr
|
||||
%td.lines
|
||||
:plain
|
||||
<pre>#{render_line_numbers(@blob.data.split("\n").length)}</pre>
|
||||
%td.blob
|
||||
:plain
|
||||
<pre>#{render_blob(@blob)}</pre>
|
||||
- case choose_render_way(@blob)
|
||||
- when :image
|
||||
%table.table.blob
|
||||
%tr
|
||||
%td.lines
|
||||
%td.blob
|
||||
:plain
|
||||
<br/>
|
||||
<center> <img src='?raw=true'/></center>
|
||||
<br/>
|
||||
- when :text
|
||||
%table.table.blob
|
||||
%tr
|
||||
%td.lines
|
||||
:plain
|
||||
<pre>#{render_line_numbers(@blob.data.split("\n").length)}</pre>
|
||||
%td.blob
|
||||
:plain
|
||||
<pre>#{render_blob(@blob)}</pre>
|
||||
- when :binary
|
||||
%table.table.blob
|
||||
%tr
|
||||
%td.lines
|
||||
%td.blob
|
||||
:plain
|
||||
<br/>
|
||||
<pre>#{ link_to @blob.basename, raw_path(@project, @treeish, @path) }</pre>
|
||||
<br/>
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
||||
|
|
Loading…
Reference in New Issue