refactored some js stuff. Fixed forms in article modul.
This commit is contained in:
parent
9388e918a7
commit
1e33411516
25 changed files with 184 additions and 249 deletions
|
|
@ -1,35 +0,0 @@
|
|||
module RoutingFilter
|
||||
class Foodcoop < Filter
|
||||
def around_recognize(path, env, &block)
|
||||
token = extract_token!(path) # remove the token from the beginning of the path
|
||||
yield.tap do |params| # invoke the given block (calls more filters and finally routing)
|
||||
params[:foodcoop] = token if token # set recognized token to the resulting params hash
|
||||
end
|
||||
end
|
||||
|
||||
def around_generate(*args, &block)
|
||||
token = args.extract_options!.delete(:foodcoop) # extract the passed :token option
|
||||
token = Foodsoft.env if token.nil? # default to Foodsoft.env
|
||||
|
||||
yield.tap do |result|
|
||||
if token
|
||||
url = result.is_a?(Array) ? result.first : result
|
||||
prepend_token!(url, token)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def extract_token!(path)
|
||||
foodcoop = nil
|
||||
path.sub! %r(^/([a-zA-Z0-9]*)(?=/|$)) do foodcoop = $1; '' end
|
||||
foodcoop
|
||||
end
|
||||
|
||||
def prepend_token!(url, token)
|
||||
url.sub!(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{token}#{$2}" }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue