1
0

change dir public/at src

This commit is contained in:
2026-03-02 15:50:01 +09:00
parent 6a1eb85a53
commit 9f8c8d9f90
10 changed files with 109 additions and 35 deletions

View File

@@ -15,21 +15,34 @@ struct SiteConfig {
}
fn load_site_url() -> Result<String> {
// Try public/config.json in current directory
let config_path = std::path::Path::new("public/config.json");
if config_path.exists() {
let content = std::fs::read_to_string(config_path)?;
// 1. Try public/config.json in current directory
let local_path = std::path::Path::new("public/config.json");
if local_path.exists() {
let content = std::fs::read_to_string(local_path)?;
let config: SiteConfig = serde_json::from_str(&content)?;
if let Some(url) = config.site_url {
return Ok(url.trim_end_matches('/').to_string());
}
}
// 2. Fallback to ~/.config/ai.syui.log/config.json
if let Some(cfg_dir) = dirs::config_dir() {
let cfg_path = cfg_dir.join(BUNDLE_ID).join("config.json");
if cfg_path.exists() {
let content = std::fs::read_to_string(&cfg_path)?;
let config: SiteConfig = serde_json::from_str(&content)?;
if let Some(url) = config.site_url {
return Ok(url.trim_end_matches('/').to_string());
}
}
}
anyhow::bail!(
"No siteUrl found in public/config.json. \
Create config.json with {{\"siteUrl\": \"https://example.com\"}}"
"No siteUrl found. Create public/config.json or run ailog oauth with --client-id"
);
}
fn percent_encode(s: &str) -> String {
let mut result = String::with_capacity(s.len() * 2);
for b in s.bytes() {