mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-10 13:38:09 +08:00
Unify error pages (#1999)
This commit is contained in:
parent
d4e950bd05
commit
9a8a252bb9
4 changed files with 54 additions and 77 deletions
|
@ -1,9 +1,61 @@
|
||||||
defmodule LivebookWeb.ErrorHTML do
|
defmodule LivebookWeb.ErrorHTML do
|
||||||
use LivebookWeb, :html
|
use LivebookWeb, :html
|
||||||
|
|
||||||
embed_templates "error_html/*"
|
def render("404.html", assigns) do
|
||||||
|
~H"""
|
||||||
|
<.error_page status={@status} title="No Numbats here!" />
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
def render("403.html", assigns) do
|
||||||
|
~H"""
|
||||||
|
<.error_page status={@status} title="No Numbats allowed here!" />
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
def render(_template, assigns) do
|
def render(_template, assigns) do
|
||||||
render("500.html", assigns)
|
~H"""
|
||||||
|
<.error_page
|
||||||
|
status={@status}
|
||||||
|
title="Something went wrong."
|
||||||
|
details="Check out the console for logs for more information."
|
||||||
|
/>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
attr :status, :integer, required: true
|
||||||
|
attr :title, :string, required: true
|
||||||
|
attr :details, :string, default: nil
|
||||||
|
|
||||||
|
defp error_page(assigns) do
|
||||||
|
~H"""
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href={~p"/favicon.svg"} />
|
||||||
|
<link rel="alternate icon" type="image/png" href={~p"/favicon.png"} />
|
||||||
|
<title><%= @status %> - Livebook</title>
|
||||||
|
<link rel="stylesheet" href={~p"/assets/app.css"} />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="h-screen flex items-center justify-center bg-gray-900">
|
||||||
|
<div class="flex flex-col space-y-4 items-center">
|
||||||
|
<a href={~p"/"}>
|
||||||
|
<img src={~p"/images/logo.png"} height="128" width="128" alt="livebook" />
|
||||||
|
</a>
|
||||||
|
<div class="text-2xl text-gray-50">
|
||||||
|
<%= @title %>
|
||||||
|
</div>
|
||||||
|
<div :if={@details} class="text-lg text-gray-50">
|
||||||
|
<%= @details %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href={~p"/favicon.svg"} />
|
|
||||||
<link rel="alternate icon" type="image/png" href={~p"/favicon.png"} />
|
|
||||||
<title><%= @status %> - Livebook</title>
|
|
||||||
<link rel="stylesheet" href={~p"/assets/app.css"} />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="h-screen flex items-center justify-center bg-gray-900">
|
|
||||||
<div class="flex flex-col space-y-4 items-center">
|
|
||||||
<a href={~p"/"}>
|
|
||||||
<img src={~p"/images/logo.png"} height="128" width="128" alt="livebook" />
|
|
||||||
</a>
|
|
||||||
<div class="text-2xl text-gray-50">
|
|
||||||
No Numbats allowed here!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href={~p"/favicon.svg"} />
|
|
||||||
<link rel="alternate icon" type="image/png" href={~p"/favicon.png"} />
|
|
||||||
<title><%= @status %> - Livebook</title>
|
|
||||||
<link rel="stylesheet" href={~p"/assets/app.css"} />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="h-screen flex items-center justify-center bg-gray-900">
|
|
||||||
<div class="flex flex-col space-y-4 items-center">
|
|
||||||
<a href={~p"/"}>
|
|
||||||
<img src={~p"/images/logo.png"} height="128" width="128" alt="livebook" />
|
|
||||||
</a>
|
|
||||||
<div class="text-2xl text-gray-50">
|
|
||||||
No Numbats here!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,27 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href={~p"/favicon.svg"} />
|
|
||||||
<link rel="alternate icon" type="image/png" href={~p"/favicon.png"} />
|
|
||||||
<title><%= @status %> - Livebook</title>
|
|
||||||
<link rel="stylesheet" href={~p"/assets/app.css"} />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="h-screen flex items-center justify-center bg-gray-900">
|
|
||||||
<div class="flex flex-col space-y-4 items-center">
|
|
||||||
<a href={~p"/"}>
|
|
||||||
<img src={~p"/images/logo.png"} height="128" width="128" alt="livebook" />
|
|
||||||
</a>
|
|
||||||
<div class="text-2xl text-gray-50">
|
|
||||||
Something went wrong.
|
|
||||||
</div>
|
|
||||||
<div class="text-lg text-gray-50">
|
|
||||||
Check out the console for logs for more information.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Add table
Reference in a new issue