diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-26 15:13:28 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-26 15:13:28 -0500 |
commit | 9853134b4fec468962260f0e713d2f87046eb8b3 (patch) | |
tree | fe10eded92f430171b8c3dd752d0aaa45240dde3 /actionpack | |
parent | 8756dd75b257b17ddda92674d4cc0db307d2153b (diff) | |
download | rails-9853134b4fec468962260f0e713d2f87046eb8b3.tar.gz rails-9853134b4fec468962260f0e713d2f87046eb8b3.tar.bz2 rails-9853134b4fec468962260f0e713d2f87046eb8b3.zip |
Require missing libraries and check for defined ActionController constant so ActionView can be used standalone
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/mime_type.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/sanitize_helper.rb | 11 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 11 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderable.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderable_partial.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 2 |
6 files changed, 30 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index a7215e6ea3..26edca3b69 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -1,3 +1,5 @@ +require 'set' + module Mime SET = [] EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? } diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb index 637caf203b..435ba936e1 100644 --- a/actionpack/lib/action_view/helpers/sanitize_helper.rb +++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb @@ -1,5 +1,14 @@ require 'action_view/helpers/tag_helper' -require 'html/document' + +begin + require 'html/document' +rescue LoadError + html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner" + if File.directory?(html_scanner_path) + $:.unshift html_scanner_path + require 'html/document' + end +end module ActionView module Helpers #:nodoc: diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index f9096d0029..ccd6c54cc8 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -1,5 +1,14 @@ require 'action_view/helpers/tag_helper' -require 'html/document' + +begin + require 'html/document' +rescue LoadError + html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner" + if File.directory?(html_scanner_path) + $:.unshift html_scanner_path + require 'html/document' + end +end module ActionView module Helpers #:nodoc: diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb index c011f21550..3a79b2b01e 100644 --- a/actionpack/lib/action_view/renderable.rb +++ b/actionpack/lib/action_view/renderable.rb @@ -72,7 +72,7 @@ module ActionView end_src begin - logger = Base.logger + logger = defined? ActionController && Base.logger logger.debug "Compiling template #{render_symbol}" if logger ActionView::Base::CompiledTemplates.module_eval(source, filename, 0) diff --git a/actionpack/lib/action_view/renderable_partial.rb b/actionpack/lib/action_view/renderable_partial.rb index 342850f0f0..5203e57ead 100644 --- a/actionpack/lib/action_view/renderable_partial.rb +++ b/actionpack/lib/action_view/renderable_partial.rb @@ -16,7 +16,11 @@ module ActionView memoize :counter_name def render(view, local_assigns = {}) - ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do + if defined? ActionController + ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do + super + end + else super end end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 5dc6708431..64597b3d39 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -1,3 +1,5 @@ +require 'action_controller/mime_type' + module ActionView #:nodoc: class Template extend TemplateHandlers |