mirror of
https://github.com/Dummi26/musicdb.git
synced 2025-12-14 20:06:16 +01:00
update client + remake web-ui (server, incomplete)
This commit is contained in:
14
musicdb-server/Cargo.toml
Executable file → Normal file
14
musicdb-server/Cargo.toml
Executable file → Normal file
@@ -7,14 +7,14 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
musicdb-lib = { path = "../musicdb-lib", features = ["playback"] }
|
||||
axum = { version = "0.6.19", features = ["headers"] }
|
||||
clap = { version = "4.4.6", features = ["derive"] }
|
||||
futures = "0.3.28"
|
||||
headers = "0.3.8"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
tokio-stream = "0.1.14"
|
||||
tower = { version = "0.4", features = ["util"] }
|
||||
tower-http = { version = "0.4.0", features = ["fs", "trace"] }
|
||||
trace = "0.1.7"
|
||||
tokio = { version = "1.37.0", optional = true, features = ["rt"] }
|
||||
rocket = { version = "0.5.0", optional = true }
|
||||
html-escape = { version = "0.2.13", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["website"]
|
||||
website = ["dep:tokio", "dep:rocket", "dep:html-escape"]
|
||||
|
||||
6
musicdb-server/Cross.toml
Normal file
6
musicdb-server/Cross.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[build]
|
||||
pre-build = [
|
||||
"dpkg --add-architecture $CROSS_DEB_ARCH",
|
||||
"apt-get update && apt-get --assume-yes install libasound2-dev libasound2-dev:$CROSS_DEB_ARCH"
|
||||
]
|
||||
default-target = "aarch64-unknown-linux-gnu"
|
||||
@@ -1,3 +0,0 @@
|
||||
<h3>\:name</h3>
|
||||
<button hx-post="/queue/add-album/\:id" hx-swap="none">Queue</button>
|
||||
\:songs
|
||||
@@ -1 +0,0 @@
|
||||
<button hx-get="/album-view/\:id" hx-target="#album-view">\:name</button>
|
||||
@@ -1,2 +0,0 @@
|
||||
<h3>\:name</h3>
|
||||
\:albums
|
||||
@@ -1,2 +0,0 @@
|
||||
<h3>Artists</h3>
|
||||
\:artists
|
||||
@@ -1 +0,0 @@
|
||||
<button hx-get="/artist-view/\:id" hx-target="#artist-view">\:name</button>
|
||||
@@ -1,3 +0,0 @@
|
||||
<h2>Queue</h2>
|
||||
<div>Now Playing: <b>\:currentTitle</b></div>
|
||||
\:content
|
||||
@@ -1,11 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small>\:name</small>
|
||||
\?shuffled? (shuffled)\;\;
|
||||
</div>
|
||||
\:content
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,11 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small><b>\:name</b></small>
|
||||
\?shuffled? (shuffled)\;\;
|
||||
</div>
|
||||
\:content
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small>repeat \:total times</small>
|
||||
</div>
|
||||
\:inner
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small><b>repeat \:total times</b></small>
|
||||
</div>
|
||||
\:inner
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small>repeat forever</small>
|
||||
</div>
|
||||
\:inner
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small><b>repeat forever</b></small>
|
||||
</div>
|
||||
\:inner
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small>random</small>
|
||||
</div>
|
||||
\:content
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small><b>random</b></small>
|
||||
</div>
|
||||
\:content
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small>shuffle</small>
|
||||
</div>
|
||||
\:content
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,10 +0,0 @@
|
||||
<div>
|
||||
<small>>></small>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<small><b>shuffle</b></small>
|
||||
</div>
|
||||
\:content
|
||||
<div>
|
||||
<small><<</small>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
</div>
|
||||
@@ -1,5 +0,0 @@
|
||||
<div>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
\:title
|
||||
</div>
|
||||
@@ -1,5 +0,0 @@
|
||||
<div>
|
||||
<button hx-post="/queue/remove/\:path" hx-swap="none">x</button>
|
||||
<button hx-post="/queue/goto/\:path" hx-swap="none">⏵</button>
|
||||
<b>\:title</b>
|
||||
</div>
|
||||
@@ -1,24 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||
<title>MusicDb</title>
|
||||
</head>
|
||||
<body>
|
||||
<div hx-sse="connect:/sse">
|
||||
<div hx-sse="swap:playing">(loading)</div>
|
||||
<button hx-post="/resume" hx-swap="none">⏵</button>
|
||||
<button hx-post="/pause" hx-swap="none">⏸</button>
|
||||
<button hx-post="/stop" hx-swap="none">⏹</button>
|
||||
<button hx-post="/next" hx-swap="none">⏭</button>
|
||||
<button hx-post="/queue/clear" hx-swap="none">-</button>
|
||||
<div hx-sse="swap:queue">(loading)</div>
|
||||
<div hx-sse="swap:artists">(loading)</div>
|
||||
<div id="artist-view"></div>
|
||||
<div id="album-view"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
<button hx-post="/queue/add-song/\:id" hx-swap="none">\:title</button>
|
||||
@@ -1,3 +1,4 @@
|
||||
#[cfg(feature = "website")]
|
||||
mod web;
|
||||
|
||||
use std::{
|
||||
@@ -5,7 +6,6 @@ use std::{
|
||||
path::PathBuf,
|
||||
process::exit,
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
};
|
||||
|
||||
use clap::Parser;
|
||||
@@ -47,8 +47,7 @@ struct Args {
|
||||
advanced_cache_song_lookahead_limit: u32,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
fn main() {
|
||||
// parse args
|
||||
let args = Args::parse();
|
||||
let mut database = if args.init {
|
||||
@@ -88,11 +87,25 @@ async fn main() {
|
||||
);
|
||||
};
|
||||
if let Some(addr) = &args.web {
|
||||
let (s, mut r) = tokio::sync::mpsc::channel(2);
|
||||
let db = Arc::clone(&database);
|
||||
thread::spawn(move || run_server(database, Some(s)));
|
||||
if let Some(sender) = r.recv().await {
|
||||
web::main(db, sender, *addr).await;
|
||||
#[cfg(not(feature = "website"))]
|
||||
{
|
||||
let _ = addr;
|
||||
eprintln!("Website support requires the 'website' feature to be enabled when compiling the server!");
|
||||
std::process::exit(80);
|
||||
}
|
||||
#[cfg(feature = "website")]
|
||||
{
|
||||
let (s, r) = std::sync::mpsc::sync_channel(1);
|
||||
let db = Arc::clone(&database);
|
||||
std::thread::spawn(move || {
|
||||
run_server(database, Some(Box::new(move |c| s.send(c).unwrap())))
|
||||
});
|
||||
let sender = r.recv().unwrap();
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(web::main(db, sender, *addr));
|
||||
}
|
||||
} else {
|
||||
run_server(database, None);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user