fix bug where relative images in previews did not render
This commit is contained in:
+2
-2
@@ -333,9 +333,9 @@ module Gollum
|
|||||||
# path - The String directory path of the page file.
|
# path - The String directory path of the page file.
|
||||||
#
|
#
|
||||||
# Returns the populated Gollum::Page.
|
# Returns the populated Gollum::Page.
|
||||||
def populate(blob, path)
|
def populate(blob, path=nil)
|
||||||
@blob = blob
|
@blob = blob
|
||||||
@path = (path + '/' + blob.name)[1..-1]
|
@path = "#{path}/#{blob.name}"[1..-1]
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -168,10 +168,10 @@ module Gollum
|
|||||||
def preview_page(name, data, format)
|
def preview_page(name, data, format)
|
||||||
page = @page_class.new(self)
|
page = @page_class.new(self)
|
||||||
ext = @page_class.format_to_ext(format.to_sym)
|
ext = @page_class.format_to_ext(format.to_sym)
|
||||||
path = @page_class.cname(name) + '.' + ext
|
name = @page_class.cname(name) + '.' + ext
|
||||||
blob = OpenStruct.new(:name => path, :data => data)
|
blob = OpenStruct.new(:name => name, :data => data)
|
||||||
page.populate(blob, path)
|
page.populate(blob)
|
||||||
page.version = @access.commit('HEAD')
|
page.version = @access.commit('master')
|
||||||
page
|
page
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,27 @@ context "Markup" do
|
|||||||
assert_equal %{<p>a <img src="/wiki/greek/alpha.jpg" /><a href="/wiki/greek/alpha.jpg">a</a> b</p>}, output
|
assert_equal %{<p>a <img src="/wiki/greek/alpha.jpg" /><a href="/wiki/greek/alpha.jpg">a</a> b</p>}, output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "image with absolute path on a preview" do
|
||||||
|
@wiki = Gollum::Wiki.new(@path, :base_path => '/wiki')
|
||||||
|
index = @wiki.repo.index
|
||||||
|
index.add("alpha.jpg", "hi")
|
||||||
|
index.commit("Add alpha.jpg")
|
||||||
|
|
||||||
|
page = @wiki.preview_page("Test", "a [[/alpha.jpg]] b", :markdown)
|
||||||
|
assert_equal %{<p>a <img src="/wiki/alpha.jpg" /> b</p>}, page.formatted_data
|
||||||
|
end
|
||||||
|
|
||||||
|
test "image with relative path on a preview" do
|
||||||
|
@wiki = Gollum::Wiki.new(@path, :base_path => '/wiki')
|
||||||
|
index = @wiki.repo.index
|
||||||
|
index.add("alpha.jpg", "hi")
|
||||||
|
index.add("greek/alpha.jpg", "hi")
|
||||||
|
index.commit("Add alpha.jpg")
|
||||||
|
|
||||||
|
page = @wiki.preview_page("Test", "a [[alpha.jpg]] [[greek/alpha.jpg]] b", :markdown)
|
||||||
|
assert_equal %{<p>a <img src="/wiki/alpha.jpg" /><img src="/wiki/greek/alpha.jpg" /> b</p>}, page.formatted_data
|
||||||
|
end
|
||||||
|
|
||||||
test "image with alt" do
|
test "image with alt" do
|
||||||
content = "a [[alpha.jpg|alt=Alpha Dog]] b"
|
content = "a [[alpha.jpg|alt=Alpha Dog]] b"
|
||||||
output = %{<p>a <img src="/greek/alpha.jpg" alt="Alpha Dog" /> b</p>}
|
output = %{<p>a <img src="/greek/alpha.jpg" alt="Alpha Dog" /> b</p>}
|
||||||
|
|||||||
Reference in New Issue
Block a user