blob: 0903bb4016047c289910ecfaa56513e11b21eeaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
class WebInterface < Sinatra::Base
get '/' do
@title = $config.title
@posts = Post.all
erb :index
end
get '/:year/:month/:day/:slug' do |y, m, d, slug|
@posts = Post.where(slug: slug)
date = DateTime.strptime("#{y}-#{m}-#{d}", "%Y-%m-%d")
if @posts.empty? or @posts[0].created_at.to_date != date.to_date then
status 404
@title = '404 Not Found'
erb :not_found
else
@post = @posts[0]
@title = @post.title
erb :post
end
end
end
|