aboutsummaryrefslogtreecommitdiff
path: root/interfaces/http/web/web.rb
blob: 16492c26c5d784a72049a12d577c6b6f8dcdc333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class WebInterface < Sinatra::Base
  get '/' do
    @title = $config.title
    @posts = Post.all
    erb :index
  end
  
  get '/:year/:month/:day/:slug' do
    @posts = Post.where(slug: params['slug'])
    
    if @posts.empty? then
      status 404
      @title = '404 Not Found'
      erb :not_found
    else
      @post = @posts[0]
      @title = @post.title
      erb :post
    end
  end
end