版本库编辑

This commit is contained in:
daiao 2017-11-08 18:00:46 +08:00
parent 14fd5eb113
commit f607f72ce4
5 changed files with 40 additions and 0 deletions

View File

@ -600,6 +600,31 @@ update
end
end
def entry_edit
@content = @repository.cat(@path, @rev)
# @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev))
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
# 总的提交数
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
if is_entry_text_data?(@content, @path)
render :layout => 'base_projects'
end
end
def entry_update
g = Gitlab.client
@path = params[:path]
@rev = params[:rev]
@content = params[:content]
code_file = g.edit_file(@project.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "...")
# if @shixun.try(:status).to_i < 2
# shixun_modify_status_without_publish(@shixun, 1)
# end
respond_to do |format|
format.js
end
end
def entry_and_raw(is_raw)
@entry = @repository.entry(@path, @rev)
(show_error_not_found; return) unless @entry

View File

@ -0,0 +1,5 @@
<form action="<%= entry_update_shixun_path(@project, :rev => @rev, :path => @path) %>" method="post" id="shixun_entry_update_id" data-remote="true">
<li class="clearfix" xmlns="http://www.w3.org/1999/html" id="edit_code_contents">
<textarea class="undis" id="content_shixun_entry" name="content"><%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %></textarea>
</li>
</form>

View File

@ -22,4 +22,10 @@
:path => to_path_param(@path),
:rev => @rev}, :class => "fr mr5") if @repository.supports_cat? %>
<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
<% if params[:action] == "entry_edit" %>
<a href="javascript:void(0);" onclick="$('#shixun_entry_update_id').submit();" class = "fl mr5">保存</a>
<% elsif params[:action] == "entry" || params[:action] == "entry_update" %>
<%= link_to "编辑", entry_edit_repository_path(@project, :path => @path, :rev => @rev), :class => "fl mr5", :remote => true %>
<% end %>
<% end %>

View File

@ -0,0 +1,2 @@
$("#common_file_content").html('<%= escape_javascript(render :partial => 'repositories/entry_content') %>');
$("#file_action").html('<%= escape_javascript(render :partial => 'repositories/link_to_functions') %>');

View File

@ -0,0 +1,2 @@
$("#common_file_content").html('<%= escape_javascript(render :partial => 'common/file', :locals => {:filename => @path, :content => @content}) %>')
$("#file_action").html('<%= escape_javascript(render :partial => 'repositories/link_to_functions') %>');