Sha256: 0d5f7972a8e55b03943bc06a1fa98a5675231a8a819d16cf9ab6819b6c28a5e5
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module ActionDispatch::Routing # I have no idea how or why this works this way, I lifted the pattern from Devise, which came with even # more weird stuff. Rails could use an API for adding route helpers to decrease the brittleness of this # approach. For now, deal with this helper. class Mapper DEFAULT_CONTROLLER = "sitepress/site".freeze DEFAULT_ACTION = "show".freeze ROUTE_GLOB_KEY = "/*resource_path".freeze # Hook up all the Sitepress pages def sitepress_pages(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION, root: false, constraints: Sitepress::RouteConstraint.new, as: :page) get ROUTE_GLOB_KEY, controller: controller, action: action, as: as, format: false, constraints: constraints sitepress_root controller: controller, action: action if root end # Hook sitepress root up to the index of rails. def sitepress_root(controller: DEFAULT_CONTROLLER, action: DEFAULT_ACTION) if has_named_route? :root Rails.logger.warn "Sitepress tried to configured the 'root' route, but it was already defined. Check the 'routes.rb' file for a 'root' route or call 'sitepress_pages(root: false)'." else root controller: controller, action: action end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sitepress-rails-4.0.5 | lib/sitepress/routing_mapper.rb |
sitepress-rails-4.0.4 | lib/sitepress/routing_mapper.rb |
sitepress-rails-4.0.3 | lib/sitepress/routing_mapper.rb |