Skip to content

Commit

Permalink
redirect /foo => /~foo
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Apr 20, 2009
1 parent d54fa58 commit f8552d5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion seinfeld_calendar.rb
Expand Up @@ -22,41 +22,49 @@
end

get '/' do
response['Cache-Control'] = 'public, max-age=300'
cache_for 5.minutes
@recent_users = Seinfeld::User.best_current_streak
@alltime_users = Seinfeld::User.best_alltime_streak
haml :index
end

get '/~:name.json' do
cache_for 5.minutes
show_user_json
end

get '/~:name' do
cache_for 5.minutes
show_user_calendar
end

get '/~:name/:year.json' do
cache_for 5.minutes
show_user_json
end

get '/~:name/:year' do
cache_for 5.minutes
show_user_calendar
end

get '/~:name/:year/:month.json' do
cache_for 5.minutes
show_user_json
end

get '/~:name/:year/:month' do
cache_for 5.minutes
show_user_calendar
end

get '/group/:names' do
cache_for 5.minutes
show_group_calendar
end

get '/group/:names/:year/:month' do
cache_for 5.minutes
show_group_calendar
end

Expand All @@ -68,6 +76,11 @@
end
end

get '/*' do
redirect "~#{params[:splat].join("/")}", 301
end


helpers do
include Seinfeld::CalendarHelper

Expand Down Expand Up @@ -152,5 +165,9 @@ def group_seinfeld
end
end
end

def cache_for(time)
response['Cache-Control'] = "public, max-age=#{time.to_i}"
end
end

0 comments on commit f8552d5

Please sign in to comment.