_tree.html.haml 2.48 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1 2 3 4 5 6 7
-#%a.right.button{:href => "#"} Download
-#-if can? current_user, :admin_project, @project
  %a.right.button.blue{:href => "#"} EDIT
#tree-breadcrumbs
  %h2.icon
    %span
    %d
8
      = link_to tree_project_path(@project, :path => nil, :commit_id => @commit.try(:id)), :remote => true do
gitlabhq's avatar
gitlabhq committed
9
        = @project.name
gitlabhq's avatar
gitlabhq committed
10 11 12 13 14 15 16 17
      - if params[:path]
        - part_path = ""
        - params[:path].split("\/").each do |part|
          - part_path = File.join(part_path, part) unless part_path.empty?
          - if part_path.empty?
            - part_path = part
          \/
          = link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id), :branch => @branch, :tag => @tag), :remote => :true
gitlabhq's avatar
gitlabhq committed
18
         
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
19
  .right= render :partial => "projects/refs", :locals => { :destination => tree_project_path(@project) }
gitlabhq's avatar
gitlabhq committed
20
.clear
gitlabhq's avatar
gitlabhq committed
21 22 23 24 25 26 27

#tree-content-holder
  - if tree.is_a?(Grit::Blob)
    = render :partial => "projects/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
  - else
    - contents = tree.contents
    %table#tree-slider.round-borders
gitlabhq's avatar
gitlabhq committed
28
      %thead
gitlabhq's avatar
gitlabhq committed
29 30 31 32
        %th Name
        %th Last Update
        %th
          Last commit
33
          = link_to "history", project_commits_path(@project, :path => params[:path], :branch => params[:branch],:tag => params[:tag]), :class => "right"
gitlabhq's avatar
gitlabhq committed
34 35 36 37 38
      - if params[:path]
        - file = File.join(params[:path], "..")
        %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
          %td.tree-item-file-name
            = image_tag "dir.png"
39
            = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true
40 41
          %td
          %td
gitlabhq's avatar
gitlabhq committed
42 43 44 45 46 47 48 49 50 51 52 53 54

      - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|
        = render :partial => "projects/tree_item", :locals => { :content => content }
      - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|
        = render :partial => "projects/tree_item", :locals => { :content => content }

:javascript
  $(function(){
    $('select#branch').selectmenu({style:'popup', width:200});
    $('select#tag').selectmenu({style:'popup', width:200});
  });

- if params[:path] && request.xhr?
55
  :javascript
gitlabhq's avatar
gitlabhq committed
56 57 58 59 60
    $(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;}});