]>
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
.new(:title => params
[:title], :text => params
[:text])
25 get
'/qr/:grito.png' do
26 tmpfile
= Tempfile
.new('tmp')
28 rpr_filepath
= tmpfile
.path +
'.png'
30 RQR
::QRCode.create
do |qr
|
31 qr
.save('http://#{request.host}/'+params
[:grito], rpr_filepath
)
34 buffer
= File
.open(rpr_filepath
).read
36 content_type
'image/png'
45 @grito = Grito
.first(:id => params
[:grito].to_i(36))
46 raise "Invalid Post" if @grito.nil?
48 @markdown = RDiscount
.new(@grito.text
)
50 haml
:grito, :layout => :layoutmini
57 DataMapper
.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita')
59 include DataMapper
::Resource
61 property
:title, String
63 property
:created_at, DateTime
65 validates_presence_of
:title, :message => "· Debes incluír un título."
66 validates_presence_of
:text, :message => "· ¡No escribiste contenido!"