diff --git a/lib/chunks/engines.rb b/lib/chunks/engines.rb index 4ed078d0..b6bb4a13 100644 --- a/lib/chunks/engines.rb +++ b/lib/chunks/engines.rb @@ -90,7 +90,7 @@ module Engines :html_math_output_png => true, :html_png_engine => 'blahtex', :html_png_dir => @content.web.files_path.join('pngs').to_s, - :html_png_url => '../files/pngs/', + :html_png_url => @content.options[:png_url], :content_only => true, :author => @content.options[:engine_opts][:author], :title => @content.options[:engine_opts][:title]}) @@ -104,7 +104,7 @@ module Engines :html_math_output_png => true, :html_png_engine => 'blahtex', :html_png_dir => @content.web.files_path.join('pngs').to_s, - :html_png_url => '../files/pngs/'}).to_html + :html_png_url => @content.options[:png_url]}).to_html html.gsub(/\A
\n?(.*?)\n?<\/div>\Z/m, '\1') end end diff --git a/lib/url_generator.rb b/lib/url_generator.rb index 9cb87930..efc3a501 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -7,6 +7,8 @@ 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. diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index e047a96a..1dee5657 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -143,6 +143,12 @@ class WikiContent < String @options[:active_chunks] = (ACTIVE_CHUNKS - [WikiChunk::Word] ) if @web.brackets_only? @options[:hide_chunks] = (HIDE_CHUNKS - [Literal::Math] ) unless [Engines::MarkdownMML, Engines::MarkdownPNG].include?(@options[:engine]) + 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) + '/' + end @not_rendered = @pre_rendered = nil diff --git a/test/test_helper.rb b/test/test_helper.rb index 6f005aa9..487fe4ee 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -104,9 +104,13 @@ end class StubUrlGenerator < AbstractUrlGenerator def initialize - super(:doesnt_need_controller) + controller = Object.new + def controller.url_for(options = {}) + '../files/pngs' + end + super(controller) end - + def file_link(mode, name, text, web_name, known_file, description) link = CGI.escape(name) case mode