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 'blog/*path',
     :action=>'posts',
     :controller=>'blog'

  ###################################################

  map.connect 'openid',
     :action=>'main',
     :controller=>'openid'

  map.connect 'openid/server',
     :action=>'server',
     :controller=>'openid'

  map.connect 'openid/consumer',
     :action=>'consumer',
     :controller=>'openid'

  map.connect ':controller/admin/:action',
     :requirements => {:action => /^[a-z]+$/}

  map.connect ':controller/:action/:user',
     :action=>'identity'

end
