Add some varied default song covers
This commit is contained in:
26
frontend/build.rs
Normal file
26
frontend/build.rs
Normal 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(())
|
||||
}
|
||||
Reference in New Issue
Block a user