Class: Precious::Views::Search

Inherits:
Layout
  • Object
show all
Includes:
Pagination
Defined in:
lib/gollum/views/search.rb

Constant Summary

Constants included from RouteHelpers

RouteHelpers::ROUTES

Constants included from LocaleHelpers

LocaleHelpers::NO_METHOD_MESSAGE, LocaleHelpers::YAML_VARIABLE_REGEXP

Instance Attribute Summary collapse

Attributes inherited from Layout

#name, #path

Instance Method Summary collapse

Methods included from Pagination

#next_page, #previous_page

Methods inherited from Layout

#base_url, #critic_markup, #css, #custom_css, #custom_js, #custom_path, #escaped_name, #has_path, #history, #js, #latest_changes, #mathjax_js, #mermaid, #overview, #partial, #per_page_uploads, #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

#t, #tt

Methods included from AppHelpers

#extract_page_dir

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



4
5
6
# File 'lib/gollum/views/search.rb', line 4

def query
  @query
end

#search_termsObject (readonly)

Returns the value of attribute search_terms.



4
5
6
# File 'lib/gollum/views/search.rb', line 4

def search_terms
  @search_terms
end

Instance Method Details

#has_resultsObject



37
38
39
# File 'lib/gollum/views/search.rb', line 37

def has_results
  !@results.empty?
end

#has_search_termsObject



33
34
35
# File 'lib/gollum/views/search.rb', line 33

def has_search_terms
  !@search_terms.empty?
end

#no_resultsObject



41
42
43
# File 'lib/gollum/views/search.rb', line 41

def no_results
  @results.empty?
end

#query_stringObject



21
22
23
# File 'lib/gollum/views/search.rb', line 21

def query_string
  "&q=%s" % CGI.escape(@query)
end

#resultsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gollum/views/search.rb', line 7

def results
  sorted = @results.sort do |a, b|
    if b.nil?
      b_filename_count = 0
      b_count          = 0
    else
      b_filename_count = b[:filename_count]
      b_count          = b[:count]
    end
    [a[:filename_count], a[:count]] <=> [b_filename_count, b_count]
  end.reverse.slice((@page_num - 1) * @max_count, @max_count)
  sorted.each {|x| x[:href] = page_route(x[:name])}
end

#searchObject



29
30
31
# File 'lib/gollum/views/search.rb', line 29

def search
  true # View has searchbar
end

#titleObject



25
26
27
# File 'lib/gollum/views/search.rb', line 25

def title
  t[:title]
end