diff options
author | John Ankarström <john@ankarstrom.se> | 2021-03-02 21:35:44 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-03-02 21:35:44 +0100 |
commit | d072b503f5ccc5d08f279aac463d37837cbbb576 (patch) | |
tree | f8f1265ea274ad1d4a32a8272da68187813231e6 /interfaces/http/web/web.rb | |
parent | 0882804d708fe5a1732c6b9faa7d9a2f369f5257 (diff) | |
download | comb-d072b503f5ccc5d08f279aac463d37837cbbb576.tar.gz |
Add 'post' and 'not_found' views
Diffstat (limited to 'interfaces/http/web/web.rb')
-rw-r--r-- | interfaces/http/web/web.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/interfaces/http/web/web.rb b/interfaces/http/web/web.rb index ca04ecc..16492c2 100644 --- a/interfaces/http/web/web.rb +++ b/interfaces/http/web/web.rb @@ -1,6 +1,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 |