Sha256: d88681e3a04e93930eb556704730c488b5dae46619dbed7c8b52077fffff4053
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'nitro/dispatcher' module Nitro # Specialize the Dispatcher to handle implicit 'nice' urls. class Dispatcher # The default dispatching algorithm that handles # implicit nice urls. Subdirectories are supported. # Action containing '/' separators look for templates # in subdirectories. The '/' char is converted to '__' # to find the actual action. # # Returns the dispatcher class, the action name and the # base url. For the root path, the base url is nil. def dispatch(path, context) path = route(path, context) parts = path.split('/') parts.shift # get rid of the leading '/'. if klass = controller_class_for("/#{parts.first}") base = "/#{parts.shift}" else base = nil klass = controller_class_for(ROOT) end =begin if klass.action_methods.include?(parts.first) action = parts.shift else action = 'index' end p '---', action getc =end unless action = parts.shift action = 'index' end unless parts.empty? context.headers['QUERY_STRING'] = "#{parts.join(';')};#{context.headers['QUERY_STRING']}" end base = nil if base == ROOT return klass, "#{action}_action", base end end Dispatcher.mode = :nice end # * George Moschovitis <gm@navel.gr>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.25.0 | lib/nitro/dispatcher/nice.rb |