forked from shibao/cannery
rename page to home
This commit is contained in:
parent
192c25c9a9
commit
21a7160be4
@ -1,4 +1,4 @@
|
|||||||
defmodule CanneryWeb.PageController do
|
defmodule CanneryWeb.HomeController do
|
||||||
use CanneryWeb, :controller
|
use CanneryWeb, :controller
|
||||||
|
|
||||||
def index(conn, _params) do
|
def index(conn, _params) do
|
@ -1,7 +1,7 @@
|
|||||||
defmodule CanneryWeb.Live.Component.Topbar do
|
defmodule CanneryWeb.Live.Component.Topbar do
|
||||||
use CanneryWeb, :live_component
|
use CanneryWeb, :live_component
|
||||||
|
|
||||||
alias CanneryWeb.{PageLive}
|
alias CanneryWeb.{HomeLive}
|
||||||
|
|
||||||
def mount(socket) do
|
def mount(socket) do
|
||||||
{:ok, socket |> assign(results: [], title_content: nil)}
|
{:ok, socket |> assign(results: [], title_content: nil)}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<nav role="navigation">
|
<nav role="navigation">
|
||||||
<div class="flex flex-row justify-between items-center space-x-4">
|
<div class="flex flex-row justify-between items-center space-x-4">
|
||||||
<div class="flex flex-row justify-start items-center space-x-2">
|
<div class="flex flex-row justify-start items-center space-x-2">
|
||||||
<%= link to: Routes.page_path(CanneryWeb.Endpoint, :index) do %>
|
<%= link to: Routes.home_path(CanneryWeb.Endpoint, :index) do %>
|
||||||
<h1 class="leading-5 text-xl text-white hover:underline">Cannery</h1>
|
<h1 class="leading-5 text-xl text-white hover:underline">Cannery</h1>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
defmodule CanneryWeb.PageLive do
|
defmodule CanneryWeb.HomeLive do
|
||||||
use CanneryWeb, :live_view
|
use CanneryWeb, :live_view
|
||||||
|
alias Cannery.{Accounts}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, session, socket) do
|
def mount(_params, session, socket) do
|
||||||
{:ok, socket |> assign_defaults(session) |> assign(query: "", results: %{})}
|
admins = Accounts.list_users_by_role(:admin)
|
||||||
|
{:ok, socket |> assign_defaults(session) |> assign(query: "", results: %{}, admins: admins)}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
68
lib/cannery_web/live/home_live.html.leex
Normal file
68
lib/cannery_web/live/home_live.html.leex
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<div class="mx-auto flex flex-col justify-center items-center text-center space-y-4 max-w-3xl">
|
||||||
|
<h1 class="title text-primary-500 text-2xl">
|
||||||
|
Welcome to Cannery
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<h2 class="title text-primary-500 text-lg">
|
||||||
|
The Self-hosted Ammo Tracker Website
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<hr class="hr" />
|
||||||
|
|
||||||
|
<ul class="flex flex-col space-y-2 text-center">
|
||||||
|
<li class="flex flex-row justify-center space-x-2">
|
||||||
|
<b>Easy to Use:</b>
|
||||||
|
<p>
|
||||||
|
Cannery lets you easily keep an eye on your ammo levels after range day
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li class="flex flex-row justify-center space-x-2">
|
||||||
|
<b>Secure:</b>
|
||||||
|
<p>
|
||||||
|
Self-host your own instance, or use an instance from someone you trust.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li class="flex flex-row justify-center space-x-2">
|
||||||
|
<b>Simple:</b>
|
||||||
|
<p>
|
||||||
|
Access from any internet-capable device
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr class="hr" />
|
||||||
|
|
||||||
|
<ul class="flex flex-col space-y-2 text-center justify-center">
|
||||||
|
<h2 class="title text-primary-500 text-lg">
|
||||||
|
Instance Information
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<li class="flex flex-col justify-center space-x-2">
|
||||||
|
<b>Admins:</b>
|
||||||
|
<p>
|
||||||
|
<%= if @admins |> Enum.empty?() do %>
|
||||||
|
<%= link "Sign up to setup Cannery!", class: "hover:underline",
|
||||||
|
to: Routes.user_registration_path(CanneryWeb.Endpoint, :new) %>
|
||||||
|
<% else %>
|
||||||
|
<div class="flex flex-wrap justify-center space-x-2">
|
||||||
|
<%= for admin <- @admins do %>
|
||||||
|
<a class="hover:underline" href="mailto:<%= admin.email %>">
|
||||||
|
<%= admin.email %>
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li class="flex flex-row justify-center space-x-2">
|
||||||
|
<b>Registration:</b>
|
||||||
|
<p>
|
||||||
|
<%= Application.get_env(:cannery, CanneryWeb.Endpoint)[:registration]
|
||||||
|
|> case do
|
||||||
|
"public" -> "Public Signups"
|
||||||
|
_ -> "Invite Only"
|
||||||
|
end %>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
@ -1,9 +0,0 @@
|
|||||||
<div class="flex flex-col justify-center items-center text-center space-y-4">
|
|
||||||
<h1 class="title text-primary-500 text-2xl">
|
|
||||||
Welcome to Cannery
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<p class="title text-primary-500 text-lg">
|
|
||||||
The Self-hosted Ammo Tracker Website
|
|
||||||
</p>
|
|
||||||
</div>
|
|
@ -1,6 +1,6 @@
|
|||||||
<nav role="navigation">
|
<nav role="navigation">
|
||||||
<div class="flex flex-row justify-between items-center space-x-4">
|
<div class="flex flex-row justify-between items-center space-x-4">
|
||||||
<%= link to: Routes.page_path(CanneryWeb.Endpoint, :index) do %>
|
<%= link to: Routes.home_path(CanneryWeb.Endpoint, :index) do %>
|
||||||
<h1 class="leading-5 text-xl text-white hover:underline">Cannery</h1>
|
<h1 class="leading-5 text-xl text-white hover:underline">Cannery</h1>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
3
lib/cannery_web/views/home_view.ex
Normal file
3
lib/cannery_web/views/home_view.ex
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
defmodule CanneryWeb.HomeView do
|
||||||
|
use CanneryWeb, :view
|
||||||
|
end
|
@ -1,3 +0,0 @@
|
|||||||
defmodule CanneryWeb.PageView do
|
|
||||||
use CanneryWeb, :view
|
|
||||||
end
|
|
8
test/cannery_web/controllers/home_controller_test.exs
Normal file
8
test/cannery_web/controllers/home_controller_test.exs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
defmodule CanneryWeb.HomeControllerTest do
|
||||||
|
use CanneryWeb.ConnCase
|
||||||
|
|
||||||
|
test "GET /", %{conn: conn} do
|
||||||
|
conn = get(conn, "/")
|
||||||
|
assert html_response(conn, 200) =~ "Welcome to Cannery"
|
||||||
|
end
|
||||||
|
end
|
@ -1,8 +0,0 @@
|
|||||||
defmodule CanneryWeb.PageControllerTest do
|
|
||||||
use CanneryWeb.ConnCase
|
|
||||||
|
|
||||||
test "GET /", %{conn: conn} do
|
|
||||||
conn = get(conn, "/")
|
|
||||||
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
|
|
||||||
end
|
|
||||||
end
|
|
11
test/cannery_web/live/home_live_test.exs
Normal file
11
test/cannery_web/live/home_live_test.exs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
defmodule CanneryWeb.HomeLiveTest do
|
||||||
|
use CanneryWeb.ConnCase
|
||||||
|
|
||||||
|
import Phoenix.LiveViewTest
|
||||||
|
|
||||||
|
test "disconnected and connected render", %{conn: conn} do
|
||||||
|
{:ok, home_live, disconnected_html} = live(conn, "/")
|
||||||
|
assert disconnected_html =~ "Welcome to Cannery"
|
||||||
|
assert render(home_live) =~ "Welcome to Cannery"
|
||||||
|
end
|
||||||
|
end
|
@ -1,11 +0,0 @@
|
|||||||
defmodule CanneryWeb.PageLiveTest do
|
|
||||||
use CanneryWeb.ConnCase
|
|
||||||
|
|
||||||
import Phoenix.LiveViewTest
|
|
||||||
|
|
||||||
test "disconnected and connected render", %{conn: conn} do
|
|
||||||
{:ok, page_live, disconnected_html} = live(conn, "/")
|
|
||||||
assert disconnected_html =~ "Welcome to Phoenix!"
|
|
||||||
assert render(page_live) =~ "Welcome to Phoenix!"
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,3 +1,3 @@
|
|||||||
defmodule CanneryWeb.PageViewTest do
|
defmodule CanneryWeb.HomeViewTest do
|
||||||
use CanneryWeb.ConnCase, async: true
|
use CanneryWeb.ConnCase, async: true
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user