Commit 6ddb35bd5e27829609e40b8dd87313a01fb6f293

Authored by Robert Speicher
1 parent 567767bc

Move tree-related views from refs to trees

app/views/refs/_submodule_item.html.haml
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -- url = content.url(@ref) rescue nil  
2 -- name = content.basename  
3 -- return unless url  
4 -%tr{ class: "tree-item", url: url }  
5 - %td.tree-item-file-name  
6 - = image_tag "submodule.png"  
7 - %strong= truncate(name, length: 40)  
8 - %td  
9 - %code= content.id[0..10]  
10 - %td  
11 - = link_to truncate(url, length: 40), url  
12 -  
13 -  
app/views/refs/_tree.html.haml
@@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
1 -%ul.breadcrumb  
2 - %li  
3 - %span.arrow  
4 - = link_to tree_project_ref_path(@project, @ref, path: nil), remote: true do  
5 - = @project.name  
6 - - tree.breadcrumbs(6) do |link|  
7 - \/  
8 - %li= link  
9 -.clear  
10 -%div.tree_progress  
11 -#tree-content-holder  
12 - - if tree.is_blob?  
13 - = render partial: "refs/tree_file", locals: { name: tree.name, content: tree.data, file: tree }  
14 - - else  
15 - - contents = tree.contents  
16 - %table#tree-slider{class: "table_#{@hex_path}" }  
17 - %thead  
18 - %th Name  
19 - %th Last Update  
20 - %th  
21 - Last commit  
22 - = link_to "History", tree.history_path, class: "right"  
23 -  
24 - - if tree.up_dir?  
25 - %tr{ class: "tree-item", url: tree.up_dir_path }  
26 - %td.tree-item-file-name  
27 - = image_tag "file_empty.png"  
28 - = link_to "..", tree.up_dir_path, remote: :true  
29 - %td  
30 - %td  
31 -  
32 - - index = 0  
33 - - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|  
34 - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) }  
35 - - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|  
36 - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) }  
37 - - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content|  
38 - = render partial: "refs/submodule_item", locals: { content: content, index: (index += 1) }  
39 -  
40 - - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first  
41 - .file_holder#README  
42 - .file_title  
43 - %i.icon-file  
44 - = content.name  
45 - .file_content.wiki  
46 - - if gitlab_markdown?(content.name)  
47 - = preserve do  
48 - = markdown(content.data)  
49 - - else  
50 - = raw GitHub::Markup.render(content.name, content.data)  
51 -  
52 -:javascript  
53 - $(function(){  
54 - history.pushState({ path: this.path }, '', "#{@history_path}");  
55 - });  
56 -  
57 -- unless tree.is_blob?  
58 - :javascript  
59 - // Load last commit log for each file in tree  
60 - $(window).load(function(){  
61 - ajaxGet('#{@logs_path}');  
62 - });  
63 -  
64 -- if params[:path] && request.xhr?  
65 - :javascript  
66 - $(window).unbind('popstate');  
67 - $(window).bind('popstate', function() {  
68 - if(location.pathname.search("tree") != -1) {  
69 - $.ajax({type: "GET", url: location.pathname, dataType: "script"})}  
70 - else { location.href = location.pathname;}});  
app/views/refs/_tree_commit.html.haml
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -- if tm  
2 - = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm)  
3 -= link_to_gfm truncate(content_commit.title, length: tm ? 30 : 50), project_commit_path(@project, content_commit.id), class: "tree-commit-link"  
app/views/refs/_tree_file.html.haml
@@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
1 -.file_holder  
2 - .file_title  
3 - %i.icon-file  
4 - %span.file_name  
5 - = name.force_encoding('utf-8')  
6 - %small #{file.mode}  
7 - %span.options  
8 - = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank"  
9 - = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small"  
10 - = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small"  
11 - - if file.text?  
12 - - if gitlab_markdown?(name)  
13 - .file_content.wiki  
14 - = preserve do  
15 - = markdown(file.data)  
16 - - elsif markup?(name)  
17 - .file_content.wiki  
18 - = raw GitHub::Markup.render(name, file.data)  
19 - - else  
20 - .file_content.code  
21 - - unless file.empty?  
22 - %div{class: current_user.dark_scheme ? "black" : "white"}  
23 - = preserve do  
24 - = raw file.colorize(options: { linenos: 'True'})  
25 - - else  
26 - %h4.nothing_here_message Empty file  
27 -  
28 - - elsif file.image?  
29 - .file_content.image_file  
30 - %img{ src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}  
31 -  
32 - - else  
33 - .file_content.blob_file  
34 - %center  
35 - = link_to blob_project_ref_path(@project, @ref, path: params[:path]) do  
36 - %div.padded  
37 - %br  
38 - = image_tag "download.png", width: 64  
39 - %h3  
40 - Download (#{file.mb_size})  
app/views/refs/_tree_item.html.haml
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -- file = tree_full_path(content)  
2 -%tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) }  
3 - %td.tree-item-file-name  
4 - = tree_icon(content)  
5 - %strong= link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true  
6 - %td.tree_time_ago.cgray  
7 - - if index == 1  
8 - %span.log_loading  
9 - Loading commit data..  
10 - = image_tag "ajax_loader_tree.gif", width: 14  
11 - %td.tree_commit  
app/views/refs/tree.html.haml
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -= render "head"  
2 -#tree-holder= render partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}  
3 -  
4 -:javascript  
5 - $(function() {  
6 - Tree.init();  
7 - });  
app/views/refs/tree.js.haml
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -:plain  
2 - // Load Files list  
3 - $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}))}");  
4 - $("#tree-content-holder").show("slide", { direction: "right" }, 150);  
5 - $('.project-refs-form #path').val("#{params[:path]}");  
6 -  
7 - // Load last commit log for each file in tree  
8 - $('#tree-slider').waitForImages(function() {  
9 - ajaxGet('#{@logs_path}');  
10 - });  
app/views/tree/_head.html.haml 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +%ul.nav.nav-tabs
  2 + %li
  3 + = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]}
  4 + %li{class: "#{'active' if (controller.controller_name == "refs") }"}
  5 + = link_to tree_project_ref_path(@project, @ref) do
  6 + Source
  7 + %li.right
  8 + .input-prepend.project_clone_holder
  9 + %button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH
  10 + %button{class: "btn small", :"data-clone" => @project.http_url_to_repo} HTTP
  11 + = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select span5"
app/views/tree/_submodule_item.html.haml 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +- url = content.url(@ref) rescue nil
  2 +- name = content.basename
  3 +- return unless url
  4 +%tr{ class: "tree-item", url: url }
  5 + %td.tree-item-file-name
  6 + = image_tag "submodule.png"
  7 + %strong= truncate(name, length: 40)
  8 + %td
  9 + %code= content.id[0..10]
  10 + %td
  11 + = link_to truncate(url, length: 40), url
  12 +
  13 +
app/views/tree/_tree.html.haml 0 → 100644
@@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
  1 +%ul.breadcrumb
  2 + %li
  3 + %span.arrow
  4 + = link_to tree_project_ref_path(@project, @ref, path: nil), remote: true do
  5 + = @project.name
  6 + - tree.breadcrumbs(6) do |link|
  7 + \/
  8 + %li= link
  9 +.clear
  10 +%div.tree_progress
  11 +#tree-content-holder
  12 + - if tree.is_blob?
  13 + = render partial: "refs/tree_file", locals: { name: tree.name, content: tree.data, file: tree }
  14 + - else
  15 + - contents = tree.contents
  16 + %table#tree-slider{class: "table_#{@hex_path}" }
  17 + %thead
  18 + %th Name
  19 + %th Last Update
  20 + %th
  21 + Last commit
  22 + = link_to "History", tree.history_path, class: "right"
  23 +
  24 + - if tree.up_dir?
  25 + %tr{ class: "tree-item", url: tree.up_dir_path }
  26 + %td.tree-item-file-name
  27 + = image_tag "file_empty.png"
  28 + = link_to "..", tree.up_dir_path, remote: :true
  29 + %td
  30 + %td
  31 +
  32 + - index = 0
  33 + - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|
  34 + = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) }
  35 + - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|
  36 + = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) }
  37 + - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content|
  38 + = render partial: "refs/submodule_item", locals: { content: content, index: (index += 1) }
  39 +
  40 + - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first
  41 + .file_holder#README
  42 + .file_title
  43 + %i.icon-file
  44 + = content.name
  45 + .file_content.wiki
  46 + - if gitlab_markdown?(content.name)
  47 + = preserve do
  48 + = markdown(content.data)
  49 + - else
  50 + = raw GitHub::Markup.render(content.name, content.data)
  51 +
  52 +:javascript
  53 + $(function(){
  54 + history.pushState({ path: this.path }, '', "#{@history_path}");
  55 + });
  56 +
  57 +- unless tree.is_blob?
  58 + :javascript
  59 + // Load last commit log for each file in tree
  60 + $(window).load(function(){
  61 + ajaxGet('#{@logs_path}');
  62 + });
  63 +
  64 +- if params[:path] && request.xhr?
  65 + :javascript
  66 + $(window).unbind('popstate');
  67 + $(window).bind('popstate', function() {
  68 + if(location.pathname.search("tree") != -1) {
  69 + $.ajax({type: "GET", url: location.pathname, dataType: "script"})}
  70 + else { location.href = location.pathname;}});
app/views/tree/_tree_commit.html.haml 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +- if tm
  2 + = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm)
  3 += link_to_gfm truncate(content_commit.title, length: tm ? 30 : 50), project_commit_path(@project, content_commit.id), class: "tree-commit-link"
app/views/tree/_tree_file.html.haml 0 → 100644
@@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
  1 +.file_holder
  2 + .file_title
  3 + %i.icon-file
  4 + %span.file_name
  5 + = name.force_encoding('utf-8')
  6 + %small #{file.mode}
  7 + %span.options
  8 + = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank"
  9 + = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small"
  10 + = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small"
  11 + - if file.text?
  12 + - if gitlab_markdown?(name)
  13 + .file_content.wiki
  14 + = preserve do
  15 + = markdown(file.data)
  16 + - elsif markup?(name)
  17 + .file_content.wiki
  18 + = raw GitHub::Markup.render(name, file.data)
  19 + - else
  20 + .file_content.code
  21 + - unless file.empty?
  22 + %div{class: current_user.dark_scheme ? "black" : "white"}
  23 + = preserve do
  24 + = raw file.colorize(options: { linenos: 'True'})
  25 + - else
  26 + %h4.nothing_here_message Empty file
  27 +
  28 + - elsif file.image?
  29 + .file_content.image_file
  30 + %img{ src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
  31 +
  32 + - else
  33 + .file_content.blob_file
  34 + %center
  35 + = link_to blob_project_ref_path(@project, @ref, path: params[:path]) do
  36 + %div.padded
  37 + %br
  38 + = image_tag "download.png", width: 64
  39 + %h3
  40 + Download (#{file.mb_size})
app/views/tree/_tree_item.html.haml 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +- file = tree_full_path(content)
  2 +%tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) }
  3 + %td.tree-item-file-name
  4 + = tree_icon(content)
  5 + %strong= link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true
  6 + %td.tree_time_ago.cgray
  7 + - if index == 1
  8 + %span.log_loading
  9 + Loading commit data..
  10 + = image_tag "ajax_loader_tree.gif", width: 14
  11 + %td.tree_commit
app/views/tree/show.html.haml 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 += render "head"
  2 +#tree-holder= render partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}
  3 +
  4 +:javascript
  5 + $(function() {
  6 + Tree.init();
  7 + });
app/views/tree/show.js.haml 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +:plain
  2 + // Load Files list
  3 + $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}))}");
  4 + $("#tree-content-holder").show("slide", { direction: "right" }, 150);
  5 + $('.project-refs-form #path').val("#{params[:path]}");
  6 +
  7 + // Load last commit log for each file in tree
  8 + $('#tree-slider').waitForImages(function() {
  9 + ajaxGet('#{@logs_path}');
  10 + });