Properly handle pages that exist in sub-dirs in search results

This commit is contained in:
Jon Frisby
2010-08-29 22:23:14 -07:00
committed by Henrik Hansen
parent 50c207ad91
commit e9239050e0
2 changed files with 11 additions and 3 deletions
+9 -1
View File
@@ -35,6 +35,14 @@ module Gollum
filename =~ /^_/ ? false : match
end
# Reusable filter to turn a filename (without path) into a canonical name.
# Strips extension, converts spaces to dashes.
#
# Returns the filtered String.
def self.canonicalize_filename(filename)
filename.split('.')[0..-2].join('.').gsub('-', ' ')
end
# Public: Initialize a page.
#
# wiki - The Gollum::Wiki in question.
@@ -57,7 +65,7 @@ module Gollum
#
# Returns the String name.
def name
filename.split('.')[0..-2].join('.').gsub('-', ' ')
self.class.canonicalize_filename(filename)
end
# Public: If the first element of a formatted page is an <h1> tag it can
+2 -2
View File
@@ -219,11 +219,11 @@ module Gollum
search_output.split("\n").collect do |line|
result = line.split(':')
file_name = result[1]
file_name = Gollum::Page.canonicalize_filename(::File.basename(result[1]))
{
:count => result[2].to_i,
:name => file_name.split('.').first
:name => file_name
}
end
end