kemal/src/kemal/view.cr

67 lines
1.7 KiB
Crystal
Raw Normal View History

2016-01-05 15:35:07 +00:00
# Template for 403 Forbidden
2016-01-24 10:22:25 +00:00
def render_403(context)
2016-01-05 15:35:07 +00:00
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
2016-01-24 10:22:25 +00:00
context.response.status_code = 403
context.response.puts template
2016-01-05 15:35:07 +00:00
end
2015-12-13 08:25:04 +00:00
# Template for 404 Not Found
2016-01-24 10:22:25 +00:00
def render_404(context)
2015-12-10 18:40:39 +00:00
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
2016-01-24 10:22:25 +00:00
context.response.status_code = 404
context.response.puts template
2015-12-10 18:40:39 +00:00
end
2015-12-13 08:25:04 +00:00
# Template for 500 Internal Server Error
2016-01-24 10:22:25 +00:00
def render_500(context, ex)
2015-12-10 18:40:39 +00:00
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
2016-01-24 10:22:25 +00:00
context.response.status_code = 500
context.response.puts template
2015-12-10 18:40:39 +00:00
end