Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

redirect /foo => /~foo

  • Loading branch information...
commit f8552d55389e36efe98adb5175406efa1e788d55 1 parent d54fa58
risk danger olson authored

Showing 1 changed file with 18 additions and 1 deletion. Show diff stats Hide diff stats

  1. 19  seinfeld_calendar.rb
19  seinfeld_calendar.rb
@@ -22,41 +22,49 @@
22 22
 end
23 23
 
24 24
 get '/' do
25  
-  response['Cache-Control'] = 'public, max-age=300'
  25
+  cache_for 5.minutes
26 26
   @recent_users  = Seinfeld::User.best_current_streak
27 27
   @alltime_users = Seinfeld::User.best_alltime_streak
28 28
   haml :index
29 29
 end
30 30
 
31 31
 get '/~:name.json' do
  32
+  cache_for 5.minutes
32 33
   show_user_json
33 34
 end
34 35
 
35 36
 get '/~:name' do
  37
+  cache_for 5.minutes
36 38
   show_user_calendar
37 39
 end
38 40
 
39 41
 get '/~:name/:year.json' do
  42
+  cache_for 5.minutes
40 43
   show_user_json
41 44
 end
42 45
 
43 46
 get '/~:name/:year' do
  47
+  cache_for 5.minutes
44 48
   show_user_calendar
45 49
 end
46 50
 
47 51
 get '/~:name/:year/:month.json' do
  52
+  cache_for 5.minutes
48 53
   show_user_json
49 54
 end
50 55
 
51 56
 get '/~:name/:year/:month' do
  57
+  cache_for 5.minutes
52 58
   show_user_calendar
53 59
 end
54 60
 
55 61
 get '/group/:names' do
  62
+  cache_for 5.minutes
56 63
   show_group_calendar
57 64
 end
58 65
 
59 66
 get '/group/:names/:year/:month' do
  67
+  cache_for 5.minutes
60 68
   show_group_calendar
61 69
 end
62 70
 
@@ -68,6 +76,11 @@
68 76
   end
69 77
 end
70 78
 
  79
+get '/*' do
  80
+  redirect "~#{params[:splat].join("/")}", 301
  81
+end
  82
+
  83
+
71 84
 helpers do
72 85
   include Seinfeld::CalendarHelper
73 86
 
@@ -152,5 +165,9 @@ def group_seinfeld
152 165
       end
153 166
     end
154 167
   end
  168
+
  169
+  def cache_for(time)
  170
+    response['Cache-Control'] = "public, max-age=#{time.to_i}"
  171
+  end
155 172
 end
156 173
 

0 notes on commit f8552d5

Please sign in to comment.
Something went wrong with that request. Please try again.