0
0
Fork 0

try to find the post with the jenkins url format

This commit is contained in:
Gibheer 2011-07-05 21:37:18 +02:00
parent 45a2dd1635
commit f60c4a45b3
2 changed files with 18 additions and 0 deletions

View File

@ -16,6 +16,10 @@ class Post
first(:id => id, :released => true)
end
def self.find_of_day time
all(:written => time..(time+86400))
end
def acknowledged_comments
comments(:acknowledged => true)
end

14
page.rb
View File

@ -9,6 +9,20 @@ class Blog < Sinatra::Base
haml :index
end
get '/:year/:month/:day/:title.html' do
@post = Post.find_of_day(
Time.mktime(params[:year], params[:month], params[:day])
).select do |post|
params[:title] == post.title.gsub(/ /, '_').downcase
end
if @post.count > 0
@post = @post[0]
haml :post_single
else
404
end
end
get '/post/:id' do
@post = Post.get_released(params[:id])
if @post.nil?