diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ae01f86d..9576a834 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,13 +19,22 @@ class ApplicationController < ActionController::Base Wiki.new end + helper_method :xhtml_enabled?, :html_ext + protected def xhtml_enabled? in_a_web? and [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) end - helper_method :xhtml_enabled? + def html_ext + if xhtml_enabled? && request.env.include?('HTTP_ACCEPT') && + Mime::Type.parse(request.env["HTTP_ACCEPT"]).include?(Mime::XHTML) + 'xhtml' + else + 'html' + end + end def check_authorization if in_a_web? and authorization_needed? and not authorized? diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 270fbebd..b4d247f2 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -380,15 +380,6 @@ class WikiController < ApplicationController end end - def html_ext - if xhtml_enabled? && request.env.include?('HTTP_ACCEPT') && - Mime::Type.parse(request.env["HTTP_ACCEPT"]).include?(Mime::XHTML) - 'xhtml' - else - 'html' - end - end - protected def do_caching? diff --git a/lib/url_generator.rb b/lib/url_generator.rb index 25b7f757..5fc4e355 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -64,7 +64,7 @@ class UrlGenerator < AbstractUrlGenerator case mode when :export if known_file - %{#{text}} + %{#{text}} else %{#{text}} end @@ -92,7 +92,7 @@ class UrlGenerator < AbstractUrlGenerator case mode when :export if known_page - %{#{text}} + %{#{text}} else %{#{text}} end @@ -181,5 +181,11 @@ class UrlGenerator < AbstractUrlGenerator href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action, :id => name, :only_path => true %{#{text}} - end + end + + def html_ext + @html_ext ||= @controller.method(:html_ext).call + # Why method().call ? A Ruby 1.9.2preview1 bug: + # http://redmine.ruby-lang.org/issues/show/1802 + end end