Merge pull request #419 from trans/metadata
Add support for embedded page metadata.
This commit is contained in:
@@ -517,6 +517,57 @@ np.array([[2,2],[1,3]],np.float)
|
||||
assert_not_nil rendered.match(output)
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Metadata Blocks
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
test "metadata blocks" do
|
||||
content = "a\n\n<!-- ---\ntags: [foo, bar]\n-->\n\nb"
|
||||
output = "<p>a</p>\n\n<p>b</p>"
|
||||
result = {'tags'=>['foo','bar']}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
index.commit("Add metadata")
|
||||
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
rendered = Gollum::Markup.new(page).render
|
||||
assert_equal output, rendered
|
||||
assert_equal result, page.meta_data
|
||||
end
|
||||
|
||||
test "metadata blocks with newline" do
|
||||
content = "a\n\n<!--\n---\ntags: [foo, bar]\n-->\n\nb"
|
||||
output = "<p>a</p>\n\n<p>b</p>"
|
||||
result = {'tags'=>['foo','bar']}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
index.commit("Add metadata")
|
||||
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
rendered = Gollum::Markup.new(page).render
|
||||
assert_equal output, rendered
|
||||
assert_equal result, page.meta_data
|
||||
end
|
||||
|
||||
test "metadata sanitation" do
|
||||
content = "a\n\n<!-- ---\nfoo: <script>alert('');</script>\n-->\n\nb"
|
||||
output = "<p>a</p>\n\n<p>b</p>"
|
||||
result = {'foo'=>nil}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
index.commit("Add metadata")
|
||||
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
rendered = Gollum::Markup.new(page).render
|
||||
assert_equal output, rendered
|
||||
assert_equal result, page.meta_data
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Various
|
||||
|
||||
Reference in New Issue
Block a user