Permalink
Browse files

404 page

  • Loading branch information...
mislav committed May 14, 2012
1 parent 80488ca commit e77819dfbbe5ea544514366dd8781b827aa55b5a
Showing with 17 additions and 2 deletions.
  1. +6 −2 app.rb
  2. +11 −0 views/not_found.erb
View
8 app.rb
@@ -80,6 +80,10 @@ def page_title title = nil
page_title "Pretty RFCs"
end
+error 404 do
+ erb :not_found
+end
+
get "/" do
cache_control :public
last_modified File.mtime('views/index.erb')
@@ -94,8 +98,8 @@ def page_title title = nil
erb :search
end
-get "/:doc_id" do
- @rfc = RfcDocument.fetch(params[:doc_id]) { halt 404 }
+get %r{^/ (?<doc_id> [a-z]* -? \d+) $}ix do
+ @rfc = RfcDocument.fetch(params[:doc_id]) { not_found }
redirect to(@rfc.id) unless request.path == "/#{@rfc.id}"
cache_control :public
View
@@ -0,0 +1,11 @@
+<div id=404 class=container>
+
+ <div class="hero-unit page-header">
+ <h1>Not found</h1>
+ <p>
+ Resource is not present in the app.
+ </p>
+ <nav><a href="<%= home_path %>">&larr; Home</a></nav>
+ </div>
+
+</div>

0 comments on commit e77819d

Please sign in to comment.