Feature: ajax load for tree commit log
This commit is contained in:
parent
b8425cf173
commit
1a2bacfb4b
9 changed files with 206 additions and 20 deletions
|
@ -12,6 +12,7 @@
|
|||
//= require jquery.cookie
|
||||
//= require jquery.endless-scroll
|
||||
//= require jquery.highlight
|
||||
//= require jquery.waitforimages
|
||||
//= require bootstrap-modal
|
||||
//= require modernizr
|
||||
//= require chosen-jquery
|
||||
|
|
|
@ -9,7 +9,7 @@ class RefsController < ApplicationController
|
|||
before_filter :require_non_empty_project
|
||||
|
||||
before_filter :ref
|
||||
before_filter :define_tree_vars, :only => [:tree, :blob, :blame]
|
||||
before_filter :define_tree_vars, :only => [:tree, :blob, :blame, :logs_tree]
|
||||
before_filter :render_full_content
|
||||
|
||||
layout "project"
|
||||
|
@ -46,6 +46,18 @@ class RefsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def logs_tree
|
||||
contents = @tree.contents
|
||||
@logs = contents.map do |content|
|
||||
file = params[:path] ? File.join(params[:path], content.name) : content.name
|
||||
last_commit = @project.commits(@commit.id, file, 1).last
|
||||
{
|
||||
:file_name => content.name,
|
||||
:commit => last_commit
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def blob
|
||||
if @tree.is_blob?
|
||||
if @tree.text?
|
||||
|
@ -79,6 +91,15 @@ class RefsController < ApplicationController
|
|||
@commit = project.commit(@ref)
|
||||
@tree = Tree.new(@commit.tree, project, @ref, params[:path])
|
||||
@tree = TreeDecorator.new(@tree)
|
||||
@hex_path = Digest::SHA1.hexdigest(params[:path] || "/")
|
||||
|
||||
if params[:path]
|
||||
@history_path = tree_file_project_ref_path(@project, @ref, params[:path])
|
||||
@logs_path = logs_file_project_ref_path(@project, @ref, params[:path])
|
||||
else
|
||||
@history_path = tree_project_ref_path(@project, @ref)
|
||||
@logs_path = logs_tree_project_ref_path(@project, @ref)
|
||||
end
|
||||
rescue
|
||||
return render_404
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
= render :partial => "refs/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
|
||||
- else
|
||||
- contents = tree.contents
|
||||
%table#tree-slider.bordered-table.table
|
||||
%table#tree-slider.bordered-table.table{:class => "table_#{@hex_path}" }
|
||||
%thead
|
||||
%th Name
|
||||
%th Last Update
|
||||
|
@ -48,17 +48,18 @@
|
|||
- else
|
||||
= simple_format(content.data)
|
||||
|
||||
- if params[:path]
|
||||
- history_path = tree_file_project_ref_path(@project, @ref, params[:path])
|
||||
- else
|
||||
- history_path = tree_project_ref_path(@project, @ref)
|
||||
:javascript
|
||||
$(function(){
|
||||
$('select#branch').selectmenu({style:'popup', width:200});
|
||||
$('select#tag').selectmenu({style:'popup', width:200});
|
||||
$('.project-refs-select').chosen();
|
||||
|
||||
history.pushState({ path: this.path }, '', "#{history_path}")
|
||||
history.pushState({ path: this.path }, '', "#{@history_path}");
|
||||
|
||||
});
|
||||
|
||||
$(window).load(function(){
|
||||
$.ajax({type: "GET", url: '#{@logs_path}', dataType: "script"});
|
||||
});
|
||||
|
||||
|
||||
|
|
3
app/views/refs/_tree_commit.html.haml
Normal file
3
app/views/refs/_tree_commit.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
- if tm
|
||||
%strong= link_to "[#{tm.user_name}]", project_team_member_path(@project, tm)
|
||||
= link_to truncate(content_commit.safe_message, :length => tm ? 30 : 50), project_commit_path(@project, content_commit.id), :class => "tree-commit-link"
|
|
@ -1,23 +1,15 @@
|
|||
- file = params[:path] ? File.join(params[:path], content.name) : content.name
|
||||
- content_commit = @project.commits(@commit.id, file, 1).last
|
||||
- return unless content_commit
|
||||
%tr{ :class => "tree-item", :url => tree_file_project_ref_path(@project, @ref, file) }
|
||||
%tr{ :class => "tree-item file_#{Digest::SHA1.hexdigest(content.name)}", :url => tree_file_project_ref_path(@project, @ref, file) }
|
||||
%td.tree-item-file-name
|
||||
- if content.is_a?(Grit::Blob)
|
||||
- if content.text?
|
||||
= image_tag "file_txt.png"
|
||||
= image_tag "file_txt.png", :class => "tree-ico"
|
||||
- elsif content.image?
|
||||
= image_tag "file_img.png"
|
||||
= image_tag "file_img.png", :class => "tree-ico"
|
||||
- else
|
||||
= image_tag "file_bin.png"
|
||||
= image_tag "file_bin.png", :class => "tree-ico"
|
||||
- else
|
||||
= image_tag "file_dir.png"
|
||||
= image_tag "file_dir.png", :class => "tree-ico"
|
||||
= link_to truncate(content.name, :length => 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), :remote => :true
|
||||
%td.tree_time_ago.cgray
|
||||
= time_ago_in_words(content_commit.committed_date)
|
||||
ago
|
||||
%td.tree_commit
|
||||
- tm = @project.team_member_by_name_or_email(content_commit.author_email, content_commit.author_name)
|
||||
- if tm
|
||||
%strong= link_to "[#{tm.user_name}]", project_team_member_path(@project, tm)
|
||||
= link_to truncate(content_commit.safe_message, :length => tm ? 30 : 50), project_commit_path(@project, content_commit.id), :class => "tree-commit-link"
|
||||
|
|
9
app/views/refs/logs_tree.js.haml
Normal file
9
app/views/refs/logs_tree.js.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- @logs.each do |content_data|
|
||||
- file_name = content_data[:file_name]
|
||||
- content_commit = content_data[:commit]
|
||||
- tm = @project.team_member_by_name_or_email(content_commit.author_email, content_commit.author_name)
|
||||
|
||||
:plain
|
||||
var row = $("table.table_#{@hex_path} tr.file_#{Digest::SHA1.hexdigest(file_name)}");
|
||||
row.find("td.tree_time_ago").html('#{escape_javascript(time_ago_in_words(content_commit.committed_date))} ago');
|
||||
row.find("td.tree_commit").html('#{escape_javascript(render("tree_commit", :tm => tm, :content_commit => content_commit))}');
|
|
@ -2,3 +2,8 @@
|
|||
$("#tree-holder").html("#{escape_javascript(render(:partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @tree}))}");
|
||||
$("#tree-content-holder").show("slide", { direction: "right" }, 150);
|
||||
$('.project-refs-form #path').val("#{params[:path]}");
|
||||
|
||||
|
||||
$('#tree-slider').waitForImages(function() {
|
||||
$.ajax({type: "GET", url: '#{@logs_path}', dataType: "script"});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue