Skip to content

Commit d4aade5

Browse files
committed
cooking
1 parent 02c07f2 commit d4aade5

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "A simple discord bot made for my [discord](https://discord.gg/mY8
44
edition = "2021"
55
license = "Apache-2"
66
name = "tricked-bot"
7-
version = "1.4.0"
7+
version = "1.5.0"
88
default-run = "tricked-bot"
99

1010
[profile.release]

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
openssl
5757
];
5858

59+
postInstall = ''
60+
mkdir -p $out/share/tricked-bot
61+
cp -r web $out/share/tricked-bot/
62+
'';
63+
5964
meta = with pkgs.lib; {
6065
description = "A simple discord bot made for my discord";
6166
homepage = "https://discord.gg/mY8zTARu4g";

src/web/server.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@ pub struct AppState {
1414
}
1515

1616
pub async fn run_web_server(db: Pool<SqliteConnectionManager>, port: u16) -> Result<(), Box<dyn std::error::Error>> {
17-
let mut tera = Tera::new("web/templates/**/*")?;
17+
// Determine template path based on environment
18+
// For Nix builds: try to find data directory relative to executable
19+
let template_path = std::env::current_exe()
20+
.ok()
21+
.and_then(|exe| exe.parent().map(|p| p.to_path_buf()))
22+
.and_then(|bin_dir| bin_dir.parent().map(|p| p.to_path_buf()))
23+
.and_then(|out_dir| {
24+
let nix_path = out_dir.join("share/tricked-bot/web/templates");
25+
if nix_path.exists() {
26+
Some(format!("{}/**/*", nix_path.display()))
27+
} else {
28+
None
29+
}
30+
})
31+
.unwrap_or_else(|| "web/templates/**/*".to_string());
32+
33+
let mut tera = Tera::new(&template_path)?;
1834
tera.autoescape_on(vec!["html"]);
1935

2036
let state = AppState {

0 commit comments

Comments
 (0)