Add some varied default song covers

This commit is contained in:
2023-09-24 01:33:55 +02:00
parent c6cc83018f
commit f42985733f
28 changed files with 47 additions and 1 deletions

26
frontend/build.rs Normal file
View File

@ -0,0 +1,26 @@
use std::fs;
use std::path::Path;
use std::io;
fn main() {
index_default_covers().expect("index default covers");
}
/// Index all pngs in static/images/default_covers and expose the list in the build as an
/// environment variable DEFAULT_SONG_COVERS. This list includes the path to the images so the
/// frontend can fetch them.
fn index_default_covers() -> io::Result<()> {
let mut files = vec![];
for dir in fs::read_dir("static/images/default_covers")? {
let path = dir?.path();
if path.extension().and_then(|s| s.to_str()) == Some("png") {
let path = Path::new("/").join(path.strip_prefix("static").unwrap());
files.push(path.to_string_lossy().to_string());
}
}
let list = files.join(",");
println!("cargo:rustc-env=DEFAULT_SONG_COVERS={list}");
Ok(())
}