ActionController::Routing::Routes.draw do |map|
  # The following are in priority order
  
  # Prefered URI for a single entry 
  map.connect ':controller/:year/:month/:day/*path',
     :action=>'by_date',
     :requirements => {:year => /(19|20)\d\d/,
                       :month => /[01]?\d/,
                       :day => /[0-3]?\d/}

  # Month range
  map.connect ':controller/:year/:month/*path',
     :action=>'by_date',
     :requirements => {:year => /(19|20)\d\d/,
                       :month => /[01]?\d/}

  # Year range
  map.connect ':controller/:year/*path',
     :action=>'by_date',
     :requirements => {:year => /(19|20)\d\d/}

  # Archives
  map.connect ':controller/archives/:year/:month',
     :action=>'archive',
     :year=>nil,
     :month=>nil,
     :requirements => {:year => /(19|20)\d\d/,
                       :month => /[01]?\d/}

  # Old style IDs
  map.connect ':controller/:path',
     :action=>'by_id',
     :requirements => {:path => /\d+(\.\w+)?/}

  # Just comments
  map.connect ':controller/:path',
     :action=>'comments',
     :requirements => {:path => /comments(\.\w+)?/}

  # All the rest (including index.html)
  map.connect ':controller/*path',
     :action=>'posts'

end
