]> git.r.bdr.sh - rbdr/grita/blobdiff - grita.rb
Fixes QR Codes.
[rbdr/grita] / grita.rb
index 28d903a420b3b989a61927fd6aa930b18370c130..cefcc909730834fdc0a00922947be6b9dcfdedb5 100644 (file)
--- a/grita.rb
+++ b/grita.rb
@@ -6,6 +6,7 @@ require 'dm-validations'
 require 'dm-timestamps'
 require 'dm-migrations'
 require 'rqr'
+require 'rdiscount'
 
 #config
 set :haml, :format => :html5
@@ -16,8 +17,7 @@ get '/' do
 end
 
 post '/' do
-  @grito = Grito.new(:title => params[:title], :text => params[:text])
-  @grito.save
+  @grito = Grito.create(:title => params[:title], :text => params[:text])
   haml :index
 end
 
@@ -27,7 +27,7 @@ get '/qr/:grito.png' do
    rpr_filepath = tmpfile.path + '.png'
 
    RQR::QRCode.create do |qr|
-     qr.save('http://grita.heroku.com/'+params[:grito], rpr_filepath)
+     qr.save("http://#{request.host}/"+params[:grito], rpr_filepath)
    end
 
    buffer = File.open(rpr_filepath).read
@@ -43,7 +43,10 @@ end
 get '/:grito' do
     @grito = Grito.first(:id => params[:grito].to_i(36))
     raise "Invalid Post" if @grito.nil?
-    haml :grito
+    
+    @markdown = RDiscount.new(@grito.text)
+    
+    haml :grito, :layout => :layoutmini
 end
 
 error do