Wiki#pages only returns pages

This commit is contained in:
rick
2010-07-14 12:26:51 -07:00
parent 0e888454ba
commit 6bd375de2e
3 changed files with 33 additions and 20 deletions
+23 -2
View File
@@ -15,6 +15,27 @@ module Gollum
:pod => "Pod",
:roff => "roff" }
# Checks if a filename has a valid extension understood by GitHub::Markup.
#
# filename - String filename, like "Home.md".
#
# Returns the matching String basename of the file without the extension.
def self.valid_filename?(filename)
filename && filename.to_s =~ VALID_PAGE_RE && $1
end
# Checks if a filename has a valid extension understood by GitHub::Markup.
# Also, checks if the filename has no "_" in the front (such as
# _Footer.md).
#
# filename - String filename, like "Home.md".
#
# Returns the matching String basename of the file without the extension.
def self.valid_page_name?(filename)
match = valid_filename?(filename)
filename =~ /^_/ ? false : match
end
# Public: Initialize a page.
#
# wiki - The Gollum::Wiki in question.
@@ -228,8 +249,8 @@ module Gollum
#
# Returns a Boolean.
def page_match(name, filename)
if filename =~ VALID_PAGE_RE
Page.cname(name) == Page.cname($1)
if match = self.class.valid_filename?(filename)
Page.cname(name) == Page.cname(match)
else
false
end
+3 -1
View File
@@ -222,7 +222,9 @@ module Gollum
tree.contents.each do |item|
case item
when Grit::Blob
list << @page_class.new(self).populate(item, path)
if @page_class.valid_page_name?(item.name)
list << @page_class.new(self).populate(item, path)
end
when Grit::Tree
list.push *tree_list(item, path)
end