Skip to content

Commit d7e1f92

Browse files
committed
fix/improve page titles (in browser)
1 parent e05be7a commit d7e1f92

File tree

6 files changed

+35
-28
lines changed

6 files changed

+35
-28
lines changed

lib/wik_web/components/layouts/root.html.heex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
content="width=device-width, initial-scale=1, interactive-widget=resizes-content"
88
/>
99
<meta name="csrf-token" content={get_csrf_token()} />
10-
<.live_title suffix={" | #{assigns[:group_name]}"}>
11-
{assigns[:page_title]}
12-
</.live_title>
10+
11+
<.live_title>Wik</.live_title>
12+
1313
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
14+
1415
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
1516
</script>
1617
</head>
18+
1719
<body class="from-slate-400 to-slate-200 bg-gradient-to-b min-h-[100vh]">
1820
{@inner_content}
1921
</body>

lib/wik_web/controllers/page_html/root_index.html.heex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<.flash_group flash={@flash} />
22

3+
<.live_title>Your Groups | Wik</.live_title>
4+
35
<Layouts.app_layout>
46
<:header_left></:header_left>
57

lib/wik_web/live/me/show_live.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ defmodule WikWeb.Me.ShowLive do
88

99
{:ok,
1010
socket
11+
|> assign(:page_title, "Your details | Wik")
1112
|> assign(:user, session["user"])
1213
|> assign(superuser?: superuser?), layout: {WikWeb.Layouts, :root}}
1314
end

lib/wik_web/live/page/show_live.ex

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@ defmodule WikWeb.Page.ShowLive do
55
require Logger
66

77
@impl true
8-
def mount(_params, session, socket) do
9-
user = session["user"] || %{}
10-
8+
def mount(%{"group_slug" => group_slug, "slug" => page_slug}, session, socket) do
119
Phoenix.PubSub.subscribe(Wik.PubSub, "pages")
1210

11+
user = session["user"]
12+
group_name = Wik.get_group_name(group_slug)
13+
1314
{:ok,
1415
socket
1516
|> assign(:user, user)
16-
|> assign(:backlinks, [])}
17+
|> assign(:page_slug, page_slug)
18+
|> assign(:page_title, "#{page_slug} | #{group_name}")
19+
|> assign(:backlinks, Page.backlinks(group_slug, page_slug))
20+
|> assign(:group_slug, group_slug)
21+
|> assign(:group_name, Wik.get_group_name(group_slug))}
1722
end
1823

1924
@impl true
2025
def handle_params(%{"group_slug" => group_slug, "slug" => page_slug}, _uri, socket) do
21-
{page_title, content} =
26+
{_page_title, content} =
2227
case Page.load(group_slug, page_slug) do
2328
{:ok, {_metadata, body}} ->
2429
{page_slug, Page.render(group_slug, body)}
@@ -29,11 +34,6 @@ defmodule WikWeb.Page.ShowLive do
2934

3035
{:noreply,
3136
socket
32-
|> assign(group_slug: group_slug)
33-
|> assign(slug: page_slug)
34-
|> assign(group_name: Wik.get_group_name(group_slug))
35-
|> assign(:backlinks, Page.backlinks(group_slug, page_slug))
36-
|> assign(:page_title, page_title)
3737
|> assign(:content, content)}
3838
end
3939

@@ -67,16 +67,17 @@ defmodule WikWeb.Page.ShowLive do
6767
6868
<:menu>
6969
<div class="flex justify-between items-end">
70-
<Layouts.page_slug group_slug={@group_slug} page_slug={@page_title} />
70+
<Layouts.page_slug group_slug={@group_slug} page_slug={@page_slug} />
7171
7272
<div class="flex gap-2">
7373
<Components.shortcut key="r">
74-
<.link href={~p"/#{@group_slug}/wiki/#{@slug}/revisions"} class="btn btn-ghost">
74+
<.link href={~p"/#{@group_slug}/wiki/#{@page_slug}/revisions"} class="btn btn-ghost">
7575
Revisions
7676
</.link>
7777
</Components.shortcut>
78+
7879
<Components.shortcut key="e">
79-
<.link href={~p"/#{@group_slug}/wiki/#{@slug}/edit"} class="btn btn-primary">
80+
<.link href={~p"/#{@group_slug}/wiki/#{@page_slug}/edit"} class="btn btn-primary">
8081
Edit
8182
</.link>
8283
</Components.shortcut>
@@ -92,6 +93,7 @@ defmodule WikWeb.Page.ShowLive do
9293
class="float-right bg-white border p-6 py-5 rounded space-y-2 ml-8 mb-8 max-w-52 overflow-hidden"
9394
>
9495
<h2 class="text-xs font-semibold text-slate-500">Backlinks</h2>
96+
9597
<ul class="text-sm space-y-2">
9698
<%= for {slug, metadata} <- @backlinks do %>
9799
<li>
@@ -105,9 +107,9 @@ defmodule WikWeb.Page.ShowLive do
105107
<% end %>
106108
</ul>
107109
</div>
108-
<Components.prose>
109-
{raw(@content)}
110-
</Components.prose>
110+
111+
<Components.prose>{raw(@content)}</Components.prose>
112+
111113
<div class="clear-both"></div>
112114
</div>
113115
</div>

lib/wik_web/live/super_admin/group_live/index.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ defmodule WikWeb.SuperAdmin.GroupLive.Index do
1717
{:noreply, apply_action(socket, socket.assigns.live_action, params)}
1818
end
1919

20+
defp apply_action(socket, :index, _params) do
21+
socket
22+
|> assign(:page_title, "Listing Groups | Admin")
23+
|> assign(:group, nil)
24+
end
25+
2026
defp apply_action(socket, :edit, %{"id" => id}) do
2127
socket
22-
|> assign(:page_title, "Edit Group")
28+
|> assign(:page_title, "Edit Group | Admin")
2329
|> assign(:group, Groups.get_group!(id))
2430
end
2531

2632
defp apply_action(socket, :new, _params) do
2733
socket
28-
|> assign(:page_title, "New Group")
34+
|> assign(:page_title, "New Group | Admin")
2935
|> assign(:group, %Group{})
3036
end
3137

32-
defp apply_action(socket, :index, _params) do
33-
socket
34-
|> assign(:page_title, "Listing Groups")
35-
|> assign(:group, nil)
36-
end
37-
3838
@impl true
3939
def handle_info({WikWeb.SuperAdmin.GroupLive.FormComponent, {:saved, group}}, socket) do
4040
{:noreply, stream_insert(socket, :groups, group)}

lib/wik_web/live/super_admin/revision_live/index.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule WikWeb.SuperAdmin.RevisionLive.Index do
2626
revisions = Revisions.list_revisions_by_resource_path(resource_path)
2727

2828
socket
29-
|> assign(:page_title, "Listing Revisions")
29+
|> assign(:page_title, "Listing Revisions | Admin")
3030
|> assign(:resource_path, resource_path)
3131
|> assign(:revision, nil)
3232
|> assign(:filter, resource_path)

0 commit comments

Comments
 (0)