Merge branch 'master' into simplify_controllers2

Conflicts:
	app/controllers/commits_controller.rb
	app/controllers/refs_controller.rb
This commit is contained in:
Cyril 2012-09-27 12:25:52 +02:00
commit e563e948bb
108 changed files with 1762 additions and 652 deletions

View file

@ -1,5 +1,3 @@
require 'github/markup'
class RefsController < ProjectController
include Gitlab::Encode
@ -9,21 +7,20 @@ class RefsController < ProjectController
before_filter :require_non_empty_project
before_filter :ref
before_filter :define_tree_vars, only: [:tree, :blob, :blame, :logs_tree]
before_filter :render_full_content
before_filter :define_tree_vars, only: [:blob, :logs_tree]
def switch
respond_to do |format|
format.html do
new_path = if params[:destination] == "tree"
tree_project_ref_path(@project, params[:ref])
project_tree_path(@project, @ref)
else
project_commits_path(@project, ref: params[:ref])
project_commits_path(@project, @ref)
end
redirect_to new_path
redirect_to new_path
end
format.js do
format.js do
@ref = params[:ref]
define_tree_vars
render "tree"
@ -31,19 +28,6 @@ class RefsController < ProjectController
end
end
#
# Repository preview
#
def tree
respond_to do |format|
format.html
format.js do
# disable cache to allow back button works
no_cache_headers
end
end
end
def logs_tree
contents = @tree.contents
@logs = contents.map do |content|
@ -51,36 +35,12 @@ class RefsController < ProjectController
last_commit = @project.commits(@commit.id, file, 1).last
last_commit = CommitDecorator.decorate(last_commit)
{
file_name: content.name,
file_name: content.name,
commit: last_commit
}
end
end
def blob
if @tree.is_blob?
if @tree.text?
encoding = detect_encoding(@tree.data)
mime_type = encoding ? "text/plain; charset=#{encoding}" : "text/plain"
else
mime_type = @tree.mime_type
end
send_data(
@tree.data,
type: mime_type,
disposition: 'inline',
filename: @tree.name
)
else
head(404)
end
end
def blame
@blame = Grit::Blob.blame(@repo, @commit.id, params[:path])
end
protected
def define_tree_vars
@ -91,20 +51,20 @@ class RefsController < ProjectController
@commit = CommitDecorator.decorate(@commit)
@tree = Tree.new(@commit.tree, project, @ref, params[:path])
@tree = TreeDecorator.new(@tree)
@hex_path = Digest::SHA1.hexdigest(params[:path] || "/")
@hex_path = Digest::SHA1.hexdigest(params[:path] || "")
if params[:path]
@history_path = tree_file_project_ref_path(@project, @ref, params[:path])
@logs_path = logs_file_project_ref_path(@project, @ref, params[:path])
@history_path = project_tree_path(@project, File.join(@ref, params[:path]))
@logs_path = logs_file_project_ref_path(@project, @ref, params[:path])
else
@history_path = tree_project_ref_path(@project, @ref)
@logs_path = logs_tree_project_ref_path(@project, @ref)
@history_path = project_tree_path(@project, @ref)
@logs_path = logs_tree_project_ref_path(@project, @ref)
end
rescue
return render_404
end
def ref
@ref = params[:id]
@ref = params[:id] || params[:ref]
end
end