Refactor of search view

This commit is contained in:
Henrik Hansen
2010-08-29 13:34:08 +02:00
parent 294847ed99
commit ed41152228
3 changed files with 4 additions and 8 deletions
+2 -2
View File
@@ -129,8 +129,8 @@ module Precious
end
get '/search' do
@q = params[:q]
@search_command = "cd #{$path} && git grep -c '#{@q}' master"
@query = params[:q]
@search_command = "cd #{$path} && git grep -c '#{@query}' master"
@results = `#{@search_command}`
mustache :search
end
@@ -5,7 +5,7 @@
<a href="/">Home</a> | <input type="search" name="q" size="10" /> <input type="submit" value="search" />
</form>
</div>
<h1>Search for “{{search_string}}”</h1>
<h1>Search for “{{query}}”</h1>
<div class="content wikistyle gollum">
{{#has_results}}
<ul>
+1 -5
View File
@@ -1,11 +1,7 @@
module Precious
module Views
class Search < Layout
attr_reader :content, :page, :footer
def search_string
@q
end
attr_reader :content, :page, :footer, :query
def has_results
!results.empty?