implement version-specific page find
This commit is contained in:
@@ -263,8 +263,7 @@ Get a list of versions for a given page:
|
|||||||
|
|
||||||
Get a specific version of a given canonical page file:
|
Get a specific version of a given canonical page file:
|
||||||
|
|
||||||
gollum.formatted_page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
gollum.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
||||||
gollum.raw_page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
|
||||||
|
|
||||||
Get the latest version of a given static file:
|
Get the latest version of a given static file:
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -83,11 +83,12 @@ module Gollum
|
|||||||
|
|
||||||
# Find a page in the given Gollum repo.
|
# 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.
|
# Returns a Gollum::Page or nil if the page could not be found.
|
||||||
def find(name)
|
def find(name, version)
|
||||||
commit = self.wiki.repo.commits.first
|
commit = self.wiki.repo.commit(version)
|
||||||
if page = find_page_in_tree(commit.tree, name)
|
if page = find_page_in_tree(commit.tree, name)
|
||||||
page.version = commit
|
page.version = commit
|
||||||
page
|
page
|
||||||
|
|||||||
+4
-3
@@ -14,11 +14,12 @@ module Gollum
|
|||||||
|
|
||||||
# Get the formatted page for a given page name.
|
# 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.
|
# Returns a Gollum::Page or nil if no matching page was found.
|
||||||
def page(name)
|
def page(name, version = 'master')
|
||||||
Page.new(self).find(name)
|
Page.new(self).find(name, version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -32,6 +32,11 @@ context "Page" do
|
|||||||
page.versions.map { |v| v.id }
|
page.versions.map { |v| v.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "specific page version" do
|
||||||
|
page = @wiki.page('Bilbo Baggins', 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb')
|
||||||
|
assert_equal 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb', page.version.id
|
||||||
|
end
|
||||||
|
|
||||||
test "no page match" do
|
test "no page match" do
|
||||||
assert_nil @wiki.page('I do not exist')
|
assert_nil @wiki.page('I do not exist')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user