]> git.r.bdr.sh - rbdr/grita/blobdiff - grita.rb
Gemfile.lock y nuevas revisiones.
[rbdr/grita] / grita.rb
index 17ed55e8097a4563db073c587ea9e778164e26b9..eaf59a715e23c03ef8b5d71d9262cf013694a353 100644 (file)
--- 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