diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 835b0c0c6..df9171097 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -601,6 +601,7 @@ update end def entry_edit + entry_and_raw(false) @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) diff --git a/app/views/repositories/_entry_content.html.erb b/app/views/repositories/_entry_content.html.erb index 0ea9def12..1d6670a99 100644 --- a/app/views/repositories/_entry_content.html.erb +++ b/app/views/repositories/_entry_content.html.erb @@ -1,5 +1,7 @@ -
+
  • - +
    + +
  • diff --git a/app/views/repositories/_latest_commit.html.erb b/app/views/repositories/_latest_commit.html.erb index acce15cd8..458e361d1 100644 --- a/app/views/repositories/_latest_commit.html.erb +++ b/app/views/repositories/_latest_commit.html.erb @@ -5,7 +5,9 @@
    提交于 <%= time_tag(@changesets_latest_coimmit.try(:time)) %> 前:
    <%= @changesets_latest_coimmit.message %>
    <% if @entry && @entry.kind == 'file' %> - <%= render :partial => 'link_to_functions' %> +
    + <%= render :partial => 'link_to_functions' %> +
    <% end %> <% end %> \ No newline at end of file diff --git a/app/views/repositories/_link_to_functions.html.erb b/app/views/repositories/_link_to_functions.html.erb index 132c7f032..d1f555d28 100644 --- a/app/views/repositories/_link_to_functions.html.erb +++ b/app/views/repositories/_link_to_functions.html.erb @@ -24,8 +24,10 @@ <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %> <% if params[:action] == "entry_edit" %> - 保存 + 保存 <% elsif params[:action] == "entry" || params[:action] == "entry_update" %> - <%= link_to "编辑", entry_edit_repository_path(@project, :path => @path, :rev => @rev), :class => "fl mr5", :remote => true %> + <%= link_to "编辑", {:controller => "repositories", :action => "entry_edit", :id => @project.id, :repository_id => @repository.identifier, :path => @path, :rev => @rev}, :class => "fr mr5", :remote => true %> + + <% end %> <% end %> diff --git a/app/views/repositories/entry.html.erb b/app/views/repositories/entry.html.erb index 14cd1c3e3..fc6aa0213 100644 --- a/app/views/repositories/entry.html.erb +++ b/app/views/repositories/entry.html.erb @@ -10,7 +10,9 @@
    <%= render :partial => 'latest_commit' %> - <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> +
    + <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> +
    <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/config/routes.rb b/config/routes.rb index 6b01ff9e7..21c931592 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1211,6 +1211,8 @@ RedmineApp::Application.routes.draw do :action => /(browse|show|entry|raw|changes|annotate|diff|commit_diff)/ get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil + get 'projects/:id/repository/:repository_id/entry_edit', :to => 'repositories#entry_edit', :path => nil + post 'projects/:id/repository/:repository_id/entry_update', :to => 'repositories#entry_update', :path => nil get 'projects/:id/repository', :to => 'repositories#show', :path => nil get 'projects/:id/exit', :to => 'projects#exit_project', :as => 'exit_cur_project' diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index 4b458ecee..5ce94c54e 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -192,6 +192,11 @@ class Gitlab::Client get("/projects/#{project}/repository/contributors") end + # update file + def edit_file(project, options={}) + put("/projects/#{project}/repository/files", :body => options) + end + # Get an archive of the repository # @param [Integer] project the ID fo a project. # sha (optional) - The commit SHA to download defaults to the tip of the default branch