aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-01 10:14:20 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-01 10:14:20 +0200
commit3fa55dba1b0ca408a10e7456a6d4308dd114c2f6 (patch)
treef1f378662406a5f091816ca97c3f1ccfb5210eef
parentd857684dd6358fb5ff979ca09ac78b5649b0f411 (diff)
downloadjellything-3fa55dba1b0ca408a10e7456a6d4308dd114c2f6.tar
jellything-3fa55dba1b0ca408a10e7456a6d4308dd114c2f6.tar.bz2
jellything-3fa55dba1b0ca408a10e7456a6d4308dd114c2f6.tar.zst
move stylesheets and refactor js bundler
-rw-r--r--Cargo.lock1
-rw-r--r--server/Cargo.toml3
-rw-r--r--server/build.rs24
-rw-r--r--server/src/routes/ui/style.rs (renamed from server/src/routes/ui/style/mod.rs)25
-rw-r--r--web/cantarell.woff2 (renamed from server/src/routes/ui/style/cantarell.woff2)bin93888 -> 93888 bytes
-rw-r--r--web/forms.css (renamed from server/src/routes/ui/style/forms.css)0
-rw-r--r--web/js-player.css (renamed from server/src/routes/ui/style/js-player.css)0
-rw-r--r--web/layout.css (renamed from server/src/routes/ui/style/layout.css)0
-rw-r--r--web/nodecard.css (renamed from server/src/routes/ui/style/nodecard.css)0
-rw-r--r--web/nodepage.css (renamed from server/src/routes/ui/style/nodepage.css)0
-rw-r--r--web/player.css (renamed from server/src/routes/ui/style/player.css)0
-rw-r--r--web/script/js-player.js (renamed from server/src/routes/ui/style/js-player.js)0
-rw-r--r--web/script/main.ts1
-rw-r--r--web/script/playerconf-copy-url.js (renamed from server/src/routes/ui/style/playerconf-copy-url.js)0
-rw-r--r--web/script/transition.js (renamed from server/src/routes/ui/style/transition.js)0
15 files changed, 42 insertions, 12 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ddcd85e..d74439f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1469,6 +1469,7 @@ dependencies = [
"chrono",
"env_logger",
"futures",
+ "glob",
"jellybase",
"jellyclient",
"jellycommon",
diff --git a/server/Cargo.toml b/server/Cargo.toml
index fbb9f63..efecfe5 100644
--- a/server/Cargo.toml
+++ b/server/Cargo.toml
@@ -36,5 +36,8 @@ rocket = { workspace = true, features = ["secrets", "json"] }
sled = "0.34.7"
typed-sled = "0.2.3"
+[build-dependencies]
+glob = "0.3.1"
+
[features]
bypass-auth = []
diff --git a/server/build.rs b/server/build.rs
new file mode 100644
index 0000000..8b067a6
--- /dev/null
+++ b/server/build.rs
@@ -0,0 +1,24 @@
+use std::process::Command;
+
+fn main() {
+ println!("cargo:rerun-if-changed=build.rs");
+ for file in glob::glob("../web/scripts/**/*.ts")
+ .unwrap()
+ .map(Result::unwrap)
+ {
+ println!("cargo:rerun-if-changed={}", file.to_str().unwrap());
+ }
+ Command::new("esbuild")
+ .arg("../web/script/main.ts")
+ .arg("--bundle")
+ .arg(format!(
+ "--outfile={}/bundle.js",
+ std::env::var("OUT_DIR").unwrap()
+ ))
+ .arg("--target=esnext")
+ .arg("--sourcemap")
+ .arg("--sourcemap")
+ .arg("--format=esm")
+ .output()
+ .unwrap();
+}
diff --git a/server/src/routes/ui/style/mod.rs b/server/src/routes/ui/style.rs
index 4a6830f..9a7fc48 100644
--- a/server/src/routes/ui/style/mod.rs
+++ b/server/src/routes/ui/style.rs
@@ -7,7 +7,7 @@
use rocket::{get, http::ContentType};
macro_rules! concat_files {
- ($($files:literal),*) => {{
+ ([$base: expr], $($files:literal),*) => {{
#[cfg(debug_assertions)]
{
use std::{fs::read_to_string, path::PathBuf, str::FromStr};
@@ -15,10 +15,10 @@ macro_rules! concat_files {
.into_iter()
.map(|n| {
read_to_string(
- PathBuf::from_str(file!())
- .unwrap()
- .parent()
- .unwrap()
+ PathBuf::from_str(file!()).unwrap()
+ .parent().unwrap()
+ .parent().unwrap()
+ .parent().unwrap()
.join(n),
)
.unwrap()
@@ -27,12 +27,12 @@ macro_rules! concat_files {
.join("\n")
}
#[cfg(not(debug_assertions))]
- concat!($(include_str!($files)),*).to_string()
+ concat!($(include_str!(concat!($base, "/", $files))),*).to_string()
}};
}
fn css_bundle() -> String {
- concat_files!(
+ concat_files!(["../../../../web"],
"layout.css",
"player.css",
"nodepage.css",
@@ -43,10 +43,8 @@ fn css_bundle() -> String {
}
fn js_bundle() -> String {
- concat_files!(
- // "transition.js",
- "playerconf-copy-url.js",
- "js-player.js"
+ concat_files!([env!("OUT_DIR")],
+ "bundle.js"
)
}
@@ -57,7 +55,10 @@ pub fn r_assets_style() -> (ContentType, String) {
#[get("/assets/cantarell.woff2")]
pub fn r_assets_font() -> (ContentType, &'static [u8]) {
- (ContentType::WOFF2, include_bytes!("cantarell.woff2"))
+ (
+ ContentType::WOFF2,
+ include_bytes!("../../../../web/cantarell.woff2"),
+ )
}
#[get("/assets/bundle.js")]
diff --git a/server/src/routes/ui/style/cantarell.woff2 b/web/cantarell.woff2
index 76fd894..76fd894 100644
--- a/server/src/routes/ui/style/cantarell.woff2
+++ b/web/cantarell.woff2
Binary files differ
diff --git a/server/src/routes/ui/style/forms.css b/web/forms.css
index 259d7ef..259d7ef 100644
--- a/server/src/routes/ui/style/forms.css
+++ b/web/forms.css
diff --git a/server/src/routes/ui/style/js-player.css b/web/js-player.css
index 79dffa0..79dffa0 100644
--- a/server/src/routes/ui/style/js-player.css
+++ b/web/js-player.css
diff --git a/server/src/routes/ui/style/layout.css b/web/layout.css
index 92a8929..92a8929 100644
--- a/server/src/routes/ui/style/layout.css
+++ b/web/layout.css
diff --git a/server/src/routes/ui/style/nodecard.css b/web/nodecard.css
index bfc0b74..bfc0b74 100644
--- a/server/src/routes/ui/style/nodecard.css
+++ b/web/nodecard.css
diff --git a/server/src/routes/ui/style/nodepage.css b/web/nodepage.css
index e40706e..e40706e 100644
--- a/server/src/routes/ui/style/nodepage.css
+++ b/web/nodepage.css
diff --git a/server/src/routes/ui/style/player.css b/web/player.css
index eb1a0a0..eb1a0a0 100644
--- a/server/src/routes/ui/style/player.css
+++ b/web/player.css
diff --git a/server/src/routes/ui/style/js-player.js b/web/script/js-player.js
index 7c3bb43..7c3bb43 100644
--- a/server/src/routes/ui/style/js-player.js
+++ b/web/script/js-player.js
diff --git a/web/script/main.ts b/web/script/main.ts
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/web/script/main.ts
@@ -0,0 +1 @@
+
diff --git a/server/src/routes/ui/style/playerconf-copy-url.js b/web/script/playerconf-copy-url.js
index 49f27fd..49f27fd 100644
--- a/server/src/routes/ui/style/playerconf-copy-url.js
+++ b/web/script/playerconf-copy-url.js
diff --git a/server/src/routes/ui/style/transition.js b/web/script/transition.js
index 7d39176..7d39176 100644
--- a/server/src/routes/ui/style/transition.js
+++ b/web/script/transition.js