Refactor of search view
This commit is contained in:
@@ -129,8 +129,8 @@ module Precious
|
|||||||
end
|
end
|
||||||
|
|
||||||
get '/search' do
|
get '/search' do
|
||||||
@q = params[:q]
|
@query = params[:q]
|
||||||
@search_command = "cd #{$path} && git grep -c '#{@q}' master"
|
@search_command = "cd #{$path} && git grep -c '#{@query}' master"
|
||||||
@results = `#{@search_command}`
|
@results = `#{@search_command}`
|
||||||
mustache :search
|
mustache :search
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<a href="/">Home</a> | <input type="search" name="q" size="10" /> <input type="submit" value="search" />
|
<a href="/">Home</a> | <input type="search" name="q" size="10" /> <input type="submit" value="search" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<h1>Search for “{{search_string}}”</h1>
|
<h1>Search for “{{query}}”</h1>
|
||||||
<div class="content wikistyle gollum">
|
<div class="content wikistyle gollum">
|
||||||
{{#has_results}}
|
{{#has_results}}
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
module Precious
|
module Precious
|
||||||
module Views
|
module Views
|
||||||
class Search < Layout
|
class Search < Layout
|
||||||
attr_reader :content, :page, :footer
|
attr_reader :content, :page, :footer, :query
|
||||||
|
|
||||||
def search_string
|
|
||||||
@q
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_results
|
def has_results
|
||||||
!results.empty?
|
!results.empty?
|
||||||
|
|||||||
Reference in New Issue
Block a user