Move tree-related views from refs to trees
This commit is contained in:
parent
567767bcf2
commit
6ddb35bd5e
8 changed files with 11 additions and 0 deletions
11
app/views/tree/_head.html.haml
Normal file
11
app/views/tree/_head.html.haml
Normal file
|
@ -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"
|
13
app/views/tree/_submodule_item.html.haml
Normal file
13
app/views/tree/_submodule_item.html.haml
Normal file
|
@ -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
|
||||
|
||||
|
70
app/views/tree/_tree.html.haml
Normal file
70
app/views/tree/_tree.html.haml
Normal file
|
@ -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;}});
|
3
app/views/tree/_tree_commit.html.haml
Normal file
3
app/views/tree/_tree_commit.html.haml
Normal file
|
@ -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"
|
40
app/views/tree/_tree_file.html.haml
Normal file
40
app/views/tree/_tree_file.html.haml
Normal file
|
@ -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})
|
11
app/views/tree/_tree_item.html.haml
Normal file
11
app/views/tree/_tree_item.html.haml
Normal file
|
@ -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
|
7
app/views/tree/show.html.haml
Normal file
7
app/views/tree/show.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
= render "head"
|
||||
#tree-holder= render partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}
|
||||
|
||||
:javascript
|
||||
$(function() {
|
||||
Tree.init();
|
||||
});
|
10
app/views/tree/show.js.haml
Normal file
10
app/views/tree/show.js.haml
Normal file
|
@ -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}');
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue