Add version display
This commit is contained in:
@@ -279,6 +279,11 @@ a:visited {
|
|||||||
color: #b3c6b4;
|
color: #b3c6b4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&_version {
|
||||||
|
color: var(--txt-color);
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
&_bttn {
|
&_bttn {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: large;
|
font-size: large;
|
||||||
|
|||||||
+56
-8
@@ -1,7 +1,39 @@
|
|||||||
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn version_env() -> Option<()> {
|
||||||
|
if env::var("MUMBLE_WEB2_VERSION").is_ok() {
|
||||||
|
return Some(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args(["rev-parse", "--short", "HEAD"])
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
let git_hash = String::from_utf8(output.stdout).ok()?;
|
||||||
|
let git_hash = git_hash.trim(); // drop trailing newline
|
||||||
|
|
||||||
|
let status = Command::new("git")
|
||||||
|
.args(["status", "--porcelain"])
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
let dirty = match status.stdout.is_empty() {
|
||||||
|
true => "",
|
||||||
|
false => "-dirty",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Expose it as a compile-time env var
|
||||||
|
println!("cargo::rustc-env=MUMBLE_WEB2_VERSION=git-{git_hash}{dirty}");
|
||||||
|
|
||||||
|
// Optional: rebuild when HEAD changes
|
||||||
|
println!("cargo::rerun-if-changed=.git/HEAD");
|
||||||
|
|
||||||
|
Some(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn download_deepfilternet() {
|
||||||
// Define the target directory and file
|
// Define the target directory and file
|
||||||
let assets_dir = "assets";
|
let assets_dir = "assets";
|
||||||
let target_file = format!("{}/DeepFilterNet3_ll_onnx.tar.gz", assets_dir);
|
let target_file = format!("{}/DeepFilterNet3_ll_onnx.tar.gz", assets_dir);
|
||||||
@@ -9,30 +41,46 @@ fn main() {
|
|||||||
|
|
||||||
// Check if the file already exists
|
// Check if the file already exists
|
||||||
if target_path.exists() {
|
if target_path.exists() {
|
||||||
println!("cargo:warning=DeepFilterNet model already exists at {}", target_file);
|
println!(
|
||||||
|
"cargo::warning=DeepFilterNet model already exists at {}",
|
||||||
|
target_file
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:warning=Downloading DeepFilterNet model to {}...", target_file);
|
println!(
|
||||||
|
"cargo::warning=Downloading DeepFilterNet model to {}...",
|
||||||
|
target_file
|
||||||
|
);
|
||||||
|
|
||||||
// Download the file using curl
|
// Download the file using curl
|
||||||
let url = "https://github.com/Rikorose/DeepFilterNet/raw/refs/heads/main/models/DeepFilterNet3_ll_onnx.tar.gz";
|
let url = "https://github.com/Rikorose/DeepFilterNet/raw/refs/heads/main/models/DeepFilterNet3_ll_onnx.tar.gz";
|
||||||
|
|
||||||
let status = Command::new("curl")
|
let status = Command::new("curl")
|
||||||
.args([
|
.args([
|
||||||
"-L", // Follow redirects
|
"-L", // Follow redirects
|
||||||
"-o", &target_file, // Output file
|
"-o",
|
||||||
|
&target_file, // Output file
|
||||||
url,
|
url,
|
||||||
])
|
])
|
||||||
.status()
|
.status()
|
||||||
.expect("Failed to execute curl command. Make sure curl is installed.");
|
.expect("Failed to execute curl command. Make sure curl is installed.");
|
||||||
|
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
panic!("Failed to download DeepFilterNet model from {}", url);
|
println!("cargo::error=Failed to download DeepFilterNet model from {url}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:warning=Successfully downloaded DeepFilterNet model to {}", target_file);
|
println!(
|
||||||
|
"cargo::warning=Successfully downloaded DeepFilterNet model to {}",
|
||||||
|
target_file
|
||||||
|
);
|
||||||
|
|
||||||
// Rerun this build script if the target file is deleted
|
// Rerun this build script if the target file is deleted
|
||||||
println!("cargo:rerun-if-changed={}", target_file);
|
println!("cargo::rerun-if-changed={}", target_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
version_env();
|
||||||
|
download_deepfilternet();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -612,11 +612,16 @@ pub fn LoginView(config: Resource<ClientConfig>) -> Element {
|
|||||||
),
|
),
|
||||||
Connected => unreachable!(),
|
Connected => unreachable!(),
|
||||||
};
|
};
|
||||||
|
let version = option_env!("MUMBLE_WEB2_VERSION");
|
||||||
rsx!(
|
rsx!(
|
||||||
div {
|
div {
|
||||||
class: "login",
|
class: "login",
|
||||||
h1 {
|
h1 {
|
||||||
"Mumble Web"
|
"Mumble Web"
|
||||||
|
match version {
|
||||||
|
Some(v) => rsx!(" " span { class: "login_version", "({v})" }),
|
||||||
|
None => rsx!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if config.read().as_ref().is_some_and(|cfg| cfg.any_server) {
|
if config.read().as_ref().is_some_and(|cfg| cfg.any_server) {
|
||||||
div {
|
div {
|
||||||
|
|||||||
Reference in New Issue
Block a user