diff --git a/app/views/refs/_submodule_item.html.haml b/app/views/refs/_submodule_item.html.haml deleted file mode 100644 index 6b9f587..0000000 --- a/app/views/refs/_submodule_item.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -- url = content.url(@ref) rescue nil -- name = content.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] - %td - = link_to truncate(url, length: 40), url - - diff --git a/app/views/refs/_tree.html.haml b/app/views/refs/_tree.html.haml deleted file mode 100644 index 5507871..0000000 --- a/app/views/refs/_tree.html.haml +++ /dev/null @@ -1,70 +0,0 @@ -%ul.breadcrumb - %li - %span.arrow - = link_to tree_project_ref_path(@project, @ref, path: nil), remote: true do - = @project.name - - tree.breadcrumbs(6) do |link| - \/ - %li= link -.clear -%div.tree_progress -#tree-content-holder - - if tree.is_blob? - = render partial: "refs/tree_file", locals: { name: tree.name, content: tree.data, file: tree } - - else - - contents = tree.contents - %table#tree-slider{class: "table_#{@hex_path}" } - %thead - %th Name - %th Last Update - %th - Last commit - = link_to "History", tree.history_path, class: "right" - - - if tree.up_dir? - %tr{ class: "tree-item", url: tree.up_dir_path } - %td.tree-item-file-name - = image_tag "file_empty.png" - = 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: "refs/tree_item", locals: { content: content, index: (index += 1) } - - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) } - - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content| - = render partial: "refs/submodule_item", locals: { content: content, index: (index += 1) } - - - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first - .file_holder#README - .file_title - %i.icon-file - = content.name - .file_content.wiki - - if gitlab_markdown?(content.name) - = preserve do - = markdown(content.data) - - else - = raw GitHub::Markup.render(content.name, content.data) - -:javascript - $(function(){ - history.pushState({ path: this.path }, '', "#{@history_path}"); - }); - -- unless tree.is_blob? - :javascript - // Load last commit log for each file in tree - $(window).load(function(){ - ajaxGet('#{@logs_path}'); - }); - -- if params[:path] && request.xhr? - :javascript - $(window).unbind('popstate'); - $(window).bind('popstate', function() { - if(location.pathname.search("tree") != -1) { - $.ajax({type: "GET", url: location.pathname, dataType: "script"})} - else { location.href = location.pathname;}}); diff --git a/app/views/refs/_tree_commit.html.haml b/app/views/refs/_tree_commit.html.haml deleted file mode 100644 index 1bcf1a7..0000000 --- a/app/views/refs/_tree_commit.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- if tm - = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm) -= link_to_gfm truncate(content_commit.title, length: tm ? 30 : 50), project_commit_path(@project, content_commit.id), class: "tree-commit-link" diff --git a/app/views/refs/_tree_file.html.haml b/app/views/refs/_tree_file.html.haml deleted file mode 100644 index 76173e2..0000000 --- a/app/views/refs/_tree_file.html.haml +++ /dev/null @@ -1,40 +0,0 @@ -.file_holder - .file_title - %i.icon-file - %span.file_name - = name.force_encoding('utf-8') - %small #{file.mode} - %span.options - = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" - = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" - = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" - - if file.text? - - if gitlab_markdown?(name) - .file_content.wiki - = preserve do - = markdown(file.data) - - elsif markup?(name) - .file_content.wiki - = raw GitHub::Markup.render(name, file.data) - - else - .file_content.code - - unless file.empty? - %div{class: current_user.dark_scheme ? "black" : "white"} - = preserve do - = raw file.colorize(options: { linenos: 'True'}) - - else - %h4.nothing_here_message Empty file - - - elsif file.image? - .file_content.image_file - %img{ src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - - - else - .file_content.blob_file - %center - = link_to blob_project_ref_path(@project, @ref, path: params[:path]) do - %div.padded - %br - = image_tag "download.png", width: 64 - %h3 - Download (#{file.mb_size}) diff --git a/app/views/refs/_tree_item.html.haml b/app/views/refs/_tree_item.html.haml deleted file mode 100644 index d4c4ee8..0000000 --- a/app/views/refs/_tree_item.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -- file = tree_full_path(content) -%tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) } - %td.tree-item-file-name - = tree_icon(content) - %strong= link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true - %td.tree_time_ago.cgray - - if index == 1 - %span.log_loading - Loading commit data.. - = image_tag "ajax_loader_tree.gif", width: 14 - %td.tree_commit diff --git a/app/views/refs/tree.html.haml b/app/views/refs/tree.html.haml deleted file mode 100644 index 181be64..0000000 --- a/app/views/refs/tree.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -= render "head" -#tree-holder= render partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree} - -:javascript - $(function() { - Tree.init(); - }); diff --git a/app/views/refs/tree.js.haml b/app/views/refs/tree.js.haml deleted file mode 100644 index 92e9057..0000000 --- a/app/views/refs/tree.js.haml +++ /dev/null @@ -1,10 +0,0 @@ -:plain - // Load Files list - $("#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]}"); - - // Load last commit log for each file in tree - $('#tree-slider').waitForImages(function() { - ajaxGet('#{@logs_path}'); - }); diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml new file mode 100644 index 0000000..3592f57 --- /dev/null +++ b/app/views/tree/_head.html.haml @@ -0,0 +1,11 @@ +%ul.nav.nav-tabs + %li + = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} + %li{class: "#{'active' if (controller.controller_name == "refs") }"} + = link_to tree_project_ref_path(@project, @ref) do + Source + %li.right + .input-prepend.project_clone_holder + %button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH + %button{class: "btn small", :"data-clone" => @project.http_url_to_repo} HTTP + = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select span5" diff --git a/app/views/tree/_submodule_item.html.haml b/app/views/tree/_submodule_item.html.haml new file mode 100644 index 0000000..6b9f587 --- /dev/null +++ b/app/views/tree/_submodule_item.html.haml @@ -0,0 +1,13 @@ +- url = content.url(@ref) rescue nil +- name = content.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] + %td + = link_to truncate(url, length: 40), url + + diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml new file mode 100644 index 0000000..5507871 --- /dev/null +++ b/app/views/tree/_tree.html.haml @@ -0,0 +1,70 @@ +%ul.breadcrumb + %li + %span.arrow + = link_to tree_project_ref_path(@project, @ref, path: nil), remote: true do + = @project.name + - tree.breadcrumbs(6) do |link| + \/ + %li= link +.clear +%div.tree_progress +#tree-content-holder + - if tree.is_blob? + = render partial: "refs/tree_file", locals: { name: tree.name, content: tree.data, file: tree } + - else + - contents = tree.contents + %table#tree-slider{class: "table_#{@hex_path}" } + %thead + %th Name + %th Last Update + %th + Last commit + = link_to "History", tree.history_path, class: "right" + + - if tree.up_dir? + %tr{ class: "tree-item", url: tree.up_dir_path } + %td.tree-item-file-name + = image_tag "file_empty.png" + = 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: "refs/tree_item", locals: { content: content, index: (index += 1) } + - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| + = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) } + - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content| + = render partial: "refs/submodule_item", locals: { content: content, index: (index += 1) } + + - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first + .file_holder#README + .file_title + %i.icon-file + = content.name + .file_content.wiki + - if gitlab_markdown?(content.name) + = preserve do + = markdown(content.data) + - else + = raw GitHub::Markup.render(content.name, content.data) + +:javascript + $(function(){ + history.pushState({ path: this.path }, '', "#{@history_path}"); + }); + +- unless tree.is_blob? + :javascript + // Load last commit log for each file in tree + $(window).load(function(){ + ajaxGet('#{@logs_path}'); + }); + +- if params[:path] && request.xhr? + :javascript + $(window).unbind('popstate'); + $(window).bind('popstate', function() { + if(location.pathname.search("tree") != -1) { + $.ajax({type: "GET", url: location.pathname, dataType: "script"})} + else { location.href = location.pathname;}}); diff --git a/app/views/tree/_tree_commit.html.haml b/app/views/tree/_tree_commit.html.haml new file mode 100644 index 0000000..1bcf1a7 --- /dev/null +++ b/app/views/tree/_tree_commit.html.haml @@ -0,0 +1,3 @@ +- if tm + = link_to "[#{tm.user_name}]", project_team_member_path(@project, tm) += link_to_gfm truncate(content_commit.title, length: tm ? 30 : 50), project_commit_path(@project, content_commit.id), class: "tree-commit-link" diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml new file mode 100644 index 0000000..76173e2 --- /dev/null +++ b/app/views/tree/_tree_file.html.haml @@ -0,0 +1,40 @@ +.file_holder + .file_title + %i.icon-file + %span.file_name + = name.force_encoding('utf-8') + %small #{file.mode} + %span.options + = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" + = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" + = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" + - if file.text? + - if gitlab_markdown?(name) + .file_content.wiki + = preserve do + = markdown(file.data) + - elsif markup?(name) + .file_content.wiki + = raw GitHub::Markup.render(name, file.data) + - else + .file_content.code + - unless file.empty? + %div{class: current_user.dark_scheme ? "black" : "white"} + = preserve do + = raw file.colorize(options: { linenos: 'True'}) + - else + %h4.nothing_here_message Empty file + + - elsif file.image? + .file_content.image_file + %img{ src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + + - else + .file_content.blob_file + %center + = link_to blob_project_ref_path(@project, @ref, path: params[:path]) do + %div.padded + %br + = image_tag "download.png", width: 64 + %h3 + Download (#{file.mb_size}) diff --git a/app/views/tree/_tree_item.html.haml b/app/views/tree/_tree_item.html.haml new file mode 100644 index 0000000..d4c4ee8 --- /dev/null +++ b/app/views/tree/_tree_item.html.haml @@ -0,0 +1,11 @@ +- file = tree_full_path(content) +%tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) } + %td.tree-item-file-name + = tree_icon(content) + %strong= link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true + %td.tree_time_ago.cgray + - if index == 1 + %span.log_loading + Loading commit data.. + = image_tag "ajax_loader_tree.gif", width: 14 + %td.tree_commit diff --git a/app/views/tree/show.html.haml b/app/views/tree/show.html.haml new file mode 100644 index 0000000..181be64 --- /dev/null +++ b/app/views/tree/show.html.haml @@ -0,0 +1,7 @@ += render "head" +#tree-holder= render partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree} + +:javascript + $(function() { + Tree.init(); + }); diff --git a/app/views/tree/show.js.haml b/app/views/tree/show.js.haml new file mode 100644 index 0000000..92e9057 --- /dev/null +++ b/app/views/tree/show.js.haml @@ -0,0 +1,10 @@ +:plain + // Load Files list + $("#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]}"); + + // Load last commit log for each file in tree + $('#tree-slider').waitForImages(function() { + ajaxGet('#{@logs_path}'); + }); -- libgit2 0.21.2