About: run your own (as angler's); OpenID Connect wording; log deliveries

78e775b · gmorell · 2026-11-18 21:28

21 files +572 -228
Message
{commit_body(@commit)}

Files changed

modified lib/final_track/federation.ex
+4 −1
@@ -20,6 +20,7 @@ defmodule FinalTrack.Federation do
20 20 ported from angler.
21 21 """
22 22 import Ecto.Query, warn: false
23 + require Logger
23 24
24 25 alias FinalTrack.Accounts.User
25 26 alias FinalTrack.{Privacy, Repo}
@@ -177,7 +178,8 @@ defmodule FinalTrack.Federation do
177 178 :ok
178 179 end
179 180
180 − # Built at send time: nil (nothing sent) if the play went private meanwhile.
181 + # Built at send time: nil (nothing sent, and logged) if the play went
182 + # private meanwhile.
181 183 # If the play's album is still waiting on its first cover lookup, give it
182 184 # a little longer: a post without its cover is a post Pixelfed drops (it
183 185 # doesn't store notes without media), and the cover is usually seconds
@@ -192,6 +194,7 @@ defmodule FinalTrack.Federation do
192 194 Objects.create(post, post.account)
193 195
194 196 _ ->
197 + Logger.info("federation: post #{post_id} not sent: no longer showable")
195 198 nil
196 199 end
197 200 end
modified lib/final_track/federation/delivery.ex
+13 −2
@@ -44,18 +44,25 @@ defmodule FinalTrack.Federation.Delivery do
44 44
45 45 defp attempt(inbox, activity, signer, backoff) do
46 46 case HTTP.deliver(inbox, activity, signer) do
47 − :ok ->
47 + {:ok, status} ->
48 + # Every outcome is logged: a remote server answers 2xx and then
49 + # validates in its own queue, so "it never showed up" starts here.
50 + Logger.info("federation: #{describe(activity)} to #{inbox}: #{status}")
48 51 :ok
49 52
50 53 {:error, reason} ->
51 54 case {HTTP.transient_error?(reason), backoff, inline?()} do
52 55 {true, [wait | rest], false} ->
56 + Logger.info(
57 + "federation: #{describe(activity)} to #{inbox}: #{inspect(reason)}, retrying in #{div(wait, 1000)}s"
58 + )
59 +
53 60 Process.sleep(wait)
54 61 attempt(inbox, activity, signer, rest)
55 62
56 63 _ ->
57 64 Logger.warning(
58 − "federation: #{activity["type"]} to #{inbox} failed: #{inspect(reason)}"
65 + "federation: #{describe(activity)} to #{inbox} failed: #{inspect(reason)}"
59 66 )
60 67
61 68 {:error, reason}
@@ -63,6 +70,10 @@ defmodule FinalTrack.Federation.Delivery do
63 70 end
64 71 end
65 72
73 + # "Create https://host/ap/notes/<id>", "Accept", ...
74 + defp describe(%{"type" => type, "object" => %{"id" => id}}), do: "#{type} #{id}"
75 + defp describe(%{"type" => type}), do: type
76 +
66 77 defp run(fun) do
67 78 if inline?() do
68 79 fun.()
modified lib/final_track/federation/http.ex
+2 −2
@@ -53,7 +53,7 @@ defmodule FinalTrack.Federation.HTTP do
53 53
54 54 @doc """
55 55 POSTs `activity` (a map) to an inbox, signed with `{key_id, private_key_pem}`.
56 − `:ok`, or `{:error, reason}` (`{:unavailable, status}` for 408/429/5xx,
56 + `{:ok, status}` for a 2xx, or `{:error, reason}` (`{:unavailable, status}` for 408/429/5xx,
57 57 which are worth retrying).
58 58 """
59 59 def deliver(inbox, activity, {key_id, private_key_pem}) do
@@ -85,7 +85,7 @@ defmodule FinalTrack.Federation.HTTP do
85 85 ]
86 86 |> request(uri, ip)
87 87 |> case do
88 − {:ok, %{status: s}} when s in 200..299 -> :ok
88 + {:ok, %{status: s}} when s in 200..299 -> {:ok, s}
89 89 {:ok, %{status: s}} -> check_status(s)
90 90 {:error, reason} -> {:error, reason}
91 91 end
deleted lib/final_track_web/controllers/page_controller.ex
+0 −7
@@ -1,7 +0,0 @@
1 −defmodule FinalTrackWeb.PageController do
2 − use FinalTrackWeb, :controller
3 −
4 − def about(conn, _params) do
5 − render(conn, :about, page_title: "About")
6 − end
7 −end
deleted lib/final_track_web/controllers/page_html.ex
+0 −10
@@ -1,10 +0,0 @@
1 −defmodule FinalTrackWeb.PageHTML do
2 − @moduledoc """
3 − This module contains pages rendered by PageController.
4 −
5 − See the `page_html` directory for all templates available.
6 − """
7 − use FinalTrackWeb, :html
8 −
9 − embed_templates "page_html/*"
10 −end
deleted lib/final_track_web/controllers/page_html/about.html.heex
+0 −175
@@ -1,175 +0,0 @@
1 −<Layouts.app flash={@flash} current_scope={@current_scope} wide>
2 − <div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
3 − <section id="hero" class="py-20 sm:py-28 text-center">
4 − <p class="font-mono text-xs uppercase tracking-[0.25em] text-accent mb-4">Final Track</p>
5 − <h1 class="text-4xl sm:text-6xl font-bold tracking-tight">
6 − What you've been playing, together.
7 − </h1>
8 − <p class="text-base-content/70 text-lg sm:text-xl mt-6 max-w-2xl mx-auto leading-relaxed">
9 − A self-hosted scrobble server for you and your people. Point Scropple at it, watch the
10 − plays roll in live, and see the artists, albums and tracks that ruled the day, the week,
11 − the month or the year.
12 − </p>
13 − <div class="flex flex-wrap justify-center gap-3 mt-8">
14 − <%= cond do %>
15 − <% @current_scope && @current_scope.user -> %>
16 − <.link navigate={~p"/charts"} class="btn btn-primary" id="hero-cta">
17 − <.icon name="hero-chart-bar-micro" class="size-4" /> Open charts
18 − </.link>
19 − <.link navigate={~p"/artists"} class="btn btn-ghost">Library</.link>
20 − <.link navigate={~p"/users/scrobbling"} class="btn btn-ghost">Connect a scrobbler</.link>
21 − <% FinalTrack.Accounts.registration_open?() and NeiamAuth.local_login_enabled?() -> %>
22 − <.link navigate={~p"/users/register"} class="btn btn-primary" id="hero-cta">
23 − Get started
24 − </.link>
25 − <.link navigate={~p"/users/log-in"} class="btn btn-ghost">Log in</.link>
26 − <.link navigate={~p"/"} class="btn btn-ghost" id="hero-live">
27 − See what's playing
28 − </.link>
29 − <% true -> %>
30 − <span class="btn btn-disabled" id="hero-cta" title="Registration is invite-only">
31 − Get started · invite-only
32 − </span>
33 − <.link navigate={~p"/users/log-in"} class="btn btn-ghost">Log in</.link>
34 − <.link navigate={~p"/"} class="btn btn-ghost" id="hero-live">
35 − See what's playing
36 − </.link>
37 − <% end %>
38 − </div>
39 − </section>
40 −
41 − <section id="features" class="py-12 sm:py-16">
42 − <h2 class="text-2xl sm:text-3xl font-bold mb-2">What you get</h2>
43 − <p class="text-base-content/70 mb-8">
44 − Your listening history, on your own server, shared only as far as you like.
45 − </p>
46 −
47 − <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
48 − <div
49 − :for={
50 − {id, icon, title, body} <-
51 − [
52 − {"live", "hero-squares-2x2-micro", "Live on the front page",
53 − "The latest plays as a wall of album art, updating as they land. Visitors see what was played; members see who played it."},
54 − {"charts", "hero-chart-bar-micro", "Charts by day, week, month, year",
55 − "Top artists, albums and tracks for any period, plays over time in your own time zone, and who's listening right now. Everyone's, or just yours."},
56 − {"library", "hero-rectangle-stack-micro", "A library with numbers",
57 − "Every artist and album that's been played, with plays, listeners, tracks and when it was first and last heard. Sort it, search it."},
58 − {"covers", "hero-photo-micro", "Covers, found or yours",
59 − "Album art is looked up on MusicBrainz and the Cover Art Archive the first time an album is played. Got a better scan? Drop it on the album."},
60 − {"private", "hero-lock-closed-micro", "Private when you want",
61 − "Mark an artist, album or track private and your plays of it are only ever shown to you, including ones from before you marked it."},
62 − {"scropple", "hero-signal-micro", "Speaks Scropple",
63 − "The same HTTP API as ircd's ScrobbleServ, so one phone can scrobble here, to an IRC channel and to Last.fm at once. One token per device."}
64 − ] ++
65 − if(FinalTrack.Federation.enabled?(),
66 − do: [
67 − {"fediverse", "hero-globe-alt-micro", "On the fediverse, if you like",
68 − "Give your plays an account Mastodon users can follow. Each play is posted with its album cover; private ones never are, and marking something private withdraws what was posted."}
69 − ],
70 − else: []
71 − ) ++
72 − if(NeiamAuth.enabled?() and NeiamAuth.providers() != [],
73 − do: [
74 − {"sso", "hero-key-micro", "Sign in with NEIAM",
75 − "Already have a NEIAM account? Use it here, no separate password needed."}
76 − ],
77 − else: []
78 − )
79 − }
80 − id={"feature-#{id}"}
81 − class="rounded-box border border-base-300 bg-base-200 p-5 transition duration-200 hover:-translate-y-0.5 hover:border-primary/40 hover:shadow-md"
82 − >
83 − <div class="flex items-center gap-2 mb-2">
84 − <.icon name={icon} class="size-5 text-accent" />
85 − <h3 class="font-semibold">{title}</h3>
86 − </div>
87 − <p class="text-sm text-base-content/80">{body}</p>
88 − </div>
89 − </div>
90 − </section>
91 −
92 − <section id="who-sees-what" class="py-12 sm:py-16">
93 − <h2 class="text-2xl sm:text-3xl font-bold mb-2">Who sees what</h2>
94 − <p class="text-base-content/70 mb-8">
95 − Plays are only ever as public as the narrowest thing about them.
96 − </p>
97 −
98 − <dl class="divide-y divide-base-300 overflow-hidden rounded-box border border-base-300 bg-base-200">
99 − <div
100 − :for={
101 − {who, icon, sees} <-
102 − [
103 − {"Anyone", "hero-eye-micro",
104 − "The front page: what was played and when. Never who played it, and nothing anyone keeps private."},
105 − {"Members", "hero-user-group-micro",
106 − "Charts, the library, album and artist pages, and who played what. Not your private plays."}
107 − ] ++
108 − if(FinalTrack.Federation.enabled?(),
109 − do: [
110 − {"Your followers", "hero-globe-alt-micro",
111 − "If you turn on a fediverse account: each of your plays that isn't private, as it happens."}
112 − ],
113 − else: []
114 − ) ++
115 − [
116 − {"You", "hero-user-circle-micro",
117 − "Everything you've played, private or not, in every chart and list."}
118 − ]
119 − }
120 − class="grid gap-1 px-5 py-4 sm:grid-cols-[10rem_1fr] sm:gap-4"
121 − >
122 − <dt class="flex items-center gap-2 font-semibold">
123 − <.icon name={icon} class="size-4 text-accent" />
124 − {who}
125 − </dt>
126 − <dd class="text-sm text-base-content/80">{sees}</dd>
127 − </div>
128 − </dl>
129 − </section>
130 −
131 − <section id="steps" class="py-12 sm:py-16">
132 − <h2 class="text-2xl sm:text-3xl font-bold mb-2">Get started in three steps</h2>
133 − <p class="text-base-content/70 mb-8">
134 − From invite link to your first chart in a few minutes.
135 − </p>
136 −
137 − <ol class="grid grid-cols-1 sm:grid-cols-3 gap-4">
138 − <li
139 − :for={
140 − {n, title, body} <- [
141 − {"01", "Accept your invite",
142 − "Final Track is invite-only: open the link a member gave you, or sign in with NEIAM if you're one of us."},
143 − {"02", "Make a token",
144 − "On the Scrobbling page, make one per device. It's shown once; copy it."},
145 − {"03", "Point Scropple here",
146 − "In Scropple, add an HTTP backend with this server's address and your token. Then just listen."}
147 − ]
148 − }
149 − class="border border-base-300 rounded-box p-5 bg-base-200 flex flex-col gap-2"
150 − >
151 − <span class="font-mono text-xs text-accent">{n}</span>
152 − <h3 class="font-semibold">{title}</h3>
153 − <p class="text-sm text-base-content/80">{body}</p>
154 − </li>
155 − </ol>
156 − </section>
157 −
158 − <footer id="footer" class="py-10 sm:py-12 mt-8 border-t border-base-300 text-center">
159 − <p class="font-mono text-xs uppercase tracking-[0.25em] text-base-content/70 flex items-center justify-center gap-2">
160 − <span class="font-bold tracking-[0.16em]">FINAL TRACK</span>
161 − <span class="opacity-50">·</span>
162 − <span>a</span>
163 − <%!--
164 − Hardcoded oklch from the neiam-co accent (the value every ported
165 − theme assigns to --color-accent), so the NEIAM mark stays yellow
166 − whichever theme the viewer has picked.
167 − --%>
168 − <span class="font-bold tracking-[0.16em]" style="color: oklch(96% 0.058 96);">
169 − <a href="https://neiam.org">NEIAM</a>
170 − </span>
171 − <span>production</span>
172 − </p>
173 − </footer>
174 − </div>
175 −</Layouts.app>
added lib/final_track_web/live/about_live.ex
+468 −0
@@ -0,0 +1,468 @@
1 +defmodule FinalTrackWeb.AboutLive do
2 + @moduledoc """
3 + `/about`: what Final Track is, who sees what, how to join, and — as
4 + angler's about page — how to run your own: pick a container runtime, type
5 + the blanks into the command, copy.
6 + """
7 + use FinalTrackWeb, :live_view
8 +
9 + # {key, label, binary}: container runtimes for "Run your own".
10 + @runtimes [{:podman, "Podman", "podman"}, {:docker, "Docker", "docker"}]
11 +
12 + # {key, label, image}: registries the image is published to. Add a row and
13 + # the registry picker appears.
14 + @registries [{:gitgud, "GitGud", "ggr.neiam.co/neiam/final_track"}]
15 +
16 + # {name, placeholder (and default), width class, label}: the blanks.
17 + @config_fields [
18 + {"user", "USER", "w-24", "Database user"},
19 + {"password", "PASS", "w-24", "Database password"},
20 + {"host", "tracks.you.com", "w-40", "Public host"}
21 + ]
22 +
23 + @optional_settings [
24 + {"SMTP_RELAY, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, MAIL_FROM_ADDRESS",
25 + "Send mail (emailed log-in links, confirmations). Without it, mail is off and registration takes a password."},
26 + {"OIDC_ENABLED, OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET",
27 + "Sign in through your OpenID Connect provider. The redirect URI is https://HOST/auth/oidc/neiam/callback."},
28 + {"FINAL_TRACK_ACTIVITYPUB=true",
29 + "Let members give their plays a fediverse account. Set PHX_HOST to its final domain first."},
30 + {"FINAL_TRACK_MUSICBRAINZ_USER_AGENT",
31 + "How the server introduces itself to MusicBrainz for cover lookups: include a URL or address to reach you."},
32 + {"FINAL_TRACK_AUTO_FETCH_COVERS=false",
33 + "Only fetch covers when someone asks on the album page."}
34 + ]
35 +
36 + @impl true
37 + def mount(_params, _session, socket) do
38 + {:ok,
39 + socket
40 + |> assign(:page_title, "About")
41 + |> assign(:runtimes, @runtimes)
42 + |> assign(:registries, @registries)
43 + |> assign(:config_fields, @config_fields)
44 + |> assign(:optional_settings, @optional_settings)
45 + |> assign(:runtime, :podman)
46 + |> assign(:registry, :gitgud)
47 + |> assign(:config_form, to_form(%{"user" => "", "password" => "", "host" => ""}))
48 + |> recompute_commands()}
49 + end
50 +
51 + @impl true
52 + def handle_event("set_runtime", %{"runtime" => runtime}, socket),
53 + do:
54 + {:noreply,
55 + socket |> assign(:runtime, pick(@runtimes, runtime, :podman)) |> recompute_commands()}
56 +
57 + def handle_event("set_registry", %{"registry" => registry}, socket),
58 + do:
59 + {:noreply,
60 + socket |> assign(:registry, pick(@registries, registry, :gitgud)) |> recompute_commands()}
61 +
62 + def handle_event("set_config", params, socket) do
63 + form = to_form(Map.take(params, ["user", "password", "host"]))
64 + {:noreply, socket |> assign(:config_form, form) |> recompute_commands()}
65 + end
66 +
67 + # The key named by a param, from a fixed list: never String.to_atom on input.
68 + defp pick(rows, value, default) do
69 + Enum.find_value(rows, default, fn {key, _, _} -> if Atom.to_string(key) == value, do: key end)
70 + end
71 +
72 + defp recompute_commands(socket) do
73 + %{runtime: runtime, registry: registry, config_form: form} = socket.assigns
74 + bin = lookup(@runtimes, runtime)
75 + image = lookup(@registries, registry)
76 + user = blank(form, "user", "USER")
77 + pass = blank(form, "password", "PASS")
78 + host = blank(form, "host", "tracks.you.com")
79 +
80 + socket
81 + |> assign(:db_command, db_command(bin, user, pass))
82 + |> assign(:run_command, run_command(bin, image, user, pass, host))
83 + |> assign(:setup_command, setup_command(bin))
84 + end
85 +
86 + defp db_command(bin, user, pass) do
87 + "#{bin} network create final-track\n\n" <>
88 + lines([
89 + "#{bin} run -d --name final-track-db --network final-track",
90 + "-e POSTGRES_USER=#{user}",
91 + "-e POSTGRES_PASSWORD=#{pass}",
92 + "-e POSTGRES_DB=final_track",
93 + "-v final-track-db:/var/lib/postgresql/data",
94 + "docker.io/postgres:17-alpine"
95 + ])
96 + end
97 +
98 + defp run_command(bin, image, user, pass, host) do
99 + lines([
100 + "#{bin} run -d --name final-track --network final-track",
101 + "-p 4000:4000",
102 + "-e PHX_HOST=#{host}",
103 + "-e SECRET_KEY_BASE=$(openssl rand -base64 48)",
104 + "-e DATABASE_URL=ecto://#{user}:#{pass}@final-track-db/final_track",
105 + "-v final-track-covers:/var/lib/final_track/covers",
106 + "#{image}:latest"
107 + ])
108 + end
109 +
110 + defp setup_command(bin) do
111 + "#{bin} exec final-track bin/migrate\n#{bin} exec final-track bin/invite --note \"first\""
112 + end
113 +
114 + defp lines(parts), do: Enum.join(parts, " \\\n ")
115 +
116 + defp blank(form, key, default) do
117 + case form[key].value |> to_string() |> String.trim() do
118 + "" -> default
119 + value -> value
120 + end
121 + end
122 +
123 + defp lookup(rows, key) do
124 + {_key, _label, value} = Enum.find(rows, fn {k, _, _} -> k == key end)
125 + value
126 + end
127 +
128 + attr :id, :string, required: true
129 + attr :text, :string, required: true
130 +
131 + defp command(assigns) do
132 + ~H"""
133 + <div class="relative">
134 + <button
135 + type="button"
136 + id={"copy-#{@id}"}
137 + phx-hook=".CopyCommand"
138 + data-target={@id}
139 + class="btn btn-ghost btn-xs absolute right-2 top-2 gap-1"
140 + aria-label="Copy command"
141 + >
142 + <.icon name="hero-clipboard-document-micro" class="size-4" />
143 + <span data-label>Copy</span>
144 + </button>
145 + <pre
146 + id={@id}
147 + class="overflow-x-auto rounded-box bg-base-300 p-4 pt-9 font-mono text-xs leading-relaxed sm:text-sm"
148 + ><code>{@text}</code></pre>
149 + <script :type={Phoenix.LiveView.ColocatedHook} name=".CopyCommand">
150 + export default {
151 + mounted() {
152 + this.el.addEventListener("click", async () => {
153 + const pre = document.getElementById(this.el.dataset.target)
154 + const label = this.el.querySelector("[data-label]")
155 + if (!pre) return
156 + try {
157 + await navigator.clipboard.writeText(pre.textContent.trim())
158 + if (label) {
159 + label.textContent = "Copied!"
160 + setTimeout(() => { label.textContent = "Copy" }, 1500)
161 + }
162 + } catch (_e) {
163 + // No clipboard API on plain http: select the text instead.
164 + const range = document.createRange()
165 + range.selectNodeContents(pre)
166 + const sel = window.getSelection()
167 + sel.removeAllRanges()
168 + sel.addRange(range)
169 + }
170 + })
171 + }
172 + }
173 + </script>
174 + </div>
175 + """
176 + end
177 +
178 + @impl true
179 + def render(assigns) do
180 + ~H"""
181 + <Layouts.app flash={@flash} current_scope={@current_scope} wide>
182 + <div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
183 + <section id="hero" class="py-20 sm:py-28 text-center">
184 + <p class="font-mono text-xs uppercase tracking-[0.25em] text-accent mb-4">Final Track</p>
185 + <h1 class="text-4xl sm:text-6xl font-bold tracking-tight">
186 + What you've been playing, together.
187 + </h1>
188 + <p class="text-base-content/70 text-lg sm:text-xl mt-6 max-w-2xl mx-auto leading-relaxed">
189 + A self-hosted scrobble server for you and your people. Point Scropple at it, watch the
190 + plays roll in live, and see the artists, albums and tracks that ruled the day, the week,
191 + the month or the year.
192 + </p>
193 + <div class="flex flex-wrap justify-center gap-3 mt-8">
194 + <%= cond do %>
195 + <% @current_scope && @current_scope.user -> %>
196 + <.link navigate={~p"/charts"} class="btn btn-primary" id="hero-cta">
197 + <.icon name="hero-chart-bar-micro" class="size-4" /> Open charts
198 + </.link>
199 + <.link navigate={~p"/artists"} class="btn btn-ghost">Library</.link>
200 + <.link navigate={~p"/users/scrobbling"} class="btn btn-ghost">Connect a scrobbler</.link>
201 + <% FinalTrack.Accounts.registration_open?() and NeiamAuth.local_login_enabled?() -> %>
202 + <.link navigate={~p"/users/register"} class="btn btn-primary" id="hero-cta">
203 + Get started
204 + </.link>
205 + <.link navigate={~p"/users/log-in"} class="btn btn-ghost">Log in</.link>
206 + <.link navigate={~p"/"} class="btn btn-ghost" id="hero-live">
207 + See what's playing
208 + </.link>
209 + <% true -> %>
210 + <span class="btn btn-disabled" id="hero-cta" title="Registration is invite-only">
211 + Get started · invite-only
212 + </span>
213 + <.link navigate={~p"/users/log-in"} class="btn btn-ghost">Log in</.link>
214 + <.link navigate={~p"/"} class="btn btn-ghost" id="hero-live">
215 + See what's playing
216 + </.link>
217 + <% end %>
218 + </div>
219 + </section>
220 +
221 + <section id="features" class="py-12 sm:py-16">
222 + <h2 class="text-2xl sm:text-3xl font-bold mb-2">What you get</h2>
223 + <p class="text-base-content/70 mb-8">
224 + Your listening history, on your own server, shared only as far as you like.
225 + </p>
226 +
227 + <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
228 + <div
229 + :for={
230 + {id, icon, title, body} <-
231 + [
232 + {"live", "hero-squares-2x2-micro", "Live on the front page",
233 + "The latest plays as a wall of album art, updating as they land. Visitors see what was played; members see who played it."},
234 + {"charts", "hero-chart-bar-micro", "Charts by day, week, month, year",
235 + "Top artists, albums and tracks for any period, plays over time in your own time zone, and who's listening right now. Everyone's, or just yours."},
236 + {"library", "hero-rectangle-stack-micro", "A library with numbers",
237 + "Every artist and album that's been played, with plays, listeners, tracks and when it was first and last heard. Sort it, search it."},
238 + {"covers", "hero-photo-micro", "Covers, found or yours",
239 + "Album art is looked up on MusicBrainz and the Cover Art Archive the first time an album is played. Got a better scan? Drop it on the album."},
240 + {"private", "hero-lock-closed-micro", "Private when you want",
241 + "Mark an artist, album or track private and your plays of it are only ever shown to you, including ones from before you marked it."},
242 + {"scropple", "hero-signal-micro", "Speaks Scropple",
243 + "The same HTTP API as ircd's ScrobbleServ, so one phone can scrobble here, to an IRC channel and to Last.fm at once. One token per device."}
244 + ] ++
245 + if(FinalTrack.Federation.enabled?(),
246 + do: [
247 + {"fediverse", "hero-globe-alt-micro", "On the fediverse, if you like",
248 + "Give your plays an account Mastodon users can follow. Each play is posted with its album cover; private ones never are, and marking something private withdraws what was posted."}
249 + ],
250 + else: []
251 + ) ++
252 + if(NeiamAuth.enabled?() and NeiamAuth.providers() != [],
253 + do: [
254 + {"sso", "hero-key-micro", "OpenID Connect",
255 + "Sign in through this server's identity provider (Authelia, Keycloak, Google and the like) instead of keeping another password."}
256 + ],
257 + else: []
258 + )
259 + }
260 + id={"feature-#{id}"}
261 + class="rounded-box border border-base-300 bg-base-200 p-5 transition duration-200 hover:-translate-y-0.5 hover:border-primary/40 hover:shadow-md"
262 + >
263 + <div class="flex items-center gap-2 mb-2">
264 + <.icon name={icon} class="size-5 text-accent" />
265 + <h3 class="font-semibold">{title}</h3>
266 + </div>
267 + <p class="text-sm text-base-content/80">{body}</p>
268 + </div>
269 + </div>
270 + </section>
271 +
272 + <section id="who-sees-what" class="py-12 sm:py-16">
273 + <h2 class="text-2xl sm:text-3xl font-bold mb-2">Who sees what</h2>
274 + <p class="text-base-content/70 mb-8">
275 + Plays are only ever as public as the narrowest thing about them.
276 + </p>
277 +
278 + <dl class="divide-y divide-base-300 overflow-hidden rounded-box border border-base-300 bg-base-200">
279 + <div
280 + :for={
281 + {who, icon, sees} <-
282 + [
283 + {"Anyone", "hero-eye-micro",
284 + "The front page: what was played and when. Never who played it, and nothing anyone keeps private."},
285 + {"Members", "hero-user-group-micro",
286 + "Charts, the library, album and artist pages, and who played what. Not your private plays."}
287 + ] ++
288 + if(FinalTrack.Federation.enabled?(),
289 + do: [
290 + {"Your followers", "hero-globe-alt-micro",
291 + "If you turn on a fediverse account: each of your plays that isn't private, as it happens."}
292 + ],
293 + else: []
294 + ) ++
295 + [
296 + {"You", "hero-user-circle-micro",
297 + "Everything you've played, private or not, in every chart and list."}
298 + ]
299 + }
300 + class="grid gap-1 px-5 py-4 sm:grid-cols-[10rem_1fr] sm:gap-4"
301 + >
302 + <dt class="flex items-center gap-2 font-semibold">
303 + <.icon name={icon} class="size-4 text-accent" />
304 + {who}
305 + </dt>
306 + <dd class="text-sm text-base-content/80">{sees}</dd>
307 + </div>
308 + </dl>
309 + </section>
310 +
311 + <section id="steps" class="py-12 sm:py-16">
312 + <h2 class="text-2xl sm:text-3xl font-bold mb-2">Get started in three steps</h2>
313 + <p class="text-base-content/70 mb-8">
314 + From invite link to your first chart in a few minutes.
315 + </p>
316 +
317 + <ol class="grid grid-cols-1 sm:grid-cols-3 gap-4">
318 + <li
319 + :for={
320 + {n, title, body} <- [
321 + {"01", "Accept your invite",
322 + "Final Track is invite-only: open the link a member gave you, or sign in through the server's OpenID Connect provider if you have an account there."},
323 + {"02", "Make a token",
324 + "On the Scrobbling page, make one per device. It's shown once; copy it."},
325 + {"03", "Point Scropple here",
326 + "In Scropple, add an HTTP backend with this server's address and your token. Then just listen."}
327 + ]
328 + }
329 + class="border border-base-300 rounded-box p-5 bg-base-200 flex flex-col gap-2"
330 + >
331 + <span class="font-mono text-xs text-accent">{n}</span>
332 + <h3 class="font-semibold">{title}</h3>
333 + <p class="text-sm text-base-content/80">{body}</p>
334 + </li>
335 + </ol>
336 + </section>
337 +
338 + <section id="run-your-own" class="py-12 sm:py-16 space-y-4">
339 + <div>
340 + <h2 class="text-2xl sm:text-3xl font-bold mb-2">Run your own</h2>
341 + <p class="text-base-content/70">
342 + <span class="font-medium text-base-content">Get started in a minute.</span>
343 + Final Track ships as a single container image next to a PostgreSQL. Pick your runtime,
344 + fill in the blanks, then run:
345 + </p>
346 + </div>
347 +
348 + <div class="flex flex-wrap items-center gap-2">
349 + <div role="tablist" class="join" aria-label="Container runtime" id="run-runtimes">
350 + <button
351 + :for={{key, label, _bin} <- @runtimes}
352 + type="button"
353 + role="tab"
354 + id={"runtime-#{key}"}
355 + phx-click="set_runtime"
356 + phx-value-runtime={key}
357 + aria-selected={to_string(@runtime == key)}
358 + class={[
359 + "btn btn-sm join-item",
360 + if(@runtime == key, do: "btn-primary", else: "btn-ghost")
361 + ]}
362 + >
363 + {label}
364 + </button>
365 + </div>
366 + <div :if={length(@registries) > 1} role="tablist" class="join" aria-label="Registry">
367 + <button
368 + :for={{key, label, _image} <- @registries}
369 + type="button"
370 + role="tab"
371 + id={"registry-#{key}"}
372 + phx-click="set_registry"
373 + phx-value-registry={key}
374 + aria-selected={to_string(@registry == key)}
375 + class={[
376 + "btn btn-sm join-item",
377 + if(@registry == key, do: "btn-secondary", else: "btn-ghost")
378 + ]}
379 + >
380 + {label}
381 + </button>
382 + </div>
383 + </div>
384 +
385 + <.form
386 + for={@config_form}
387 + id="run-config"
388 + phx-change="set_config"
389 + class="flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-sm"
390 + >
391 + <label
392 + :for={{name, placeholder, width, aria} <- @config_fields}
393 + class="flex items-center gap-1.5"
394 + >
395 + <span class="text-base-content/40">{name}</span>
396 + <input
397 + type="text"
398 + name={name}
399 + value={@config_form[name].value}
400 + placeholder={placeholder}
401 + autocomplete="off"
402 + spellcheck="false"
403 + phx-debounce="150"
404 + aria-label={aria}
405 + class={["input input-ghost input-xs px-1", width]}
406 + />
407 + </label>
408 + </.form>
409 +
410 + <div class="collapse collapse-arrow rounded-box border border-base-300 bg-base-200">
411 + <input type="checkbox" aria-label="Toggle database setup" />
412 + <div class="collapse-title text-sm font-medium">First: start your database</div>
413 + <div class="collapse-content space-y-2">
414 + <p class="text-xs text-base-content/60">
415 + A network for the two containers, and PostgreSQL on it. The app finds it by name.
416 + </p>
417 + <.command id="db-command" text={@db_command} />
418 + </div>
419 + </div>
420 +
421 + <.command id="run-command" text={@run_command} />
422 +
423 + <div class="space-y-2 text-sm text-base-content/70">
424 + <p>Then migrate the database and make the first invite (registration is invite-only):</p>
425 + <.command id="setup-command" text={@setup_command} />
426 + </div>
427 +
428 + <details class="rounded-box border border-base-300 bg-base-200 p-4 text-sm">
429 + <summary class="cursor-pointer font-medium">Optional settings</summary>
430 + <dl class="mt-3 space-y-2">
431 + <div
432 + :for={{vars, what} <- @optional_settings}
433 + class="grid gap-1 sm:grid-cols-[18rem_1fr]"
434 + >
435 + <dt class="font-mono text-xs text-base-content/80">{vars}</dt>
436 + <dd class="text-base-content/70">{what}</dd>
437 + </div>
438 + </dl>
439 + </details>
440 +
441 + <p class="text-xs text-base-content/50">
442 + The server listens on port 4000; put a TLS-terminating proxy in front of it. Album covers
443 + live in the <code class="text-base-content/70">final-track-covers</code>
444 + volume. Clustered and Kubernetes setups are in the repo's deployment notes.
445 + </p>
446 + </section>
447 +
448 + <footer id="footer" class="py-10 sm:py-12 mt-8 border-t border-base-300 text-center">
449 + <p class="font-mono text-xs uppercase tracking-[0.25em] text-base-content/70 flex items-center justify-center gap-2">
450 + <span class="font-bold tracking-[0.16em]">FINAL TRACK</span>
451 + <span class="opacity-50">·</span>
452 + <span>a</span>
453 + <%!--
454 + Hardcoded oklch from the neiam-co accent (the value every ported
455 + theme assigns to --color-accent), so the NEIAM mark stays yellow
456 + whichever theme the viewer has picked.
457 + --%>
458 + <span class="font-bold tracking-[0.16em]" style="color: oklch(96% 0.058 96);">
459 + <a href="https://neiam.org">NEIAM</a>
460 + </span>
461 + <span>production</span>
462 + </p>
463 + </footer>
464 + </div>
465 + </Layouts.app>
466 + """
467 + end
468 +end
modified lib/final_track_web/router.ex
+2 −1
@@ -28,7 +28,6 @@ defmodule FinalTrackWeb.Router do
28 28 scope "/", FinalTrackWeb do
29 29 pipe_through :browser
30 30
31 − get "/about", PageController, :about
32 31 # Album art isn't private (plays are), and the landing grid shows it to
33 32 # signed-out visitors too.
34 33 get "/covers/:id", CoverController, :show
@@ -131,6 +130,8 @@ defmodule FinalTrackWeb.Router do
131 130 on_mount: [{FinalTrackWeb.UserAuth, :mount_current_scope}] do
132 131 # The landing grid: public, with more for members.
133 132 live "/", HomeLive, :index
133 + # What it is, and how to run your own.
134 + live "/about", AboutLive, :index
134 135 live "/users/register", UserLive.Registration, :new
135 136 live "/users/log-in", UserLive.Login, :new
136 137 live "/users/log-in/:token", UserLive.Confirmation, :new
deleted test/final_track_web/controllers/page_controller_test.exs
+0 −30
@@ -1,30 +0,0 @@
1 −defmodule FinalTrackWeb.PageControllerTest do
2 − use FinalTrackWeb.ConnCase
3 −
4 − test "GET /about renders the about page inside the shared chrome", %{conn: conn} do
5 − doc = conn |> get(~p"/about") |> html_response(200) |> LazyHTML.from_document()
6 −
7 − for selector <-
8 − ~w(#brand #theme-toggle #hero #hero-live #features #feature-live #feature-library #feature-private #who-sees-what #steps #footer) do
9 − refute Enum.empty?(LazyHTML.query(doc, selector)), "missing #{selector}"
10 − end
11 − end
12 −
13 − test "theme picker lists system plus every theme", %{conn: conn} do
14 − doc = conn |> get(~p"/about") |> html_response(200) |> LazyHTML.from_document()
15 −
16 − offered =
17 − doc
18 − |> LazyHTML.query("button[data-phx-theme]")
19 − |> LazyHTML.attribute("data-phx-theme")
20 −
21 − assert offered == ["system" | FinalTrack.Themes.all()]
22 − end
23 −
24 − test "features that are on here are described; federation is on in test", %{conn: conn} do
25 − doc = conn |> get(~p"/about") |> html_response(200) |> LazyHTML.from_document()
26 − refute Enum.empty?(LazyHTML.query(doc, "#feature-fediverse"))
27 − # NEIAM sign-in is off (OIDC_ENABLED unset): not advertised.
28 − assert Enum.empty?(LazyHTML.query(doc, "#feature-sso"))
29 − end
30 −end
added test/final_track_web/live/about_live_test.exs
+83 −0
@@ -0,0 +1,83 @@
1 +defmodule FinalTrackWeb.AboutLiveTest do
2 + use FinalTrackWeb.ConnCase
3 +
4 + test "renders inside the shared chrome", %{conn: conn} do
5 + doc = conn |> get(~p"/about") |> html_response(200) |> LazyHTML.from_document()
6 +
7 + for selector <-
8 + ~w(#brand #theme-toggle #hero #hero-live #features #feature-live #feature-library #feature-private #who-sees-what #steps #footer) do
9 + refute Enum.empty?(LazyHTML.query(doc, selector)), "missing #{selector}"
10 + end
11 + end
12 +
13 + test "theme picker lists system plus every theme", %{conn: conn} do
14 + doc = conn |> get(~p"/about") |> html_response(200) |> LazyHTML.from_document()
15 +
16 + offered =
17 + doc
18 + |> LazyHTML.query("button[data-phx-theme]")
19 + |> LazyHTML.attribute("data-phx-theme")
20 +
21 + assert offered == ["system" | FinalTrack.Themes.all()]
22 + end
23 +
24 + test "features that are on here are described; federation is on in test", %{conn: conn} do
25 + doc = conn |> get(~p"/about") |> html_response(200) |> LazyHTML.from_document()
26 + refute Enum.empty?(LazyHTML.query(doc, "#feature-fediverse"))
27 + # NEIAM sign-in is off (OIDC_ENABLED unset): not advertised.
28 + assert Enum.empty?(LazyHTML.query(doc, "#feature-sso"))
29 + end
30 +
31 + describe "run your own" do
32 + import Phoenix.LiveViewTest
33 +
34 + test "ready-to-copy commands, podman by default", %{conn: conn} do
35 + {:ok, lv, _html} = live(conn, ~p"/about")
36 +
37 + assert has_element?(lv, "#run-your-own")
38 + assert has_element?(lv, "#runtime-podman[aria-selected=true]")
39 + assert has_element?(lv, "#db-command", "podman network create final-track")
40 + assert has_element?(lv, "#db-command", "POSTGRES_DB=final_track")
41 + assert has_element?(lv, "#run-command", "--network final-track")
42 + assert has_element?(lv, "#run-command", "ecto://USER:PASS@final-track-db/final_track")
43 + assert has_element?(lv, "#run-command", "ggr.neiam.co/neiam/final_track:latest")
44 + assert has_element?(lv, "#run-command", "-v final-track-covers:/var/lib/final_track/covers")
45 + assert has_element?(lv, "#setup-command", "podman exec final-track bin/migrate")
46 + assert has_element?(lv, "#setup-command", "bin/invite")
47 + # One registry so far: no picker.
48 + refute has_element?(lv, "[id^=registry-]")
49 + end
50 +
51 + test "switch runtime, fill in the blanks", %{conn: conn} do
52 + {:ok, lv, _html} = live(conn, ~p"/about")
53 +
54 + lv |> element("#runtime-docker") |> render_click()
55 + assert has_element?(lv, "#run-command", "docker run -d --name final-track")
56 + assert has_element?(lv, "#setup-command", "docker exec final-track bin/migrate")
57 +
58 + lv
59 + |> form("#run-config", %{user: "tracks", password: "s3cret", host: "music.example.org"})
60 + |> render_change()
61 +
62 + assert has_element?(lv, "#run-command", "PHX_HOST=music.example.org")
63 + assert has_element?(lv, "#run-command", "ecto://tracks:s3cret@final-track-db/final_track")
64 + assert has_element?(lv, "#db-command", "POSTGRES_USER=tracks")
65 +
66 + # Blank again: back to the placeholders.
67 + lv |> form("#run-config", %{user: " ", password: "", host: ""}) |> render_change()
68 + assert has_element?(lv, "#run-command", "PHX_HOST=tracks.you.com")
69 + end
70 +
71 + test "a forged runtime is ignored, never turned into an atom", %{conn: conn} do
72 + {:ok, lv, _html} = live(conn, ~p"/about")
73 + render_hook(lv, "set_runtime", %{"runtime" => "rkt-#{System.unique_integer()}"})
74 + assert has_element?(lv, "#runtime-podman[aria-selected=true]")
75 + end
76 + end
77 +
78 + test "OpenID Connect, not NEIAM, in the copy", %{conn: conn} do
79 + html = conn |> get(~p"/about") |> html_response(200)
80 + refute html =~ "Sign in with NEIAM"
81 + assert html =~ "OpenID Connect"
82 + end
83 +end

Parents: 64c470b