Instiki 0.16.3: Rails 2.3.0

Instiki now runs on the Rails 2.3.0 Candidate Release.
Among other improvements, this means that it now 
automagically selects between WEBrick and Mongrel.

Just run

    ./instiki --daemon
This commit is contained in:
Jacques Distler 2009-02-04 14:26:08 -06:00
parent 43aadecc99
commit 4e14ccc74d
893 changed files with 71965 additions and 28511 deletions

View file

@ -2,14 +2,7 @@ module ActionView #:nodoc:
class PathSet < Array #:nodoc:
def self.type_cast(obj)
if obj.is_a?(String)
if Base.warn_cache_misses && defined?(Rails) && Rails.initialized?
Base.logger.debug "[PERFORMANCE] Processing view path during a " +
"request. This an expense disk operation that should be done at " +
"boot. You can manually process this view path with " +
"ActionView::Base.process_view_paths(#{obj.inspect}) and set it " +
"as your view path"
end
Path.new(obj)
Template::EagerPath.new(obj)
else
obj
end
@ -39,87 +32,26 @@ module ActionView #:nodoc:
super(*objs.map { |obj| self.class.type_cast(obj) })
end
class Path #:nodoc:
def self.eager_load_templates!
@eager_load_templates = true
end
def find_template(original_template_path, format = nil)
return original_template_path if original_template_path.respond_to?(:render)
template_path = original_template_path.sub(/^\//, '')
def self.eager_load_templates?
@eager_load_templates || false
end
attr_reader :path, :paths
delegate :to_s, :to_str, :hash, :inspect, :to => :path
def initialize(path, load = true)
raise ArgumentError, "path already is a Path class" if path.is_a?(Path)
@path = path.freeze
reload! if load
end
def ==(path)
to_str == path.to_str
end
def eql?(path)
to_str == path.to_str
end
def [](path)
raise "Unloaded view path! #{@path}" unless @loaded
@paths[path]
end
def loaded?
@loaded ? true : false
end
def load
reload! unless loaded?
self
end
# Rebuild load path directory cache
def reload!
@paths = {}
templates_in_path do |template|
# Eager load memoized methods and freeze cached template
template.freeze if self.class.eager_load_templates?
@paths[template.path] = template
@paths[template.path_without_extension] ||= template
end
@paths.freeze
@loaded = true
end
private
def templates_in_path
(Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file|
unless File.directory?(file)
yield Template.new(file.split("#{self}/").last, self)
end
end
end
end
def load
each { |path| path.load }
end
def reload!
each { |path| path.reload! }
end
def [](template_path)
each do |path|
if template = path[template_path]
each do |load_path|
if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"])
return template
elsif format && (template = load_path["#{template_path}.#{format}"])
return template
elsif template = load_path["#{template_path}.#{I18n.locale}"]
return template
elsif template = load_path[template_path]
return template
# Try to find html version if the format is javascript
elsif format == :js && template = load_path["#{template_path}.html"]
return template
end
end
nil
Template.new(original_template_path, self)
end
end
end