Skip to content
Snippets Groups Projects
Commit 3f35cccf authored by gitlabhq's avatar gitlabhq
Browse files

ref controller refactored

parent 4bf4efe7
No related branches found
No related tags found
No related merge requests found
class RefsController < ApplicationController
before_filter :project
before_filter :ref
before_filter :define_tree_vars, :only => [:tree, :blob]
layout "project"
 
# Authorize
Loading
Loading
@@ -22,12 +23,6 @@ class RefsController < ApplicationController
# Repository preview
#
def tree
@repo = project.repo
@commit = @repo.commits(@ref).first
@tree = Tree.new(@commit.tree, project, @ref, params[:path])
@tree = TreeDecorator.new(@tree)
respond_to do |format|
format.html
format.js do
Loading
Loading
@@ -40,11 +35,7 @@ class RefsController < ApplicationController
end
 
def blob
@repo = project.repo
@commit = project.commit(@ref)
@tree = project.tree(@commit, params[:path])
if @tree.is_a?(Grit::Blob)
if @tree.is_blob?
send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name)
else
head(404)
Loading
Loading
@@ -55,6 +46,13 @@ class RefsController < ApplicationController
 
protected
 
def define_tree_vars
@repo = project.repo
@commit = project.commit(@ref)
@tree = Tree.new(@commit.tree, project, @ref, params[:path])
@tree = TreeDecorator.new(@tree)
end
def ref
@ref = params[:id]
end
Loading
Loading
Loading
Loading
@@ -5,6 +5,7 @@ class Tree
:basename,
:name,
:data,
:mime_type,
:text?,
:colorize,
:to => :tree
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment