Sha256: ac09a0fae5c8969e0f8cb6dae0c9430619e1541db2e15043d3bad9b7a4933299

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

EffectivePosts::Engine.routes.draw do
  namespace :admin do
    resources :posts, except: [:show]

    if EffectivePosts.submissions_enabled && EffectivePosts.submissions_require_approval
      match 'posts/:id/approve', to: 'posts#approve', via: :get, as: :approve_post
    end

    match 'posts/excerpts', to: 'posts#excerpts', via: :get
  end

  scope :module => 'effective' do
    categories = Array(EffectivePosts.categories).map { |cat| cat.to_s unless cat == 'posts'}.compact
    onlies = ([:index, :show] unless EffectivePosts.submissions_enabled)

    if EffectivePosts.use_blog_routes
      categories.each do |category|
        match "blog/category/#{category}", to: 'posts#index', via: :get, defaults: { category: category }
      end

      resources :posts, only: onlies, path: 'blog'
    elsif EffectivePosts.use_category_routes
      categories.each do |category|
        match category, to: 'posts#index', via: :get, defaults: { category: category }
        match "#{category}/:id", to: 'posts#show', via: :get, defaults: { category: category }
      end

      resources :posts, only: onlies
    else
      resources :posts, only: onlies
    end
  end

end

# Automatically mount the engine as an append
Rails.application.routes.append do
  unless Rails.application.routes.routes.find { |r| r.name == 'effective_posts' }
    mount EffectivePosts::Engine => '/', :as => 'effective_posts'
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
effective_posts-1.2.0 config/routes.rb
effective_posts-1.1.11 config/routes.rb
effective_posts-1.1.10 config/routes.rb
effective_posts-1.1.9 config/routes.rb
effective_posts-1.1.8 config/routes.rb
effective_posts-1.1.7 config/routes.rb
effective_posts-1.1.6 config/routes.rb
effective_posts-1.1.5 config/routes.rb
effective_posts-1.1.4 config/routes.rb
effective_posts-1.1.3 config/routes.rb
effective_posts-1.1.2 config/routes.rb
effective_posts-1.1.1 config/routes.rb
effective_posts-1.1.0 config/routes.rb
effective_posts-1.0.6 config/routes.rb
effective_posts-1.0.5 config/routes.rb
effective_posts-1.0.4 config/routes.rb
effective_posts-1.0.3 config/routes.rb