Sha256: 8408c742695e746d888b91b5c780aaa0bc13fee6dca148ffa8bf85fdf84fa85a

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

module Webgit
  module GitHelper
  
    def navigation
      ps = (params[:path] || "").split("/")
      i = -1
      nav = ps.map do|p|      
        i += 1
        if i < ps.length - 1
          link_to p, webgit_tree_path(params[:branch], ps[0..i].join('/'))
        else
          p
        end      
      end.join(" / ")
      raw nav
    end
  
  
    def git_tree_path(item)
      if params[:path]
        webgit_tree_path(params[:branch], "#{params[:path]}/#{item}")
      else
        webgit_tree_path(params[:branch], item)
      end
    end

    def git_blob_path(item)
      if params[:path]
        webgit_blob_path(params[:branch], "#{params[:path]}/#{item}")
      else
        webgit_blob_path(params[:branch], item)
      end
    end

    def upper_path()
      paths = params[:path].try(:split, "/")
      if paths
        path_url = paths.tap{|ps|ps.pop}.join("/")      
      end
      webgit_tree_path(params[:branch], path_url)
    end
  
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webgit-0.0.2 app/helpers/webgit/git_helper.rb
webgit-0.0.1 app/helpers/webgit/git_helper.rb