From f6a8e6944984eabb21a3ce9c15d1f14eb87ee06d Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Mon, 8 Oct 2012 18:43:54 +0300 Subject: [PATCH] WebEditor: base form --- app/controllers/tree_controller.rb | 8 ++++++++ app/views/tree/_tree_file.html.haml | 1 + app/views/tree/edit.html.haml | 10 ++++++++++ config/routes.rb | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/views/tree/edit.html.haml diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index 2270eede..6224ed06 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -19,4 +19,12 @@ class TreeController < ProjectResourceController format.js { no_cache_headers } end end + + def edit + @last_commit = @project.commits(@ref, @path, 1).first.sha + end + + def update + last_commit = @project.commits(@ref, @path, 1).first.sha + end end diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index 82aaed24..bae43087 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -8,6 +8,7 @@ = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, @id), class: "btn very_small" = link_to "blame", project_blame_path(@project, @id), class: "btn very_small" + = link_to "Edit", edit_project_tree_path(@project, @id), class: "btn very_small" - if tree_file.text? - if gitlab_markdown?(tree_file.name) .file_content.wiki diff --git a/app/views/tree/edit.html.haml b/app/views/tree/edit.html.haml new file mode 100644 index 00000000..d4571f76 --- /dev/null +++ b/app/views/tree/edit.html.haml @@ -0,0 +1,10 @@ +.file_holder + Edit file: + %span.file_name + = @tree.path.force_encoding('utf-8') + %br + = form_tag(project_tree_path(@project, @id), :method => :put) do + %textarea + = @tree.data + = hidden_field_tag 'last_commit', @last_commit + = submit_tag "Save" diff --git a/config/routes.rb b/config/routes.rb index 54b298c9..de5261d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -183,7 +183,7 @@ Gitlab::Application.routes.draw do resources :compare, only: [:index, :create] resources :blame, only: [:show], constraints: {id: /.+/} resources :blob, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show, :edit, :update], constraints: {id: /.+/} match "/compare/:from...:to" => "compare#show", as: "compare", :via => [:get, :post], constraints: {from: /.+/, to: /.+/}