Refactor of search view
This commit is contained in:
@@ -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,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?
|
||||
|
||||
Reference in New Issue
Block a user