Compare commits

...

3 Commits

Author SHA1 Message Date
blek 3ba86697b7
fix minor git issues with docker 2023-10-09 22:46:47 +10:00
blek f7e69e5067
display the commit hash on the footer 2023-10-09 22:46:32 +10:00
blek 7c525808a4
add note about build dependencies 2023-10-09 20:55:26 +10:00
8 changed files with 76 additions and 3 deletions

View File

@ -8,6 +8,7 @@ services:
bfile:
volumes:
- './filed:/opt/code'
- './.git:/opt/code/.git:ro' # for fetching the latest commit version
- '/opt/code/target'
- './volatile/files:/opt/user_uploads'
caddy:

59
filed/Cargo.lock generated
View File

@ -32,6 +32,12 @@ dependencies = [
"libc",
]
[[package]]
name = "anyhow"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "askama"
version = "0.12.0"
@ -280,6 +286,7 @@ dependencies = [
"serde",
"serde_json",
"sha2",
"static_dir",
"tokio",
"warp",
]
@ -541,6 +548,29 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "include_dir"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24b56e147e6187d61e9d0f039f10e070d0c0a887e24fe0bb9ca3f29bfde62cab"
dependencies = [
"include_dir_impl",
"proc-macro-hack",
]
[[package]]
name = "include_dir_impl"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df"
dependencies = [
"anyhow",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "indexmap"
version = "1.9.3"
@ -812,6 +842,12 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro-hack"
version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
version = "1.0.67"
@ -1018,6 +1054,23 @@ version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "static_dir"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8286dc044d09abcb8bf85440b94f2c41aee322733a58cd195cf830ee660cadf5"
dependencies = [
"headers",
"http",
"hyper",
"include_dir",
"log",
"mime_guess",
"once_cell",
"urlencoding",
"warp",
]
[[package]]
name = "sval"
version = "2.9.1"
@ -1307,6 +1360,12 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "urlencoding"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a1f0175e03a0973cf4afd476bef05c26e228520400eb1fd473ad417b1c00ffb"
[[package]]
name = "utf-8"
version = "0.7.6"

View File

@ -20,5 +20,6 @@ redis = { version = "0.23.3", features = ["tokio"] }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
sha2 = "0.10.8"
static_dir = "0.2.0"
tokio = { version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] }
warp = "0.3.6"

View File

@ -4,6 +4,8 @@ FROM rust as builder
WORKDIR /opt/code
COPY . .
RUN apt install -y git
# No build is done during this step
# since the directory will be mounted anyways
# to the dev's machine.

View File

@ -3,6 +3,11 @@ This is a part of blek! File that is responsible for serving and uploading files
This module is released under the GPLv3 with additions, copy of which is included in the top level of this repository.
## Building
First, install the build dependencies:
1. Rust toolchain
2. Git (latest version)
To get started with this, copy either `Dockerfile.dev` or `Dockerfile.prod` to `Dockerfile`, depending on your environment.
Then either build it manually or start it up using the `docker-compose.yml` file, which is provided in the top level directory.

View File

@ -70,4 +70,8 @@ impl Env {
pub fn usercontent_dir(self: &Self) -> Box<&Path> {
Box::new(Path::new(&self.filedir))
}
pub fn shortcommit(self: &Self) -> String {
let commit = self.last_commit.to_string().clone();
commit.chars().take(6).collect()
}
}

View File

@ -31,7 +31,7 @@
<tbody>
<tr>
<td>
Made with Rust
bleK! File {{ env.shortcommit() }}
</td>
<td>
Released under GPLv3

View File

@ -50,8 +50,9 @@
<input type="checkbox" name="passworded">
I want to add a password to the file:
<span style="font-size:80%;display:block;padding:2px 0 0 24px">
Warning: the file WILL NOT be encrypted.<br/>
<span style="font-size:80%;display:block">
Warning: the file WILL NOT be encrypted,<br/>
therefore this is not 100% secure.<br/>
<a href="/passworded-files">
Learn more
</a>