Class: Stickler::Middleware::NotFound
- Inherits:
-
Object
- Object
- Stickler::Middleware::NotFound
- Defined in:
- lib/stickler/middleware/not_found.rb
Overview
Idea completely taken from rack-contrib, it can function as a middleware also, and in that case, completely swallows all requests and returns the 4040 page.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil) ⇒ NotFound
constructor
A new instance of NotFound.
Constructor Details
#initialize(app = nil) ⇒ NotFound
Returns a new instance of NotFound.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stickler/middleware/not_found.rb', line 9 def initialize( app = nil ) @body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n <head>\n<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />\n<style type=\"text/css\" media=\"screen\">\n * { margin: 0; padding: 0; border: 0; outline: 0; }\n div.clear { clear: both; }\n body { background: #eeeeee; margin: 0; padding: 0; }\n #wrap { width: 1000px; margin: 0 auto; padding: 30px 50px 20px 50px;\n background: #fff; border-left: 1px solid #DDD;\n border-right: 1px solid #DDD; }\n #header { margin: 0 auto 25px auto; }\n h1 { margin: 0; font-size: 36px; color: #981919; text-align: center; }\n h2 { margin: 0; font-size: 22px; color: #333333; }\n table.gem { width: 980px; text-align: left; font-size: 12px;\n color: #666666; padding: 0; border-spacing: 0;\n border: 1px solid #EEEEEE; border-bottom: 0;\n border-left: 0;\n clear:both;}\n table.gem tr th { padding: 2px 10px; font-weight: bold;\n font-size: 22px; background: #f7f7f7; text-align: center;\n border-left: 1px solid #eeeeee;\n border-bottom: 1px solid #eeeeee; }\n table.gem tr td { padding: 2px 20px 2px 10px;\n border-bottom: 1px solid #eeeeee;\n border-left: 1px solid #eeeeee; }\n\n</style>\n<title>Stickler - Not Found</title>\n </head>\n <body>\n<div id=\"wrap\">\n <div id=\"header\">\n <h1>Nothing Found</h1>\n </div>\n <h2>Try <a href=\"/\">Over Here</a></h2>\n</div>\n </body>\n</html>\n _\n @size = @body.size.to_s\nend\n" |
Instance Method Details
#call(env) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/stickler/middleware/not_found.rb', line 57 def call( env ) [ 404, { 'Content-Type' => 'text/html', 'Content-Length' => @size }, [ @body ] ] end |