b0VIM 7.3phornairswinslow U3210#"! Utp|"}ad,8|xZ> v V U C   j i  k U T 9  w v i J ' q p & vuaML6 gfG/. ihK&%h=  gH d87 collection: (collectionCallback) -> resource: resource ops = app = @ if callback _route "#{resource}/:id/edit", "#{controller}#edit", 'edit' if options.edit isnt false _route "#{resource}/:id", "#{controller}#show", 'show' if options.show isnt false _route "#{resource}/new", "#{controller}#new", 'new' if options.new isnt false _route resource, "#{controller}#index", 'index' if options.index isnt false resource = "#{options.parentResource}/:#{helpers.singularize(options.parentResource)}Id/#{resource}" if options.parentResource @route url, signature, resource: controller, action: action _route = (url, signature, action) => controller = options.controller || resource resource = helpers.pluralize(resource) (callback = options; options = {}) if typeof options is 'function' resource: (resource, options = {}, callback) -> @route '/', signature, options root: (signature, options) -> @_dispatcherCache[url] = options @_dispatcherCache ||= {} $mixin options, signature else if signature options = signature else if $typeOf(signature) is 'Function' options.signature = signature if typeof signature is 'string' return dispatcher @_dispatcherCache = null dispatcher.register key, value for key, value of @_dispatcherCache dispatcher = url if url instanceof Batman.Dispatcher return if not url route: (url, signature, options={}) ->Batman.App.classMixin# -----------------# Route Declarators return params.target?[action](params) return params.target.dispatch(action, params) if params.target?.dispatch return action(params) if typeof action is 'function' $redirect('/404') if not (action = params.action) and url isnt '/404' @dispatcher.app.get('currentParams').replace(params) params = @paramsFromURL url dispatch: (url) -> urlFromParams: (params) -> params params[key] = value [key, value] = s.split '=' for s in query.split '&' if query params[@namedArguments[index]] = param for param, index in array if array $mixin params, action else params.action = action if typeof action is 'function' action = @get 'action' params = url: url array = @regexp.exec(url)?.slice(1) [url, query] = url.split '?' paramsFromURL: (url) -> @action = action set: (key, action) -> @set 'action', result result.target = @dispatcher.app.controllers.get(result.controller) result.action = components[1] || 'index' result.controller = components[0] components = signature.split('#') if signature = result.signature result = $mixin {}, @options if @options return @action if @action get: -> @accessor 'action', @namedArguments.push(array[1]) if array[1] while (array = namedOrSplat.exec(@pattern))? @namedArguments = [] @regexp = new RegExp('^' + @pattern.replace(namedParam, '([^\/]*)').replace(splatParam, '(.*?)') + queryParam + '$') @pattern = @url.replace(escapeRegExp, '\\$&') super @options = {} constructor: -> escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g namedOrSplat = /[:|\*]([\w\d]+)/g queryParam = '(?:\\?.+)?' splatParam = /\*([\w\d]+)/g namedParam = /:([\w\d]+)/g # Route regexes courtesy of Backboneclass Batman.Route extends Batman.Object# ----------# Dispatcherad H "Y5O  P , y [ .   f ` _ I H redirect: $redirect @ @resource resources, options, callback else @resource resource, options, callback for resource in names callback = resource else options = resource else if $typeOf(options) is 'String' names.push resource if $typeOf(resource) is 'String' for resource in resources names = [] callback = null options = null resources = Array::slice.call arguments if $typeOf(options) is 'String' resources: (resources, options, callback) -> @ callback.call ops @resources childResources, options, callback options.parentResource = resource (callback = options; options = {}) if typeof options is 'function' resources: (childResources, options = {}, callback) => app.route "#{resource}/:id/#{url}", "#{controller}##{action}", {action, resource, controller} memberCallback?.call route: (url, action = url) -> member: (memberCallback) -> app.route "#{resource}/#{url}", "#{controller}##{action}", {action, resource, controller} collectionCallback?.call route: (url, action = url) ->