diff options
author | Johan Sørensen <johan@johansorensen.com> | 2008-03-17 14:10:16 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2008-03-17 14:14:13 +0100 |
commit | cb2612bf2fdafbb6016ea6402e3d1b86748a2603 (patch) | |
tree | 4027952e3ea0a517a94e0d2d1a6171c8c097a52a /app/controllers/blobs_controller.rb | |
parent | 1fe38d36cf3557a732f244c257d38d1efc44763a (diff) | |
download | gitorious-mainline-outdated-cb2612bf2fdafbb6016ea6402e3d1b86748a2603.zip gitorious-mainline-outdated-cb2612bf2fdafbb6016ea6402e3d1b86748a2603.tar.gz gitorious-mainline-outdated-cb2612bf2fdafbb6016ea6402e3d1b86748a2603.tar.bz2 |
Refactored BrowseController into several specific controllers
Grouped by responsibility Trees, Blobs, Commits and Logs
Diffstat (limited to 'app/controllers/blobs_controller.rb')
-rw-r--r-- | app/controllers/blobs_controller.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/controllers/blobs_controller.rb b/app/controllers/blobs_controller.rb new file mode 100644 index 0000000..c417adf --- /dev/null +++ b/app/controllers/blobs_controller.rb @@ -0,0 +1,38 @@ +class BlobsController < ApplicationController + before_filter :find_project_and_repository + before_filter :check_repository_for_commits + + + def show + @git = @repository.git + @commit = @git.commit(params[:id]) + unless @commit + redirect_to project_repository_blob_path(@project, @repository, "HEAD", params[:path]) + return + end + @blob = @git.tree(@commit.tree.id, ["#{params[:path].join("/")}"]).contents.first + render_not_found and return unless @blob + unless @blob.respond_to?(:data) # it's a tree + redirect_to project_repository_tree_path(@project, @repository, @commit.id, params[:path]) + end + end + + def raw + @git = @repository.git + @commit = @git.commit(params[:id]) + unless @commit + redirect_to project_repository_raw_blob_path(@project, @repository, "HEAD", params[:path]) + return + end + @blob = @git.tree(@commit.tree.id, ["#{params[:path].join("/")}"]).contents.first + render_not_found and return unless @blob + if @blob.size > 500.kilobytes + flash[:error] = "Blob is too big. Clone the repository locally to see it" + redirect_to project_repository_path(@project, @repository) and return + end + render :text => @blob.data, :content_type => @blob.mime_type + end + + # def text + # end +end |