module Weeler::ActionDispatch::Routing::Mapper

Public Instance Methods

mount_weeler_at(mount_location, options={}) { || ... } click to toggle source

Mounts weeler at mount_location location. E.g.

mount_weeler_at "root" do
  weeler_resources :posts, include_in_weeler_menu: true
end
# File lib/weeler/action_dispatch/routing/mapper.rb, line 25
def mount_weeler_at mount_location, options={}, &block
  Weeler.mount_location_namespace = mount_location.gsub("/", "").to_sym
  scope mount_location do
    namespace :weeler, :path => nil do
      mount_configuration_controllers

      weeler_resources :static_sections

      resources :seos, :only => [:update]


      root :to => "home#index"
      get "/home/about"
      get "/content", to: "content#index"
      get "/administration", to: "administration#index"
      get "/configuration", to: "configuration#index"

      add_concerns

      yield if block_given?
    end
  end
end
weeler_resources(*args) { || ... } click to toggle source

Pass given resource to “resources” mount method and add extra routes for members and collections needed by weeler

Options:

  • include_in_weeler_menu: true to include this resource in content section.

# File lib/weeler/action_dispatch/routing/mapper.rb, line 12
def weeler_resources(*args, &block)
  add_menu_item args[0] if args[0].present? && args[1].present? && args[1][:include_in_weeler_menu] == true
  resources *args do
    yield if block_given?
  end
end

Private Instance Methods

add_concerns() click to toggle source

Ordable route concern for dynamic sorting and removing image

# File lib/weeler/action_dispatch/routing/mapper.rb, line 65
def add_concerns
  concern :orderable do
    collection do
      post :order
    end
  end

  concern :imageable do
    member do
      get "remove_image"
    end
  end
end
add_menu_item(resource) click to toggle source

Add route menu

# File lib/weeler/action_dispatch/routing/mapper.rb, line 80
def add_menu_item resource
  Weeler.content_menu_items << {name: resource.to_s.capitalize, weeler_path: resource} unless Weeler.content_menu_items.select{ |item| item[:name] == resource.to_s.capitalize }.size > 0
  Weeler.build_main_menu
end
mount_configuration_controllers() click to toggle source

Mount translations controller

# File lib/weeler/action_dispatch/routing/mapper.rb, line 52
def mount_configuration_controllers
  resources :translations, :except => [:show] do
    collection do
      get :export
      post :import
      get :usage_stats
    end
  end
  resources :seo_items
  resources :settings, :only => [:index, :edit, :update]
end