版本库文件目录

This commit is contained in:
huang 2016-04-19 10:21:12 +08:00
parent adc17c5038
commit ad3d27d6b0
2 changed files with 11 additions and 9 deletions

View File

@ -42,10 +42,10 @@ module RepositoriesHelper
end end
# 获取文件目录的最新动态 # 获取文件目录的最新动态
def get_trees_last_changes(project_id, rev) def get_trees_last_changes(project_id, rev, ent_name)
g = Gitlab.client g = Gitlab.client
begin begin
tree_changes = g.rep_last_changes(project_id, :rev => rev) tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name)
tree_changes tree_changes
rescue rescue
logger.error("faile to get tress activities!") logger.error("faile to get tress activities!")

View File

@ -3,11 +3,10 @@
depth = params[:depth].to_i %> depth = params[:depth].to_i %>
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) %> <% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) %>
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> <% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
<% get_trees_last_changes(@project.id, @rev) %> <% latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_name) %>
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>"> <tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
<td style="padding-left: <%=18 * depth%>px;" class="<%= <td style="padding-left: <%=18 * depth%>px;" class="<%=@repository.report_last_commit ? "filename" : "filename_no_report" %>">
@repository.report_last_commit ? "filename" : "filename_no_report" %>">
<% if entry.is_dir? %> <% if entry.is_dir? %>
<%# 展开文件目录 %> <%# 展开文件目录 %>
<span class="expander" onclick="scmEntryClick('<%= tr_id %>', '<%= escape_javascript(url_for( <span class="expander" onclick="scmEntryClick('<%= tr_id %>', '<%= escape_javascript(url_for(
@ -21,15 +20,18 @@
<% end %> <% end %>
<%= link_to h(ent_name), <%= link_to h(ent_name),
{:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev},
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
</td> </td>
<!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>--> <!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>-->
<!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>--> <!--<td class="size"><%#= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>-->
<%# if @repository.report_last_commit %> <%# if @repository.report_last_commit %>
<td class="tree-age c_grey">一个月前<%#= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td> <td class="tree-age c_grey">
<td class="tree-author c_grey">huang<%#= entry.author %></td> <%#= format_time(latest_changes.first.last_change.split(",")[1]) %>
<td class="tree-comments c_grey">修改版本库<%#=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %></td> <%= distance_of_time_in_words(latest_changes.first.last_change.split(",")[1], Time.now) if latest_changes && latest_changes.first.last_change %>
</td>
<td class="tree-author c_grey"><%= (latest_changes.first.last_change.split(",")[2]) if latest_changes && latest_changes.first.last_change %><%#= entry.author %></td>
<td class="tree-comments c_grey"><%= (latest_changes.first.last_change.split(",")[3]) if latest_changes && latest_changes.first.last_change %><%#=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %></td>
<%# end %> <%# end %>
</tr> </tr>
<% end %> <% end %>