Skip to content

Commit

Permalink
Cleanup Layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Feb 28, 2022
1 parent ce52acc commit d113322
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 140 deletions.
53 changes: 0 additions & 53 deletions lib/athena_web/admin/templates/layout/app.html.eex

This file was deleted.

6 changes: 6 additions & 0 deletions lib/athena_web/admin/templates/layout/app.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<main role="main" class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-warning" role="alert"><%= get_flash(@conn, :warning) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= @inner_content %>
</main>
11 changes: 11 additions & 0 deletions lib/athena_web/admin/templates/layout/live.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<main class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>

<p class="alert alert-danger" role="alert"
phx-click="lv:clear-flash"
phx-value-key="error"><%= live_flash(@flash, :error) %></p>

<%= @inner_content %>
</main>
50 changes: 50 additions & 0 deletions lib/athena_web/admin/templates/layout/root.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!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"/>
<title>
<%=
case assigns[:event] do
nil -> "Athena"
%{name: name} -> name
end
%>
</title>
<link rel="stylesheet" href={ Routes.static_path(@conn, "/css/app.css") } />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
<%= csrf_meta_tag() %>
<script async type="text/javascript" src={ Routes.static_path(@conn, "/js/app.js") }></script>
</head>
<body class={ if Map.has_key?(assigns, :navigation), do: "has_nav", else: "" }>
<%= if Map.has_key?(assigns, :navigation) do %>
<input type="checkbox" id="toggle-nav" hidden />
<nav>
<header>
<span><%= @navigation.event.name %></span>
<label for="toggle-nav">
<span></span>
</label>
</header>
<main>
<ul>
<%= for %{id: location_id, name: location_name} <- @navigation.locations do %>
<li>
<%= link location_name, to: Routes.admin_location_path(@conn, :show, location_id) %>
</li>
<% end %>
<li class="divider"></li>
<%= for %{id: item_group_id, name: item_group_name} <- @navigation.item_groups do %>
<li>
<%= link item_group_name, to: Routes.admin_item_group_path(@conn, :show, item_group_id) %>
</li>
<% end %>
</ul>
</main>
</nav>
<% end %>

<%= @inner_content %>
</body>
</html>
6 changes: 6 additions & 0 deletions lib/athena_web/frontend/templates/layout/app.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<main role="main" class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-warning" role="alert"><%= get_flash(@conn, :warning) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<%= @inner_content %>
</main>
11 changes: 11 additions & 0 deletions lib/athena_web/frontend/templates/layout/live.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<main class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>

<p class="alert alert-danger" role="alert"
phx-click="lv:clear-flash"
phx-value-key="error"><%= live_flash(@flash, :error) %></p>

<%= @inner_content %>
</main>
48 changes: 0 additions & 48 deletions lib/athena_web/frontend/templates/layout/logistics.html.eex

This file was deleted.

55 changes: 55 additions & 0 deletions lib/athena_web/frontend/templates/layout/root.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!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"/>
<title><%= @event.name %></title>
<link rel="stylesheet" href={ Routes.static_path(@conn, "/css/app.css") } />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
<%= csrf_meta_tag() %>
<script async type="text/javascript" src={ Routes.static_path(@conn, "/js/app.js") }></script>
</head>
<body class={
case @access do
:logistics -> "has_nav"
:vendor -> ""
end
}>
<%= case @access do %>
<% :logistics -> %>
<input type="checkbox" id="toggle-nav" hidden />
<nav>
<header>
<span><%= @navigation.event.name %></span>
<label for="toggle-nav">
<span></span>
</label>
</header>
<main>
<ul>
<li>
<%= "Logistics Overview" |> gettext |> link(to: Routes.frontend_logistics_live_url(@conn, AthenaWeb.Frontend.LogisticsLive, @navigation.event.id)) %>
</li>
<li>
<%= "Supply Item" |> gettext |> link(to: Routes.frontend_logistics_movement_url(@conn, :supply_new, @navigation.event.id)) %>
</li>
<li>
<%= "Move Item" |> gettext |> link(to: Routes.frontend_logistics_movement_url(@conn, :relocate_new, @navigation.event.id)) %>
</li>
<li class="divider"></li>
<%= for %{id: location_id, name: location_name} <- @navigation.locations do %>
<li>
<%= link location_name, to: Routes.frontend_logistics_location_url(@conn, :show, location_id) %>
</li>
<% end %>
</ul>
</main>
</nav>

<% :vendor -> %>
<% end %>

<%= @inner_content %>
</body>
</html>
20 changes: 0 additions & 20 deletions lib/athena_web/frontend/templates/layout/vendor.html.eex

This file was deleted.

27 changes: 8 additions & 19 deletions lib/athena_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,16 @@ defmodule AthenaWeb.Router do

pipeline :admin do
plug :auth
plug :put_layout, {AthenaWeb.Admin.LayoutView, "app.html"}
plug :put_layout, {AthenaWeb.Admin.LayoutView, :app}
plug :put_root_layout, {AthenaWeb.Admin.LayoutView, :root}
end

pipeline :frontend_logistics do
plug :put_layout, {AthenaWeb.Frontend.LayoutView, "logistics.html"}
pipeline :frontend do
plug :put_layout, {AthenaWeb.Frontend.LayoutView, :app}
plug :put_root_layout, {AthenaWeb.Frontend.LayoutView, :root}
end

pipeline :frontend_vendor do
plug :put_layout, {AthenaWeb.Frontend.LayoutView, "vendor.html"}
end

pipeline :api do
plug :accepts, ["json"]
end

scope "/admin", AthenaWeb.Admin, as: :admin do
scope "/admin", AthenaWeb.Admin, as: :admin, assigns: %{access: :admin} do
pipe_through [:browser, :admin]

resources "/events", EventController
Expand All @@ -66,7 +60,7 @@ defmodule AthenaWeb.Router do
end

scope "/logistics/", AthenaWeb.Frontend, as: :frontend_logistics, assigns: %{access: :logistics} do
pipe_through [:browser, :frontend_logistics]
pipe_through [:browser, :frontend]

get "/locations/:id", LocationController, :show

Expand All @@ -79,7 +73,7 @@ defmodule AthenaWeb.Router do
end

scope "/vendor/", AthenaWeb.Frontend, as: :frontend_vendor, assigns: %{access: :vendor} do
pipe_through [:browser, :frontend_vendor]
pipe_through [:browser, :frontend]

get "/locations/:id", LocationController, :show
end
Expand All @@ -88,11 +82,6 @@ defmodule AthenaWeb.Router do
get "/", Redirector, to: "/admin/events"
end

# Other scopes may use custom stacks.
# scope "/api", AthenaWeb do
# pipe_through :api
# end

defp auth(conn, _opts),
do: Plug.BasicAuth.basic_auth(conn, Application.fetch_env!(:athena, Plug.BasicAuth))
end

0 comments on commit d113322

Please sign in to comment.