Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/postmarkdown/routes.rb

Instance Method Summary collapse

Instance Method Details

#postmarkdown(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/postmarkdown/routes.rb', line 4

def postmarkdown(options = {})
  options.reverse_merge!({ :as => :posts, :permalink_format => :day })

  get "/#{options[:as]}(/:year(/:month(/:day)))" => 'posts#index', :as => :posts, :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/}
  get "/#{options[:as]}/feed" => 'posts#feed', :as => :posts_feed, :format => :xml
  get "/#{options[:as]}/*id" => 'posts#show', :as => :post, :constraints => { :id => postmarkdown_permalink_regex(options) }

  postmarkdown_feed_title(options[:as])
end