Privacy and terms pages with config-driven branding (#91)

* comment out begin with basics until lessons are on the way

* route to footer link dead views

* proposed >7 piece engame processing

* basic privacy and terms pages with default text

* add branding to config and reference across the site

* disclose guest puzzle limit in privacy policy (#87)
This commit is contained in:
2026-11-06 13:56:20 +01:00
committed by GitHub
parent 6a4288bb6c
commit bd8be4d10d
15 changed files with 548 additions and 23 deletions
+1
View File
@@ -22,6 +22,7 @@
@import "./components/_learning-strip.css"; @import "./components/_learning-strip.css";
@import "./components/_board.css"; @import "./components/_board.css";
@import "./components/_promotion.css"; @import "./components/_promotion.css";
@import "./pages/_legal.css";
@source "../css"; @source "../css";
@source "../js"; @source "../js";
+72
View File
@@ -0,0 +1,72 @@
.legal {
width: min(760px, calc(100% - 48px));
margin: 0 auto;
padding: 84px 0 120px;
}
.legal h1 {
max-width: none;
font-size: clamp(42px, 5vw, 62px);
line-height: 1.02;
}
.legal-meta {
margin-top: 14px;
color: var(--color-muted);
font-size: 13px;
}
.legal h2 {
margin: 42px 0 12px;
font-size: 26px;
line-height: 1.15;
}
.legal p,
.legal li {
color: var(--color-muted);
font-size: 15px;
line-height: 1.75;
}
.legal p + p {
margin-top: 12px;
}
.legal ul {
display: grid;
gap: 8px;
margin: 12px 0 0 20px;
list-style: disc;
}
.legal strong {
color: var(--color-body);
font-weight: 600;
}
.legal a {
color: var(--color-coral-text);
text-decoration: underline;
text-underline-offset: 2px;
}
.legal a:hover {
opacity: 0.75;
}
@media (max-width: 650px) {
.legal {
width: calc(100% - 36px);
padding: 56px 0 84px;
}
.legal h1 {
font-size: clamp(34px, 11vw, 44px);
}
.legal h2 {
margin-top: 34px;
font-size: 23px;
}
}
+9
View File
@@ -7,6 +7,15 @@
# General application configuration # General application configuration
import Config import Config
# Public-facing branding. Change these values to rename the site without
# touching templates. The OTP app (`:chesstrainer`) and module namespaces are
# identity, not branding, and stay as they are.
config :chesstrainer, :branding,
name: "Lucid Chess",
wordmark: "LUCID",
tagline: "Endgame Trainer",
support_email: "support@lucidchess.app"
config :chesstrainer, :scopes, config :chesstrainer, :scopes,
user: [ user: [
default: true, default: true,
+55
View File
@@ -0,0 +1,55 @@
# Eight-or-more-piece endgames are trained from engine-sourced corridors that hand off to the tablebase at seven
_Status: proposed. Extends ADR-0005: the ≤7-piece source split stands; this adds a source for 8+._
Syzygy stops at seven pieces and there is no tablebase for eight or more. To
train such endgames without pretending to a completeness they lack, each 8+
endgame is backed by a **corridor**: one or two winning lines, generated offline
with a chess engine (Stockfish), that stay clearly winning at every step. The
corridor is stored as solved positions keyed by position key and served by a new
tablebase backend, so the play loop and grading are unchanged.
The corridor ends at the first capture that brings the board to seven pieces or
fewer. From that position the existing router answers from Syzygy (≤5, local) or
Lichess (6–7), so the tail of every puzzle is tablebase-optimal. Generation
verifies the handoff: it probes the ≤7 position and asserts it is still a win for
the winning side. A promotion does not end the corridor, because it does not
reduce the piece count; only a capture does.
A second line is stored only when both lines are clearly winning — the engine's
evaluation stays above the winning threshold throughout. A line that dips is
discarded rather than shipped as a dubious alternative.
## Grading
Inside the corridor grading is binary: a move on a stored line passes, a move
off the lines fails. The stored move list is deliberately incomplete, so it
cannot support the "any winning move passes" rule the tablebase enables; the
user must find the technique the corridor encodes. Once the position reaches
seven pieces, grading returns to the existing optimal/winning/losing model.
## Why not the alternatives
- **Engine at runtime.** Removes the offline step but adds per-move latency, a
rate limit if it is a remote service, and non-determinism in what counts as
"winning". The corridor is deterministic and free at play time.
- **Hand-authored book.** The same shape without an engine to generate it:
fragile, narrow, and prone to grading a move as losing only because nobody
wrote it down.
- **Solving the whole 8+ region.** Infeasible. The corridor trades completeness
for a short, verified path to a position the tablebase can finish.
## Consequences
- Endgames gain an `oracle` (`:tablebase` or `:corridor`). The changeset admits
8+ FENs only for corridor endgames.
- A corridor-position store (keyed by position key) and a tree backend join the
existing Fathom/Lichess backends. Eight-plus positions without a corridor are
still rejected.
- Generation depends on a Stockfish binary at build/curation time, not at
runtime.
- The corridor is engine-best, not proven-optimal. Honest wording ("engine-best
defence") is required in player-facing copy, and GLOSSARY's *optimal move* and
*winning move* need a corridor-aware distinction.
- An off-corridor legal move fails the attempt; this is a deliberate departure
from tablebase grading and must be reflected in the play surface.
+2 -1
View File
@@ -1,6 +1,7 @@
defmodule Chesstrainer.Accounts.UserNotifier do defmodule Chesstrainer.Accounts.UserNotifier do
import Swoosh.Email import Swoosh.Email
alias Chesstrainer.Branding
alias Chesstrainer.Mailer alias Chesstrainer.Mailer
# Delivers the email using the application mailer. # Delivers the email using the application mailer.
@@ -8,7 +9,7 @@ defmodule Chesstrainer.Accounts.UserNotifier do
email = email =
new() new()
|> to(recipient) |> to(recipient)
|> from({"Chesstrainer", "contact@example.com"}) |> from({Branding.name(), Branding.support_email()})
|> subject(subject) |> subject(subject)
|> text_body(body) |> text_body(body)
+39
View File
@@ -0,0 +1,39 @@
defmodule Chesstrainer.Branding do
@moduledoc """
Public-facing branding, read from `config :chesstrainer, :branding`.
Keeps display names out of templates and controllers so the site can be
renamed in one place. Values are read at runtime, so a deploy can override
them without recompiling.
"""
@defaults [
name: "Lucid Chess",
wordmark: "LUCID",
tagline: "Endgame Trainer",
support_email: "support@lucidchess.app"
]
@doc "The display name, e.g. `\"Lucid Chess\"`."
def name, do: get(:name)
@doc "The short wordmark used in the navbar and footer."
def wordmark, do: get(:wordmark)
@doc "The tagline appended to the home title, e.g. `\"Endgame Trainer\"`."
def tagline, do: get(:tagline)
@doc "The address shown in legal pages and used as the mailer `from`."
def support_email, do: get(:support_email)
@doc "The home-page title, e.g. `\"Lucid Chess — Endgame Trainer\"`."
def home_title, do: "#{name()} — #{tagline()}"
@doc "Builds a page title, e.g. `title(\"Privacy Policy\")`."
def title(page), do: "#{page} — #{name()}"
defp get(key) do
config = Application.get_env(:chesstrainer, :branding) || []
Keyword.get(config, key, Keyword.fetch!(@defaults, key))
end
end
+1
View File
@@ -91,6 +91,7 @@ defmodule ChesstrainerWeb do
# Common modules used in templates # Common modules used in templates
alias Phoenix.LiveView.JS alias Phoenix.LiveView.JS
alias Chesstrainer.Branding
alias ChesstrainerWeb.Layouts alias ChesstrainerWeb.Layouts
# Routes generation with the ~p sigil # Routes generation with the ~p sigil
+7 -7
View File
@@ -70,9 +70,9 @@ defmodule ChesstrainerWeb.Layouts do
~H""" ~H"""
<header> <header>
<nav class="nav-wrap" aria-label="Main navigation"> <nav class="nav-wrap" aria-label="Main navigation">
<a class="brand" href="/" aria-label="Lucid Chess home"> <a class="brand" href="/" aria-label={"#{Branding.name()} home"}>
<span class="brand-mark">♞</span> <span class="brand-mark">♞</span>
<span>LUCID</span> <span>{Branding.wordmark()}</span>
</a> </a>
<div class="nav-right"> <div class="nav-right">
@@ -166,19 +166,19 @@ defmodule ChesstrainerWeb.Layouts do
~H""" ~H"""
<footer class="site-footer"> <footer class="site-footer">
<div class="footer-brand"> <div class="footer-brand">
<a class="brand" href="/" aria-label="Lucid Chess home"> <a class="brand" href="/" aria-label={"#{Branding.name()} home"}>
<span class="brand-mark">♞</span> <span class="brand-mark">♞</span>
<span>LUCID</span> <span>{Branding.wordmark()}</span>
</a> </a>
<p>Short, focused endgame training.</p> <p>Short, focused endgame training.</p>
</div> </div>
<nav class="footer-links" aria-label="Footer"> <nav class="footer-links" aria-label="Footer">
<a href="/#privacy">Privacy Policy</a> <a href="/privacy">Privacy Policy</a>
<a href="/#terms-conditions">Terms & Conditions</a> <a href="/terms-conditions">Terms & Conditions</a>
</nav> </nav>
<small>© {@year} Lucid Chess</small> <small>© {@year} {Branding.name()}</small>
</footer> </footer>
""" """
end end
@@ -6,8 +6,8 @@
<meta name="csrf-token" content={get_csrf_token()} /> <meta name="csrf-token" content={get_csrf_token()} />
<.live_title <.live_title
default="Lucid Chess — Endgame Trainer" default={Branding.home_title()}
suffix={assigns[:title_suffix] || " · Lucid Chess"} suffix={assigns[:title_suffix] || " · #{Branding.name()}"}
phx-no-format phx-no-format
>{assigns[:page_title]}</.live_title> >{assigns[:page_title]}</.live_title>
<meta <meta
@@ -17,11 +17,11 @@
/> />
<link :if={assigns[:canonical_url]} rel="canonical" href={assigns[:canonical_url]} /> <link :if={assigns[:canonical_url]} rel="canonical" href={assigns[:canonical_url]} />
<meta :if={assigns[:meta_description]} property="og:type" content="website" /> <meta :if={assigns[:meta_description]} property="og:type" content="website" />
<meta :if={assigns[:meta_description]} property="og:site_name" content="Lucid Chess" /> <meta :if={assigns[:meta_description]} property="og:site_name" content={Branding.name()} />
<meta <meta
:if={assigns[:meta_description]} :if={assigns[:meta_description]}
property="og:title" property="og:title"
content={assigns[:page_title] || "Lucid Chess — Endgame Trainer"} content={assigns[:page_title] || Branding.home_title()}
/> />
<meta <meta
:if={assigns[:meta_description]} :if={assigns[:meta_description]}
@@ -33,7 +33,7 @@
<meta <meta
:if={assigns[:meta_description]} :if={assigns[:meta_description]}
name="twitter:title" name="twitter:title"
content={assigns[:page_title] || "Lucid Chess — Endgame Trainer"} content={assigns[:page_title] || Branding.home_title()}
/> />
<meta <meta
:if={assigns[:meta_description]} :if={assigns[:meta_description]}
@@ -2,6 +2,7 @@ defmodule ChesstrainerWeb.PageController do
use ChesstrainerWeb, :controller use ChesstrainerWeb, :controller
alias Chesstrainer.Attempts alias Chesstrainer.Attempts
alias Chesstrainer.Branding
alias Chesstrainer.DailyPuzzles alias Chesstrainer.DailyPuzzles
alias Chesstrainer.Endgames alias Chesstrainer.Endgames
@@ -13,7 +14,7 @@ defmodule ChesstrainerWeb.PageController do
conn conn
|> assign(:js_entry, ~p"/assets/js/marketing.js") |> assign(:js_entry, ~p"/assets/js/marketing.js")
|> assign(:page_title, "Lucid Chess — Endgame Trainer") |> assign(:page_title, Branding.home_title())
|> assign(:title_suffix, "") |> assign(:title_suffix, "")
|> assign(:meta_description, @description) |> assign(:meta_description, @description)
|> assign(:canonical_url, current_url(conn)) |> assign(:canonical_url, current_url(conn))
@@ -25,4 +26,27 @@ defmodule ChesstrainerWeb.PageController do
today: Date.utc_today() today: Date.utc_today()
) )
end end
def privacy(conn, _params) do
conn
|> assign(:js_entry, ~p"/assets/js/marketing.js")
|> assign(:page_title, Branding.title("Privacy Policy"))
|> assign(:title_suffix, "")
|> assign(
:meta_description,
"How #{Branding.name()} collects, uses, and protects your personal data."
)
|> assign(:canonical_url, current_url(conn))
|> render(:privacy)
end
def terms_conditions(conn, _params) do
conn
|> assign(:js_entry, ~p"/assets/js/marketing.js")
|> assign(:page_title, Branding.title("Terms & Conditions"))
|> assign(:title_suffix, "")
|> assign(:meta_description, "The terms that apply when you use #{Branding.name()}.")
|> assign(:canonical_url, current_url(conn))
|> render(:terms_conditions)
end
end end
@@ -75,7 +75,7 @@
</div> </div>
</section> </section>
<section class="progress-banner" id="progress"> <%!-- <section class="progress-banner" id="progress">
<div> <div>
<span class="section-kicker">A calmer way to improve</span> <span class="section-kicker">A calmer way to improve</span>
<h2> <h2>
@@ -85,5 +85,5 @@
<.pill_button variant={:light} navigate={play_path(@active_endgame)}> <.pill_button variant={:light} navigate={play_path(@active_endgame)}>
Begin with the basics <.icon_arrow /> Begin with the basics <.icon_arrow />
</.pill_button> </.pill_button>
</section> </section> --%>
</main> </main>
@@ -0,0 +1,137 @@
<Layouts.flash_group flash={@flash} />
<main>
<article class="legal">
<h1>Privacy Policy</h1>
<p class="legal-meta">Last updated: 6 November 2026</p>
<p>
{Branding.name()} is an endgame training site. This policy explains what
information we collect when you use it, why we collect it, and the choices
you have. It covers the website and every page under it, including the
guest trainer.
</p>
<h2>What we collect</h2>
<ul>
<li>
<strong>Account details.</strong>
If you register, we store your username, email address, and a hashed
password. We never store passwords in plain text.
</li>
<li>
<strong>Training activity.</strong>
We record the puzzles you attempt and whether you solved them, so we can
show your progress and keep the daily puzzle meaningful.
</li>
<li>
<strong>Technical data.</strong>
Our hosting and server infrastructure may keep standard request logs
(IP address, browser, timestamps) for security and troubleshooting.
These logs are rotated regularly.
</li>
<li>
<strong>Messages you send us.</strong>
If you contact us, we keep the message and our reply for as long as
needed to help you.
</li>
</ul>
<h2>Cookies and local storage</h2>
<p>
We use a small number of cookies and local storage entries that are
required for the site to work:
</p>
<ul>
<li>a session cookie that keeps you signed in;</li>
<li>a CSRF token that protects forms from cross-site requests;</li>
<li>a colour-mode preference stored in your browser.</li>
</ul>
<p>
We do not use advertising cookies, third-party analytics, or cross-site
tracking. You can clear these entries at any time in your browser
settings; doing so will sign you out and reset your colour mode.
</p>
<h2>How we use your information</h2>
<ul>
<li>To create and secure your account and sign you in.</li>
<li>To run the trainer and remember your progress.</li>
<li>To send service emails, such as confirmation and password reset links.</li>
<li>To keep the site available, prevent abuse, and fix faults.</li>
<li>To respond when you ask for help.</li>
</ul>
<p>
We rely on our contract with you to provide the service, our legitimate
interests in keeping it secure and improving it, and your consent where we
ask for it. You can withdraw consent at any time.
</p>
<h2>Guest puzzle limit</h2>
<p>
Visitors who use the guest trainer without an account get a limited number
of free puzzles per UTC day. To enforce that limit and prevent abuse, we
identify each visitor by a keyed hash (HMAC-SHA256) of their IP address.
The limiter itself never stores, logs, or shares the raw address.
</p>
<p>
The hash exists only in the memory of the server that handled your request.
It is tied to the current UTC day, stops being usable at 00:00 UTC, and is
deleted by a periodic sweep shortly afterwards; it is also discarded when
the server restarts. It is never written to a database, a log, or a
backup, and no cookie or other client-side storage is involved. Signed-in
accounts are not metered this way.
</p>
<p>
We process this hash on the basis of our legitimate interests
(Article 6(1)(f) GDPR) in keeping the service available and preventing
abuse of the free tier. We do not share it with anyone. You have the right
to object to this processing; to do so, contact us using the address below.
</p>
<h2>Sharing</h2>
<p>
We do not sell your personal information. We share it only with providers
who help us run the site — for example hosting, database, and email
delivery providers — and only as far as they need it to perform that work.
We may also disclose information where the law requires it or to protect
the rights and safety of our users.
</p>
<h2>Retention</h2>
<p>
We keep account and training data while your account is open. If you
delete your account, we remove your personal information within a
reasonable period, except where we must keep records for legal, security,
or accounting reasons.
</p>
<h2>Your rights</h2>
<p>
Depending on where you live, you may have the right to access, correct,
delete, restrict, or export your personal information, and to object to
some uses of it. To make a request, contact us using the address below. If
you are in the UK or EU and are unhappy with our response, you can complain
to your local data protection authority.
</p>
<h2>Children</h2>
<p>
The service is not directed at children under 13, and we do not knowingly
collect their personal information. If you believe a child has created an
account, contact us and we will remove it.
</p>
<h2>Changes</h2>
<p>
We may update this policy as the service changes. When we do, we will
change the date at the top of this page and, for significant changes,
notify signed-in users by email or on the site.
</p>
<h2>Contact</h2>
<p>
Questions about this policy or your data can be sent to <a href={"mailto:" <> Branding.support_email()}>{Branding.support_email()}</a>.
</p>
</article>
</main>
@@ -0,0 +1,118 @@
<Layouts.flash_group flash={@flash} />
<main>
<article class="legal">
<h1>Terms &amp; Conditions</h1>
<p class="legal-meta">Last updated: 6 November 2026</p>
<p>
These terms govern your use of {Branding.name()}. By browsing the site, using
the guest trainer, or creating an account, you agree to them. If you do not
agree, please do not use the service.
</p>
<h2>The service</h2>
<p>
{Branding.name()} provides short endgame puzzles and training tools. Some
features are available without an account; others, such as saved progress
and the full puzzle list, require you to register. We may add, change, or
remove features over time.
</p>
<p>
The guest trainer is limited to a fixed number of puzzles per UTC day,
which we may change. The limit is enforced as described in our <a href="/privacy">Privacy Policy</a>.
</p>
<h2>Accounts</h2>
<ul>
<li>You must be at least 13 years old to create an account.</li>
<li>Give accurate information and keep it up to date.</li>
<li>Keep your password private and tell us promptly about unauthorised use.</li>
<li>You are responsible for activity that happens under your account.</li>
<li>Do not share, sell, or transfer your account to someone else.</li>
</ul>
<h2>Acceptable use</h2>
<p>You agree not to:</p>
<ul>
<li>break the law or infringe anyone else's rights;</li>
<li>interfere with the site, its servers, or other users;</li>
<li>attempt to gain access to accounts or data that are not yours;</li>
<li>scrape, crawl, or bulk-download the site without our permission;</li>
<li>copy, resell, or redistribute the service or its content;</li>
<li>use the service to send spam or malicious code.</li>
</ul>
<h2>Our content and your licence</h2>
<p>
The site, its design, text, and software are owned by {Branding.name()} or its
licensors and are protected by copyright and other laws. We grant you a
personal, non-exclusive, non-transferable licence to use the service for
your own training. You may not reproduce, modify, distribute, or create
derivative works from our content without written permission.
</p>
<p>
Chess positions and puzzle data are drawn from public sources and
tablebase material. You may use the training output for your own study,
but not to build a competing product.
</p>
<h2>Your data</h2>
<p>
You keep ownership of the information you provide. You give us permission
to store and use it as described in our <a href="/privacy">Privacy Policy</a>
so that we can run the service.
</p>
<h2>Paid plans</h2>
<p>
Some features may be offered as part of a paid plan. Prices, billing
periods, and cancellation terms will be shown before you purchase. Unless
the law requires otherwise, payments are non-refundable once a billing
period has started. We may change prices with reasonable notice.
</p>
<h2>Availability and changes</h2>
<p>
We aim to keep the site available, but we do not guarantee uninterrupted
access. Maintenance, faults, or circumstances outside our control may
interrupt it. We may suspend or discontinue the service, in whole or in
part, with reasonable notice where practical.
</p>
<h2>Disclaimer</h2>
<p>
{Branding.name()} is an educational tool. We do not promise that using it will
improve your rating or results, and puzzle solutions are provided for
training purposes only. The service is provided "as is" to the extent
permitted by law.
</p>
<h2>Limitation of liability</h2>
<p>
To the extent permitted by law, {Branding.name()} is not liable for indirect or
consequential losses, loss of data, or loss of profits arising from your
use of the service. Nothing in these terms limits liability that cannot be
limited by law, including for death, personal injury, or fraud.
</p>
<h2>Termination</h2>
<p>
You may stop using the service and delete your account at any time. We may
suspend or close an account that breaches these terms, that we reasonably
believe is being misused, or where we are required to do so by law.
</p>
<h2>Governing law</h2>
<p>
These terms are governed by the laws of France. Any dispute
will be handled by the courts of France, unless the law where
you live gives you the right to bring it elsewhere.
</p>
<h2>Contact</h2>
<p>
Questions about these terms can be sent to <a href={"mailto:" <> Branding.support_email()}>{Branding.support_email()}</a>.
</p>
</article>
</main>
+2
View File
@@ -21,6 +21,8 @@ defmodule ChesstrainerWeb.Router do
pipe_through :browser pipe_through :browser
get "/", PageController, :home get "/", PageController, :home
get "/privacy", PageController, :privacy
get "/terms-conditions", PageController, :terms_conditions
end end
scope "/admin", ChesstrainerWeb do scope "/admin", ChesstrainerWeb do
@@ -6,6 +6,7 @@ defmodule ChesstrainerWeb.PageControllerTest do
alias Chesstrainer.Accounts.Scope alias Chesstrainer.Accounts.Scope
alias Chesstrainer.Attempts alias Chesstrainer.Attempts
alias Chesstrainer.Branding
alias Chesstrainer.DailyPuzzles alias Chesstrainer.DailyPuzzles
alias Chesstrainer.Endgames alias Chesstrainer.Endgames
alias Chesstrainer.Themes alias Chesstrainer.Themes
@@ -51,19 +52,19 @@ defmodule ChesstrainerWeb.PageControllerTest do
document = LazyHTML.from_document(html) document = LazyHTML.from_document(html)
assert html =~ "Learn to see the" assert html =~ "Learn to see the"
assert html =~ "LUCID" assert html =~ Branding.wordmark()
assert html =~ "Privacy Policy" assert html =~ "Privacy Policy"
assert html =~ "/#terms-conditions" assert html =~ "/terms-conditions"
assert html =~ "Start training" assert html =~ "Start training"
assert html =~ ~s(id="nav-links") assert html =~ ~s(id="nav-links")
assert html =~ "menu-button" assert html =~ "menu-button"
assert html =~ ~s(class="site-footer") assert html =~ ~s(class="site-footer")
assert html =~ "© #{DateTime.utc_now().year} Lucid Chess" assert html =~ "© #{DateTime.utc_now().year} #{Branding.name()}"
assert html =~ ~p"/endgames" assert html =~ ~p"/endgames"
assert html =~ "/assets/js/marketing.js" assert html =~ "/assets/js/marketing.js"
refute html =~ "/assets/js/app.js" refute html =~ "/assets/js/app.js"
assert LazyHTML.text(LazyHTML.query(document, "title")) =~ "Lucid Chess — Endgame Trainer" assert LazyHTML.text(LazyHTML.query(document, "title")) =~ Branding.home_title()
refute html =~ "Phoenix Framework" refute html =~ "Phoenix Framework"
eyebrow = LazyHTML.query(document, ".eyebrow") eyebrow = LazyHTML.query(document, ".eyebrow")
@@ -80,18 +81,83 @@ defmodule ChesstrainerWeb.PageControllerTest do
for {selector, content} <- [ for {selector, content} <- [
{~s(meta[property="og:type"]), "website"}, {~s(meta[property="og:type"]), "website"},
{~s(meta[property="og:site_name"]), "Lucid Chess"}, {~s(meta[property="og:site_name"]), Branding.name()},
{~s(meta[property="og:title"]), "Lucid Chess — Endgame Trainer"}, {~s(meta[property="og:title"]), Branding.home_title()},
{~s(meta[property="og:description"]), @description}, {~s(meta[property="og:description"]), @description},
{~s(meta[property="og:url"]), canonical}, {~s(meta[property="og:url"]), canonical},
{~s(meta[name="twitter:card"]), "summary"}, {~s(meta[name="twitter:card"]), "summary"},
{~s(meta[name="twitter:title"]), "Lucid Chess — Endgame Trainer"}, {~s(meta[name="twitter:title"]), Branding.home_title()},
{~s(meta[name="twitter:description"]), @description} {~s(meta[name="twitter:description"]), @description}
] do ] do
assert LazyHTML.attribute(LazyHTML.query(document, selector), "content") == [content] assert LazyHTML.attribute(LazyHTML.query(document, selector), "content") == [content]
end end
end end
test "GET /privacy renders the privacy policy", %{conn: conn} do
html = conn |> get(~p"/privacy") |> html_response(200)
document = LazyHTML.from_document(html)
assert LazyHTML.text(LazyHTML.query(document, "h1")) == "Privacy Policy"
assert html =~ "Last updated: 6 November 2026"
assert html =~ "What we collect"
assert html =~ "Cookies and local storage"
assert html =~ "Guest puzzle limit"
assert html =~ "HMAC-SHA256"
assert html =~ "Article 6(1)(f) GDPR"
assert LazyHTML.text(LazyHTML.query(document, "title")) ==
Branding.title("Privacy Policy")
assert [canonical] =
LazyHTML.attribute(LazyHTML.query(document, ~s(link[rel="canonical"])), "href")
assert URI.parse(canonical).path == "/privacy"
end
test "GET /terms-conditions renders the terms", %{conn: conn} do
html = conn |> get(~p"/terms-conditions") |> html_response(200)
document = LazyHTML.from_document(html)
assert LazyHTML.text(LazyHTML.query(document, "h1")) == "Terms & Conditions"
assert html =~ "Last updated: 6 November 2026"
assert html =~ "Acceptable use"
assert html =~ "Governing law"
assert html =~ "fixed number of puzzles per UTC day"
assert html =~ ~p"/privacy"
assert LazyHTML.text(LazyHTML.query(document, "title")) ==
Branding.title("Terms & Conditions")
assert [canonical] =
LazyHTML.attribute(LazyHTML.query(document, ~s(link[rel="canonical"])), "href")
assert URI.parse(canonical).path == "/terms-conditions"
end
test "branding is read from application config", %{conn: conn} do
previous = Application.get_env(:chesstrainer, :branding)
on_exit(fn ->
if previous,
do: Application.put_env(:chesstrainer, :branding, previous),
else: Application.delete_env(:chesstrainer, :branding)
end)
Application.put_env(:chesstrainer, :branding,
name: "Test Brand",
wordmark: "TEST",
tagline: "Trainer",
support_email: "help@test.example"
)
html = conn |> get(~p"/privacy") |> html_response(200)
assert html =~ "Privacy Policy — Test Brand"
assert html =~ "Test Brand is an endgame training site"
assert html =~ "help@test.example"
assert html =~ ~s(content="Test Brand")
end
test "hero shows the number of players with at least one attempt", %{conn: conn} do test "hero shows the number of players with at least one attempt", %{conn: conn} do
user = user_fixture() user = user_fixture()
endgame = endgame_fixture() endgame = endgame_fixture()