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.
133 lines
3.2 KiB
Elixir
133 lines
3.2 KiB
Elixir
defmodule ChesstrainerWeb do
|
|
@moduledoc """
|
|
The entrypoint for defining your web interface, such
|
|
as controllers, components, channels, and so on.
|
|
|
|
This can be used in your application as:
|
|
|
|
use ChesstrainerWeb, :controller
|
|
use ChesstrainerWeb, :html
|
|
|
|
The definitions below will be executed for every controller,
|
|
component, etc, so keep them short and clean, focused
|
|
on imports, uses and aliases.
|
|
|
|
Do NOT define functions inside the quoted expressions
|
|
below. Instead, define additional modules and import
|
|
those modules here.
|
|
"""
|
|
|
|
def static_paths do
|
|
~w(assets fonts images favicon.ico favicon.svg favicon-16x16.png favicon-32x32.png
|
|
apple-touch-icon.png android-chrome-192x192.png android-chrome-512x512.png
|
|
site.webmanifest)
|
|
end
|
|
|
|
@doc "Whether the app is gated behind the prelaunch page."
|
|
def prelaunch?, do: Application.get_env(:chesstrainer, :prelaunch, false)
|
|
|
|
@doc "Whether the mailing-list form and endpoint are open."
|
|
def mailing_list_enabled? do
|
|
Application.get_env(:chesstrainer, :mailing_list_enabled, true)
|
|
end
|
|
|
|
def router do
|
|
quote do
|
|
use Phoenix.Router, helpers: false
|
|
|
|
# Import common connection and controller functions to use in pipelines
|
|
import Plug.Conn
|
|
import Phoenix.Controller
|
|
import Phoenix.LiveView.Router
|
|
end
|
|
end
|
|
|
|
def channel do
|
|
quote do
|
|
use Phoenix.Channel
|
|
end
|
|
end
|
|
|
|
def controller do
|
|
quote do
|
|
use Phoenix.Controller, formats: [:html, :json]
|
|
|
|
use Gettext, backend: ChesstrainerWeb.Gettext
|
|
|
|
import Plug.Conn
|
|
|
|
unquote(verified_routes())
|
|
end
|
|
end
|
|
|
|
def live_view do
|
|
quote do
|
|
use Phoenix.LiveView
|
|
|
|
unquote(html_helpers())
|
|
end
|
|
end
|
|
|
|
def live_component do
|
|
quote do
|
|
use Phoenix.LiveComponent
|
|
|
|
unquote(html_helpers())
|
|
end
|
|
end
|
|
|
|
def html do
|
|
quote do
|
|
use Phoenix.Component
|
|
|
|
# Import convenience functions from controllers
|
|
import Phoenix.Controller,
|
|
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
|
|
|
# Include general helpers for rendering HTML
|
|
unquote(html_helpers())
|
|
end
|
|
end
|
|
|
|
defp html_helpers do
|
|
quote do
|
|
# Translation
|
|
use Gettext, backend: ChesstrainerWeb.Gettext
|
|
|
|
# HTML escaping functionality
|
|
import Phoenix.HTML
|
|
# Core UI components
|
|
import ChesstrainerWeb.CoreComponents
|
|
# Landing-page primitives (pill buttons, marketing icons)
|
|
import ChesstrainerWeb.LandingComponents
|
|
# Rating gauge and explainer
|
|
import ChesstrainerWeb.RatingComponents
|
|
|
|
# Common modules used in templates
|
|
alias Phoenix.LiveView.JS
|
|
alias Chesstrainer.Branding
|
|
alias ChesstrainerWeb.Layouts
|
|
alias ChesstrainerWeb.SEO
|
|
|
|
# Routes generation with the ~p sigil
|
|
unquote(verified_routes())
|
|
end
|
|
end
|
|
|
|
def verified_routes do
|
|
quote do
|
|
use Phoenix.VerifiedRoutes,
|
|
endpoint: ChesstrainerWeb.Endpoint,
|
|
router: ChesstrainerWeb.Router,
|
|
statics: ChesstrainerWeb.static_paths()
|
|
end
|
|
end
|
|
|
|
@doc """
|
|
When used, dispatch to the appropriate controller/live_view/etc.
|
|
"""
|
|
defmacro __using__(which) when is_atom(which) do
|
|
apply(__MODULE__, which, [])
|
|
end
|
|
end
|