]>
Commit | Line | Data |
---|---|---|
3e43ab35 BB |
1 | require 'sinatra' |
2 | require 'haml' | |
3 | require 'less' | |
5573b3c2 BB |
4 | require 'dm-core' |
5 | require 'dm-timestamps' | |
3e43ab35 BB |
6 | |
7 | #config | |
8 | set :haml, :format => :html5 | |
9 | ||
10 | #app | |
11 | get '/' do | |
12 | haml :index | |
13 | end | |
14 | ||
5573b3c2 BB |
15 | post '/' do |
16 | @grito = Grito.first_or_create(:title => params[:title], :text => params[:text]) | |
17 | haml :index | |
18 | end | |
19 | ||
3e43ab35 BB |
20 | get '/style.css' do |
21 | less :style | |
22 | end | |
23 | ||
24 | not_found do | |
5573b3c2 BB |
25 | haml :error |
26 | end | |
27 | ||
28 | DataMapper.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita') | |
29 | class Grito | |
30 | include DataMapper::Resource | |
31 | property :id, Serial | |
32 | property :title, String, :required => true | |
33 | property :text, Text, :required => true | |
34 | property :created_at, DateTime | |
35 | ||
36 | def geturl() | |
37 | self.id.to_s(36) | |
38 | end | |
3e43ab35 | 39 | end |