]> git.r.bdr.sh - rbdr/grita/blob - grita.rb
Gemfile.lock y nuevas revisiones.
[rbdr/grita] / grita.rb
1 require 'sinatra'
2 require 'haml'
3 require 'less'
4 require 'dm-core'
5 require 'dm-timestamps'
6
7 #config
8 set :haml, :format => :html5
9
10 #app
11 get '/' do
12 haml :index
13 end
14
15 post '/' do
16 @grito = Grito.first_or_create(:title => params[:title], :text => params[:text])
17 haml :index
18 end
19
20 get '/style.css' do
21 less :style
22 end
23
24 not_found do
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
39 end