chadtmiller.com/group-host
atmosphere group host
0
0
A host's operator picks the console's palette as PALETTE
.changeset/host-colours.md+2−2
| @@ -2,6 +2,6 @@ | ||
default: minor | ||
--- | ||
| ||
# A host's operator sets the colour that acts, and a cooler set of colours | ||
# A host's operator sets the colour that acts, and a cooler palette | ||
| ||
`PRIMARY_COLOR` and `PRIMARY_COLOR_DARK`, each `#rgb` or `#rrggbb`, make the console's buttons, links and marks the operator's colour, with their hover, wash and link line mixed from it and the text on a button whichever of white or the page's ink reads better. Without a dark one, the light one is lifted lighter. `THEME=slate` sets the rest of the console, its paper, cards, lines and ink, cool rather than warm. `getBrand` answers them as `colors` and `theme`; the host refuses to start on any other colour or theme. | ||
`PRIMARY_COLOR` and `PRIMARY_COLOR_DARK`, each `#rgb` or `#rrggbb`, make the console's buttons, links and marks the operator's colour, with their hover, wash and link line mixed from it and the text on a button whichever of white or the page's ink reads better. Without a dark one, the light one is lifted lighter. `PALETTE=slate` sets the rest of the console, its paper, cards, lines and ink, cool rather than warm. `getBrand` answers them as `colors` and `palette`; the host refuses to start on any other colour or palette. | ||
crates/group-host/src/brand.rs+7−3
| @@ -27,11 +27,15 @@ pub(crate) fn set<const N: usize>(fields: [(&str, &Option<String>); N]) -> Value | ||
} | ||
| ||
/// How the host shows itself: its name and logo, the links to its | ||
/// operator's pages, its backgrounds, its colours and the console's set of | ||
/// colours it's in, each only when set. | ||
/// operator's pages, its backgrounds, its colours and the console's | ||
/// palette it's in, each only when set. | ||
pub async fn get_brand(State(host): State<Arc<Host>>) -> Json<Value> { | ||
let b = &host.config.brand; | ||
let mut brand = set([("name", &b.name), ("logo", &b.logo), ("theme", &b.theme)]); | ||
let mut brand = set([ | ||
("name", &b.name), | ||
("logo", &b.logo), | ||
("palette", &b.palette), | ||
]); | ||
brand["links"] = set([ | ||
("home", &b.home), | ||
("privacyPolicy", &b.privacy_policy), | ||
crates/group-host/src/config.rs+10−10
| @@ -118,16 +118,16 @@ pub struct Brand { | ||
/// The same in a dark colour scheme, `PRIMARY_COLOR_DARK`: unset, the | ||
/// console lifts `primary_color` lighter. | ||
pub primary_color_dark: Option<String>, | ||
/// Which of the console's sets of colours its pages are in, `THEME`, | ||
/// one of [`THEMES`] but the first, `paper`, which is none. | ||
pub theme: Option<String>, | ||
/// Which of the console's palettes its pages are in, `PALETTE`, one of | ||
/// [`PALETTES`] but the first, `paper`, which is none. | ||
pub palette: Option<String>, | ||
} | ||
| ||
/// The most characters a host's name may be, as a page's header has room for. | ||
pub const NAME_AT_MOST: usize = 40; | ||
| ||
/// The console's sets of colours, its own first. | ||
pub const THEMES: [&str; 2] = ["paper", "slate"]; | ||
/// The console's palettes, its own first. | ||
pub const PALETTES: [&str; 2] = ["paper", "slate"]; | ||
| ||
impl Brand { | ||
/// The brand `var` names, each variable left empty as unset. | ||
| @@ -167,11 +167,11 @@ impl Brand { | ||
None => bail!("{name} is a colour as #rgb or #rrggbb, not {c}"), | ||
} | ||
}; | ||
let theme = match set("THEME") { | ||
Some(t) if !THEMES.contains(&t.as_str()) => { | ||
bail!("THEME is one of {}, not {t}", THEMES.join(", ")) | ||
let palette = match set("PALETTE") { | ||
Some(p) if !PALETTES.contains(&p.as_str()) => { | ||
bail!("PALETTE is one of {}, not {p}", PALETTES.join(", ")) | ||
} | ||
t => t.filter(|t| t != THEMES[0]), | ||
p => p.filter(|p| p != PALETTES[0]), | ||
}; | ||
Ok(Brand { | ||
name, | ||
| @@ -185,7 +185,7 @@ impl Brand { | ||
background_dark: page("BACKGROUND_DARK_URL")?, | ||
primary_color: colour("PRIMARY_COLOR")?, | ||
primary_color_dark: colour("PRIMARY_COLOR_DARK")?, | ||
theme, | ||
palette, | ||
}) | ||
} | ||
} | ||
crates/group-host/tests/brand.rs+2−2
| @@ -91,7 +91,7 @@ async fn a_host_shows_its_operators_name_logo_and_pages() { | ||
("SUPPORT_URL", "https://riverside.example/help"), | ||
("CONTACT_EMAIL", "hello@riverside.example"), | ||
("PRIMARY_COLOR", "#0F766E"), | ||
("THEME", "slate"), | ||
("PALETTE", "slate"), | ||
]) | ||
.await; | ||
| ||
| @@ -102,7 +102,7 @@ async fn a_host_shows_its_operators_name_logo_and_pages() { | ||
json!({ | ||
"name": "Riverside Groups", | ||
"logo": logo_url, | ||
"theme": "slate", | ||
"palette": "slate", | ||
"links": { | ||
"home": "https://riverside.example", | ||
"privacyPolicy": "https://riverside.example/privacy", | ||
crates/group-host/tests/config.rs+6−6
| @@ -206,7 +206,7 @@ fn the_host_shows_itself_as_its_operator_names_it() { | ||
("BACKGROUND_DARK_URL", "https://riverside.example/dark.jpg"), | ||
("PRIMARY_COLOR", "#0F766E"), | ||
("PRIMARY_COLOR_DARK", "#2dd"), | ||
("THEME", "slate"), | ||
("PALETTE", "slate"), | ||
]) | ||
.unwrap(); | ||
let some = |s: &str| Some(s.to_string()); | ||
| @@ -224,7 +224,7 @@ fn the_host_shows_itself_as_its_operator_names_it() { | ||
background_dark: some("https://riverside.example/dark.jpg"), | ||
primary_color: some("#0f766e"), | ||
primary_color_dark: some("#2dd"), | ||
theme: some("slate"), | ||
palette: some("slate"), | ||
} | ||
); | ||
| ||
| @@ -253,9 +253,9 @@ fn the_host_shows_itself_as_its_operator_names_it() { | ||
); | ||
} | ||
assert_eq!( | ||
err(&[("THEME", "neon")]), | ||
"THEME is one of paper, slate, not neon" | ||
err(&[("PALETTE", "neon")]), | ||
"PALETTE is one of paper, slate, not neon" | ||
); | ||
// The console's own set of colours is no set at all. | ||
assert_eq!(config(&[("THEME", "paper")]).unwrap().brand.theme, None); | ||
// The console's own palette is no palette at all. | ||
assert_eq!(config(&[("PALETTE", "paper")]).unwrap().brand.palette, None); | ||
} | ||
deploy/docker-compose.yml+1−1
| @@ -56,7 +56,7 @@ services: | ||
BACKGROUND_DARK_URL: ${GROUP_HOST_BACKGROUND_DARK_URL:-} | ||
PRIMARY_COLOR: ${GROUP_HOST_PRIMARY_COLOR:-} | ||
PRIMARY_COLOR_DARK: ${GROUP_HOST_PRIMARY_COLOR_DARK:-} | ||
THEME: ${GROUP_HOST_THEME:-} | ||
PALETTE: ${GROUP_HOST_PALETTE:-} | ||
volumes: | ||
# The database, blobs and keys: back it up (docs/deploying.md). | ||
# Owned by uid 1000, the node user the image runs as. | ||
docs/reference/api.md+1−1
| @@ -312,7 +312,7 @@ Moving groups between hosts, and accounts here to become groups ([moving](../des | ||
| `POST /console/switch` | switches to another account the browser is signed in to (`did`), and goes back to the page `back` | | ||
| `GET /console/move/login`, `GET /console/move/callback` | signs in to an account to move here | | ||
| `GET /console/client-metadata.json` | the host's metadata as the console's OAuth client, a confidential web client's as atproto's profile has one; 500 where `CONSOLE_URL` cannot be one (not https at a public name) | | ||
| `GET org.atgrp.internal.getBrand` | how the host shows itself, as its operator names it ([config](config.md#how-it-shows-itself)): its `name`, its `logo`, `links` to its operator's home page, privacy policy, terms of service and support, the `backgrounds` of the page an app's request is approved on, light and dark, its `colors`, and the console's set of colours it's in (`theme`), each only when set. Anyone may ask | | ||
| `GET org.atgrp.internal.getBrand` | how the host shows itself, as its operator names it ([config](config.md#how-it-shows-itself)): its `name`, its `logo`, `links` to its operator's home page, privacy policy, terms of service and support, the `backgrounds` of the page an app's request is approved on, light and dark, its `colors`, and the console's palette it's in (`palette`), each only when set. Anyone may ask | | ||
| `GET /img/host`, `GET /img/background-light`, `GET /img/background-dark` | serve the host's logo (`LOGO_URL`) and backgrounds (`BACKGROUND_LIGHT_URL`, `BACKGROUND_DARK_URL`), as `/img/app` serves an app's logo: from a public address, only a PNG, JPEG, GIF or WebP image, of at most 256 KiB for the logo and 2 MiB for a background, kept for 10 minutes. Each answers 404 when the host has none, or when what it names is no such image | | ||
| ||
## The PDS | ||
docs/reference/config.md+1−1
| @@ -74,7 +74,7 @@ the host (`getBrand`), so they are set on the host alone. | ||
| `BACKGROUND_LIGHT_URL`, `BACKGROUND_DARK_URL` | `http` or `https` URLs of the pictures behind the card an app's request is approved on, by the reader's colour scheme, either standing in for the other when one is unset. Each is a PNG, JPEG, GIF or WebP image of at most 2 MiB, read as the logo is and served at `/img/background-light` and `/img/background-dark`. It's drawn to cover the screen, cut at its edges, under an opaque card: one about 2000 pixels wide, with nothing that matters at its edges, reads at any size | | ||
| `PRIMARY_COLOR` | the colour of what acts on the console's pages, its buttons, links and marks, as `#rgb` or `#rrggbb`. Their hover, the soft wash behind what they mark and the line under links are mixed from it, and the text on a button is white or the page's ink, whichever reads better on it | | ||
| `PRIMARY_COLOR_DARK` | the same in a dark colour scheme. Unset, it's `PRIMARY_COLOR` lifted to a lightness dark ink reads on | | ||
| `THEME` | the console's set of colours for everything else, its paper, cards, lines and ink: `paper`, its own warm one, or `slate`, a cool one | | ||
| `PALETTE` | the console's colours for everything else, its paper, cards, lines and ink: `paper`, its own warm palette, or `slate`, a cool one | | ||
| ||
Whether a page is light or dark is the reader's, not the operator's: as | ||
their device has it, or as they choose under Appearance in the menu under | ||
docs/deploying.md+1−1
| @@ -84,7 +84,7 @@ Compose reads these and passes each to the host under the name the host knows: | ||
| `GROUP_HOST_ADMINS` | `HOST_ADMINS`, the operators who read its logs and stats | none | | ||
| `GROUP_HOST_LOGS_KEEP` | `LOGS_KEEP` | `500000` | | ||
| `GROUP_HOST_RATE_LIMITS` | `RATE_LIMITS`, `on` or `off` ([limits](design/limits.md)) | `on` | | ||
| `GROUP_HOST_SERVICE_NAME`, `GROUP_HOST_LOGO_URL`, `GROUP_HOST_HOME_URL`, `GROUP_HOST_PRIVACY_POLICY_URL`, `GROUP_HOST_TERMS_OF_SERVICE_URL`, `GROUP_HOST_SUPPORT_URL`, `GROUP_HOST_CONTACT_EMAIL`, `GROUP_HOST_BACKGROUND_LIGHT_URL`, `GROUP_HOST_BACKGROUND_DARK_URL`, `GROUP_HOST_PRIMARY_COLOR`, `GROUP_HOST_PRIMARY_COLOR_DARK`, `GROUP_HOST_THEME` | the same without `GROUP_HOST_`, how the host shows itself ([config](reference/config.md#how-it-shows-itself)) | the console's own name and colours, no logo, links or backgrounds | | ||
| `GROUP_HOST_SERVICE_NAME`, `GROUP_HOST_LOGO_URL`, `GROUP_HOST_HOME_URL`, `GROUP_HOST_PRIVACY_POLICY_URL`, `GROUP_HOST_TERMS_OF_SERVICE_URL`, `GROUP_HOST_SUPPORT_URL`, `GROUP_HOST_CONTACT_EMAIL`, `GROUP_HOST_BACKGROUND_LIGHT_URL`, `GROUP_HOST_BACKGROUND_DARK_URL`, `GROUP_HOST_PRIMARY_COLOR`, `GROUP_HOST_PRIMARY_COLOR_DARK`, `GROUP_HOST_PALETTE` | the same without `GROUP_HOST_`, how the host shows itself ([config](reference/config.md#how-it-shows-itself)) | the console's own name and colours, no logo, links or backgrounds | | ||
| `GROUP_HOST_DATA` | the directory mounted at `/data` | `/var/lib/group-host` | | ||
| `GROUP_HOST_PROXY_NETWORK` | the proxy's docker network | `group-host` | | ||
| ||
lexicons/org/atgrp/internal/getBrand.json+2−2
| @@ -26,11 +26,11 @@ | ||
"format": "uri", | ||
"description": "Its logo (LOGO_URL), which the host serves at /img/host, as a page is to draw it; absent when it has none." | ||
}, | ||
"theme": { | ||
"palette": { | ||
"type": "string", | ||
"knownValues": ["paper", "slate"], | ||
"maxLength": 64, | ||
"description": "Which of the console's sets of colours its pages are in (THEME); absent for the console's own, paper." | ||
"description": "Which of the console's palettes its pages are in (PALETTE): its paper, cards, lines and ink; absent for the console's own, paper." | ||
}, | ||
"links": { | ||
"type": "ref", | ||