Skip to content

Commit 0c059dd

Browse files
committed
Replace author manager with template type manager, remove content-type UI
- Delete author_manager_live.ex (content-type-specific) - Create template_type_manager_live.ex with CRUD for template types: field definitions, JSON-LD mapping, meta tag mapping editors - SEO tab: remove FAQ editor, author dropdown, page_type selector; add template type selector with set_template_type event - SEO scoring: replace page_type check with template_type_id check - Measurement: replace author/article cards with template_type card - Router: replace /authors with /template_types route - Client content: replace author wrappers with template type wrappers
1 parent cffc0e0 commit 0c059dd

7 files changed

Lines changed: 265 additions & 214 deletions

File tree

lib/beacon/live_admin/client/content.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ defmodule Beacon.LiveAdmin.Client.Content do
347347
def update_redirect(site, redirect, attrs), do: call(site, Beacon.Content, :update_redirect, [redirect, attrs])
348348
def delete_redirect(site, redirect), do: call(site, Beacon.Content, :delete_redirect, [redirect])
349349

350-
# Authors
350+
# Template Types
351351

352-
def list_authors(site, opts \\ []), do: call(site, Beacon.Content, :list_authors, [site, opts])
353-
def get_author(site, id), do: call(site, Beacon.Content, :get_author, [site, id])
354-
def create_author(site, attrs), do: call(site, Beacon.Content, :create_author, [attrs])
355-
def update_author(site, redirect, attrs), do: call(site, Beacon.Content, :update_author, [redirect, attrs])
356-
def delete_author(site, redirect), do: call(site, Beacon.Content, :delete_author, [redirect])
352+
def list_template_types(site, opts \\ []), do: call(site, Beacon.Content, :list_template_types, [site, opts])
353+
def get_template_type(site, id), do: call(site, Beacon.Content, :get_template_type, [site, id])
354+
def create_template_type(site, attrs), do: call(site, Beacon.Content, :create_template_type, [site, attrs])
355+
def update_template_type(site, tt, attrs), do: call(site, Beacon.Content, :update_template_type, [tt, attrs])
356+
def delete_template_type(site, tt), do: call(site, Beacon.Content, :delete_template_type, [tt])
357357

358358
# Link Health
359359

lib/beacon/live_admin/live/author_manager_live.ex

Lines changed: 0 additions & 194 deletions
This file was deleted.

lib/beacon/live_admin/live/measurement_live.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,8 @@ defmodule Beacon.LiveAdmin.MeasurementLive do
9292
<div class="text-xs text-gray-500 uppercase">With Canonical</div>
9393
</div>
9494
<div class="bg-white rounded-lg border p-4 text-center">
95-
<div class="text-2xl font-bold text-gray-900"><%= metric(@latest, "pages_with_author") %></div>
96-
<div class="text-xs text-gray-500 uppercase">With Author</div>
97-
</div>
98-
<div class="bg-white rounded-lg border p-4 text-center">
99-
<div class="text-2xl font-bold text-gray-900"><%= metric(@latest, "pages_article_type") %></div>
100-
<div class="text-xs text-gray-500 uppercase">Articles</div>
95+
<div class="text-2xl font-bold text-gray-900"><%= metric(@latest, "pages_with_template_type") %></div>
96+
<div class="text-xs text-gray-500 uppercase">With Template Type</div>
10197
</div>
10298
<div class="bg-white rounded-lg border p-4 text-center">
10399
<div class="text-2xl font-bold text-gray-900"><%= metric(@latest, "redirect_count") %></div>

lib/beacon/live_admin/live/page_editor_live/seo.ex

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ defmodule Beacon.LiveAdmin.PageEditorLive.SEO do
3232
"og_image" => params["og_image"],
3333
"canonical_url" => params["canonical_url"],
3434
"robots" => params["robots"],
35-
"twitter_card" => params["twitter_card"],
36-
"page_type" => params["page_type"]
35+
"twitter_card" => params["twitter_card"]
3736
}
3837

3938
case Content.update_page(page.site, page, attrs) do
@@ -53,21 +52,64 @@ defmodule Beacon.LiveAdmin.PageEditorLive.SEO do
5352
{:noreply, assign(socket, :form_data, params)}
5453
end
5554

55+
def handle_event("mark_updated", _, socket) do
56+
page = socket.assigns.page
57+
58+
case Content.mark_page_updated(socket.assigns.beacon_page.site, page) do
59+
{:ok, updated_page} ->
60+
{:noreply,
61+
socket
62+
|> assign(:page, updated_page)
63+
|> assign_seo_fields(updated_page)
64+
|> put_flash(:info, "Page marked as substantially updated")}
65+
66+
{:error, _} ->
67+
{:noreply, put_flash(socket, :error, "Failed to update")}
68+
end
69+
end
70+
71+
def handle_event("set_template_type", %{"template_type_id" => ""}, socket) do
72+
page = socket.assigns.page
73+
case Content.update_page(page.site, page, %{"template_type_id" => nil}) do
74+
{:ok, updated} ->
75+
{:noreply, socket |> assign(:page, updated) |> assign_seo_fields(updated)}
76+
{:error, _} ->
77+
{:noreply, put_flash(socket, :error, "Failed to update")}
78+
end
79+
end
80+
81+
def handle_event("set_template_type", %{"template_type_id" => id}, socket) do
82+
page = socket.assigns.page
83+
case Content.update_page(page.site, page, %{"template_type_id" => id}) do
84+
{:ok, updated} ->
85+
{:noreply, socket |> assign(:page, updated) |> assign_seo_fields(updated)}
86+
{:error, _} ->
87+
{:noreply, put_flash(socket, :error, "Failed to update")}
88+
end
89+
end
90+
5691
defp assign_seo_fields(socket, page) do
92+
site = socket.assigns.beacon_page.site
93+
template_types = Content.list_template_types(site)
94+
current_tt = if page.template_type_id, do: Content.get_template_type(site, page.template_type_id)
95+
5796
form_data = %{
5897
"meta_description" => page.meta_description || "",
5998
"og_title" => page.og_title || "",
6099
"og_description" => page.og_description || "",
61100
"og_image" => page.og_image || "",
62101
"canonical_url" => page.canonical_url || "",
63102
"robots" => page.robots || "index, follow",
64-
"twitter_card" => page.twitter_card || "summary_large_image",
65-
"page_type" => page.page_type || "website"
103+
"twitter_card" => page.twitter_card || "summary_large_image"
66104
}
67105

68106
socket
69107
|> assign(:form_data, form_data)
70108
|> assign(:seo_score, compute_seo_score(page))
109+
|> assign(:template_types, template_types)
110+
|> assign(:current_template_type, current_tt)
111+
|> assign(:page_fields, page.fields || %{})
112+
|> assign(:date_modified, page.date_modified)
71113
end
72114

73115
defp compute_seo_score(page) do
@@ -82,7 +124,7 @@ defmodule Beacon.LiveAdmin.PageEditorLive.SEO do
82124
{10, non_empty?(page.canonical_url)},
83125
{10, page.raw_schema != nil and page.raw_schema != []},
84126
{5, non_empty?(page.robots)},
85-
{5, page.page_type != nil and page.page_type != "website"},
127+
{5, page.template_type_id != nil},
86128
{5, non_empty?(page.twitter_card)}
87129
]
88130

lib/beacon/live_admin/live/seo_audit_live.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defmodule Beacon.LiveAdmin.SEOAuditLive do
4343
{10, non_empty?(page.canonical_url)},
4444
{10, page.raw_schema != nil and page.raw_schema != []},
4545
{5, non_empty?(page.robots)},
46-
{5, page.page_type != nil and page.page_type != "website"},
46+
{5, page.template_type_id != nil},
4747
{5, non_empty?(page.twitter_card)}
4848
]
4949

0 commit comments

Comments
 (0)