mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
* Send transactional email from no-reply@mail.innersquare.app Centralise the sender identity, reply-to address and SES configuration set in Chesstrainer.Mail so no notifier can drift. Add MAIL_REDIRECT_TO for smoke tests and a mix mail.check task that exercises the SES mailbox simulators, and document the setup in the deploy guide and .env.example. * Tighten crawler metadata and keep play pages out of search Canonical URLs no longer carry query strings, public pages get an OG image, WebSite JSON-LD and a per-page language, and the sitemap dates the landing page only. Play and guest-training routes are marked noindex so tens of thousands of near-identical pages stay out of the index. * Measure built asset sizes with mix assets.sizes Report raw, gzip and brotli sizes for built JS and CSS, and record the current numbers plus the board-code split recommendation in docs/assets.md.
56 lines
1.8 KiB
Elixir
56 lines
1.8 KiB
Elixir
defmodule ChesstrainerWeb.SitemapController do
|
|
@moduledoc """
|
|
Generates `/sitemap.xml` for the indexable public pages.
|
|
|
|
Endgame play pages are deliberately left out: there are tens of thousands of
|
|
them and they render the same interactive surface with only the position
|
|
differing, so listing them all would be index bloat. Revisit that if public
|
|
browse pages (by Key or theme) exist and are worth ranking.
|
|
"""
|
|
|
|
use ChesstrainerWeb, :controller
|
|
|
|
def index(conn, _params) do
|
|
# The landing page changes every day (daily puzzle, counts), so its
|
|
# lastmod is honest. The legal pages have no stored modification time, and
|
|
# an invented lastmod is worse than none.
|
|
entries = [
|
|
{url(conn, ~p"/"), Date.utc_today()},
|
|
{url(conn, ~p"/privacy"), nil},
|
|
{url(conn, ~p"/terms-conditions"), nil},
|
|
{url(conn, ~p"/mentions-legales"), nil}
|
|
]
|
|
|
|
conn
|
|
|> put_resp_content_type("application/xml")
|
|
|> send_resp(200, render_sitemap(entries))
|
|
end
|
|
|
|
defp render_sitemap(entries) do
|
|
urls =
|
|
Enum.map_join(entries, fn {loc, lastmod} ->
|
|
" <url><loc>#{escape(loc)}</loc>#{lastmod_entry(lastmod)}</url>\n"
|
|
end)
|
|
|
|
"""
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
#{urls}</urlset>
|
|
"""
|
|
end
|
|
|
|
defp lastmod_entry(nil), do: ""
|
|
defp lastmod_entry(%Date{} = date), do: "<lastmod>#{Date.to_iso8601(date)}</lastmod>"
|
|
|
|
# Templates escape automatically; this response is built as a plain string,
|
|
# so XML-significant characters must be escaped here.
|
|
defp escape(value) do
|
|
value
|
|
|> String.replace("&", "&")
|
|
|> String.replace("<", "<")
|
|
|> String.replace(">", ">")
|
|
|> String.replace("\"", """)
|
|
|> String.replace("'", "'")
|
|
end
|
|
end
|