MishkaCmsCore.Runtime.ErrorStatus (Mishka CMS Core v0.0.1)

Copy Markdown View Source

What one entry of a site's Error Page answers for: an HTTP status code (404, 500, …) or :offline, the page an offline site shows its visitors.

:offline is not an HTTP code. The page it names is answered as a 503 by MishkaCms.Plugs.MaintenanceGate, at whatever address the visitor asked for, and when a site has no such entry the gate draws its built-in page instead.

It is the status field's type on MishkaCmsCore.Runtime.ErrorPage and MishkaCmsCore.Runtime.ErrorPageDraft, so both store the same thing: a code stays a JSON number, :offline is stored as "offline" and read back as the atom.

parse/1 is the same reading for everything else that is handed a status as text — the builder's ?status=, the preview's error-code picker, the Code tab's <!-- offline --> markers.

Summary

Functions

The choices the Error Page form offers, :offline first, then the client and server error codes by group, in the shape a Gervaz :select takes.

A status as a person reads it: 404 · Not Found, or Offline.

The status of the page an offline site shows.

Whether a list of Error Page entries holds the :offline one, however its status was spelled.

A status from whatever spelled it, or nil when it names none.

Types

t()

@type t() :: integer() | :offline

Functions

choices()

@spec choices() :: [{String.t(), String.t() | [{String.t(), integer()}]}]

The choices the Error Page form offers, :offline first, then the client and server error codes by group, in the shape a Gervaz :select takes.

handle_change?()

label(code)

@spec label(t()) :: String.t()

A status as a person reads it: 404 · Not Found, or Offline.

offline()

@spec offline() :: :offline

The status of the page an offline site shows.

offline_entry?(entries)

@spec offline_entry?([map()]) :: boolean()

Whether a list of Error Page entries holds the :offline one, however its status was spelled.

parse(status)

@spec parse(term()) :: t() | nil

A status from whatever spelled it, or nil when it names none.

iex> MishkaCmsCore.Runtime.ErrorStatus.parse("404")
404
iex> MishkaCmsCore.Runtime.ErrorStatus.parse("offline")
:offline
iex> MishkaCmsCore.Runtime.ErrorStatus.parse("teapot")
nil

prepare_change?()