Module: Hyde::Server::PageHelpers

Defined in:
lib/hyde/server.rb

Instance Method Summary collapse

Instance Method Details

#mime_type_for(page) ⇒ Object



35
36
37
38
39
# File 'lib/hyde/server.rb', line 35

def mime_type_for(page)
  type   = page.mime_type
  type ||= Rack::Mime::MIME_TYPES[File.extname(page.file)]
  type
end

#not_foundObject



14
15
16
17
18
# File 'lib/hyde/server.rb', line 14

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



20
21
22
# File 'lib/hyde/server.rb', line 20

def options
  @options ||= Hash.new
end

#serverObject



41
42
43
# File 'lib/hyde/server.rb', line 41

def server
  Hyde::Server
end

#show_status(page) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/hyde/server.rb', line 24

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