summaryrefslogtreecommitdiff
path: root/app/helpers/tree_helper.rb
blob: ed3053d8af59d649ddad414e4719e1ccf9f65a0a (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
module TreeHelper
  def tree_icon(content)
    if content.is_a?(Grit::Blob)
      if content.text?
        image_tag "file_txt.png"
      elsif content.image?
        image_tag "file_img.png"
      else
        image_tag "file_bin.png"
      end
    else
      image_tag "file_dir.png"
    end
  end

  def tree_hex_class(content)
    "file_#{hexdigest(content.name)}"
  end

  def tree_full_path(content)
    if params[:path] 
      File.join(params[:path], content.name)
    else
      content.name
    end
  end
end