0
0
Fork 0

show a single post

This commit is contained in:
Gibheer 2011-07-05 19:02:26 +02:00
parent 1bd4158b17
commit 4ce3f643dd
2 changed files with 16 additions and 0 deletions

View File

@ -11,4 +11,8 @@ class Post
belongs_to :account
has n, :comments
def self.get_released id
first(:id => id, :released => true)
end
end

12
page.rb
View File

@ -1,12 +1,24 @@
class Blog < Sinatra::Base
set $settings
register Sinatra::CompassSupport
use Rack::Session::Pool, :expire_after => 1800
use Rack::Flash, :accessorize => [:error, :warning, :notice]
get '/' do
@posts = Post.all(:released => true, :order => [:written.desc])
haml :index
end
get '/post/:id' do
@post = Post.get_released(params[:id])
if @post.nil?
flash.warning = 'Post not found!'
redirect '/'
else
haml :post_single
end
end
get '/stylesheet.css' do
scss :stylesheet
end