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