_tree.html.haml 2.5 KB
Newer Older
1
%ul.breadcrumb
2 3 4 5 6 7
  %li
    = form_tag switch_project_refs_path(@project), :method => :get, :class => "project-refs-form left", :remote => true do
      = select_tag "ref", grouped_options_refs, :onchange => "$(this.form).trigger('submit');", :class => "project-refs-select"
      = hidden_field_tag :destination, "tree"
      = hidden_field_tag :path, params[:path]

8
  %li
D
Dmitriy Zaporozhets 已提交
9 10
    = link_to tree_project_ref_path(@project, @ref, :path => nil), :remote => true do
      = @project.code
11 12 13
  - tree.breadcrumbs(6) do |link|
    \/
    %li= link
G
gitlabhq 已提交
14
.clear
15 16
%div.tree_progress
  = image_tag "ajax-loader.gif"
G
gitlabhq 已提交
17
#tree-content-holder
D
Dmitriy Zaporozhets 已提交
18
  - if tree.is_blob?
G
gitlabhq 已提交
19
    = render :partial => "refs/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
G
gitlabhq 已提交
20 21
  - else
    - contents = tree.contents
22
    %table#tree-slider
G
gitlabhq 已提交
23
      %thead
G
gitlabhq 已提交
24 25 26 27
        %th Name
        %th Last Update
        %th
          Last commit
28
          = link_to "History", tree.history_path, :class => "right"
S
Saito 已提交
29

D
Dmitriy Zaporozhets 已提交
30 31
      - if tree.up_dir?
        %tr{ :class => "tree-item", :url => tree.up_dir_path }
G
gitlabhq 已提交
32 33
          %td.tree-item-file-name
            = image_tag "dir.png"
D
Dmitriy Zaporozhets 已提交
34
            = link_to "..", tree.up_dir_path, :remote => :true
35 36
          %td
          %td
G
gitlabhq 已提交
37 38

      - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content|
G
gitlabhq 已提交
39
        = render :partial => "refs/tree_item", :locals => { :content => content }
G
gitlabhq 已提交
40
      - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content|
G
gitlabhq 已提交
41
        = render :partial => "refs/tree_item", :locals => { :content => content }
G
gitlabhq 已提交
42

43
    - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first
S
Saito 已提交
44 45 46
      #tree-readme-holder
        %h3= content.name
        .readme
47
          - if content.name =~ /\.(md|markdown)$/i
S
Saito 已提交
48
            = markdown(content.data)
49
          - else
S
Saito 已提交
50
            = simple_format(content.data)
S
Saito 已提交
51

52 53 54 55
- if params[:path]
  - history_path = tree_file_project_ref_path(@project, @ref, params[:path])
- else
  - history_path = tree_project_ref_path(@project, @ref)
G
gitlabhq 已提交
56 57 58 59
:javascript
  $(function(){
    $('select#branch').selectmenu({style:'popup', width:200});
    $('select#tag').selectmenu({style:'popup', width:200});
60 61 62
    $('.project-refs-select').chosen();

    history.pushState({ path: this.path }, '', "#{history_path}")
G
gitlabhq 已提交
63
  });
64

65

66 67 68 69 70 71 72
- 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;}});