From cd6bc3fbd50046be7ddb4e434cafad36ce52daf7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 19:48:03 +0000 Subject: [PATCH] App name: the names in the code and on the disk read from the values The shown name, the request header, the names written on disk or in a file, and the names the system sees are read from `brand`: - `USER_AGENT` and `is_default` from the display name; the GNOME shortcut's name too. - The profile folder from the identifier; the library file, the preference keys (`Preferences` puts the slug before a key the code names without it), the drawing address in a Note, the export's file name and the import's filter from the slug and the extension. - The instance's socket, the autostart entry, the GNOME prefix, the portal's identifiers, the tray's and the shortcuts' fallbacks, the window's app id, the log file and the terminal messages from the slug. - The sample notes' tag, the documentation's address and the GNOME note of the preferences read the values instead of a translation's word. The engine's error details drop the name rather than read it: they go to the log alone. Today's values are unchanged, so an installed copy finds everything where it was; `layout.rs`'s test spells the slug and the suffix. Part of #1896 (steps 2, 3, 4) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BbVs5tCyTr9AasGra3Zzg3 --- Cargo.lock | 4 + crates/app/Cargo.toml | 1 + crates/app/src/desktop.rs | 7 +- crates/app/src/logging.rs | 4 +- crates/app/src/main.rs | 8 +- crates/brand/build.rs | 13 ++- crates/brand/src/lib.rs | 17 ++-- crates/engine/src/error.rs | 2 +- crates/engine/src/http/history.rs | 2 +- crates/engine/src/http/send.rs | 9 +- crates/engine/src/layout.rs | 14 +-- crates/engine/src/transfer/model.rs | 2 +- crates/engine/src/transfer/protect.rs | 4 +- crates/engine/src/vault/file.rs | 4 +- crates/i18n/translations/en.json | 3 +- crates/i18n/translations/fr.json | 3 +- crates/platform/Cargo.toml | 1 + crates/platform/src/autostart/system.rs | 2 +- crates/platform/src/instance.rs | 2 +- crates/platform/src/paths.rs | 6 +- crates/platform/src/shortcuts.rs | 2 +- crates/platform/src/shortcuts/system/gnome.rs | 4 +- .../platform/src/shortcuts/system/portal.rs | 6 +- .../platform/src/shortcuts/system/wayland.rs | 2 +- crates/platform/src/tray/system.rs | 2 +- crates/richtext/Cargo.toml | 1 + crates/richtext/src/picture.rs | 2 +- crates/richtext/tests/golden.rs | 12 ++- crates/ui/Cargo.toml | 1 + crates/ui/src/api/transfer.rs | 2 +- crates/ui/src/app/screens.rs | 4 +- crates/ui/src/app/titlebar_tests.rs | 2 +- crates/ui/src/gate/prompt.rs | 2 +- crates/ui/src/http/tests.rs | 2 +- crates/ui/src/notes/canvas/board/tests.rs | 5 +- crates/ui/src/notes/prettier.rs | 2 +- crates/ui/src/services/preferences.rs | 33 ++++--- crates/ui/src/services/samples.rs | 10 +- crates/ui/src/services/settings.rs | 91 +++++++++---------- crates/ui/src/services/shortcuts.rs | 8 +- crates/ui/src/state/board.rs | 4 +- crates/ui/src/state/folders.rs | 2 +- crates/ui/src/state/http/environments.rs | 2 +- crates/ui/src/state/http/mod.rs | 2 +- crates/ui/src/state/http/tabs.rs | 2 +- crates/ui/src/state/mod.rs | 16 ++-- crates/ui/src/state/notes_query.rs | 2 +- crates/ui/src/state/spaces.rs | 2 +- crates/ui/src/state/tools.rs | 8 +- crates/ui/src/state/transfer.rs | 11 ++- crates/ui/src/titlebar/about_menu/docs/mod.rs | 4 +- .../ui/src/titlebar/preferences/shortcuts.rs | 2 +- docs/architecture/backend.md | 3 +- docs/architecture/overview.md | 8 +- golden/markdown/cases.json | 4 +- 55 files changed, 204 insertions(+), 169 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da20f91a9..b8a0e02ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,6 +249,7 @@ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" name = "app" version = "1.3.0" dependencies = [ + "brand", "eframe", "egui", "engine", @@ -4742,6 +4743,7 @@ version = "1.3.0" dependencies = [ "arboard", "auto-launch", + "brand", "cargo-packager-updater", "dirs 6.0.0", "global-hotkey", @@ -5518,6 +5520,7 @@ dependencies = [ name = "richtext" version = "1.3.0" dependencies = [ + "brand", "html5ever", "pulldown-cmark", "serde_json", @@ -6951,6 +6954,7 @@ name = "ui" version = "1.3.0" dependencies = [ "base64 0.23.1", + "brand", "chrono", "crossbeam-channel", "drawing", diff --git a/crates/app/Cargo.toml b/crates/app/Cargo.toml index a6aa9aba2..86f7eba11 100644 --- a/crates/app/Cargo.toml +++ b/crates/app/Cargo.toml @@ -74,6 +74,7 @@ e2e = ["eframe/inspection", "platform/e2e", "ui/e2e"] profiling = ["dep:profiling", "dep:puffin", "dep:puffin_http", "profiling/profile-with-puffin"] [dependencies] +brand.workspace = true engine.workspace = true platform.workspace = true ui.workspace = true diff --git a/crates/app/src/desktop.rs b/crates/app/src/desktop.rs index d9d31a401..afc3a1f5d 100644 --- a/crates/app/src/desktop.rs +++ b/crates/app/src/desktop.rs @@ -12,13 +12,10 @@ use platform::tray::{NoTray, Picture, Tray}; use platform::updater::{Source, Updater}; use ui::{Inbox, Input, Preferences, Settings}; -/// Who sends a toast on Windows. -const IDENTIFIER: &str = "com.devnotes.app"; - /// The address and the key the published versions already use (D26). const UPDATES: Source<'_> = Source { version: env!("CARGO_PKG_VERSION"), - endpoint: "https://github.com/vmillet-dev/devnotes-rs/releases/latest/download/latest.json", + endpoint: concat!(env!("CARGO_PKG_REPOSITORY"), "/releases/latest/download/latest.json"), public_key: "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBMjJGNDA1RkVGMEEzNkYKUldSdm8vRCtCZlFpK3IzSFdQSFZ0YlM3VTh5eXNpVDhueWp2SzNPYyt6VmVHQVJ6eWs1ZDBzeE4K", }; @@ -29,7 +26,7 @@ pub(crate) fn start(preferences: &Preferences, inbox: &Inbox) -> ui::Desktop { tray: start_tray(preferences, inbox.clone()), shortcuts: take_shortcuts(preferences, inbox.clone()), autostart: autostart(), - notifier: platform::notify::system(METADATA.name, IDENTIFIER), + notifier: platform::notify::system(METADATA.name, brand::IDENTIFIER), dialog: dialog(inbox.clone()), updater: updater(), clipboard: platform::clipboard::system(), diff --git a/crates/app/src/logging.rs b/crates/app/src/logging.rs index 5076f81a4..90f0a18a2 100644 --- a/crates/app/src/logging.rs +++ b/crates/app/src/logging.rs @@ -84,7 +84,7 @@ fn start_as(directory: &Path, build: Build) -> Option { }; let file = FileSpec::default() .directory(directory) - .basename("devnotes") + .basename(brand::SLUG) .suppress_timestamp(); let handle = FileLogWriter::builder(file) .append() @@ -98,7 +98,7 @@ fn start_as(directory: &Path, build: Build) -> Option { .format_for_stderr(line) .start() }) - .inspect_err(|error| eprintln!("devnotes: no log file: {error}")) + .inspect_err(|error| eprintln!("{}: no log file: {error}", brand::SLUG)) .ok()?; if unreadable { log::warn!("{LEVELS} is no log specification: the levels of the build apply"); diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 5fdf3bd9e..d7165fb52 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -46,7 +46,7 @@ fn main() -> ExitCode { .map(Locations::inside) .or_else(|| Locations::installed(paths::DEFAULT_PROFILE)) else { - eprintln!("devnotes: the system names no directory for the profile"); + eprintln!("{}: the system names no directory for the profile", brand::SLUG); return ExitCode::FAILURE; }; // Before the log: a second launch writes nothing of its own. @@ -55,7 +55,7 @@ fn main() -> ExitCode { Ok(Claim::Taken) => return hand_over(&locations.profile, arguments.action), Err(error) => { // Fails closed: a second writer would make the index silently wrong. - eprintln!("devnotes: the profile could not be claimed: {error}"); + eprintln!("{}: the profile could not be claimed: {error}", brand::SLUG); return ExitCode::FAILURE; } }; @@ -116,7 +116,7 @@ fn hand_over(profile: &Path, action: Option) -> ExitCode { match instance::send(profile, &message) { Ok(()) => ExitCode::SUCCESS, Err(error) => { - eprintln!("devnotes: the running instance did not answer: {error}"); + eprintln!("{}: the running instance did not answer: {error}", brand::SLUG); ExitCode::FAILURE } } @@ -173,7 +173,7 @@ fn profiler() -> Option { fn options(restored: Option) -> eframe::NativeOptions { let viewport = egui::ViewportBuilder::default() .with_title(METADATA.name) - .with_app_id("devnotes") + .with_app_id(brand::SLUG) .with_inner_size([1_100.0, 720.0]) .with_min_inner_size([640.0, 480.0]) .with_visible(false); diff --git a/crates/brand/build.rs b/crates/brand/build.rs index 07e895c86..815d25ec2 100644 --- a/crates/brand/build.rs +++ b/crates/brand/build.rs @@ -1,6 +1,7 @@ //! The only reader of `[workspace.metadata]` in the root `Cargo.toml` (D36): Cargo hands no -//! metadata to a crate, so the values are read here and handed over as environment variables. +//! metadata to a crate, so the values are read here and written as macros that expand to them. +use std::fmt::Write as _; use std::path::Path; const MANIFEST: &str = "../../Cargo.toml"; @@ -36,13 +37,19 @@ fn main() { .and_then(|workspace| workspace.get("metadata")) .expect("the root manifest has [workspace.metadata]"); + let mut macros = String::new(); for (key, holds) in VALUES { let value = values .get(key) .and_then(toml::Value::as_str) .unwrap_or_else(|| panic!("[workspace.metadata] {key} is a string")); assert!(holds(value), "[workspace.metadata] {key} = {value:?} cannot be used"); - let name = key.to_uppercase().replace('-', "_"); - println!("cargo::rustc-env=BRAND_{name}={value}"); + let name = key.replace('-', "_"); + let _ = writeln!( + macros, + "#[macro_export]\nmacro_rules! {name} {{\n () => {{\n {value:?}\n }};\n}}" + ); } + let out = std::env::var("OUT_DIR").expect("cargo sets OUT_DIR"); + std::fs::write(Path::new(&out).join("values.rs"), macros).expect("values.rs is written"); } diff --git a/crates/brand/src/lib.rs b/crates/brand/src/lib.rs index ef0f2cdf8..3bbb77a7f 100644 --- a/crates/brand/src/lib.rs +++ b/crates/brand/src/lib.rs @@ -1,21 +1,26 @@ //! The application's names, written once in the root `Cargo.toml`'s `[workspace.metadata]` and //! read here alone (D36). Every name in the code, on the disk and in the packages is one of these, //! or made from one. +//! +//! Each is also a macro that expands to its literal (`brand::slug!()`), for a constant another +//! crate builds with `concat!`: `concat!(brand::slug!(), ".sqlite3")`. + +include!(concat!(env!("OUT_DIR"), "/values.rs")); /// What a person is shown: the window, the menus, the request header. -pub const NAME: &str = env!("BRAND_DISPLAY_NAME"); +pub const NAME: &str = display_name!(); /// The author's handle, on the about card. -pub const AUTHOR_HANDLE: &str = env!("BRAND_AUTHOR_HANDLE"); +pub const AUTHOR_HANDLE: &str = author_handle!(); /// The technical name: the binary, the library's file, the preference keys, the system's names. -pub const SLUG: &str = env!("BRAND_SLUG"); +pub const SLUG: &str = slug!(); /// The profile's folder, and the packages' bundle identifier. -pub const IDENTIFIER: &str = env!("BRAND_IDENTIFIER"); +pub const IDENTIFIER: &str = identifier!(); /// The extension of an exported library, without its dot. -pub const EXTENSION: &str = env!("BRAND_FILE_EXTENSION"); +pub const EXTENSION: &str = file_extension!(); /// The website, without a trailing slash. -pub const SITE: &str = env!("BRAND_SITE"); +pub const SITE: &str = site!(); diff --git a/crates/engine/src/error.rs b/crates/engine/src/error.rs index 221ace81e..f8f623041 100644 --- a/crates/engine/src/error.rs +++ b/crates/engine/src/error.rs @@ -72,7 +72,7 @@ pub enum StorageError { ImportFormat(String), #[error("Note \"{id}\" unreadable: field \"{field}\" is out of format")] CorruptRow { id: String, field: &'static str }, - #[error("Database carrying migration \"{0}\", unknown to this version of DevNotes")] + #[error("Database carrying migration \"{0}\", unknown to this version")] SchemaTooRecent(String), #[error("Migration failed: {0}")] Migration(String), diff --git a/crates/engine/src/http/history.rs b/crates/engine/src/http/history.rs index 962ec7240..cc7176a8c 100644 --- a/crates/engine/src/http/history.rs +++ b/crates/engine/src/http/history.rs @@ -1008,7 +1008,7 @@ mod tests { vec![ header("Authorization", &format!("Bearer {MASK}")), header("Content-Type", "application/json; charset=utf-8"), - header("User-Agent", "DevNotes/1.3.0"), + header("User-Agent", concat!(brand::display_name!(), "/1.3.0")), header("Accept", "*/*"), header("X-Trace", "1"), ], diff --git a/crates/engine/src/http/send.rs b/crates/engine/src/http/send.rs index 88ac9161f..16c02cc22 100644 --- a/crates/engine/src/http/send.rs +++ b/crates/engine/src/http/send.rs @@ -29,13 +29,13 @@ use super::{variables, websocket}; use crate::notes::language::Language; /// What a request says it comes from when it says nothing: many APIs refuse one that is silent. -pub const USER_AGENT: &str = concat!("DevNotes/", env!("CARGO_PKG_VERSION")); +pub const USER_AGENT: &str = concat!(brand::display_name!(), "/", env!("CARGO_PKG_VERSION")); const ACCEPT_ANYTHING: &str = "*/*"; /// Whether a header that left is one the application writes by itself, whatever its version: /// what is rebuilt from the history leaves it out, and it is written again when sent. pub fn is_default(name: &str, value: &str) -> bool { - (name.eq_ignore_ascii_case("user-agent") && value.starts_with("DevNotes/")) + (name.eq_ignore_ascii_case("user-agent") && value.starts_with(concat!(brand::display_name!(), "/"))) || (name.eq_ignore_ascii_case("accept") && value == ACCEPT_ANYTHING) } @@ -1392,7 +1392,10 @@ mod tests { ); assert_eq!(value(&silenced, "User-Agent"), None); assert_eq!(value(&silenced_above, "User-Agent"), None); - assert!(is_default("user-agent", "DevNotes/0.1.0") && is_default("Accept", "*/*")); + assert!( + is_default("user-agent", concat!(brand::display_name!(), "/0.1.0")) + && is_default("Accept", "*/*") + ); assert!(!is_default("User-Agent", "curl/8") && !is_default("Accept", "text/html")); } diff --git a/crates/engine/src/layout.rs b/crates/engine/src/layout.rs index 70646ecd4..e83bb0515 100644 --- a/crates/engine/src/layout.rs +++ b/crates/engine/src/layout.rs @@ -9,7 +9,7 @@ use chrono::{DateTime, NaiveDateTime, Utc}; /// Spelled once, so the sidecars below cannot drift from it. macro_rules! database { () => { - "devnotes.sqlite3" + concat!(brand::slug!(), ".sqlite3") }; } @@ -70,14 +70,16 @@ pub(crate) fn parse_stamp(name: &str) -> Option> { mod tests { use super::*; - /// ⚠️ Each name is where an installed copy looks: spelled out here, a rename fails a test - /// before it sends anyone's application looking for files under a new name. + /// ⚠️ Each name is where an installed copy looks: spelled out here, a change other than of + /// the slug (D36) fails a test before it sends anyone's application looking for new files. #[test] fn every_name_on_disk_is_spelled_as_installed_copies_wrote_it() { + let database = format!("{}.sqlite3", brand::SLUG); + assert_eq!( + [DATABASE, DATABASE_SIDECARS[0], DATABASE_SIDECARS[1]], + [database.clone(), format!("{database}-wal"), format!("{database}-shm")] + ); let names = [ - (DATABASE, "devnotes.sqlite3"), - (DATABASE_SIDECARS[0], "devnotes.sqlite3-wal"), - (DATABASE_SIDECARS[1], "devnotes.sqlite3-shm"), (KEY_FILE, "vault.json"), (ATTACHMENTS, "attachments"), (BACKUPS, "backups"), diff --git a/crates/engine/src/transfer/model.rs b/crates/engine/src/transfer/model.rs index 0fa997268..3acc0b315 100644 --- a/crates/engine/src/transfer/model.rs +++ b/crates/engine/src/transfer/model.rs @@ -108,7 +108,7 @@ pub fn read_bundle(json: &str) -> Result { if version > u64::from(FORMAT_VERSION) { return Err(StorageError::ImportFormat(format!( - "format version {version}, this version of DevNotes reads up to {FORMAT_VERSION}" + "format version {version}, this version reads up to {FORMAT_VERSION}" ))); } diff --git a/crates/engine/src/transfer/protect.rs b/crates/engine/src/transfer/protect.rs index f33f7bb91..91fc6481d 100644 --- a/crates/engine/src/transfer/protect.rs +++ b/crates/engine/src/transfer/protect.rs @@ -52,13 +52,13 @@ pub fn seal_with(passphrase: &str) -> Result<(Vault, Recipe), StorageError> { pub fn open_with(passphrase: &str, recipe: &Recipe) -> Result { if recipe.version > FORMAT_VERSION { return Err(StorageError::ImportFormat(format!( - "protected with format version {}, this version of DevNotes reads up to {FORMAT_VERSION}", + "protected with format version {}, this version reads up to {FORMAT_VERSION}", recipe.version ))); } if recipe.algorithm != "argon2id" { return Err(StorageError::ImportFormat(format!( - "protected with \"{}\", which this version of DevNotes cannot reproduce", + "protected with \"{}\", which this version cannot reproduce", recipe.algorithm ))); } diff --git a/crates/engine/src/vault/file.rs b/crates/engine/src/vault/file.rs index 24b3f7b56..7bda6ca28 100644 --- a/crates/engine/src/vault/file.rs +++ b/crates/engine/src/vault/file.rs @@ -114,13 +114,13 @@ pub fn unlock(directory: &Path, passphrase: &str) -> Result if file.version > FORMAT_VERSION { return Err(StorageError::Vault(format!( - "key file version {}, this version of DevNotes reads up to {FORMAT_VERSION}", + "key file version {}, this version reads up to {FORMAT_VERSION}", file.version ))); } if file.kdf.algorithm != "argon2id" { return Err(StorageError::Vault(format!( - "key derived with \"{}\", which this version of DevNotes cannot reproduce", + "key derived with \"{}\", which this version cannot reproduce", file.kdf.algorithm ))); } diff --git a/crates/i18n/translations/en.json b/crates/i18n/translations/en.json index a79991587..74e575154 100644 --- a/crates/i18n/translations/en.json +++ b/crates/i18n/translations/en.json @@ -137,7 +137,6 @@ "source": "TypeScript / Prettier" }, "tags": { - "devnotes": "devnotes", "example": "example", "database": "sql", "json": "json", @@ -1151,7 +1150,7 @@ "reset": "Reset", "globalNote": "These three work everywhere, window closed included, so each needs at least one modifier — without one the key would be swallowed in every application you use. A combination another application already holds is reported under its field, and cannot be typed there: Windows hands it to that application.", "globalPortalNote": "Under Wayland, these three are handed to the desktop, which asked you to accept them in its own window: it may have changed one, and shows them in its shortcut settings. They work everywhere, window closed included.", - "globalDesktopNote": "Under Wayland, these three are written into GNOME’s custom shortcuts (Settings, Keyboard), each running “devnotes --action …”: they work everywhere, window closed included, and stay there if the application is uninstalled.", + "globalDesktopNote": "Under Wayland, these three are written into GNOME’s custom shortcuts (Settings, Keyboard), each running “{{binary}} --action …”: they work everywhere, window closed included, and stay there if the application is uninstalled.", "globalNobodyNote": "Under Wayland, this desktop lets no application listen to the keyboard outside its windows, and offers no way to hand them over: bind these commands yourself in its shortcut settings. A second launch hands the action to the running one.", "canvasNote": "These only act on the canvas, never while typing, so a bare letter is enough. Click the field, then press the combination.", "areasNote": "This one acts in the three areas — Notes, Tools and HTTP — and, with Ctrl or Alt, while typing too.", diff --git a/crates/i18n/translations/fr.json b/crates/i18n/translations/fr.json index 1cb498f04..7ae69bcaf 100644 --- a/crates/i18n/translations/fr.json +++ b/crates/i18n/translations/fr.json @@ -137,7 +137,6 @@ "source": "TypeScript / Prettier" }, "tags": { - "devnotes": "devnotes", "example": "exemple", "database": "sql", "json": "json", @@ -1151,7 +1150,7 @@ "reset": "Rétablir", "globalNote": "Ces trois-là agissent partout, fenêtre fermée comprise : ils demandent donc au moins un modificateur, sans quoi la touche serait avalée dans toutes vos applications. Une combinaison qu’une autre application tient déjà est signalée sous son champ, et ne peut pas y être saisie : Windows la lui remet.", "globalPortalNote": "Sous Wayland, ces trois-là sont confiés au bureau, qui vous a demandé de les accepter dans sa propre fenêtre : il peut en avoir changé un, et les montre dans ses réglages de raccourcis. Ils agissent partout, fenêtre fermée comprise.", - "globalDesktopNote": "Sous Wayland, ces trois-là sont écrits dans les raccourcis personnalisés de GNOME (Paramètres, Clavier), chacun lançant « devnotes --action … » : ils agissent partout, fenêtre fermée comprise, et y restent si l’application est désinstallée.", + "globalDesktopNote": "Sous Wayland, ces trois-là sont écrits dans les raccourcis personnalisés de GNOME (Paramètres, Clavier), chacun lançant « {{binary}} --action … » : ils agissent partout, fenêtre fermée comprise, et y restent si l’application est désinstallée.", "globalNobodyNote": "Sous Wayland, ce bureau ne laisse aucune application écouter le clavier hors de ses fenêtres, et n’offre pas de quoi les lui confier : liez vous-même ces commandes dans ses réglages de raccourcis. Une seconde instance remet l’action à celle qui tourne.", "canvasNote": "Ceux-ci n’agissent que sur le canevas, jamais pendant une saisie : une lettre nue suffit. Cliquez dans le champ puis composez la combinaison.", "areasNote": "Celui-ci agit dans les trois zones — Notes, Outils et HTTP — et, avec Ctrl ou Alt, pendant une saisie aussi.", diff --git a/crates/platform/Cargo.toml b/crates/platform/Cargo.toml index ee16b6303..8fc93c14c 100644 --- a/crates/platform/Cargo.toml +++ b/crates/platform/Cargo.toml @@ -14,6 +14,7 @@ publish = false e2e = [] [dependencies] +brand.workspace = true arboard.workspace = true dirs.workspace = true interprocess.workspace = true diff --git a/crates/platform/src/autostart/system.rs b/crates/platform/src/autostart/system.rs index 0603c82c1..15dde7bfb 100644 --- a/crates/platform/src/autostart/system.rs +++ b/crates/platform/src/autostart/system.rs @@ -7,7 +7,7 @@ use auto_launch::{AutoLaunch, AutoLaunchBuilder}; use super::{Autostart, NoAutostart}; -const ENTRY: &str = "devnotes"; +const ENTRY: &str = brand::SLUG; struct System(AutoLaunch); diff --git a/crates/platform/src/instance.rs b/crates/platform/src/instance.rs index 699a70c05..836146709 100644 --- a/crates/platform/src/instance.rs +++ b/crates/platform/src/instance.rs @@ -161,7 +161,7 @@ fn socket_name(profile: &Path) -> io::Result { let _ = write!(hex, "{byte:02x}"); hex }); - Ok(format!("devnotes-{hex}")) + Ok(format!("{}-{hex}", brand::SLUG)) } #[cfg(test)] diff --git a/crates/platform/src/paths.rs b/crates/platform/src/paths.rs index 97fac9e5b..1715bf73c 100644 --- a/crates/platform/src/paths.rs +++ b/crates/platform/src/paths.rs @@ -2,9 +2,9 @@ use std::path::PathBuf; -/// The installed profile, named after the packages' identifier (`[package.metadata.packager]`). -/// Until 1.0.0 it was `com.devnotes.app.dev`, kept apart from the Angular application (D16). -pub const DEFAULT_PROFILE: &str = "com.devnotes.app"; +/// The installed profile, named after the packages' identifier (D36). Until 1.0.0 it was the +/// identifier with `.dev`, kept apart from the Angular application (D16). +pub const DEFAULT_PROFILE: &str = brand::IDENTIFIER; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Locations { diff --git a/crates/platform/src/shortcuts.rs b/crates/platform/src/shortcuts.rs index d1bfac57d..792eda695 100644 --- a/crates/platform/src/shortcuts.rs +++ b/crates/platform/src/shortcuts.rs @@ -87,7 +87,7 @@ pub fn command(global: Global) -> String { let executable = std::env::var_os("APPIMAGE") .map(std::path::PathBuf::from) .or_else(|| std::env::current_exe().ok()) - .map_or_else(|| "devnotes".to_owned(), |path| path.display().to_string()); + .map_or_else(|| brand::SLUG.to_owned(), |path| path.display().to_string()); format!("{} --action {}", shell_quoted(&executable), global.name()) } diff --git a/crates/platform/src/shortcuts/system/gnome.rs b/crates/platform/src/shortcuts/system/gnome.rs index 06780fc9c..d05dea1d0 100644 --- a/crates/platform/src/shortcuts/system/gnome.rs +++ b/crates/platform/src/shortcuts/system/gnome.rs @@ -12,7 +12,7 @@ const LIST: &str = "org.gnome.settings-daemon.plugins.media-keys"; const ENTRY: &str = "org.gnome.settings-daemon.plugins.media-keys.custom-keybinding"; const BASE: &str = "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/"; /// Ours, among the person's: rewritten or removed with the preference, theirs left alone. -const OURS: &str = "devnotes-"; +const OURS: &str = concat!(brand::slug!(), "-"); /// A GNOME session whose settings take custom shortcuts. pub(super) fn offered() -> bool { @@ -44,7 +44,7 @@ pub(super) fn bind(wanted: &[(Global, String)], described: &[(Global, String)]) .iter() .find(|(named, _)| *named == global) .map_or(global.name(), |(_, words)| words.as_str()); - let name = format!("DevNotes — {words}"); + let name = format!("{} — {words}", brand::NAME); gsettings(&["set", &entry, "name", ¬ation::gvariant(&name)])?; let command = super::super::command(global); gsettings(&["set", &entry, "command", ¬ation::gvariant(&command)])?; diff --git a/crates/platform/src/shortcuts/system/portal.rs b/crates/platform/src/shortcuts/system/portal.rs index abf6a0faf..6ac67890e 100644 --- a/crates/platform/src/shortcuts/system/portal.rs +++ b/crates/platform/src/shortcuts/system/portal.rs @@ -53,7 +53,7 @@ pub(super) fn open(on_pressed: Listener) -> zbus::Result { fn register(connection: &Connection) { let registered = Proxy::new(connection, DESKTOP, PATH, "org.freedesktop.host.portal.Registry").and_then(|registry| { - registry.call::<_, _, ()>("Register", &("devnotes", HashMap::<&str, Value<'_>>::new())) + registry.call::<_, _, ()>("Register", &(brand::SLUG, HashMap::<&str, Value<'_>>::new())) }); if let Err(error) = registered { log::info!("The portal took no application name: {error}"); @@ -74,7 +74,7 @@ impl Session { "CreateSession", &(HashMap::from([ ("handle_token", Value::from(token.as_str())), - ("session_handle_token", Value::from("devnotes")), + ("session_handle_token", Value::from(brand::SLUG)), ]),), ) })?; @@ -125,7 +125,7 @@ impl Session { fn token(&mut self) -> String { self.requests += 1; - format!("devnotes{}", self.requests) + format!("{}{}", brand::SLUG, self.requests) } /// Calls the portal, then waits for the request's one answer: 0 granted, 1 cancelled by the diff --git a/crates/platform/src/shortcuts/system/wayland.rs b/crates/platform/src/shortcuts/system/wayland.rs index 684c5c69f..73cbebbf7 100644 --- a/crates/platform/src/shortcuts/system/wayland.rs +++ b/crates/platform/src/shortcuts/system/wayland.rs @@ -98,6 +98,6 @@ fn found(on_pressed: Listener) -> Way { if gnome::offered() { return Way::Gnome; } - log::warn!("No global shortcuts under this Wayland desktop: bind `devnotes --action` there"); + log::warn!("No global shortcuts under this Wayland desktop: bind `{} --action` there", brand::SLUG); Way::Nobody } diff --git a/crates/platform/src/tray/system.rs b/crates/platform/src/tray/system.rs index acf86d316..29585749b 100644 --- a/crates/platform/src/tray/system.rs +++ b/crates/platform/src/tray/system.rs @@ -134,7 +134,7 @@ mod native { impl ksni::Tray for Item { fn id(&self) -> String { - "devnotes".to_owned() + brand::SLUG.to_owned() } fn title(&self) -> String { diff --git a/crates/richtext/Cargo.toml b/crates/richtext/Cargo.toml index 6e0981899..ab12596a2 100644 --- a/crates/richtext/Cargo.toml +++ b/crates/richtext/Cargo.toml @@ -10,6 +10,7 @@ license.workspace = true publish = false [dependencies] +brand.workspace = true html5ever.workspace = true pulldown-cmark.workspace = true diff --git a/crates/richtext/src/picture.rs b/crates/richtext/src/picture.rs index aaa5193a7..aedfadf90 100644 --- a/crates/richtext/src/picture.rs +++ b/crates/richtext/src/picture.rs @@ -6,7 +6,7 @@ use crate::model::{Block, Document, Position, Selection}; use crate::tree; /// How a Note names a drawing. -pub const DRAWING_SOURCE: &str = "devnotes:drawing/"; +pub const DRAWING_SOURCE: &str = concat!(brand::slug!(), ":drawing/"); /// The narrowest and the widest a drawing is, in percent of the text's width. pub const NARROWEST: u8 = 10; diff --git a/crates/richtext/tests/golden.rs b/crates/richtext/tests/golden.rs index b726b77dc..664b90ad2 100644 --- a/crates/richtext/tests/golden.rs +++ b/crates/richtext/tests/golden.rs @@ -1,20 +1,26 @@ //! A Note read in and written back (`golden/markdown`), and typed text as it is stored //! (`golden/markdown-escape`): byte for byte. +use richtext::picture::DRAWING_SOURCE; use serde_json::Value; fn cases(json: &str) -> Vec { serde_json::from_str(json).unwrap() } +/// A drawing's address is the application's: the cases name it `{{drawing}}`. +fn filled(case: &Value, side: &str) -> String { + case[side].as_str().unwrap().replace("{{drawing}}", DRAWING_SOURCE) +} + #[test] fn markdown_is_read_and_written_back_as_stored() { let differing: Vec = cases(include_str!("../../../golden/markdown/cases.json")) .iter() .filter_map(|case| { - let input = case["input"].as_str().unwrap(); - let written = richtext::write(&richtext::read(input)); - let expected = case["output"].as_str().unwrap(); + let input = filled(case, "input"); + let written = richtext::write(&richtext::read(&input)); + let expected = filled(case, "output"); (written != expected).then(|| format!("{input:?}\n gave {written:?}\n want {expected:?}")) }) .collect(); diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 9596df39e..37bf26fdf 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -14,6 +14,7 @@ publish = false e2e = [] [dependencies] +brand.workspace = true engine.workspace = true text.workspace = true richtext.workspace = true diff --git a/crates/ui/src/api/transfer.rs b/crates/ui/src/api/transfer.rs index cdc468930..7c9dbc5b9 100644 --- a/crates/ui/src/api/transfer.rs +++ b/crates/ui/src/api/transfer.rs @@ -12,7 +12,7 @@ use platform::dialog::FileDialog; use crate::backend::{Backend, Pending}; /// `json` stays on the way in: an export written before the archive is still importable. -const READABLE: [&str; 2] = ["devnotes", "json"]; +const READABLE: [&str; 2] = [brand::EXTENSION, "json"]; pub fn pick_bundle(backend: &Backend, dialog: Arc) -> Pending> { backend.compute(move |_| Ok(dialog.open_of(&READABLE))) diff --git a/crates/ui/src/app/screens.rs b/crates/ui/src/app/screens.rs index fc308e428..cd64b95a2 100644 --- a/crates/ui/src/app/screens.rs +++ b/crates/ui/src/app/screens.rs @@ -50,9 +50,9 @@ fn output() -> Option { fn preferences(compact: bool) -> Preferences { let mut preferences = Preferences::default(); - preferences.set("devnotes.locale", "en"); + preferences.set("locale", "en"); if compact { - preferences.set("devnotes.density", "compact"); + preferences.set("density", "compact"); } preferences } diff --git a/crates/ui/src/app/titlebar_tests.rs b/crates/ui/src/app/titlebar_tests.rs index 8234eb6e4..471a3e7d1 100644 --- a/crates/ui/src/app/titlebar_tests.rs +++ b/crates/ui/src/app/titlebar_tests.rs @@ -16,7 +16,7 @@ const EMPTY: Pos2 = pos2(700.0, 19.0); fn window(directory: &std::path::Path) -> Harness<'static, DevNotesApp> { let mut startup = startup(directory); // Its controls are named in the language on screen, the machine's otherwise. - startup.preferences.set("devnotes.locale", "en"); + startup.preferences.set("locale", "en"); // A frame a sixtieth of a second, as on screen: two clicks a step apart are one double click. let mut harness = Harness::builder() .with_size(SIZE) diff --git a/crates/ui/src/gate/prompt.rs b/crates/ui/src/gate/prompt.rs index e9402d401..12490df1d 100644 --- a/crates/ui/src/gate/prompt.rs +++ b/crates/ui/src/gate/prompt.rs @@ -171,7 +171,7 @@ mod tests { use super::*; fn request(purpose: Purpose) -> Request { - Request { purpose, file_name: "notes.devnotes".to_string(), refused: false, working: false } + Request { purpose, file_name: format!("notes.{}", brand::EXTENSION), refused: false, working: false } } fn view(passphrase: &str, confirmation: &str) -> PromptView { diff --git a/crates/ui/src/http/tests.rs b/crates/ui/src/http/tests.rs index f001f7be6..2a9e5d13e 100644 --- a/crates/ui/src/http/tests.rs +++ b/crates/ui/src/http/tests.rs @@ -762,7 +762,7 @@ fn a_header_typed_with_its_value_is_split_and_a_bad_name_is_said() { values(&harness, "http-implied-value") .iter() .chain(&names(&harness, "http-implied-value")) - .any(|value| value.starts_with("DevNotes/")) + .any(|value| value.starts_with(concat!(brand::display_name!(), "/"))) ); type_into(&mut harness, "http-kv-key", 0, "Accept: application/json"); diff --git a/crates/ui/src/notes/canvas/board/tests.rs b/crates/ui/src/notes/canvas/board/tests.rs index 5572420a0..3a4e66f8a 100644 --- a/crates/ui/src/notes/canvas/board/tests.rs +++ b/crates/ui/src/notes/canvas/board/tests.rs @@ -85,10 +85,7 @@ fn the_board_draws_each_folder_as_a_zone_holding_its_notes_the_loose_ones_beside let perf = rect_of(&harness, "board-zone", "Perf"); let migrations = rect_of(&harness, "board-zone", "Migrations"); assert!(!perf.intersects(migrations), "laid out beside, not on top"); - assert_eq!( - remembered(&harness, &format!("devnotes.notes.view.{}", tableau.id)).as_deref(), - Some("board") - ); + assert_eq!(remembered(&harness, &format!("notes.view.{}", tableau.id)).as_deref(), Some("board")); } #[test] diff --git a/crates/ui/src/notes/prettier.rs b/crates/ui/src/notes/prettier.rs index 2c5786ce8..81f6c2d7a 100644 --- a/crates/ui/src/notes/prettier.rs +++ b/crates/ui/src/notes/prettier.rs @@ -4,7 +4,7 @@ use serde_json::{Value, json}; use text::format::Options; -pub const KEY: &str = "devnotes.notes.prettier"; +pub const KEY: &str = "notes.prettier"; pub const WIDTH_RANGE: (u32, u32) = (40, 200); /// The width of a tab when the level is one: what the editor's Shift+Tab takes back. const TAB_WIDTH: u32 = 4; diff --git a/crates/ui/src/services/preferences.rs b/crates/ui/src/services/preferences.rs index d9637d20b..98f64fd72 100644 --- a/crates/ui/src/services/preferences.rs +++ b/crates/ui/src/services/preferences.rs @@ -1,6 +1,6 @@ -//! A `preferences.json`, as the reference wrote it: one flat object of `devnotes.*` keys, each a -//! string. Two of them: the application's, in the profile, and the open library's, in its directory, -//! for `devnotes.notes.*`. +//! A `preferences.json`, as the reference wrote it: one flat object of keys under the slug +//! (`.theme`), each a string. Two of them: the application's, in the profile, and the open +//! library's, in its directory, for `notes.*`. use std::collections::{BTreeMap, BTreeSet}; use std::io; @@ -37,7 +37,7 @@ impl Preferences { } pub fn get(&self, key: &str) -> Option<&str> { - self.0.get(key).and_then(Value::as_str) + self.0.get(&stored(key)).and_then(Value::as_str) } /// How many keys the two do not say alike, one of them alone having it included. @@ -48,14 +48,20 @@ impl Preferences { } pub fn remove(&mut self, key: &str) { - self.0.remove(key); + self.0.remove(&stored(key)); } pub fn set(&mut self, key: &str, value: &str) { - self.0.insert(key.to_string(), Value::String(value.to_string())); + self.0.insert(stored(key), Value::String(value.to_string())); } } +/// A key as the file holds it, under the application's slug (`.theme`, D36): the code +/// names it without. +fn stored(key: &str) -> String { + format!("{}.{key}", brand::SLUG) +} + #[cfg(test)] mod tests { use super::*; @@ -64,17 +70,18 @@ mod tests { fn a_key_this_version_does_not_know_survives_a_write() { let directory = tempfile::tempdir().unwrap(); let file = directory.path().join("preferences.json"); - std::fs::write(&file, r#"{ "devnotes.theme": "dark", "devnotes.later": { "kept": [1, 2] } }"#) - .unwrap(); + let (theme, later) = (stored("theme"), stored("later")); + let written = serde_json::json!({ &theme: "dark", &later: { "kept": [1, 2] } }); + std::fs::write(&file, written.to_string()).unwrap(); let mut preferences = Preferences::read(&file); - preferences.set("devnotes.theme", "light"); + preferences.set("theme", "light"); preferences.write(&file).unwrap(); let again: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(&file).unwrap()).unwrap(); - assert_eq!(again["devnotes.theme"], "light"); - assert_eq!(again["devnotes.later"]["kept"][1], 2); + assert_eq!(again[&theme], "light"); + assert_eq!(again[&later]["kept"][1], 2); assert!(!file.with_extension("json.part").exists()); } @@ -92,7 +99,9 @@ mod tests { fn only_a_text_is_the_value_of_a_key() { let directory = tempfile::tempdir().unwrap(); let file = directory.path().join("preferences.json"); - std::fs::write(&file, r#"{ "a": "x", "b": 3, "c": null, "d": true }"#).unwrap(); + let written = + serde_json::json!({ stored("a"): "x", stored("b"): 3, stored("c"): null, stored("d"): true }); + std::fs::write(&file, written.to_string()).unwrap(); let preferences = Preferences::read(&file); assert_eq!( diff --git a/crates/ui/src/services/samples.rs b/crates/ui/src/services/samples.rs index c48dd4e86..d5ae77565 100644 --- a/crates/ui/src/services/samples.rs +++ b/crates/ui/src/services/samples.rs @@ -11,7 +11,7 @@ use engine::notes::priority::Priority; use i18n::{Key, keys}; /// In the open library's preferences: written once the samples are seeded, or found unneeded. -pub const SEEDED_KEY: &str = "devnotes.notes.samplesSeeded"; +pub const SEEDED_KEY: &str = "notes.samplesSeeded"; /// ⚠️ Untranslatable: a translation reads `{{name}}` as one of its parameters. const PSQL_SNIPPET: &str = "psql -h {{host}} -p {{port=5432}} -U {{user}} -d {{database}}"; @@ -69,7 +69,7 @@ pub fn samples(language: i18n::Language, now: DateTime) -> Samples { NoteDraft { content: tr(text::welcome::CONTENT), source: tr(text::welcome::SOURCE), - tags: vec![tr(text::tags::DEVNOTES)], + tags: vec![brand::SLUG.to_owned()], pinned: true, ..draft(tr(text::welcome::TITLE), NoteKind::Note) }, @@ -98,14 +98,14 @@ pub fn samples(language: i18n::Language, now: DateTime) -> Samples { START_HERE, NoteDraft { content: tr(text::release::CONTENT), - tags: vec![tr(text::tags::DEVNOTES)], + tags: vec![brand::SLUG.to_owned()], ..draft(tr(text::release::TITLE), NoteKind::Note) }, ), SampleNote { folder: None, draft: NoteDraft { - tags: vec![tr(text::tags::DEVNOTES)], + tags: vec![brand::SLUG.to_owned()], lifecycle: NoteLifecycle::Expires { at: deadline(now) }, priority: Priority::High, items: checklist.to_vec(), @@ -183,7 +183,7 @@ mod tests { assert_ne!(en.space, fr.space); assert_ne!(en.notes[0].draft.title, fr.notes[0].draft.title); - assert!(en.notes[0].draft.title.contains("DevNotes")); + assert!(en.notes[0].draft.title.contains(brand::NAME)); } #[test] diff --git a/crates/ui/src/services/settings.rs b/crates/ui/src/services/settings.rs index b382e06ae..b87c5972d 100644 --- a/crates/ui/src/services/settings.rs +++ b/crates/ui/src/services/settings.rs @@ -152,33 +152,33 @@ impl Default for Settings { } } -const LOCALE: &str = "devnotes.locale"; -const THEME: &str = "devnotes.theme"; -const DENSITY: &str = "devnotes.density"; -const AREA: &str = "devnotes.area"; -const RAIL: &str = "devnotes.libraryRailWidth"; -const RAIL_SHOWN: &str = "devnotes.showLibraryRail"; -const EDITOR_FULLSCREEN: &str = "devnotes.editorFullscreen"; -const EDITOR_PANEL_WIDTH: &str = "devnotes.editorPanelWidth"; -const EDITOR_HEADER_FOLDED: &str = "devnotes.editorHeaderFolded"; -const EDITOR_FIELDS_OPEN: &str = "devnotes.editorFieldsPanel"; -const EDITOR_DETAILS_OPEN: &str = "devnotes.editorDetails"; -const HTTP_REQUEST_SHARE: &str = "devnotes.httpRequestShare"; -const HISTORY_LIST_WIDTH_KEY: &str = "devnotes.httpHistoryListWidth"; -const CODE_INDENT: &str = "devnotes.codeIndent"; -const CODE_WRAP: &str = "devnotes.codeWrap"; -const DEFAULT_NOTE_KIND: &str = "devnotes.defaultNoteKind"; -const START_WITH_SYSTEM: &str = "devnotes.startWithSystem"; -const MINIMIZE_TO_TRAY: &str = "devnotes.minimizeToTray"; -const CLOSE_TO_TRAY: &str = "devnotes.closeToTray"; -const SHOW_PINNED_FIRST: &str = "devnotes.showPinnedFirst"; -const AUTOMATIC_BACKUPS: &str = "devnotes.automaticBackups"; -const COPY_CONFIRMATION: &str = "devnotes.copyConfirmation"; -const UPDATE_NOTIFICATIONS: &str = "devnotes.updateNotifications"; -const SKIPPED_UPDATE: &str = "devnotes.skippedUpdate"; -const CALC_DECIMALS: &str = "devnotes.calcDecimals"; -const CALC_NUMBER_FORMAT: &str = "devnotes.calcNumberFormat"; -const CALC_DATE_FORMAT: &str = "devnotes.calcDateFormat"; +const LOCALE: &str = "locale"; +const THEME: &str = "theme"; +const DENSITY: &str = "density"; +const AREA: &str = "area"; +const RAIL: &str = "libraryRailWidth"; +const RAIL_SHOWN: &str = "showLibraryRail"; +const EDITOR_FULLSCREEN: &str = "editorFullscreen"; +const EDITOR_PANEL_WIDTH: &str = "editorPanelWidth"; +const EDITOR_HEADER_FOLDED: &str = "editorHeaderFolded"; +const EDITOR_FIELDS_OPEN: &str = "editorFieldsPanel"; +const EDITOR_DETAILS_OPEN: &str = "editorDetails"; +const HTTP_REQUEST_SHARE: &str = "httpRequestShare"; +const HISTORY_LIST_WIDTH_KEY: &str = "httpHistoryListWidth"; +const CODE_INDENT: &str = "codeIndent"; +const CODE_WRAP: &str = "codeWrap"; +const DEFAULT_NOTE_KIND: &str = "defaultNoteKind"; +const START_WITH_SYSTEM: &str = "startWithSystem"; +const MINIMIZE_TO_TRAY: &str = "minimizeToTray"; +const CLOSE_TO_TRAY: &str = "closeToTray"; +const SHOW_PINNED_FIRST: &str = "showPinnedFirst"; +const AUTOMATIC_BACKUPS: &str = "automaticBackups"; +const COPY_CONFIRMATION: &str = "copyConfirmation"; +const UPDATE_NOTIFICATIONS: &str = "updateNotifications"; +const SKIPPED_UPDATE: &str = "skippedUpdate"; +const CALC_DECIMALS: &str = "calcDecimals"; +const CALC_NUMBER_FORMAT: &str = "calcNumberFormat"; +const CALC_DATE_FORMAT: &str = "calcDateFormat"; /// The number format that follows the language on screen. pub const CALC_LANGUAGE: &str = "language"; @@ -425,13 +425,13 @@ mod tests { chosen.write(&mut preferences); - assert_eq!(preferences.get("devnotes.theme"), Some("light")); - assert_eq!(preferences.get("devnotes.httpRequestShare"), Some("42.3")); - assert_eq!(preferences.get("devnotes.area"), Some("http")); - assert_eq!(preferences.get("devnotes.closeToTray"), Some("false")); - assert_eq!(preferences.get("devnotes.calcDecimals"), Some("3")); - assert_eq!(preferences.get("devnotes.shortcut.canvas.pin"), Some("J")); - assert_eq!(preferences.get("devnotes.shortcut.canvas.copy"), None); + assert_eq!(preferences.get("theme"), Some("light")); + assert_eq!(preferences.get("httpRequestShare"), Some("42.3")); + assert_eq!(preferences.get("area"), Some("http")); + assert_eq!(preferences.get("closeToTray"), Some("false")); + assert_eq!(preferences.get("calcDecimals"), Some("3")); + assert_eq!(preferences.get("shortcut.canvas.pin"), Some("J")); + assert_eq!(preferences.get("shortcut.canvas.copy"), None); assert_eq!(Settings::read(&preferences), chosen); } @@ -441,7 +441,7 @@ mod tests { let read = |value: Option<&str>| { let mut preferences = Preferences::default(); if let Some(value) = value { - preferences.set("devnotes.automaticBackups", value); + preferences.set("automaticBackups", value); } Settings::read(&preferences).automatic_backups }; @@ -453,7 +453,7 @@ mod tests { #[test] fn an_unknown_value_is_the_default() { let mut preferences = Preferences::default(); - preferences.set("devnotes.theme", "sepia"); + preferences.set("theme", "sepia"); assert_eq!(Settings::read(&preferences).theme, Appearance::System); } @@ -510,7 +510,7 @@ mod tests { ("-3", RAIL_DEFAULT), ("", RAIL_DEFAULT), ] { - assert_eq!(stored("devnotes.libraryRailWidth", written).rail_width, width, "{written}"); + assert_eq!(stored("libraryRailWidth", written).rail_width, width, "{written}"); } } @@ -529,16 +529,16 @@ mod tests { ("NaN", 0), ("half", 0), ] { - assert_eq!(stored("devnotes.httpRequestShare", written).http_request_share, share, "{written}"); + assert_eq!(stored("httpRequestShare", written).http_request_share, share, "{written}"); } } #[test] fn a_number_that_does_not_read_is_the_default() { - assert_eq!(stored("devnotes.editorPanelWidth", "wide").editor_panel_width, 0); - assert_eq!(stored("devnotes.httpHistoryListWidth", "wide").history_list_width, 380); + assert_eq!(stored("editorPanelWidth", "wide").editor_panel_width, 0); + assert_eq!(stored("httpHistoryListWidth", "wide").history_list_width, 380); for (written, places) in [("auto", None), ("", None), ("2", Some(2)), ("-1", None)] { - assert_eq!(stored("devnotes.calcDecimals", written).calc_decimals, places, "{written}"); + assert_eq!(stored("calcDecimals", written).calc_decimals, places, "{written}"); } } @@ -563,11 +563,10 @@ mod tests { ("updateNotifications", true, |s| s.update_notifications), ]; for (name, shipped, read) in switches { - let key = format!("devnotes.{name}"); let moves = if shipped { "false" } else { "true" }; - assert_eq!(read(&stored(&key, moves)), !shipped, "{name}"); + assert_eq!(read(&stored(name, moves)), !shipped, "{name}"); for other in ["", "1", "0", "TRUE", "False", if shipped { "true" } else { "false" }] { - assert_eq!(read(&stored(&key, other)), shipped, "{name} {other}"); + assert_eq!(read(&stored(name, other)), shipped, "{name} {other}"); } } } @@ -595,10 +594,10 @@ mod tests { fn a_key_put_back_leaves_the_file() { let mut preferences = Preferences::default(); Settings { bindings: moved_key(), ..Settings::default() }.write(&mut preferences); - assert!(preferences.get("devnotes.shortcut.canvas.pin").is_some()); + assert!(preferences.get("shortcut.canvas.pin").is_some()); Settings::default().write(&mut preferences); - assert_eq!(preferences.get("devnotes.shortcut.canvas.pin"), None); + assert_eq!(preferences.get("shortcut.canvas.pin"), None); } #[test] diff --git a/crates/ui/src/services/shortcuts.rs b/crates/ui/src/services/shortcuts.rs index 71e569ff4..79d9eed65 100644 --- a/crates/ui/src/services/shortcuts.rs +++ b/crates/ui/src/services/shortcuts.rs @@ -248,8 +248,8 @@ impl Bindings { /// Where a key is stored: the three global ones as the native side takes them, the rest one each. pub fn preference_key(action: Rebindable) -> String { match action.scope { - Scope::Global => format!("devnotes.{}Shortcut", action.id), - _ => format!("devnotes.shortcut.{}", action.id), + Scope::Global => format!("{}Shortcut", action.id), + _ => format!("shortcut.{}", action.id), } } @@ -386,8 +386,8 @@ mod tests { #[test] fn global_keys_keep_the_reference_storage_names() { - assert_eq!(preference_key(GLOBAL), "devnotes.paletteShortcut"); - assert_eq!(preference_key(PIN), "devnotes.shortcut.canvas.pin"); + assert_eq!(preference_key(GLOBAL), "paletteShortcut"); + assert_eq!(preference_key(PIN), "shortcut.canvas.pin"); } #[test] diff --git a/crates/ui/src/state/board.rs b/crates/ui/src/state/board.rs index ab2190a72..a9029ad9a 100644 --- a/crates/ui/src/state/board.rs +++ b/crates/ui/src/state/board.rs @@ -25,7 +25,7 @@ use crate::services::preferences::Preferences; /// One key per space, not one map: arranging one space must not move the switch on the others. fn view_key(space_id: &str) -> String { - format!("devnotes.notes.view.{space_id}") + format!("notes.view.{space_id}") } #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] @@ -455,7 +455,7 @@ mod tests { assert_eq!(Mode::read(&preferences, "a"), Mode::Board); assert_eq!(Mode::read(&preferences, "b"), Mode::List); - preferences.set("devnotes.notes.view.b", "grid"); + preferences.set("notes.view.b", "grid"); assert_eq!(Mode::read(&preferences, "b"), Mode::List); } diff --git a/crates/ui/src/state/folders.rs b/crates/ui/src/state/folders.rs index ecf65fb53..8c5737062 100644 --- a/crates/ui/src/state/folders.rs +++ b/crates/ui/src/state/folders.rs @@ -17,7 +17,7 @@ use crate::services::preferences::Preferences; use crate::services::status::StatusNotifier; /// The library's, like everything under `devnotes.notes.`: an id means nothing elsewhere. -pub const ACTIVE_FOLDER_KEY: &str = "devnotes.notes.activeFolder"; +pub const ACTIVE_FOLDER_KEY: &str = "notes.activeFolder"; enum Write { Folder(Pending), diff --git a/crates/ui/src/state/http/environments.rs b/crates/ui/src/state/http/environments.rs index 2a49bab17..5943660b6 100644 --- a/crates/ui/src/state/http/environments.rs +++ b/crates/ui/src/state/http/environments.rs @@ -15,7 +15,7 @@ use crate::state::query::QueryCell; /// In the library's preferences: the environment a request is sent with belongs to its /// collections. -pub const ACTIVE_KEY: &str = "devnotes.notes.http.environment"; +pub const ACTIVE_KEY: &str = "notes.http.environment"; /// How long the keys rest before a table is written, in seconds. const SAVE_AFTER: f64 = 0.4; diff --git a/crates/ui/src/state/http/mod.rs b/crates/ui/src/state/http/mod.rs index 0ade4716d..6f3157fa0 100644 --- a/crates/ui/src/state/http/mod.rs +++ b/crates/ui/src/state/http/mod.rs @@ -44,7 +44,7 @@ use moves::{KeyMove, RailMove, Refusal, Where}; use tree::RailRow; /// In the library's preferences: which folds were left closed belongs to its collections. -pub const COLLAPSED_KEY: &str = "devnotes.notes.http.collapsed"; +pub const COLLAPSED_KEY: &str = "notes.http.collapsed"; /// How long a move made with the keys stays marked, in seconds: as long as its fade. pub const MARK_SECONDS: f64 = crate::theme::motion::MARK as f64; diff --git a/crates/ui/src/state/http/tabs.rs b/crates/ui/src/state/http/tabs.rs index 3aa331157..b91173465 100644 --- a/crates/ui/src/state/http/tabs.rs +++ b/crates/ui/src/state/http/tabs.rs @@ -24,7 +24,7 @@ use crate::services::errors::ErrorNotifier; use crate::services::preferences::Preferences; /// In the library's preferences: which requests were open, and which one was in front. -pub const TABS_KEY: &str = "devnotes.notes.http.tabs"; +pub const TABS_KEY: &str = "notes.http.tabs"; /// What a tab edits. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/ui/src/state/mod.rs b/crates/ui/src/state/mod.rs index ec9bb122b..2a67b2b78 100644 --- a/crates/ui/src/state/mod.rs +++ b/crates/ui/src/state/mod.rs @@ -69,7 +69,7 @@ pub enum EditorNext { } /// The library's: its board's loose cards are stored in pixels, at that card's height. -pub const PREVIEW_LINES_KEY: &str = "devnotes.notes.previewLines"; +pub const PREVIEW_LINES_KEY: &str = "notes.previewLines"; /// Bumped after every write the interface adopts: the queries that read notes carry it among /// their parameters, so the list and the board ask again together. Writes are not optimistic: @@ -735,8 +735,8 @@ mod tests { fn compact() -> Preferences { let mut preferences = Preferences::default(); - preferences.set("devnotes.density", "compact"); - preferences.set("devnotes.someday", "kept"); + preferences.set("density", "compact"); + preferences.set("someday", "kept"); preferences } @@ -746,7 +746,7 @@ mod tests { let directory = engine::db::run_here(backend.engine(), engine::libraries::open_library_directory).unwrap(); let mut library = Preferences::default(); - library.set("devnotes.notes.arrangement", "board"); + library.set("notes.arrangement", "board"); library.write(&directory.join(engine::layout::PREFERENCES)).unwrap(); let ctx = egui::Context::default(); let mut state = AppState::new(compact(), true); @@ -762,7 +762,7 @@ mod tests { backend.settle(); state.update(&ctx, &backend); - assert_eq!(state.library_preferences.get("devnotes.notes.arrangement"), Some("board")); + assert_eq!(state.library_preferences.get("notes.arrangement"), Some("board")); assert_eq!(state.settings.density, Density::Compact); assert_eq!(ctx.data(|data| data.get_temp::(typed)), None); assert_eq!(theme::spacing(&ctx), &theme::tokens::COMPACT); @@ -807,9 +807,9 @@ mod tests { backend.settle(); let written = Preferences::read(&profile.path().join(engine::layout::PREFERENCES)); - assert_eq!(written.get("devnotes.area"), Some("http")); - assert_eq!(written.get("devnotes.theme"), Some("light")); - assert_eq!(written.get("devnotes.someday"), Some("kept")); + assert_eq!(written.get("area"), Some("http")); + assert_eq!(written.get("theme"), Some("light")); + assert_eq!(written.get("someday"), Some("kept")); assert_eq!(Settings::read(&written), state.settings); } diff --git a/crates/ui/src/state/notes_query.rs b/crates/ui/src/state/notes_query.rs index 9555ec7a0..62eb04876 100644 --- a/crates/ui/src/state/notes_query.rs +++ b/crates/ui/src/state/notes_query.rs @@ -18,7 +18,7 @@ use crate::backend::Backend; use crate::services::preferences::Preferences; /// The library's, like the space each was left on. -pub const ARRANGEMENT_KEY: &str = "devnotes.notes.arrangement"; +pub const ARRANGEMENT_KEY: &str = "notes.arrangement"; /// How long the search waits after the last key, in egui's seconds: barely needed with the /// index in memory, kept so a burst of keys asks once. diff --git a/crates/ui/src/state/spaces.rs b/crates/ui/src/state/spaces.rs index e6f8c0e3d..f0ea20147 100644 --- a/crates/ui/src/state/spaces.rs +++ b/crates/ui/src/state/spaces.rs @@ -14,7 +14,7 @@ use crate::services::preferences::Preferences; use crate::services::status::StatusNotifier; /// The library's, like everything under `devnotes.notes.`: an id means nothing elsewhere. -pub const ACTIVE_SPACE_KEY: &str = "devnotes.notes.activeSpace"; +pub const ACTIVE_SPACE_KEY: &str = "notes.activeSpace"; enum Write { /// Shown once made: its id arrives with the answer. diff --git a/crates/ui/src/state/tools.rs b/crates/ui/src/state/tools.rs index 9eace2f14..e25a82414 100644 --- a/crates/ui/src/state/tools.rs +++ b/crates/ui/src/state/tools.rs @@ -8,10 +8,10 @@ use crate::services::preferences::Preferences; use crate::tools::catalogue::{self, Category, ToolEntry}; use engine::tools::identity::CsvSeparator; -const RECENTS: &str = "devnotes.recentTools"; -const FAVOURITES: &str = "devnotes.favouriteTools"; -const ZONES: &str = "devnotes.timeZones"; -const CSV_SEPARATOR: &str = "devnotes.csvSeparator"; +const RECENTS: &str = "recentTools"; +const FAVOURITES: &str = "favouriteTools"; +const ZONES: &str = "timeZones"; +const CSV_SEPARATOR: &str = "csvSeparator"; const DEFAULT_ZONES: [&str; 3] = ["UTC", "America/New_York", "Asia/Tokyo"]; /// Read back from a file nobody checks. diff --git a/crates/ui/src/state/transfer.rs b/crates/ui/src/state/transfer.rs index d61c6016a..132cc68c0 100644 --- a/crates/ui/src/state/transfer.rs +++ b/crates/ui/src/state/transfer.rs @@ -287,7 +287,8 @@ fn file_name(path: &str) -> String { /// Stamped to the second, and in local time: to the minute, two exports in a row were offered the /// same name, and replacing the first was one Enter away. fn default_file_name(now: DateTime) -> String { - now.format("devnotes-%Y-%m-%d-%H%M%S.devnotes").to_string() + let stamp = now.format("%Y-%m-%d-%H%M%S"); + format!("{}-{stamp}.{}", brand::SLUG, brand::EXTENSION) } fn empty_key(scope: &ExportScope) -> Key { @@ -378,7 +379,7 @@ mod tests { fn new() -> Self { let (backend, profile) = testing::unlocked(); let directory = tempfile::tempdir().unwrap(); - let file = directory.path().join("library.devnotes"); + let file = directory.path().join(format!("library.{}", brand::EXTENSION)); Self { backend, _profile: profile, @@ -450,7 +451,7 @@ mod tests { bench.export(); let request = bench.transfer.prompt().unwrap(); assert_eq!(request.purpose, Purpose::Protect); - assert_eq!(request.file_name, "library.devnotes"); + assert_eq!(request.file_name, format!("library.{}", brand::EXTENSION)); bench.answer(Answer::Plain); assert_eq!(bench.said(), Some(keys::file::EXPORTED)); @@ -536,8 +537,8 @@ mod tests { let name = default_file_name(now); - assert!(name.starts_with("devnotes-2026-11-0"), "{name}"); - assert!(name.ends_with(".devnotes"), "{name}"); + assert!(name.starts_with(&format!("{}-2026-11-0", brand::SLUG)), "{name}"); + assert!(name.ends_with(&format!(".{}", brand::EXTENSION)), "{name}"); } #[test] diff --git a/crates/ui/src/titlebar/about_menu/docs/mod.rs b/crates/ui/src/titlebar/about_menu/docs/mod.rs index 0ddf8ad57..b228072e0 100644 --- a/crates/ui/src/titlebar/about_menu/docs/mod.rs +++ b/crates/ui/src/titlebar/about_menu/docs/mod.rs @@ -180,8 +180,8 @@ fn rail_content(ui: &mut Ui, state: &AppState, id: &str, view: &mut View) -> Opt fn site_of(language: Language) -> &'static str { match language { - Language::Fr => "https://devnotes.fr/docs", - Language::En => "https://devnotes.fr/en/docs", + Language::Fr => concat!(brand::site!(), "/docs"), + Language::En => concat!(brand::site!(), "/en/docs"), } } diff --git a/crates/ui/src/titlebar/preferences/shortcuts.rs b/crates/ui/src/titlebar/preferences/shortcuts.rs index f8926dae0..476cabf0e 100644 --- a/crates/ui/src/titlebar/preferences/shortcuts.rs +++ b/crates/ui/src/titlebar/preferences/shortcuts.rs @@ -55,7 +55,7 @@ pub(super) fn page(ui: &mut Ui, state: &AppState, settings: &mut Settings, view: held_elsewhere(ui, state, action, settings); }); } - note(ui, &tr(said)); + note(ui, &i18n::translate(language, said, &[("binary", brand::SLUG.into())])); if scope == Scope::Global && holder == Holder::Nobody { commands(ui); } diff --git a/docs/architecture/backend.md b/docs/architecture/backend.md index c5672700a..89165e362 100644 --- a/docs/architecture/backend.md +++ b/docs/architecture/backend.md @@ -124,7 +124,8 @@ egui's focus navigation. The two `preferences.json` keep the reference's format — one flat object of `devnotes.*` keys, each a string. `services::preferences::Preferences` keeps every key it read, those this version does not know -included, and is written staged then renamed. The application's file is read by `main` before +included, and is written staged then renamed. The code names a key without its prefix +(`"notes.activeSpace"`): `Preferences` puts the slug before it (D36). The application's file is read by `main` before the window exists; the open library's (`devnotes.notes.*`) is read again on the db queue each time a library opens (`AppState::reset_library_scope`). Both are written on the db queue, so two changes in a row land in that order. diff --git a/docs/architecture/overview.md b/docs/architecture/overview.md index a6699456f..9466998db 100644 --- a/docs/architecture/overview.md +++ b/docs/architecture/overview.md @@ -65,9 +65,11 @@ beside the version (D27): `crates/brand` is their one reader: its `build.rs` reads them, refuses one that could not name a file, a folder, a key or a URL, and hands them to `brand::NAME`, `AUTHOR_HANDLE`, `SLUG`, -`IDENTIFIER`, `EXTENSION` and `SITE`. A leaf crate, so that `engine`, `i18n`, `richtext`, -`platform`, `ui` and `app` take a name from it, never from one another (D10). The -`DEVNOTES_` prefix of the environment variables stays as it is for now: the owner's choice. +`IDENTIFIER`, `EXTENSION` and `SITE`; each is also a macro expanding to its literal, for a +constant another crate builds with `concat!` (`concat!(brand::slug!(), ".sqlite3")`). A leaf +crate, so that `engine`, `i18n`, `richtext`, `platform`, `ui` and `app` take a name from it, +never from one another (D10). The `DEVNOTES_` prefix of the environment variables stays as it is +for now: the owner's choice. **What a rename costs**, accepted and not migrated: an archive exported under the previous extension is no longer offered by the import's filter, and a request history holding the previous diff --git a/golden/markdown/cases.json b/golden/markdown/cases.json index 3fd769d4b..07124b77b 100644 --- a/golden/markdown/cases.json +++ b/golden/markdown/cases.json @@ -56,8 +56,8 @@ "output": "[un lien](https://exemple.fr) et [https://nu.exemple.fr](https://nu.exemple.fr)" }, { - "input": "![image](devnotes:drawing/abc)", - "output": "![image](devnotes:drawing/abc)" + "input": "![image]({{drawing}}abc)", + "output": "![image]({{drawing}}abc)" }, { "input": "---",