lib/gollum/page.rb in gollum-bibanon-1.4.0 vs lib/gollum/page.rb in gollum-bibanon-1.4.1

- old
+ new

@@ -74,26 +74,17 @@ nil end end # Reusable filter to turn a filename (without path) into a canonical name. - # Strips extension, converts dashes to spaces. + # Strips extension, converts spaces to dashes. # # Returns the filtered String. def self.canonicalize_filename(filename) - strip_filename(filename).gsub('-', ' ') + filename.split('.')[0..-2].join('.').gsub('-', ' ') end - # Reusable filter to strip extension and path from filename - # - # filename - The string path or filename to strip - # - # Returns the stripped String. - def self.strip_filename(filename) - ::File.basename(filename, ::File.extname(filename)) - end - # Public: Initialize a page. # # wiki - The Gollum::Wiki in question. # # Returns a newly initialized Gollum::Page. @@ -107,17 +98,10 @@ # Returns the String name. def filename @blob && @blob.name end - # Public: The on-disk filename of the page with extension stripped. - # - # Returns the String name. - def filename_stripped - self.class.strip_filename(filename) - end - # Public: The canonical page name without extension, and dashes converted # to spaces. # # Returns the String name. def name @@ -258,26 +242,21 @@ # ######################################################################### # Convert a human page name into a canonical page name. # - # name - The String human page name. - # char_white_sub - Substitution for whitespace - # char_other_sub - Substitution for other special chars + # name - The String human page name. # # Examples # # Page.cname("Bilbo Baggins") # # => 'Bilbo-Baggins' # - # Page.cname("Bilbo Baggins",'_') - # # => 'Bilbo_Baggins' - # # Returns the String canonical name. - 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) : + def self.cname(name) + name.respond_to?(:gsub) ? + name.gsub(%r{[ /<>]}, '-') : '' end # Convert a format Symbol into an extension String. # @@ -387,14 +366,13 @@ # filename - the String filename on disk (including extension). # # Returns a Boolean. def page_match(name, filename) if match = self.class.valid_filename?(filename) - @wiki.ws_subs.each do |sub| - return true if Page.cname(name).downcase == Page.cname(match, sub).downcase - end + Page.cname(name).downcase == Page.cname(match).downcase + else + false end - false end # Loads a sub page. Sub page nanes (footers) are prefixed with # an underscore to distinguish them from other Pages. #