summaryrefslogtreecommitdiff
path: root/app/controllers/projects/blob_controller.rb
diff options
context:
space:
mode:
authorliyakun <liyakun127@gmail.com>2015-09-10 16:18:40 +0200
committerliyakun <liyakun127@gmail.com>2015-09-15 02:12:56 +0200
commite2ece2bc350bf881e9716e51c01a59eecac65fc9 (patch)
tree422d043e1cd6bc09c62fd726958384c320c483d8 /app/controllers/projects/blob_controller.rb
parent7abb744eb961d95ef9f34e8b64c47084d3f620b6 (diff)
downloadgitlab-ce-e2ece2bc350bf881e9716e51c01a59eecac65fc9.tar.gz
Add "Replace" and "Upload" features
Refactor upload and replace functionality Rename file and move CSS Fix typo Make dropzone a div Remove unnecessary file Change color of "upload existing one" Add missing changes
Diffstat (limited to 'app/controllers/projects/blob_controller.rb')
-rw-r--r--app/controllers/projects/blob_controller.rb28
1 files changed, 24 insertions, 4 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 100d3d3b317..8776721d243 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -26,10 +26,16 @@ class Projects::BlobController < Projects::ApplicationController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @file_path))
+ respond_to do |format|
+ format.html { redirect_to namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @file_path)) }
+ format.json { render json: { message: "success", filePath: namespace_project_blob_path(@project.namespace, @project, File.join(@target_branch, @file_path)) } }
+ end
else
flash[:alert] = result[:message]
- render :new
+ respond_to do |format|
+ format.html { render :new }
+ format.json { render json: { message: "failed", filePath: namespace_project_new_blob_path(@project.namespace, @project, @id) } }
+ end
end
end
@@ -45,10 +51,16 @@ class Projects::BlobController < Projects::ApplicationController
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
- redirect_to after_edit_path
+ respond_to do |format|
+ format.html { redirect_to after_edit_path }
+ format.json { render json: { message: "success", filePath: after_edit_path } }
+ end
else
flash[:alert] = result[:message]
- render :edit
+ respond_to do |format|
+ format.html { render :edit }
+ format.json { render json: { message: "failed", filePath: namespace_project_new_blob_path(@project.namespace, @project, @id) } }
+ end
end
end
@@ -146,11 +158,19 @@ class Projects::BlobController < Projects::ApplicationController
@file_path =
if action_name.to_s == 'create'
+ if params[:file].present?
+ params[:file_name] = params[:file].original_filename
+ end
File.join(@path, File.basename(params[:file_name]))
else
@path
end
+ if params[:file].present?
+ params[:content] = Base64.encode64(params[:file].read)
+ params[:encoding] = 'base64'
+ end
+
@commit_params = {
file_path: @file_path,
current_branch: @current_branch,