summaryrefslogtreecommitdiff
path: root/app/views/refs/_tree.html.haml
blob: 6f8175da7a033df2b21b8e882b98a7951f9a36e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%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.bordered-table.table{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 content.name =~ /\.(md|markdown)$/i
            = preserve do
              = markdown(content.data)
          - else
            = simple_format(content.data)

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

    history.pushState({ path: this.path }, '', "#{@history_path}");

  });

  // 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;}});