require 'sinatra'
require 'haml'
require 'less'
-require 'mongo'
+require 'dm-core'
+require 'dm-timestamps'
#config
set :haml, :format => :html5
haml :index
end
+post '/' do
+ @grito = Grito.first_or_create(:title => params[:title], :text => params[:text])
+ haml :index
+end
+
get '/style.css' do
less :style
end
not_found do
- "Estos no son los droides que estás buscando."
+ haml :error
+end
+
+DataMapper.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita')
+class Grito
+ include DataMapper::Resource
+ property :id, Serial
+ property :title, String, :required => true
+ property :text, Text, :required => true
+ property :created_at, DateTime
+
+ def geturl()
+ self.id.to_s(36)
+ end
end
\ No newline at end of file