Module: Proton::Server::PageHelpers

Defined in:
lib/proton/server.rb

Instance Method Summary collapse

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_foundObject



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

#optionsObject



25
26
27
# File 'lib/proton/server.rb', line 25

def options
  @options ||= Hash.new
end

#serverObject



46
47
48
# File 'lib/proton/server.rb', line 46

def server
  Proton::Server
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 options[: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