Class: Precious::Views::Overview
- Defined in:
- lib/gollum/views/overview.rb
Constant Summary collapse
- HIDDEN_PATHS =
['.gitkeep']
Constants included from RouteHelpers
Constants included from LocaleHelpers
LocaleHelpers::NO_METHOD_MESSAGE, LocaleHelpers::YAML_VARIABLE_REGEXP
Instance Attribute Summary collapse
-
#allow_editing ⇒ Object
readonly
Returns the value of attribute allow_editing.
-
#newable ⇒ Object
readonly
Returns the value of attribute newable.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Attributes inherited from Layout
Instance Method Summary collapse
- #breadcrumb ⇒ Object
-
#current_path ⇒ Object
def editable false end.
- #files_folders ⇒ Object
- #has_results ⇒ Object
- #latest_changes ⇒ Object
- #no_results ⇒ Object
- #title ⇒ Object
Methods inherited from Layout
#base_url, #critic_markup, #css, #custom_css, #custom_js, #custom_path, #escaped_name, #has_path, #history, #js, #mathjax_config_path, #mathjax_js, #overview, #partial, #per_page_uploads, #search, #show_local_time
Methods included from TemplateCascade
#first_path_available, #template_file, #template_priority_path, #template_priority_path=
Methods included from OcticonHelpers
included, #octicon, #rocticon, #rocticon_css
Methods included from RouteHelpers
#clean_url, included, #page_route, parse_routes
Methods included from SprocketsHelpers
included, #sprockets_asset_path, #sprockets_image_path, #sprockets_javascript_tag, #sprockets_stylesheet_tag
Methods included from LocaleHelpers
Methods included from AppHelpers
Instance Attribute Details
#allow_editing ⇒ Object (readonly)
Returns the value of attribute allow_editing.
6 7 8 |
# File 'lib/gollum/views/overview.rb', line 6 def allow_editing @allow_editing end |
#newable ⇒ Object (readonly)
Returns the value of attribute newable.
6 7 8 |
# File 'lib/gollum/views/overview.rb', line 6 def newable @newable end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
6 7 8 |
# File 'lib/gollum/views/overview.rb', line 6 def ref @ref end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
6 7 8 |
# File 'lib/gollum/views/overview.rb', line 6 def results @results end |
Instance Method Details
#breadcrumb ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gollum/views/overview.rb', line 21 def if @path path = Pathname.new(@path) = [%{<nav aria-label="Breadcrumb"><ol><li class="breadcrumb-item"><a href="#{overview_path}">Home</a></li>}] path.descend do |crumb| title = crumb.basename if title == path.basename << %{<li class="breadcrumb-item" aria-current="page">#{CGI.escapeHTML(title.to_s)}</li>} else << %{<li class="breadcrumb-item"><a href="#{overview_path}/#{crumb}/">#{CGI.escapeHTML(title.to_s)}</a></li>} end end << %{</ol></nav>} .join("\n") else 'Home' end end |
#current_path ⇒ Object
def editable
false
end
17 18 19 |
# File 'lib/gollum/views/overview.rb', line 17 def current_path @path ? @path : '/' end |
#files_folders ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gollum/views/overview.rb', line 42 def files_folders if has_results files_and_folders = [] @results.each do |result| result_path = result.url_path result_path = result_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil? if result_path.include?('/') # result contains a folder folder_name = result_path.split('/').first folder_path = @path ? "#{@path}/#{folder_name}" : folder_name folder_url = "#{overview_path}/#{folder_path}/" files_and_folders << {name: folder_name, icon: rocticon('file-directory'), type: 'dir', url: folder_url, is_file: false} elsif !HIDDEN_PATHS.include?(result_path) file_url = page_route(result.escaped_url_path) files_and_folders << {name: result.filename, icon: rocticon('file'), type: 'file', url: file_url, file_path: result.escaped_url_path, is_file: true} end end # 1012: Overview should list folders first, followed by files and pages sorted alphabetically files_and_folders.uniq{|f| f[:name]}.sort_by!{|f| [f[:type], f[:name]]} end end |
#has_results ⇒ Object
66 67 68 |
# File 'lib/gollum/views/overview.rb', line 66 def has_results !@results.empty? end |
#latest_changes ⇒ Object
74 75 76 |
# File 'lib/gollum/views/overview.rb', line 74 def latest_changes true end |
#no_results ⇒ Object
70 71 72 |
# File 'lib/gollum/views/overview.rb', line 70 def no_results @results.empty? end |
#title ⇒ Object
9 10 11 |
# File 'lib/gollum/views/overview.rb', line 9 def title "Overview of #{@ref}" end |