Merge pull request #1627 from tsigo/tree_performance
Tree performance improvements
This commit is contained in:
commit
a9cce9358a
10 changed files with 83 additions and 95 deletions
|
@ -1,13 +1,11 @@
|
|||
- url = content.url(@ref) rescue nil
|
||||
- name = content.basename
|
||||
- url = submodule_item.url(@ref) rescue nil
|
||||
- name = submodule_item.basename
|
||||
- return unless url
|
||||
%tr{ class: "tree-item", url: url }
|
||||
%td.tree-item-file-name
|
||||
= image_tag "submodule.png"
|
||||
%strong= truncate(name, length: 40)
|
||||
%td
|
||||
%code= content.id[0..10]
|
||||
%code= submodule_item.id[0..10]
|
||||
%td
|
||||
= link_to truncate(url, length: 40), url
|
||||
|
||||
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
- tree.breadcrumbs(6) do |link|
|
||||
\/
|
||||
%li= link
|
||||
|
||||
.clear
|
||||
%div.tree_progress
|
||||
|
||||
%div#tree-content-holder.tree-content-holder
|
||||
- if tree.is_blob?
|
||||
= render partial: "tree/tree_file", locals: { name: tree.name, content: tree.data, file: tree }
|
||||
= render partial: "tree/tree_file", object: tree
|
||||
- else
|
||||
- contents = tree.contents
|
||||
%table#tree-slider{class: "table_#{@hex_path} tree-table" }
|
||||
%thead
|
||||
%th Name
|
||||
|
@ -22,22 +23,16 @@
|
|||
= link_to "History", tree.history_path, class: "right"
|
||||
|
||||
- if tree.up_dir?
|
||||
%tr{ class: "tree-item", url: tree.up_dir_path }
|
||||
%tr.tree-item
|
||||
%td.tree-item-file-name
|
||||
= image_tag "file_empty.png"
|
||||
= link_to "..", tree.up_dir_path, remote: :true
|
||||
= image_tag "file_empty.png", size: '16x16'
|
||||
= link_to "..", tree.up_dir_path, remote: true
|
||||
%td
|
||||
%td
|
||||
|
||||
- index = 0
|
||||
- contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|
|
||||
= render partial: "tree/tree_item", locals: { content: content, index: (index += 1) }
|
||||
- contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|
|
||||
= render partial: "tree/tree_item", locals: { content: content, index: (index += 1) }
|
||||
- contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content|
|
||||
= render partial: "tree/submodule_item", locals: { content: content, index: (index += 1) }
|
||||
= render_tree(tree.contents)
|
||||
|
||||
- if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first
|
||||
- if content = tree.contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
|
||||
.file_holder#README
|
||||
.file_title
|
||||
%i.icon-file
|
||||
|
|
|
@ -2,32 +2,32 @@
|
|||
.file_title
|
||||
%i.icon-file
|
||||
%span.file_name
|
||||
= name.force_encoding('utf-8')
|
||||
%small #{file.mode}
|
||||
= tree_file.name.force_encoding('utf-8')
|
||||
%small #{tree_file.mode}
|
||||
%span.options
|
||||
= link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank"
|
||||
= link_to "history", project_commits_path(@project, @id), class: "btn very_small"
|
||||
= link_to "blame", project_blame_path(@project, @id), class: "btn very_small"
|
||||
- if file.text?
|
||||
- if gitlab_markdown?(name)
|
||||
- if tree_file.text?
|
||||
- if gitlab_markdown?(tree_file.name)
|
||||
.file_content.wiki
|
||||
= preserve do
|
||||
= markdown(file.data)
|
||||
- elsif markup?(name)
|
||||
= markdown(tree_file.data)
|
||||
- elsif markup?(tree_file.name)
|
||||
.file_content.wiki
|
||||
= raw GitHub::Markup.render(name, file.data)
|
||||
= raw GitHub::Markup.render(tree_file.name, tree_file.data)
|
||||
- else
|
||||
.file_content.code
|
||||
- unless file.empty?
|
||||
- unless tree_file.empty?
|
||||
%div{class: current_user.dark_scheme ? "black" : "white"}
|
||||
= preserve do
|
||||
= raw file.colorize(options: { linenos: 'True'})
|
||||
= raw tree_file.colorize(options: { linenos: 'True'})
|
||||
- else
|
||||
%h4.nothing_here_message Empty file
|
||||
|
||||
- elsif file.image?
|
||||
- elsif tree_file.image?
|
||||
.file_content.image_file
|
||||
%img{ src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
|
||||
%img{ src: "data:#{tree_file.mime_type};base64,#{Base64.encode64(tree_file.data)}"}
|
||||
|
||||
- else
|
||||
.file_content.blob_file
|
||||
|
@ -37,4 +37,4 @@
|
|||
%br
|
||||
= image_tag "download.png", width: 64
|
||||
%h3
|
||||
Download (#{file.mb_size})
|
||||
Download (#{tree_file.mb_size})
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
- file = tree_full_path(content)
|
||||
%tr{ class: "tree-item #{tree_hex_class(content)}", url: project_tree_path(@project, tree_join(@id, file)) }
|
||||
%tr{ class: "tree-item #{tree_hex_class(tree_item)}" }
|
||||
%td.tree-item-file-name
|
||||
= tree_icon(content)
|
||||
%strong= link_to truncate(content.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, file)), remote: :true
|
||||
= tree_icon(type)
|
||||
%strong= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)), remote: true
|
||||
%td.tree_time_ago.cgray
|
||||
- if index == 1
|
||||
%span.log_loading
|
||||
Loading commit data..
|
||||
= image_tag "ajax_loader_tree.gif", width: 14
|
||||
%span.log_loading.hide
|
||||
Loading commit data...
|
||||
= image_tag "ajax_loader_tree.gif", width: 14
|
||||
%td.tree_commit
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
= render "head"
|
||||
%div#tree-holder.tree-holder
|
||||
= render "tree", commit: @commit, tree: @tree
|
||||
|
||||
:javascript
|
||||
$(function() {
|
||||
Tree.init();
|
||||
});
|
||||
= render "tree", tree: @tree
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
:plain
|
||||
// Load Files list
|
||||
$("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {commit: @commit, tree: @tree}))}");
|
||||
$("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {tree: @tree}))}");
|
||||
$("#tree-content-holder").show("slide", { direction: "right" }, 150);
|
||||
$('.project-refs-form #path').val("#{@path}");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue