Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/admin_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ defmodule AdminWeb do
those modules here.
"""

def static_paths, do: ~w(assets fonts images icons favicon.ico robots.txt)
def static_paths,
do: ~w(assets fonts images icons favicon.ico favicons robots.txt)

def router do
quote do
Expand Down
47 changes: 47 additions & 0 deletions lib/admin_web/components/layouts/admin_root.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang={assigns[:locale]}>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content={get_csrf_token()} />
<meta
name="description"
content={
assigns[:page_description] ||
gettext("Graasp is a platform for collaborative learning and teaching.")
}
/>
<.live_title default={gettext("Home")} suffix=" · Admin">
{assigns[:page_title]}
</.live_title>
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
<link rel="icon" type="image/png" href="/favicons/admin_favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicons/admin_favicon.svg" />
<link rel="shortcut icon" href="/favicons/admin_favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/admin_apple-touch-icon.png" />
<script defer phx-track-static type="text/javascript" src={~p"/assets/js/app.js"}>
</script>
<script>
(() => {
const setTheme = (theme) => {
if (theme === "system") {
localStorage.removeItem("phx:theme");
document.documentElement.removeAttribute("data-theme");
} else {
localStorage.setItem("phx:theme", theme);
document.documentElement.setAttribute("data-theme", theme);
}
};
if (!document.documentElement.hasAttribute("data-theme")) {
setTheme(localStorage.getItem("phx:theme") || "system");
}
window.addEventListener("storage", (e) => e.key === "phx:theme" && setTheme(e.newValue || "system"));

window.addEventListener("phx:set-theme", (e) => setTheme(e.target.dataset.phxTheme));
})();
</script>
</head>
<body class="min-h-screen flex flex-col flex-1">
{@inner_content}
</body>
</html>
4 changes: 4 additions & 0 deletions lib/admin_web/components/layouts/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
{assigns[:page_title]}
</.live_title>
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
<link rel="icon" type="image/png" href="/favicons/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicons/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico?v=3" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png" />
<script defer phx-track-static type="text/javascript" src={~p"/assets/js/app.js"}>
</script>
<script>
Expand Down
21 changes: 16 additions & 5 deletions lib/admin_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ defmodule AdminWeb.Router do
plug AdminWeb.Plugs.Locale, "en"
end

pipeline :browser_admin do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {AdminWeb.Layouts, :admin_root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_scope_for_user
plug AdminWeb.Plugs.Locale, "en"
end

pipeline :api do
plug :accepts, ["json"]
end
Expand Down Expand Up @@ -45,7 +56,7 @@ defmodule AdminWeb.Router do
end

scope "/admin", AdminWeb do
pipe_through :browser
pipe_through :browser_admin

get "/", AdminController, :home
end
Expand All @@ -65,7 +76,7 @@ defmodule AdminWeb.Router do
import Phoenix.LiveDashboard.Router

scope "/dev" do
pipe_through :browser
pipe_through :browser_admin

live_dashboard "/dashboard", metrics: AdminWeb.Telemetry
forward "/mailbox", Plug.Swoosh.MailboxPreview
Expand All @@ -83,7 +94,7 @@ defmodule AdminWeb.Router do

## Authentication LV routes
scope "/admin", AdminWeb do
pipe_through [:browser, :require_authenticated_user]
pipe_through [:browser_admin, :require_authenticated_user]

live_session :require_authenticated_user,
on_mount: [{AdminWeb.UserAuth, :require_authenticated}] do
Expand Down Expand Up @@ -148,7 +159,7 @@ defmodule AdminWeb.Router do

## Authentication related routes
scope "/admin", AdminWeb do
pipe_through [:browser]
pipe_through [:browser_admin]

live_session :current_user,
on_mount: [{AdminWeb.UserAuth, :mount_current_scope}] do
Expand All @@ -164,7 +175,7 @@ defmodule AdminWeb.Router do

## Authenticated controller routes
scope "/admin", AdminWeb do
pipe_through [:browser, :require_authenticated_user]
pipe_through [:browser_admin, :require_authenticated_user]

get "/dashboard", AdminController, :dashboard
resources "/maintenance", PlannedMaintenanceController
Expand Down
Binary file modified priv/static/favicon.ico
Binary file not shown.
Binary file added priv/static/favicons/admin_apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added priv/static/favicons/admin_favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added priv/static/favicons/admin_favicon.ico
Binary file not shown.
13 changes: 13 additions & 0 deletions priv/static/favicons/admin_favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added priv/static/favicons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added priv/static/favicons/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions priv/static/favicons/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading