]>
git.r.bdr.sh - rbdr/grita/blob - grita.rb
5 require 'dm-validations'
6 require 'dm-timestamps'
7 require 'dm-migrations'
12 set
:haml, :format => :html5
20 @grito = Grito
.create(:title => params
[:title], :text => params
[:text])
24 get
'/qr/:grito.png' do
25 tmpfile
= Tempfile
.new('tmp')
27 rpr_filepath
= tmpfile
.path +
'.png'
29 RQR
::QRCode.create
do |qr
|
30 qr
.save('http://#{request.host}/'+params
[:grito], rpr_filepath
)
33 buffer
= File
.open(rpr_filepath
).read
35 content_type
'image/png'
44 @grito = Grito
.first(:id => params
[:grito].to_i(36))
45 raise "Invalid Post" if @grito.nil?
47 @markdown = RDiscount
.new(@grito.text
)
49 haml
:grito, :layout => :layoutmini
56 DataMapper
.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita')
58 include DataMapper
::Resource
60 property
:title, String
62 property
:created_at, DateTime
64 validates_presence_of
:title, :message => "· Debes incluír un título."
65 validates_presence_of
:text, :message => "· ¡No escribiste contenido!"