Module: Dolt::View::Tree
- Included in:
- Sinatra::MultiRepoBrowser, Sinatra::SingleRepoBrowser
- Defined in:
- lib/dolt/view/tree.rb
Instance Method Summary collapse
- #tree_context(repo, ref, path) ⇒ Object
- #tree_entries(tree) ⇒ Object
- #tree_table_padding_td(path) ⇒ Object
- #tree_table_padding_width(path) ⇒ Object
- #tree_url(repository, ref, path) ⇒ Object
Instance Method Details
#tree_context(repo, ref, path) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dolt/view/tree.rb', line 31 def tree_context(repo, ref, path) acc = "" pieces = path.sub(/^\.?\//, "").split("/") total = 5 + pieces.length colspan = total pieces.inject("") do |html, dir| padding_td = tree_table_padding_td(acc.sub(/^\.?\//, "")) url = object_url(repo, ref, acc, { :type => :tree, :name => dir }) acc << "/#{dir}" colspan -= 1 <<-HTML #{html} <tr> #{padding_td} <td colspan="#{colspan}"> <a href=\"#{url}\"> <i class="icon icon-folder-open"></i> #{dir} </a> </td> </tr> HTML end end |
#tree_entries(tree) ⇒ Object
26 27 28 29 |
# File 'lib/dolt/view/tree.rb', line 26 def tree_entries(tree) sort(tree.entries.select { |e| e[:type] == :tree }) + sort(tree.entries.select { |e| e[:type] == :blob }) end |
#tree_table_padding_td(path) ⇒ Object
55 56 57 |
# File 'lib/dolt/view/tree.rb', line 55 def tree_table_padding_td(path) "<td></td>" * tree_table_padding_width(path) end |
#tree_table_padding_width(path) ⇒ Object
59 60 61 |
# File 'lib/dolt/view/tree.rb', line 59 def tree_table_padding_width(path) path.split("/").length end |
#tree_url(repository, ref, path) ⇒ Object
22 23 24 |
# File 'lib/dolt/view/tree.rb', line 22 def tree_url(repository, ref, path) repo_url(repository, "/tree/#{ref}:#{path}") end |