From 630cd2b82887da49cacb2deb032c6a51b3c2faf7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 21 Feb 2023 15:12:38 +0100 Subject: server-side client configuration --- server/src/config.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 server/src/config.rs (limited to 'server/src/config.rs') diff --git a/server/src/config.rs b/server/src/config.rs new file mode 100644 index 0000000..9d6213c --- /dev/null +++ b/server/src/config.rs @@ -0,0 +1,20 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ClientConfig { + webrtc: ClientWebrtcConfig, + appearance: ClientAppearanceConfig, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ClientWebrtcConfig { + stun: String, + turn: Option, + turn_user: Option, + turn_cred: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ClientAppearanceConfig { + accent: Option, +} -- cgit v1.2.3-70-g09d2 From e31c48f5a9cfe6fd8988b83b17e00538fa69d6d3 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 21 Feb 2023 15:52:06 +0100 Subject: server-side appearance config --- client-web/source/index.ts | 16 +++++++++++++++- client-web/source/preferences/decl.ts | 6 ------ client-web/source/protocol/mod.ts | 1 - config/client.example.toml | 16 ++++++++++++++++ server/src/config.rs | 8 ++++++-- 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 config/client.example.toml (limited to 'server/src/config.rs') diff --git a/client-web/source/index.ts b/client-web/source/index.ts index 4590625..83f1dfc 100644 --- a/client-web/source/index.ts +++ b/client-web/source/index.ts @@ -18,7 +18,13 @@ export const VERSION = "0.1.12" export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" }) export interface ClientConfig { - appearance: { accent: string } + appearance?: { + accent: string + accent_dark: string + accent_light: string + background: string + background_dark: string + } webrtc: { stun: string, turn?: string, @@ -73,6 +79,14 @@ export async function main() { username: config.webrtc.turn_user, }] } + if (config.appearance) { + document.body.style.setProperty("--ac", config.appearance.accent) + document.body.style.setProperty("--ac-dark", config.appearance.accent_dark) + document.body.style.setProperty("--ac-light", config.appearance.accent_light) + document.body.style.setProperty("--bg", config.appearance.background) + document.body.style.setProperty("--bg-dark", config.appearance.background_dark) + + } r = new Room(conn, rtc_config) diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts index 68cb9ee..f3f8e84 100644 --- a/client-web/source/preferences/decl.ts +++ b/client-web/source/preferences/decl.ts @@ -18,13 +18,7 @@ export const PREF_DECLS = { username: { type: string, default: "guest-" + hex_id(), description: "Username", allow_url: true }, warn_redirect: { type: bool, hidden: true, default: false, description: "Internal option that is set by a server redirect.", allow_url: true }, image_view_popup: { type: bool, default: true, description: "Open image in popup instead of new tab" }, - - // TODO! - /* WEBRTC */ webrtc_debug: { type: bool, default: false, description: "Show additional information for WebRTC related stuff" }, - webrtc_stun: { type: string, default: "stun:meet.metamuffin.org:16900", description: "Custom STUN server (all participants must use the same server)" }, - webrtc_turn: { type: optional(string), default: "turn:meet.metamuffin.org:16900", description: "Custom TURN server (all participants must use the same server)" }, - webrtc_turn_cred: { type: optional(string), description: "TURN server credentials" }, /* MEDIA */ microphone_enabled: { type: bool, default: false, description: "Add one microphone track on startup" }, diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts index 3674c08..6d49a17 100644 --- a/client-web/source/protocol/mod.ts +++ b/client-web/source/protocol/mod.ts @@ -33,7 +33,6 @@ export class SignalingConnection { this.on_open() r() }) - log("ws", "connection opened") return this } diff --git a/config/client.example.toml b/config/client.example.toml new file mode 100644 index 0000000..39e942a --- /dev/null +++ b/config/client.example.toml @@ -0,0 +1,16 @@ + +[appearance] +accent = "#5e3f84" +accent_dark = "#2d0d52" +accent_light = "#7c43bd" +background = "#151315" +background_dark = "#070707" + +# If you decide to host your own TURN server, adjust this. +[webrtc] +stun = "stun:meet.metamuffin.org:16900" +# turn = "turn:meet.metamuffin.org:16900" +## Set the default turn credentials. +## If not provided, TURN is disabled by default and requires manual activation via password (TODO). +# turn_user = "keksmeet" +# turn_cred = "thatsmypassword" diff --git a/server/src/config.rs b/server/src/config.rs index 9d6213c..6dd380f 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ClientConfig { webrtc: ClientWebrtcConfig, - appearance: ClientAppearanceConfig, + appearance: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -16,5 +16,9 @@ pub struct ClientWebrtcConfig { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ClientAppearanceConfig { - accent: Option, + accent: String, + accent_light: String, + accent_dark: String, + background: String, + background_dark: String, } -- cgit v1.2.3-70-g09d2 From 0cc79a94471d4b12caad8e29dfbedba0149aae02 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 27 Feb 2023 18:19:50 +0100 Subject: properly apply configured theme everywheere --- client-web/source/index.ts | 8 -------- server/src/config.rs | 22 +++++++++++----------- server/src/main.rs | 29 ++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 20 deletions(-) (limited to 'server/src/config.rs') diff --git a/client-web/source/index.ts b/client-web/source/index.ts index 83f1dfc..c92ca2b 100644 --- a/client-web/source/index.ts +++ b/client-web/source/index.ts @@ -79,14 +79,6 @@ export async function main() { username: config.webrtc.turn_user, }] } - if (config.appearance) { - document.body.style.setProperty("--ac", config.appearance.accent) - document.body.style.setProperty("--ac-dark", config.appearance.accent_dark) - document.body.style.setProperty("--ac-light", config.appearance.accent_light) - document.body.style.setProperty("--bg", config.appearance.background) - document.body.style.setProperty("--bg-dark", config.appearance.background_dark) - - } r = new Room(conn, rtc_config) diff --git a/server/src/config.rs b/server/src/config.rs index 6dd380f..870315e 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -2,23 +2,23 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ClientConfig { - webrtc: ClientWebrtcConfig, - appearance: Option, + pub webrtc: ClientWebrtcConfig, + pub appearance: ClientAppearanceConfig, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ClientWebrtcConfig { - stun: String, - turn: Option, - turn_user: Option, - turn_cred: Option, + pub stun: String, + pub turn: Option, + pub turn_user: Option, + pub turn_cred: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ClientAppearanceConfig { - accent: String, - accent_light: String, - accent_dark: String, - background: String, - background_dark: String, + pub accent: String, + pub accent_light: String, + pub accent_dark: String, + pub background: String, + pub background_dark: String, } diff --git a/server/src/main.rs b/server/src/main.rs index 8a0e342..78f236a 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -8,7 +8,7 @@ pub mod config; pub mod protocol; pub mod room; -use config::ClientConfig; +use config::{ClientAppearanceConfig, ClientConfig}; use hyper::{header, StatusCode}; use listenfd::ListenFd; use log::{debug, error}; @@ -39,6 +39,7 @@ async fn run() { let client_config: ClientConfig = toml::from_str(include_str!("../../config/client.toml")) .expect("client configuration invalid"); let client_config_json = serde_json::to_string(&client_config).unwrap(); + let client_config_css = css_overrides(&client_config.appearance); let rooms: _ = Rooms::default(); let rooms: _ = warp::any().map(move || rooms.clone()); @@ -64,6 +65,9 @@ async fn run() { "application/json", ) }); + let client_config_css: _ = warp::path!("overrides.css").map(move || { + warp::reply::with_header(client_config_css.clone(), "content-type", "text/css") + }); let favicon: _ = warp::path!("favicon.ico").map(|| ""); let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| { reply::with_header( @@ -82,6 +86,7 @@ async fn run() { .or(favicon) .or(sw_script) .or(old_format_redirect) + .or(client_config_css) .recover(handle_rejection) .with(warp::log("stuff")); @@ -140,3 +145,25 @@ fn signaling_connect(rsecret: String, rooms: Rooms, ws: warp::ws::Ws) -> impl Re } ws.on_upgrade(move |sock| inner(sock, rsecret, rooms)) } + +fn css_overrides( + ClientAppearanceConfig { + accent, + accent_light, + accent_dark, + background, + background_dark, + }: &ClientAppearanceConfig, +) -> String { + format!( + r#":root {{ + --bg: {background}; + --bg-dark: {background_dark}; + --ac: {accent}; + --ac-dark: {accent_dark}; + --ac-dark-transparent: {accent_dark}c9; + --ac-light: {accent_light}; +}} +"# + ) +} -- cgit v1.2.3-70-g09d2