diff --git a/.gitignore b/.gitignore index a422ad2..3059489 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/dist + /target **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock index e1e54f7..dc529f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1710,7 +1710,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "upend-rust" +name = "upend" version = "0.1.0" dependencies = [ "actix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 1e788a6..72f025a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "upend-rust" +name = "upend" version = "0.1.0" authors = ["Tomáš Mládek "] edition = "2018" @@ -32,4 +32,4 @@ bs58 = "0.3.1" dotenv = "0.15.0" xdg = "^2.1" -webbrowser = "0.5.5" \ No newline at end of file +webbrowser = "0.5.5" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bb79bda --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ + +all: backend frontend + rm -fr dist + mkdir dist + cp target/release/upend dist/upend + cp -r ui/dist dist/webui + +backend: + cargo build --release + +frontend: + cd ui && \ + npm install && \ + npm run build + +clean: + rm -r target + rm -r ui/node_modules ui/dist \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 220b280..89852d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,6 +77,13 @@ fn main() -> std::io::Result<()> { .service(routes::get_raw) .service(routes::get_lookup) .service(routes::api_refresh) + .service( + actix_files::Files::new( + "/", + env::current_exe().unwrap().parent().unwrap().join("webui"), + ) + .index_file("index.html"), + ) }) .bind(&bind)? .run(); @@ -87,7 +94,7 @@ fn main() -> std::io::Result<()> { } // TODO REMOVE - if !matches.is_present("NO_BROWSER") && false { + if !matches.is_present("NO_BROWSER") { let ui_result = webbrowser::open(&format!("http://localhost:{}", bind.port())); if ui_result.is_err() { warn!("Could not open UI in browser!");