try to find the post with the jenkins url format
This commit is contained in:
parent
45a2dd1635
commit
f60c4a45b3
|
@ -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
14
page.rb
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue