repositories_helper.rb.diff

Yuki Kita, 2010-03-24 16:59

Download (2.58 KB)

View differences:

app/helpers/repositories_helper.rb (working copy)
58 58
    changes.each do |change|
59 59
      p = tree
60 60
      dirs = change.path.to_s.split('/').select {|d| !d.blank?}
61
      path = ''
61 62
      dirs.each do |dir|
63
        path += '/' + dir
62 64
        p[:s] ||= {}
63 65
        p = p[:s]
64
        p[dir] ||= {}
65
        p = p[dir]
66
        p[path] ||= {}
67
        p = p[path]
66 68
      end
67 69
      p[:c] = change
68 70
    end
......
76 78
    output = ''
77 79
    output << '<ul>'
78 80
    tree.keys.sort.each do |file|
79
      s = !tree[file][:s].nil?
80
      c = tree[file][:c]
81
      
82 81
      style = 'change'
83
      style << ' folder' if s
84
      style << " change-#{c.action}" if c
85
      
86
      text = h(file)
87
      unless c.nil?
82
      text = File.basename(h(file))
83
      if s = tree[file][:s]
84
        style << ' folder'
85
        path_param = to_path_param(@repository.relative_path(file))
86
        text = link_to(text, :controller => 'repositories',
87
                             :action => 'show',
88
                             :id => @project,
89
                             :path => path_param,
90
                             :rev => @changeset.revision)
91
        output << "<li class='#{style}'>#{text}</li>"
92
        output << render_changes_tree(s)
93
      elsif c = tree[file][:c]
94
        style << " change-#{c.action}"
88 95
        path_param = to_path_param(@repository.relative_path(c.path))
89 96
        text = link_to(text, :controller => 'repositories',
90 97
                             :action => 'entry',
91 98
                             :id => @project,
92 99
                             :path => path_param,
93
                             :rev => @changeset.revision) unless s || c.action == 'D'
100
                             :rev => @changeset.revision) unless c.action == 'D'
94 101
        text << " - #{c.revision}" unless c.revision.blank?
95 102
        text << ' (' + link_to('diff', :controller => 'repositories',
96 103
                                       :action => 'diff',
......
98 105
                                       :path => path_param,
99 106
                                       :rev => @changeset.revision) + ') ' if c.action == 'M'
100 107
        text << ' ' + content_tag('span', c.from_path, :class => 'copied-from') unless c.from_path.blank?
108
        output << "<li class='#{style}'>#{text}</li>"
101 109
      end
102
      output << "<li class='#{style}'>#{text}</li>"
103
      output << render_changes_tree(tree[file][:s]) if s
104 110
    end
105 111
    output << '</ul>'
106 112
    output