class Precious::Views::Overview

Constants

HIDDEN_PATHS

Attributes

allow_editing[R]
name[R]
newable[R]
ref[R]
results[R]

Public Instance Methods

breadcrumb() click to toggle source
current_path() click to toggle source

def editable

false

end

# File lib/gollum/views/overview.rb, line 17
def current_path
  @path ? @path : '/'
end
files_folders() click to toggle source
# 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-fill'), 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() click to toggle source
# File lib/gollum/views/overview.rb, line 66
def has_results
  !@results.empty?
end
latest_changes() click to toggle source
# File lib/gollum/views/overview.rb, line 74
def latest_changes
  true
end
no_results() click to toggle source
# File lib/gollum/views/overview.rb, line 70
def no_results
  @results.empty?
end
title() click to toggle source
# File lib/gollum/views/overview.rb, line 9
def title
  t[:title]
end