diff --git a/lib/url_generator.rb b/lib/url_generator.rb index efc3a501..b6da0a15 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -7,8 +7,6 @@ class AbstractUrlGenerator @controller = controller end - attr :controller - # Create a link for the given page (or file) name and link text based # on the render mode in options and whether the page (file) exists # in the web. @@ -55,7 +53,10 @@ class AbstractUrlGenerator raise "Unknown link type: #{link_type}" end end - + + def url_for(hash = {}) + @controller.url_for hash + end end class UrlGenerator < AbstractUrlGenerator diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index 1dee5657..33eaabdb 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -146,8 +146,8 @@ class WikiContent < String if @options[:engine] == Engines::MarkdownPNG @options[:png_url] = @options[:mode] == :export ? 'files/pngs/' : - (@url_generator.controller.url_for :controller => 'file', :web => @web.address, - :action => 'file', :id => 'pngs', :only_path => true) + '/' + (@url_generator.url_for :controller => 'file', :web => @web.address, + :action => 'file', :id => 'pngs', :only_path => true) + '/' end @not_rendered = @pre_rendered = nil diff --git a/test/test_helper.rb b/test/test_helper.rb index 487fe4ee..ca143480 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -104,13 +104,13 @@ end class StubUrlGenerator < AbstractUrlGenerator def initialize - controller = Object.new - def controller.url_for(options = {}) - '../files/pngs' - end - super(controller) + super(:doesnt_need_controller) end - + + def url_for(hash = {}) + '../files/pngs' + end + def file_link(mode, name, text, web_name, known_file, description) link = CGI.escape(name) case mode