Class: Page

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/directory_listing/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def current_page
  @current_page
end

#embed_inObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def embed_in
  @embed_in
end

#faviconObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def favicon
  @favicon
end

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def file_sort_link
  @file_sort_link
end

#filename_truncate_lengthObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def filename_truncate_length
  @filename_truncate_length
end

#files_htmlObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def files_html
  @files_html
end

#last_modified_formatObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def last_modified_format
  @last_modified_format
end

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def mtime_sort_link
  @mtime_sort_link
end

Generate the page’s navigation bar



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def nav_bar
  @nav_bar
end

#public_folderObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def public_folder
  @public_folder
end

#readmeObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def readme
  @readme
end

#request_paramsObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def request_params
  @request_params
end

#request_params_displayObject

Get URL-appendable (Hash -> String) parameters for a request



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def request_params_display
  @request_params_display
end

#request_pathObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def request_path
  @request_path
end

#should_list_invisiblesObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def should_list_invisibles
  @should_list_invisibles
end

#should_show_file_extsObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def should_show_file_exts
  @should_show_file_exts
end

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def size_sort_link
  @size_sort_link
end

#smart_sortObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def smart_sort
  @smart_sort
end

#sort_directionObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def sort_direction
  @sort_direction
end

#sort_direction_displayObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def sort_direction_display
  @sort_direction_display
end

#sort_itemObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def sort_item
  @sort_item
end

#sort_item_displayObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def sort_item_display
  @sort_item_display
end

#stylesheetObject

Class definition for the page to be generated.



6
7
8
# File 'lib/sinatra/directory_listing/page.rb', line 6

def stylesheet
  @stylesheet
end

Instance Method Details

#sorting_info(s_item, s_direction) ⇒ Object

Return sorting information given an item and the sorting direction



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/sinatra/directory_listing/page.rb', line 91

def sorting_info(s_item, s_direction)

  file_link_dir = mtime_link_dir = sortby_link_dir = "ascending"
  s_item_display = s_direction_display = ""
  
  case s_item
  when "file"
    s_item_display = "alphabetically"
    case s_direction
    when "ascending"
      s_direction_display = ""
      file_link_dir = "descending"
    when "descending"
      s_direction_display = "reversed"
      file_link_dir = "ascending"
    end
  when "mtime"
    s_item_display = "by modification date"
    case s_direction
    when "ascending"
      s_direction_display = "oldest to newest"
      mtime_link_dir = "descending"
    when "descending"
      s_direction_display = "newest to oldest"
      mtime_link_dir = "ascending"
    end
  when "size"
    s_item_display = "by size"
    case s_direction
    when "ascending"
      s_direction_display = "smallest to largest"
      sortby_link_dir = "descending"
    when "descending"
      s_direction_display = "largest to smallest"
      sortby_link_dir = "ascending"
    end
  end
  
  return  "?sortby=file&direction=#{file_link_dir}",
          "?sortby=mtime&direction=#{mtime_link_dir}",
          "?sortby=size&direction=#{sortby_link_dir}",
          s_item_display,
          s_direction_display
  
end