diff options
Diffstat (limited to 'interfaces')
-rw-r--r-- | interfaces/http/web/web.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/interfaces/http/web/web.rb b/interfaces/http/web/web.rb index 16492c2..0903bb4 100644 --- a/interfaces/http/web/web.rb +++ b/interfaces/http/web/web.rb @@ -5,10 +5,11 @@ class WebInterface < Sinatra::Base erb :index end - get '/:year/:month/:day/:slug' do - @posts = Post.where(slug: params['slug']) + get '/:year/:month/:day/:slug' do |y, m, d, slug| + @posts = Post.where(slug: slug) - if @posts.empty? then + 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 |