2012-09-17 13:49:57 -04:00
|
|
|
# Controller for viewing a file's blame
|
2013-06-23 12:47:22 -04:00
|
|
|
class Projects::BlobController < Projects::ApplicationController
|
2012-09-20 13:55:14 -04:00
|
|
|
include ExtractsPath
|
2012-09-17 13:49:57 -04:00
|
|
|
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
|
|
|
before_filter :authorize_code_access!
|
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
2013-11-19 09:14:48 -05:00
|
|
|
before_filter :blob
|
|
|
|
|
2012-09-17 13:49:57 -04:00
|
|
|
def show
|
2013-11-19 09:14:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2014-01-16 12:03:42 -05:00
|
|
|
result = Files::DeleteService.new(@project, current_user, params, @ref, @path).execute
|
2013-11-19 09:14:48 -05:00
|
|
|
|
|
|
|
if result[:status] == :success
|
2013-12-16 03:57:50 -05:00
|
|
|
flash[:notice] = "Your changes have been successfully committed"
|
2013-11-19 09:14:48 -05:00
|
|
|
redirect_to project_tree_path(@project, @ref)
|
|
|
|
else
|
|
|
|
flash[:alert] = result[:error]
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def blob
|
|
|
|
@blob ||= @repository.blob_at(@commit.id, @path)
|
|
|
|
|
|
|
|
return not_found! unless @blob
|
2013-10-01 11:26:55 -04:00
|
|
|
|
2013-11-19 09:14:48 -05:00
|
|
|
@blob
|
2012-09-17 13:49:57 -04:00
|
|
|
end
|
|
|
|
end
|