Refactoring of Wiki.search.
This commit is contained in:
+9
-12
@@ -214,20 +214,17 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns an Array with Objects of page name and count of matches
|
# Returns an Array with Objects of page name and count of matches
|
||||||
def search(query)
|
def search(query)
|
||||||
search_command = "cd #{$path} && git grep -c '#{query}' master"
|
search_output = `cd #{$path} && git grep -c '#{query}' master`
|
||||||
command_output = `#{search_command}`
|
|
||||||
results = []
|
search_output.split("\n").collect do |line|
|
||||||
command_output.each_line do |line|
|
result = line.split(':')
|
||||||
result = line.split(":")
|
file_name = result[1]
|
||||||
file = result[1]
|
|
||||||
count = result[2].to_i
|
{
|
||||||
name = file.split(".")[0]
|
:count => result[2].to_i,
|
||||||
results << {
|
:name => file_name.split('.').first
|
||||||
:name => name,
|
|
||||||
:count => count
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
results
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: All of the versions that have touched the Page.
|
# Public: All of the versions that have touched the Page.
|
||||||
|
|||||||
Reference in New Issue
Block a user