class Repobrowse::GitRawTreeHTML

ugly “raw” tree view, “git_src_tree_html” has the prettier one

Public Class Methods

new(tree, ref, path) click to toggle source
# File lib/repobrowse/git_raw_tree_html.rb, line 10
def initialize(tree, ref, path)
  @tree = tree
  @ref = ref
  @path = path # nil ok
end

Public Instance Methods

close() click to toggle source
# File lib/repobrowse/git_raw_tree_html.rb, line 47
def close
end
each() { |"<html><head><title>#{t}</title></head><body><h2>#{t}</h2><ul>"| ... } click to toggle source
# File lib/repobrowse/git_raw_tree_html.rb, line 16
def each
  if @path
    t = ht(+"/#@path/")
    path = @path.split('/')
    case path.size
    when 1
      ref = CGI.escape(@ref.split('/')[-1])
      pfx = "./#{ref}:#{CGI.escape(path[0])}/"
      up = ha('./' + ref)
    else
      pfx = "#{CGI.escape(path[-1])}/"
      up = "#@ref:#@path".split('/')[-2]
      up = up.split(':').map! { |u| CGI.escape(u) }.join(':')
      up = ha('../' + up)
    end
  else
    t = '/'
    pfx = "./#{CGI.escape(@ref.split('/')[-1])}:"
  end
  yield "<html><head><title>#{t}</title></head><body><h2>#{t}</h2><ul>"
  yield %Q(<li><a\nhref=#{up}>../</a></li>) if up
  @tree.each do |ent|
    name = ent[:name]
    href = ha(pfx + CGI.escape(name))
    name = ht(name)
    yield %Q(<li><a\nhref=#{href}>#{name}</a></li>)
  end
  yield '</ul></body></html>'
  self
end