implement version-specific page find

This commit is contained in:
Tom Preston-Werner
2010-04-11 12:40:29 -06:00
parent 14b29135a8
commit 769bf89587
4 changed files with 14 additions and 8 deletions
+1 -2
View File
@@ -263,8 +263,7 @@ Get a list of versions for a given page:
Get a specific version of a given canonical page file:
gollum.formatted_page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
gollum.raw_page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
gollum.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
Get the latest version of a given static file:
+4 -3
View File
@@ -83,11 +83,12 @@ module Gollum
# Find a page in the given Gollum repo.
#
# name - The human or canonical String page name to find.
# name - The human or canonical String page name to find.
# version - The String version ID to find.
#
# Returns a Gollum::Page or nil if the page could not be found.
def find(name)
commit = self.wiki.repo.commits.first
def find(name, version)
commit = self.wiki.repo.commit(version)
if page = find_page_in_tree(commit.tree, name)
page.version = commit
page
+4 -3
View File
@@ -14,11 +14,12 @@ module Gollum
# Get the formatted page for a given page name.
#
# name - The human or canonical String page name of the wiki page.
# name - The human or canonical String page name of the wiki page.
# version - The String version ID to find (default: "master").
#
# Returns a Gollum::Page or nil if no matching page was found.
def page(name)
Page.new(self).find(name)
def page(name, version = 'master')
Page.new(self).find(name, version)
end
end
end
+5
View File
@@ -32,6 +32,11 @@ context "Page" do
page.versions.map { |v| v.id }
end
test "specific page version" do
page = @wiki.page('Bilbo Baggins', 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb')
assert_equal 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb', page.version.id
end
test "no page match" do
assert_nil @wiki.page('I do not exist')
end