Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 82 lines (70 sloc) 1.604 kb
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
1 require 'rubygems'
62f587cd » mwhuss
2012-02-05 Cache static assets too
2 require 'rack/cache'
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
3 require 'sinatra'
c01c90c1 » mwhuss
2012-02-05 Load last tweet
4 require 'haml'
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
5 require 'sass'
c01c90c1 » mwhuss
2012-02-05 Load last tweet
6 require 'twitter'
305c928a » mwhuss
2012-02-05 Added memcache:
7 require 'dalli'
8
87a65522 » mwhuss
2012-02-05 Cache static assets too
9 # Cache it...cache it good
da912fbf » mwhuss
2012-02-05 Added rack-cache
10 $cache = Dalli::Client.new
87a65522 » mwhuss
2012-02-05 Cache static assets too
11 set :enable_cache, true
da912fbf » mwhuss
2012-02-05 Added rack-cache
12 set :cache, $cache
87a65522 » mwhuss
2012-02-05 Cache static assets too
13 use ::Rack::Cache, metastore: $cache, entitystore: 'file:tmp/cache/entity'
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
14
15 set :haml, format: :html5
16
66b766e9 » mwhuss
2012-02-05 moved caching to before filter
17 before do
62f587cd » mwhuss
2012-02-05 Cache static assets too
18 # response["Cache-Control"] = "max-age=300, public"
4f99cf4d » mwhuss
2012-02-05 oops
19 set :static_cache_control, [:public, max_age: 300]
62f587cd » mwhuss
2012-02-05 Cache static assets too
20 cache_control :public, max_age: 300
66b766e9 » mwhuss
2012-02-05 moved caching to before filter
21 end
22
23 get '/' do
91e3f3af » djbrowning
2012-02-05 Moved twitter code into the sinatra app (out of the view) to handle e…
24 begin
c20a4128 » mwhuss
2012-02-09 Set TTL for tweet
25 @twitter_text = settings.cache.get("tweet", 300)
f667c1ee » mwhuss
2012-02-08 Try caching tweet
26 unless @twitter_text
27 tweet = Twitter.user_timeline("nezumiapp").first.text
28 @twitter_text = tweet.size > 94 ? tweet.slice(0..93) << "..." : tweet
3cab9ac1 » mwhuss
2012-02-09 set TTL on set too
29 settings.cache.set("tweet", @twitter_text, 300)
f667c1ee » mwhuss
2012-02-08 Try caching tweet
30 end
31 rescue Twitter::Error => e
87a65522 » mwhuss
2012-02-05 Cache static assets too
32 # rate exceeded...by your face!
f667c1ee » mwhuss
2012-02-08 Try caching tweet
33 @twitter_text = e.message
34 rescue Dalli::RingError
35 # no memcache
91e3f3af » djbrowning
2012-02-05 Moved twitter code into the sinatra app (out of the view) to handle e…
36 end
75b4ce9f » djbrowning
2012-02-04 Started working on the history stuff.
37 haml :iphone
38 end
39
40 get '/iphone' do
41 haml :iphone, layout: false
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
42 end
43
44 get '/ipad' do
f3d531d3 » djbrowning
2012-02-07 Added remote checks for layout.
45 if params[:remote]
46 haml :ipad, layout: false
47 else
48 haml :ipad
49 end
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
50 end
51
52 get '/android' do
f3d531d3 » djbrowning
2012-02-07 Added remote checks for layout.
53 if params[:remote]
54 haml :android, layout: false
55 else
56 haml :android
57 end
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
58 end
59
60 get '/addons' do
f3d531d3 » djbrowning
2012-02-07 Added remote checks for layout.
61 if params[:remote]
62 haml :addons, layout: false
63 else
64 haml :addons
65 end
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
66 end
67
22b95b98 » mwhuss
2012-02-05 Added itunes link
68 get '/appstore' do
69 redirect 'http://itunes.apple.com/us/app/nezumi/id346715875?mt=8'
70 end
71
d2ae2fb0 » djbrowning
2012-02-04 Initial commit
72 # STYLESHEETS
73
74 get '/stylesheets/reset.css' do
75 content_type 'text/css', charset: 'utf-8'
76 sass :reset
77 end
78
79 get '/stylesheets/styles.css' do
80 content_type 'text/css', charset: 'utf-8'
81 sass :styles
82 end
Something went wrong with that request. Please try again.