0
0
Fork 0

Merge branch 'master' of github.com:Gibheer/zero-blog

This commit is contained in:
Stormwind 2011-07-05 21:10:11 +02:00
commit 51ffe200d2
3 changed files with 23 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

7
views/post_single.haml Normal file
View File

@ -0,0 +1,7 @@
%article
%header
%h1=@post.title
%footer
.author=@post.account.username
.date=@post.written
%section=markup(@post.content, @post.markup)