From fffc7a3b8a8a3ead3992d400ec9ed035f1f93b39 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 3 Oct 2023 09:31:05 +0200 Subject: use yaml for configuration --- Cargo.lock | 22 +++++++++++++++++++++- base/Cargo.toml | 2 +- base/src/lib.rs | 4 ++-- import/Cargo.toml | 1 + import/src/main.rs | 4 ++-- readme.md | 2 +- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a0c6e0..767246b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1393,7 +1393,7 @@ dependencies = [ "jellycommon", "log", "serde", - "serde_json", + "serde_yaml", "sha2", "tokio", ] @@ -1507,6 +1507,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "serde_yaml", ] [[package]] @@ -2637,6 +2638,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" +dependencies = [ + "indexmap 2.0.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha2" version = "0.10.8" @@ -3181,6 +3195,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "unsafe-libyaml" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" + [[package]] name = "url" version = "2.4.1" diff --git a/base/Cargo.toml b/base/Cargo.toml index 03b5055..45c3843 100644 --- a/base/Cargo.toml +++ b/base/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] jellycommon = { path = "../common" } serde = { version = "1.0.188", features = ["derive"] } -serde_json = "1.0.107" +serde_yaml = "0.9.25" log = { workspace = true } sha2 = "0.10.8" base64 = "0.21.4" diff --git a/base/src/lib.rs b/base/src/lib.rs index 062b028..132fd45 100644 --- a/base/src/lib.rs +++ b/base/src/lib.rs @@ -12,11 +12,11 @@ use jellycommon::{config::GlobalConfig, AssetLocation}; use std::{fs::File, path::PathBuf, sync::LazyLock}; pub static CONF: LazyLock = LazyLock::new(|| { - serde_json::from_reader( + serde_yaml::from_reader( File::open( std::env::args() .nth(1) - .expect("First argument must specify the config.json to use."), + .expect("First argument must specify the configuration to use."), ) .unwrap(), ) diff --git a/import/Cargo.toml b/import/Cargo.toml index 89d3ea9..9f0912a 100644 --- a/import/Cargo.toml +++ b/import/Cargo.toml @@ -16,6 +16,7 @@ reqwest = { version = "0.11.20", features = ["blocking", "json"] } serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" +serde_yaml = "0.9.25" bincode = { version = "2.0.0-rc.3", features = ["serde"] } base64 = "0.21.4" rand = "0.8.5" diff --git a/import/src/main.rs b/import/src/main.rs index f017407..3affabd 100644 --- a/import/src/main.rs +++ b/import/src/main.rs @@ -94,8 +94,8 @@ fn main() -> anyhow::Result<()> { std::fs::create_dir_all(path.join("assets"))?; File::create_new(path.join("assets/front.htm"))? .write_fmt(format_args!("

My very own jellything instance

"))?; - serde_json::to_writer( - File::create_new(path.join("config.json"))?, + serde_yaml::to_writer( + File::create_new(path.join("config.yaml"))?, &GlobalConfig { brand: brand.clone(), slogan: "Creative slogan here".to_string(), diff --git a/readme.md b/readme.md index e867c95..11d8fa4 100644 --- a/readme.md +++ b/readme.md @@ -28,7 +28,7 @@ rustup install nightly cargo +nightly install jellything --git https://codeberg.org/metamuffin/jellything.git cargo +nightly install jellything-import --git https://codeberg.org/metamuffin/jellything.git jellything-import init --brand 'Blubflix' data # data will be a directory containing all the instances data -jellything data/config.json +jellything data/config.yaml ``` ## Licence -- cgit v1.2.3-70-g09d2