add: icon resolver

add: config "no_track" file list option
add: rainbeam-shared -> tetratto-shared
add: l10n
This commit is contained in:
trisua 2025-03-23 12:31:48 -04:00
parent b6fe2fba37
commit d2ca9e23d3
40 changed files with 1107 additions and 583 deletions

View file

@ -1,16 +1,46 @@
#[macro_export]
macro_rules! write_template {
($html_path:ident->$path:literal($as:expr)) => {
std::fs::write($html_path.join($path), $as).unwrap();
($into:ident->$path:literal($as:expr)) => {
std::fs::write($into.join($path), $as).unwrap();
};
($html_path:ident->$path:literal($as:expr) -d $dir_path:literal) => {
let dir = $html_path.join($dir_path);
($into:ident->$path:literal($as:expr) --config=$config:ident) => {
std::fs::write(
$into.join($path),
crate::assets::replace_in_html($as, &$config).await,
)
.unwrap();
};
($into:ident->$path:literal($as:expr) -d $dir_path:literal) => {
let dir = $into.join($dir_path);
if !std::fs::exists(&dir).unwrap() {
std::fs::create_dir(dir).unwrap();
}
std::fs::write($html_path.join($path), $as).unwrap();
std::fs::write($into.join($path), $as).unwrap();
};
($into:ident->$path:literal($as:expr) -d $dir_path:literal --config=$config:ident) => {
let dir = $into.join($dir_path);
if !std::fs::exists(&dir).unwrap() {
std::fs::create_dir(dir).unwrap();
}
std::fs::write(
$into.join($path),
crate::assets::replace_in_html($as, &$config).await,
)
.unwrap();
};
}
#[macro_export]
macro_rules! write_if_track {
($into:ident->$path:literal($as:expr) --config=$config:ident) => {
if !$config.no_track.contains(&$path.to_string()) {
write_template!($into->$path($as));
}
};
}
@ -28,7 +58,7 @@ macro_rules! get_user_from_token {
(($jar:ident, $db:expr) <optional>) => {{
if let Some(token) = $jar.get("__Secure-atto-token") {
match $db
.get_user_by_token(&rainbeam_shared::hash::hash(
.get_user_by_token(&tetratto_shared::hash::hash(
token.to_string().replace("__Secure-atto-token=", ""),
))
.await
@ -52,3 +82,20 @@ macro_rules! get_user_from_token {
}
}};
}
#[macro_export]
macro_rules! get_lang {
($jar:ident, $db:expr) => {{
if let Some(lang) = $jar.get("__Secure-atto-lang") {
match $db
.1
.get(&lang.to_string().replace("__Secure-atto-lang=", ""))
{
Some(lang) => lang,
None => $db.1.get("com.tetratto.langs:en-US").unwrap(),
}
} else {
$db.1.get("com.tetratto.langs:en-US").unwrap()
}
}};
}