lib/gollum/views/search.rb in gollum-4.1.4 vs lib/gollum/views/search.rb in gollum-5.0.0
- old
+ new
@@ -1,11 +1,37 @@
module Precious
module Views
class Search < Layout
- attr_reader :content, :page, :footer, :results, :query
+ attr_reader :query, :search_terms
+ include Pagination
+ def results
+ @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)
+ end
+
+ def query_string
+ "&q=#{@query}"
+ end
+
def title
"Search results for " + @query
+ end
+
+ def search
+ true # View has searchbar
+ end
+
+ def has_search_terms
+ !@search_terms.empty?
end
def has_results
!@results.empty?
end