diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 4ada4b5e..f1e091a7 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -12,6 +12,7 @@ module Gollum @name = page.name @data = page.raw_data @version = page.version.id + @dir = ::File.dirname(page.path) @tagmap = {} end @@ -78,12 +79,17 @@ module Gollum if name =~ /^\// if file = @wiki.file(name[1..-1], @version) - %{} + %{} else nil end else - nil + path = ::File.join(@dir, name) + if file = @wiki.file(path, @version) + %{} + else + nil + end end end diff --git a/test/test_markup.rb b/test/test_markup.rb index 08134359..7d33e648 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -24,15 +24,26 @@ context "Markup" do assert_equal %{

a Bilbo Baggins b

\n}, output end - test "image" do + test "image with absolute path" do index = @wiki.repo.index index.add("alpha.jpg", "hi") index.commit("Add alpha.jpg") - @wiki.write_page("Bilbo Baggins", :markdown, "a [[/alpha.jpg]] b", @commit) page = @wiki.page("Bilbo Baggins") output = Gollum::Markup.new(page).render - assert_equal %{

a b

\n}, output + assert_equal %{

a b

\n}, output end + + test "image with relative path" do + index = @wiki.repo.index + index.add("greek/alpha.jpg", "hi") + index.add("greek/Bilbo-Baggins.md", "a [[alpha.jpg]] b") + index.commit("Add alpha.jpg") + + page = @wiki.page("Bilbo Baggins") + output = Gollum::Markup.new(page).render + assert_equal %{

a b

\n}, output + end + end