kemal/src/kemal/view.cr

64 lines
1.6 KiB
Crystal
Raw Normal View History

2016-01-05 15:35:07 +00:00
# Template for 403 Forbidden
def render_403
template = <<-HTML
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body { text-align:center;font-family:helvetica,arial;font-size:22px;
color:#888;margin:20px}
#c {margin:0 auto;width:500px;text-align:left}
</style>
</head>
<body>
<h2>Forbidden</h2>
<h3>Kemal doesn't allow you to see this page.</h3>
<img src="/__kemal__/404.png">
</body>
</html>
HTML
HTTP::Response.new(403, template)
end
2015-12-13 08:25:04 +00:00
# Template for 404 Not Found
2015-12-10 18:40:39 +00:00
def render_404
template = <<-HTML
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body { text-align:center;font-family:helvetica,arial;font-size:22px;
color:#888;margin:20px}
#c {margin:0 auto;width:500px;text-align:left}
</style>
</head>
<body>
<h2>Kemal doesn't know this way.</h2>
<img src="/__kemal__/404.png">
</body>
</html>
HTML
HTTP::Response.new(404, template)
end
2015-12-13 08:25:04 +00:00
# Template for 500 Internal Server Error
2015-12-10 18:40:39 +00:00
def render_500(ex)
template = <<-HTML
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body { text-align:center;font-family:helvetica,arial;font-size:22px;
color:#888;margin:20px}
#c {margin:0 auto;width:500px;text-align:left}
</style>
</head>
<body>
<h2>Kemal has encountered an error. (500)</h2>
<p>#{ex}</p>
</body>
</html>
HTML
HTTP::Response.error("text/html", template)
end