Repository page files with spaces, will now match using urls with hyphens, underscores and urlencoded spaces. This is for compatibility with mediawiki conversions.

This commit is contained in:
Arran Cudbard-Bell
2011-05-31 14:30:44 -07:00
committed by Arran Cudbard-Bell
parent 4abc32f1ec
commit af7a52970f
2 changed files with 25 additions and 8 deletions
+13 -7
View File
@@ -237,17 +237,22 @@ module Gollum
# Convert a human page name into a canonical page name.
#
# name - The String human page name.
# name - The String human page name.
# char_white_sub - Substitution for whitespace
# char_other_sub - Substitution for other special chars
#
# Examples
#
# Page.cname("Bilbo Baggins")
# # => 'Bilbo-Baggins'
#
# Page.cname("Bilbo Baggins",'_')
# # => 'Bilbo_Baggins'
#
# Returns the String canonical name.
def self.cname(name)
name.respond_to?(:gsub) ?
name.gsub(%r{[ /<>]}, '-') :
def self.cname(name, char_white_sub = '-', char_other_sub = '-')
name.respond_to?(:gsub) ?
name.gsub(%r{\s},char_white_sub).gsub(%r{[/<>+]}, char_other_sub) :
''
end
@@ -361,10 +366,11 @@ module Gollum
# Returns a Boolean.
def page_match(name, filename)
if match = self.class.valid_filename?(filename)
Page.cname(name).downcase == Page.cname(match).downcase
else
false
@wiki.ws_subs.each do |sub|
return true if Page.cname(name).downcase == Page.cname(match, sub).downcase
end
end
false
end
# Loads a sub page. Sub page nanes (footers) are prefixed with