Module: Proton::Server::PageHelpers
- Defined in:
- lib/proton/server.rb
Instance Method Summary collapse
- #mime_type_for(page) ⇒ Object
- #not_found ⇒ Object
- #options ⇒ Object
- #server ⇒ Object
- #show_status(page) ⇒ Object
Instance Method Details
#mime_type_for(page) ⇒ Object
40 41 42 43 44 |
# File 'lib/proton/server.rb', line 40 def mime_type_for(page) type = page.mime_type type ||= Rack::Mime::MIME_TYPES[File.extname(page.file)] type end |
#not_found ⇒ Object
19 20 21 22 23 |
# File 'lib/proton/server.rb', line 19 def not_found show_status nil res.status = 404 res.write "<h1>File Not Found</h1><p>The path <code>#{env['PATH_INFO']}</code> was not found." + " "*1024 end |
#options ⇒ Object
25 26 27 |
# File 'lib/proton/server.rb', line 25 def @options ||= Hash.new end |
#show_status(page) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/proton/server.rb', line 29 def show_status(page) return if [:quiet] path = env['PATH_INFO'] return if path == '/favicon.ico' status = page ? "\033[0;32m[ OK ]" : "\033[0;31m[404 ]" verb = get ? 'GET ' : (post ? 'POST' : '') puts "%s\033[0;m %s %s" % [ status, verb, env['PATH_INFO'] ] puts " src: #{page.filepath} (#{page.tilt_engine_name})" if page && page.tilt? end |