Sha256: 886abbc031c8ffa22b14c966922c03dda62afa102f43270e8a2daa8998002fa1

Contents?: true

Size: 871 Bytes

Versions: 4

Compression:

Stored size: 871 Bytes

Contents

class ActionDispatch::Routing::Mapper

  def comfy_route_blog(options = {})
    options[:path] ||= 'blog'
    path = ['(:cms_path)', options[:path], '(:blog_path)'].join('/')
    
    scope :module => :comfy, :as => :comfy do
      namespace :blog, :path => path, :constraints => {:blog_path => /\w[a-z0-9_-]*/} do
        with_options :constraints => {:year => /\d{4}/, :month => /\d{1,2}/} do |o|
          o.get ':year'               => 'posts#index', :as => :posts_of_year
          o.get ':year/:month'        => 'posts#index', :as => :posts_of_month
          o.get ':year/:month/:slug'  => 'posts#show',  :as => :posts_dated
        end
        post ':slug/comments' => 'comments#create', :as => :comments
        get  ':slug'          => 'posts#serve',     :as => :post
        get  '/'              => 'posts#serve',     :as => :posts
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfy_blog-1.12.3 lib/comfy_blog/routes/blog.rb
comfy_blog-1.12.2 lib/comfy_blog/routes/blog.rb
comfy_blog-1.12.1 lib/comfy_blog/routes/blog.rb
comfy_blog-1.12.0 lib/comfy_blog/routes/blog.rb