class RoutingFilter::SectionRouter
Public Instance Methods
around_generate(params) { || ... }
click to toggle source
# File lib/knitkit/routing_filter/section_router.rb, line 39 def around_generate(params, &block) yield.tap do |path| result = result.first if result.is_a?(Array) if result =~ generate_pattern section = WebsiteSection.find $2.to_i result.sub! "#{$1}/#{$2}", "#{section.path[1..section.path.length]}#{$3}" end end
around_recognize(path, env) { || ... }
click to toggle source
# File lib/knitkit/routing_filter/section_router.rb, line 15 def around_recognize(path, env, &block) unless excluded_paths.include?(path.split('/').second) website = Website.find_by_host(env["HTTP_HOST"]) if website paths = paths_for_website(website) if path.to_sym == :/ home_page_url = website.configurations.first.get_configuration_item(ConfigurationItemType.find_by_internal_identifier('homepage_url')).options.first.value valid_section = website.website_sections.detect { |website_section| website_section.path == home_page_url } type = valid_section.type.pluralize.downcase path.sub!('/', "/#{$1}#{type}/#{valid_section.id}#{$3}") else if !Rails.application.config.knitkit.ignored_prefix_paths.include?(path) and !paths.empty? and path =~ recognize_pattern(paths) if section = website_section_by_path(website, $2) type = section.type.pluralize.downcase path.sub! %r(^/([\w]{2,4}/)?(#{paths})(?=/|\.|$)), "/#{$1}#{type}/#{section.id}#{$3}" end end end end end yield end
excluded_paths()
click to toggle source
# File lib/knitkit/routing_filter/section_router.rb, line 7 def excluded_paths paths = %w{ erp_app session } paths.push(Rails.configuration.assets.prefix.split('/').second) paths end