mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
* lesson library shown as com,ing soon. re-enable learngin strip * replace learning strip text with a lasker quote * remove admin login endpoint * fix crawler directives and prelaunch login - noindex the authenticated scope and the 404 catch-all, and cover the mailing-list confirmation redirect - emit noindex, nofollow from the robots meta and /health, and assert public pages stay indexable and followable - stop inventing lastmod values in the sitemap - log in through /users/log-in during prelaunch now that the admin login endpoint is gone; drop create_admin/2 and its orphaned tests * update caching length to 1 year - name change will invalidate cache * remove logger * fix tablebase path breaking tests * test: check cache headers without requiring built assets CI's test job does not run mix assets.build, so /assets/css/app.css is a 404 there. Committed piece art is already content-hashed and takes the same Plug.Static cache option, so the test no longer needs a build step and passes on a fresh checkout.
54 lines
1.6 KiB
Elixir
54 lines
1.6 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.
|
|
|
|
No `<lastmod>` is emitted: none of these pages has a stored modification time,
|
|
and an invented date (such as "today" on every request) teaches crawlers to
|
|
distrust the sitemap.
|
|
"""
|
|
|
|
use ChesstrainerWeb, :controller
|
|
|
|
def index(conn, _params) do
|
|
entries = [
|
|
url(conn, ~p"/"),
|
|
url(conn, ~p"/privacy"),
|
|
url(conn, ~p"/terms-conditions"),
|
|
url(conn, ~p"/mentions-legales")
|
|
]
|
|
|
|
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 ->
|
|
" <url><loc>#{escape(loc)}</loc></url>\n"
|
|
end)
|
|
|
|
"""
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
#{urls}</urlset>
|
|
"""
|
|
end
|
|
|
|
# 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
|