tangled
alpha
login
or
join now
j0.lol
/
bog
1
fork
atom
Blog attempt 5
1
fork
atom
overview
issues
1
pulls
pipelines
Fix bug in job banner hiding. Add js cachebusting.
j0.lol
4 months ago
cddfff7d
1726584f
+23
-8
4 changed files
expand all
collapse all
unified
split
Cargo.toml
build.rs
src
index.js
template.rs
+2
-1
Cargo.toml
reviewed
···
8
8
chrono = { version = "0.4", features = ["serde"] }
9
9
maud = { version = "0.27", features = ["poem"] }
10
10
poem = { version = "3", features = ["static-files", "chrono", "cookie"] }
11
11
-
rand = "0.9"
12
11
rusqlite = { version = "0.37.0", features = ["chrono", "bundled"] }
13
12
rusqlite_migration = "2.3.0"
14
13
serde = "1"
···
23
22
derive_typst_intoval = "0.5.0"
24
23
autumnus = { version = "0.7", features = ["all-languages"]}
25
24
makup = { git = "https://tangled.org/j0.lol/makup", version = "0.1.0" }
25
25
+
rand = "0.9"
26
26
27
27
[build-dependencies]
28
28
vergen-git2 = { version = "1", features = ["build", "cargo", "rustc", "si"] }
29
29
+
rand = "0.9"
+17
-4
build.rs
reviewed
···
1
1
use std::{env, error::Error, fs::copy, path::PathBuf, process::Command};
2
2
3
3
+
use rand::distr::Alphabetic;
3
4
use vergen_git2::{BuildBuilder, CargoBuilder, Emitter, Git2Builder, RustcBuilder, SysinfoBuilder};
4
5
5
6
pub fn main() -> Result<(), Box<dyn Error>> {
···
10
11
}
11
12
12
13
pub fn bundle_js() -> Result<(), Box<dyn Error>> {
13
13
-
println!("cargo::rerun-if-changed=src/index.js");
14
14
-
println!("cargo::rerun-if-changed=src/login.js");
15
15
-
println!("cargo::rerun-if-changed=src/bun.lock");
14
14
+
use rand::Rng;
15
15
+
let mut rng = rand::rng();
16
16
+
17
17
+
// println!("cargo::rerun-if-changed=src/index.js");
18
18
+
// println!("cargo::rerun-if-changed=src/login.js");
19
19
+
// println!("cargo::rerun-if-changed=src/bun.lock");
20
20
+
21
21
+
let env_name = "CACHEBUSTING-HASH";
22
22
+
let env_var: String = (&mut rng)
23
23
+
.sample_iter(Alphabetic)
24
24
+
.take(16)
25
25
+
.map(char::from)
26
26
+
.collect();
27
27
+
28
28
+
println!("cargo:rustc-env={env_name}={env_var}");
16
29
17
30
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
18
31
let out_dir = out_dir.to_str().ok_or("malformed osstr")?;
···
20
33
let status = Command::new("bun")
21
34
.args([
22
35
"build",
23
23
-
&format!("--outfile={out_dir}/bundle.js"),
36
36
+
&format!("--outfile={out_dir}/bundle-{env_var}.js"),
24
37
"src/index.js",
25
38
])
26
39
.status()?;
+2
-2
src/index.js
reviewed
···
9
9
10
10
/* Lasts for browser session */
11
11
document.cookie =
12
12
-
"HideJobCallout=true; max-age=7200; SameSite=strict; Secure";
12
12
+
"HideJobCallout=true; max-age=7200; SameSite=strict; Path=/; Secure";
13
13
});
14
14
15
15
job_button_forever?.addEventListener("click", (e) => {
···
17
17
18
18
/* 10 years should outlast this notice */
19
19
document.cookie =
20
20
-
"HideJobCallout=true; max-age=315360000; SameSite=strict; Secure";
20
20
+
"HideJobCallout=true; max-age=315360000; SameSite=strict; Path=/; Secure";
21
21
});
22
22
23
23
if (
+2
-1
src/template.rs
reviewed
···
12
12
13
13
#[must_use]
14
14
pub fn header_extra(markup: &Markup) -> Markup {
15
15
+
let bundle_path = format!("/dist/bundle-{}.js", env!("CACHEBUSTING-HASH"));
15
16
html! {
16
17
(DOCTYPE)
17
18
head {
···
25
26
meta name="theme-color" content="#b497ee";
26
27
meta name="apple-mobile-web-app-status-bar-style" content="#b497ee";
27
28
28
28
-
script defer src="/dist/bundle.js" {}
29
29
+
script defer src=(bundle_path) {}
29
30
link rel="stylesheet" type="text/css" href="/dist/modern-normalize.css";
30
31
31
32
link rel="icon" href="/static/favicon.ico" sizes="any";