use std::path::Path; pub const STATIC_DIR: &str = "static"; static STATIC_FILES: &[(&str, &[u8])] = &[ ("style1.css", include_bytes!("../static/style1.css")), ("standgm.png", include_bytes!("../static/standgm.png")), ("banner.jpg", include_bytes!("../static/banner.jpg")), ("icon.png", include_bytes!("../static/icon.png")), ("Karma-Bold.otf", include_bytes!("../static/Karma-Bold.otf")), ( "LinBiolinum_R.otf", include_bytes!("../static/LinBiolinum_R.otf"), ), ("bg0.jpg", include_bytes!("../static/bg0.jpg")), ("bg1.jpg", include_bytes!("../static/bg1.jpg")), ("bg2.jpg", include_bytes!("../static/bg2.jpg")), ("script1.js", include_bytes!("../static/script1.js")), ]; pub static BACKGROUND_ABOUT: &[&str] = &[ "Claudia Peters, FreeImages.com", r#"Muhammad Haris, CC BY-SA 4.0"#, r#"Wilfredor, CC BY-SA 4.0"#, ]; pub fn init_static_files(dir: &Path) { let dir = dir.join(STATIC_DIR); std::fs::create_dir_all(&dir).expect("Cannot create static dir"); for &(file, default) in STATIC_FILES { let file_path = dir.join(file); if !file_path.is_file() { std::fs::write(file_path, default) .unwrap_or_else(|_| panic!("Cannot write template file {}", file)); } } } pub fn get_background() -> usize { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map_or(0, |t| t.as_secs() as usize / 86400 % 3) }