Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki

This commit is contained in:
Jacques Distler 2009-12-16 01:04:56 -06:00
commit c391c0eeee
3 changed files with 19 additions and 13 deletions

View file

@ -19,13 +19,22 @@ class ApplicationController < ActionController::Base
Wiki.new Wiki.new
end end
helper_method :xhtml_enabled?, :html_ext
protected protected
def xhtml_enabled? def xhtml_enabled?
in_a_web? and [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) in_a_web? and [:markdownMML, :markdownPNG, :markdown].include?(@web.markup)
end 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 def check_authorization
if in_a_web? and authorization_needed? and not authorized? if in_a_web? and authorization_needed? and not authorized?

View file

@ -380,15 +380,6 @@ class WikiController < ApplicationController
end end
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 protected
def do_caching? def do_caching?

View file

@ -64,7 +64,7 @@ class UrlGenerator < AbstractUrlGenerator
case mode case mode
when :export when :export
if known_file if known_file
%{<a class="existingWikiWord" title="#{description}" href="#{CGI.escape(name)}.#{@controller.html_ext}">#{text}</a>} %{<a class="existingWikiWord" title="#{description}" href="#{CGI.escape(name)}.#{html_ext}">#{text}</a>}
else else
%{<span class="newWikiWord">#{text}</span>} %{<span class="newWikiWord">#{text}</span>}
end end
@ -92,7 +92,7 @@ class UrlGenerator < AbstractUrlGenerator
case mode case mode
when :export when :export
if known_page if known_page
%{<a class="existingWikiWord" href="#{CGI.escape(name)}.#{@controller.html_ext}">#{text}</a>} %{<a class="existingWikiWord" href="#{CGI.escape(name)}.#{html_ext}">#{text}</a>}
else else
%{<span class="newWikiWord">#{text}</span>} %{<span class="newWikiWord">#{text}</span>}
end end
@ -182,4 +182,10 @@ class UrlGenerator < AbstractUrlGenerator
:id => name, :only_path => true :id => name, :only_path => true
%{<a class="existingWikiWord" href="#{href}">#{text}</a>} %{<a class="existingWikiWord" href="#{href}">#{text}</a>}
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 end