1+ require "sinatra/base"
2+ require "sinatra/activerecord"
3+ require "sinatra/flash"
4+ require "sinatra/contrib/all"
5+
6+ class Stringer < Sinatra ::Base
7+ configure do
8+ set :database_file , "config/database.yml"
9+ set :views , "app/views"
10+ set :public_dir , "app/public"
11+
12+ enable :sessions
13+ set :session_secret , "secret!"
14+
15+ register Sinatra ::ActiveRecordExtension
16+ register Sinatra ::Flash
17+ register Sinatra ::Contrib
18+ end
19+
20+ helpers do
21+ # allow for partials using this syntax
22+ # = render partial: :foo
23+ def render ( *args )
24+ if args . first . is_a? ( Hash ) && args . first . keys . include? ( :partial )
25+ return haml "partials/_#{ args . first [ :partial ] } " . to_sym , :layout => false
26+ else
27+ super
28+ end
29+ end
30+ end
31+
32+ get "/" do
33+ @stories = [ ]
34+ @stories << Story . new ( "The GitHub Blog" , "New GitHub Pages domain: github.io" , "Beginning today all GitHub pages..." )
35+ @stories << Story . new ( "Quantified Self" , "Eric Boyd: Learning from my Nike FuelBand Data" , "We've been getting some..." )
36+ @stories << Story . new ( "Atomic Spin" , "Why Mou Is My New Note-Taking App" , "Taking notes has been a part..." )
37+ @stories << Story . new ( "FlowingData" , "Introducing Data Points" , "Whoa, that was fast. Data..." )
38+
39+ erb :index
40+ end
41+
42+ class Story < Struct . new ( :source , :headline , :lead ) ; end ;
43+ end
0 commit comments