Sha256: 375e8f5e5b3c8dd2dceee57ff13c94a9cb7f3c095bcdb3a0c817c52326e99569

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

Rails.application.routes.draw do
  scope constraints: ->(req) { Site.count.zero? } do
    get "/" => redirect("/admin/install")
  end

  scope :constraints => lambda { |req| Page.where(:permalink => req.params[:section_permalink]).exists? } do
    get "/:section_permalink" => "articles#index", :as => :page
    scope :constraints => lambda { |req| Article.where(:permalink => req.params[:permalink]).exists? } do
      get "/:section_permalink/:permalink" => "articles#show", :as => :page_article
    end
  end

  scope :constraints => lambda { |req|
    Section.any? && begin
      permalinks = Article.where(:section_id => Section.first.id).pluck(:permalink)
      permalinks.include? req.fullpath[1..-1]
    end
  } do
    get "/:permalink" => "articles#show"
  end

  get "/" => "articles#index", :as => :root

  namespace :admin do
    post "install" => "install#index"
    get "install" => "install#index"

    resources :sites
    resource :site

    resources :sections do
      put "/", :action => "update_all", :on => :collection
      resources :contents, :articles, :links, :categories do
        put "/", :action => "update_all", :on => :collection
      end
    end

    resources :pages do
      scope :module => :page do
        resources :contents, :articles, :links, :categories do
          put "/", :action => "update_all", :on => :collection
        end
      end
    end

    resources :cells, :only => :index

    resources :users
  end

  get "login" => "session#new"
  delete "logout" => "session#destroy"

  resource :session,     :controller => "session"
  resource :password,    :controller => "password"
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
adva-0.3.2 config/routes.rb
adva-0.3.1 config/routes.rb
adva-0.3.0 config/routes.rb
adva-0.2.4 config/routes.rb
adva-0.2.3 config/routes.rb
adva-0.2.2 config/routes.rb
adva-0.2.1 config/routes.rb
adva-0.2.0 config/routes.rb
adva-0.1.4 config/routes.rb
adva-0.1.3 config/routes.rb
adva-0.1.2 config/routes.rb
adva-0.1.1 config/routes.rb
adva-0.1.0 config/routes.rb