WebEditor: sceleton

This commit is contained in:
Valeriy Sizov 2012-10-12 00:15:24 +03:00
parent 02c83f122a
commit e53b47b447
3 changed files with 30 additions and 2 deletions

View file

@ -26,5 +26,13 @@ class TreeController < ProjectResourceController
def update def update
last_commit = @project.commits(@ref, @path, 1).first.sha last_commit = @project.commits(@ref, @path, 1).first.sha
file_editor = Gitlab::FileEditor.new(current_user, @project)
if file_editor.can_edit?(@path, last_commit)
file_editor.update(@path, params[:content])
redirect_to project_tree_path(@project, @id), :notice => "File has been successfully changed"
else
flash[:notice] = "You can't save file because it has been changed"
render :edit
end
end end
end end

View file

@ -8,9 +8,9 @@
#editor= @tree.data #editor= @tree.data
.editor-commit-comment .editor-commit-comment
= label_tag 'text-commit' do = label_tag 'commit_message' do
%p.slead Commit message %p.slead Commit message
= text_area_tag 'text_commit' = text_area_tag 'commit_message'
.form-actions .form-actions
= hidden_field_tag 'last_commit', @last_commit = hidden_field_tag 'last_commit', @last_commit
= hidden_field_tag 'content' = hidden_field_tag 'content'

20
lib/gitlab/file_editor.rb Normal file
View file

@ -0,0 +1,20 @@
module Gitlab
class FileEditor
attr_accessor :user, :project
def initialize(user, project)
self.user = user
self.project = project
end
def can_edit?(path, last_commit)
true
end
def update(path, content)
true
end
end
end