X-Git-Url: https://git.r.bdr.sh/rbdr/grita/blobdiff_plain/a7ac2194708c39f02fa20ad4edff78fc4f24ea91..5573b3c2672a04d58a91ce1c74f9c543e14fb423:/grita.rb diff --git a/grita.rb b/grita.rb index 17ed55e..eaf59a7 100644 --- a/grita.rb +++ b/grita.rb @@ -1,7 +1,8 @@ require 'sinatra' require 'haml' require 'less' -require 'mongo' +require 'dm-core' +require 'dm-timestamps' #config set :haml, :format => :html5 @@ -11,10 +12,28 @@ get '/' do 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