Class: Precious::Views::Search
- Includes:
- Pagination
- Defined in:
- lib/gollum/views/search.rb
Constant Summary
Constants included from RouteHelpers
Constants included from LocaleHelpers
LocaleHelpers::NO_METHOD_MESSAGE, LocaleHelpers::YAML_VARIABLE_REGEXP
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#search_terms ⇒ Object
readonly
Returns the value of attribute search_terms.
Attributes inherited from Layout
Instance Method Summary collapse
- #has_results ⇒ Object
- #has_search_terms ⇒ Object
- #no_results ⇒ Object
- #query_string ⇒ Object
- #results ⇒ Object
- #search ⇒ Object
- #title ⇒ Object
Methods included from Pagination
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
Methods included from AppHelpers
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
4 5 6 |
# File 'lib/gollum/views/search.rb', line 4 def query @query end |
#search_terms ⇒ Object (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_results ⇒ Object
37 38 39 |
# File 'lib/gollum/views/search.rb', line 37 def has_results !@results.empty? end |
#has_search_terms ⇒ Object
33 34 35 |
# File 'lib/gollum/views/search.rb', line 33 def has_search_terms !@search_terms.empty? end |
#no_results ⇒ Object
41 42 43 |
# File 'lib/gollum/views/search.rb', line 41 def no_results @results.empty? end |
#query_string ⇒ Object
21 22 23 |
# File 'lib/gollum/views/search.rb', line 21 def query_string "&q=%s" % CGI.escape(@query) end |
#results ⇒ Object
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 |
#search ⇒ Object
29 30 31 |
# File 'lib/gollum/views/search.rb', line 29 def search true # View has searchbar end |
#title ⇒ Object
25 26 27 |
# File 'lib/gollum/views/search.rb', line 25 def title t[:title] end |