lib/sinatra/directory_listing/page.rb
def nav_bar
    path_array = self.current_page.split("/").drop(1)
    path_count = path_array.count
    params = self.request_params_display
  
    if CGI.unescape(self.current_page) == "/"
      nav_bar = "Index of /"
    else
      nav_bar = "Index of <a href=\'/#{params}'>/</a>"
    end
      
    previous_path = ""
    0.upto(path_array.count - 1) do |a|
      
      ##
      # Get escaped versions of this path and previous path
      
      escaped_path = path_array[a].gsub(" ", "%20").gsub("'", "%27")
      escaped_previous = previous_path.gsub(" ", "%20").gsub("'", "%27")
      
      ##
      # If this is the last directory in the path, it shouldn't have a link
      
      if a == path_array.count - 1
        href = ""
      else
        href = "<a href=\'/#{escaped_previous}#{escaped_path}#{params}\'>"
      end
      
      ##
      # If this is the first directory above the root, don't prepend a slash
      
      if a == 0 
      nav_bar << " #{href}#{path_array[a]}</a>"
      else
        nav_bar << " / #{href}#{path_array[a]}</a>"
      end
      
      previous_path << path_array[a] + "/"
    end
    
    @nav_bar = nav_bar
    
  end
##
# Generate the page's navigation bar
Generate the page's navigation bar
Generate the page ' s navigation bar
def nav_bar
    path_array = self.current_page.split("/").drop(1)
    path_count = path_array.count
    params = self.request_params_display
    if CGI.unescape(self.current_page) == "/"
      nav_bar = "Index of /"
    else
      nav_bar = "Index of <a href=\'/#{params}'>/</a>"
    end
    previous_path = ""
    0.upto(path_array.count - 1) do |a|
      escaped_path = path_array[a].gsub(" ", "%20").gsub("'", "%27")
      escaped_previous = previous_path.gsub(" ", "%20").gsub("'", "%27")
      if a == path_array.count - 1
        href = ""
      else
        href = "<a href=\'/#{escaped_previous}#{escaped_path}#{params}\'>"
      end
      if a == 0 
      nav_bar << " #{href}#{path_array[a]}</a>"
      else
        nav_bar << " / #{href}#{path_array[a]}</a>"
      end
      previous_path << path_array[a] + "/"
    end
    @nav_bar = nav_bar
  end
def nav_bar path_array = self . current_page . split ( "/" ) . drop ( 1 ) path_count = path_array . count params = self . request_params_display if CGI . unescape ( self . current_page ) == "/" nav_bar = "Index of /" else nav_bar = "Index of <a href=\'/#{params}'>/</a>" end previous_path = "" 0 . upto ( path_array . count - 1 ) do | a | escaped_path = path_array [ a ] . gsub ( " " , "%20" ) . gsub ( "'" , "%27" ) escaped_previous = previous_path . gsub ( " " , "%20" ) . gsub ( "'" , "%27" ) if a == path_array . count - 1 href = "" else href = "<a href=\'/#{escaped_previous}#{escaped_path}#{params}\'>" end if a == 0 nav_bar << " #{href}#{path_array[a]}</a>" else nav_bar << " / #{href}#{path_array[a]}</a>" end previous_path << path_array [ a ] + "/" end @nav_bar = nav_bar end
Generate the page's navigation bar
Generate the page ' s navigation bar
## # Get escaped versions of this path and previous path ## # If this is the last directory in the path, it shouldn't have a link ## # If this is the first directory above the root, don't prepend a slash