Basic frontend

I'm sorry for the big commit

- Added yarte templating engine
- Wrote frontend: all HTML except file input area, basic CSS (themes soon), JS.
No client-side encryption yet. And no working API.
- Simple but handy build system in Makefile
(requires pacman -S entr / apt install entr)
This commit is contained in:
DarkCat09 2024-03-09 16:17:18 +04:00
parent 4b6b3f7da4
commit 96376f2fba
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
12 changed files with 805 additions and 11 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target
/static/*.css
/static/*.map

590
Cargo.lock generated
View file

@ -26,6 +26,16 @@ dependencies = [
"memchr",
]
[[package]]
name = "annotate-snippets"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e"
dependencies = [
"unicode-width",
"yansi-term",
]
[[package]]
name = "async-channel"
version = "2.2.0"
@ -66,6 +76,12 @@ version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.2"
@ -114,6 +130,12 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "convert_case"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "cpufeatures"
version = "0.2.12"
@ -144,6 +166,21 @@ name = "dc09bin"
version = "0.1.0"
dependencies = [
"ntex",
"ntex-files",
"yarte",
]
[[package]]
name = "derive_more"
version = "0.99.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
"syn 1.0.109",
]
[[package]]
@ -156,6 +193,12 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "dtoa"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653"
[[package]]
name = "encoding_rs"
version = "0.8.33"
@ -211,24 +254,111 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "futf"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843"
dependencies = [
"mac",
"new_debug_unreachable",
]
[[package]]
name = "futures"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]]
name = "futures-executor"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]]
name = "futures-macro"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.50",
]
[[package]]
name = "futures-sink"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]]
name = "futures-task"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]]
name = "futures-timer"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
[[package]]
name = "futures-util"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]]
name = "fxhash"
version = "0.2.1"
@ -261,6 +391,17 @@ dependencies = [
"version_check",
]
[[package]]
name = "getrandom"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "gimli"
version = "0.28.1"
@ -296,6 +437,12 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "language-tags"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -314,6 +461,16 @@ version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "lock_api"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.20"
@ -334,6 +491,26 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "mac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "markup5ever"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016"
dependencies = [
"log",
"phf",
"phf_codegen",
"string_cache",
"string_cache_codegen",
"tendril",
]
[[package]]
name = "matchers"
version = "0.1.0"
@ -355,6 +532,16 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "miniz_oxide"
version = "0.7.2"
@ -381,6 +568,12 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
[[package]]
name = "new_debug_unreachable"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "ntex"
version = "1.1.0"
@ -389,7 +582,7 @@ checksum = "459affa3ce5e34ad01588f6bb090a13a334de1633d228653abe662af6b8bf21b"
dependencies = [
"async-channel",
"base64",
"bitflags",
"bitflags 2.4.2",
"encoding_rs",
"httparse",
"httpdate",
@ -428,7 +621,7 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb17fec7b1e5f1b504a7f2f02a05ccfe7ad9ecb47fa039a0d7f5a55ff940dfa"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"bytes",
"futures-core",
"serde",
@ -461,13 +654,35 @@ dependencies = [
"thiserror",
]
[[package]]
name = "ntex-files"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c487856bc8733bae14450ce8d0d83cdd474e68305d86160afb008fe1c9ef8c"
dependencies = [
"bitflags 2.4.2",
"derive_more",
"futures",
"http",
"httpdate",
"language-tags",
"log",
"mime",
"mime_guess",
"ntex",
"ntex-http",
"percent-encoding",
"unicase",
"v_htmlescape",
]
[[package]]
name = "ntex-h2"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d7eee598e3b94175cef2f8c3818b61460307be543f2d9132aac36ac8d78f3d5"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"fxhash",
"log",
"nanorand",
@ -503,7 +718,7 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ae09b6d287fb72d50804cac045fba24a9d871bb59472bd20321d18c6525141b"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"log",
"ntex-bytes",
"ntex-codec",
@ -592,7 +807,7 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caad794a6eb4d73fb4c13b7874fe3e6e9042deab50d6d325b584436efd0db433"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"futures-core",
"futures-sink",
"futures-timer",
@ -650,12 +865,73 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae"
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets 0.48.5",
]
[[package]]
name = "percent-encoding"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "phf"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
"phf_shared",
]
[[package]]
name = "phf_codegen"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
dependencies = [
"phf_generator",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared",
"rand",
]
[[package]]
name = "phf_shared"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096"
dependencies = [
"siphasher",
]
[[package]]
name = "pin-project-lite"
version = "0.2.13"
@ -682,6 +958,28 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "prettyplease"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86"
dependencies = [
"proc-macro2",
"syn 1.0.109",
]
[[package]]
name = "proc-macro2"
version = "1.0.78"
@ -700,6 +998,45 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "regex"
version = "1.10.3"
@ -750,13 +1087,22 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"errno",
"libc",
"linux-raw-sys",
@ -781,6 +1127,18 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
[[package]]
name = "serde"
version = "1.0.197"
@ -853,6 +1211,12 @@ dependencies = [
"libc",
]
[[package]]
name = "siphasher"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "slab"
version = "0.4.9"
@ -878,6 +1242,32 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "string_cache"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b"
dependencies = [
"new_debug_unreachable",
"once_cell",
"parking_lot",
"phf_shared",
"precomputed-hash",
"serde",
]
[[package]]
name = "string_cache_codegen"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988"
dependencies = [
"phf_generator",
"phf_shared",
"proc-macro2",
"quote",
]
[[package]]
name = "syn"
version = "1.0.109"
@ -900,6 +1290,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "tendril"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0"
dependencies = [
"futf",
"mac",
"utf-8",
]
[[package]]
name = "thiserror"
version = "1.0.57"
@ -945,6 +1346,15 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "toml"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"serde",
]
[[package]]
name = "tracing"
version = "0.1.40"
@ -1012,12 +1422,55 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicase"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "unicode-xid"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "utf-8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "v_eval"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd8b599d797eb038d0dde9a3860aacb6bbba3bffa4ac64f807c8673820cc9d9"
dependencies = [
"regex",
"syn 1.0.109",
]
[[package]]
name = "v_htmlescape"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"
[[package]]
name = "valuable"
version = "0.1.0"
@ -1198,3 +1651,128 @@ name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "yansi-term"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1"
dependencies = [
"winapi",
]
[[package]]
name = "yarte"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfce1df93f3b16e5272221a559e60bbbaaa71dbc042a43996d223e51a690aab2"
dependencies = [
"yarte_derive",
"yarte_helpers",
]
[[package]]
name = "yarte_codegen"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a79312078b97a195de91a8c1457c2e0d7abd97e6e605f3cdeb01b3c105d2cff"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"yarte_dom",
"yarte_helpers",
"yarte_hir",
"yarte_html",
]
[[package]]
name = "yarte_derive"
version = "0.15.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b296edd7e1a81717b6f794baa2de8dfe89646050847161550b2d963b3ca6fe80"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"yarte_codegen",
"yarte_helpers",
"yarte_hir",
"yarte_parser",
]
[[package]]
name = "yarte_dom"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "333bb63a5c0abdfd635b0e3238e0308d6e7dd12787cef875c9272ae6cb114324"
dependencies = [
"markup5ever",
"quote",
"syn 1.0.109",
"yarte_helpers",
"yarte_hir",
"yarte_html",
]
[[package]]
name = "yarte_helpers"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0d1076f8cee9541ea5ffbecd9102f751252c91f085e7d30a18a3ce805ebd3ee"
dependencies = [
"dtoa",
"itoa",
"prettyplease",
"serde",
"syn 1.0.109",
"toml",
"v_htmlescape",
]
[[package]]
name = "yarte_hir"
version = "0.15.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee42d2f704a3b1d8bc111d47a705d1302a0943d85e4c230f4e8300ee0dde4a6"
dependencies = [
"derive_more",
"proc-macro2",
"quote",
"syn 1.0.109",
"v_eval",
"v_htmlescape",
"yarte_helpers",
"yarte_parser",
]
[[package]]
name = "yarte_html"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03e1fb0c85969cbe25b8a3031b278b484025882e20cadbc81735444c6e3d7613"
dependencies = [
"log",
"mac",
"markup5ever",
"proc-macro2",
"quote",
"syn 1.0.109",
"yarte_parser",
]
[[package]]
name = "yarte_parser"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "538f72049cf7104e12d5c444048d112cb8fc788a31308afd912442a381ba860c"
dependencies = [
"annotate-snippets",
"derive_more",
"proc-macro2",
"quote",
"serde",
"syn 1.0.109",
"unicode-xid",
"yarte_helpers",
]

View file

@ -7,3 +7,8 @@ edition = "2021"
[dependencies]
ntex = { version = "1.1.0", features = ["tokio"] }
ntex-files = "0.4"
yarte = { version = "0.15.7", features = ["html-min"] }
[build-dependencies]
yarte = "0.15.7"

12
Makefile Normal file
View file

@ -0,0 +1,12 @@
watch-scss:
@sass --watch scss:static
build-scss:
@sass scss:static -s compressed
build:
make build-scss
cargo build --release
dev:
@while sleep 0.1; do find ./templates -type f | entr -d -r cargo run && break; done

66
scss/style.scss Normal file
View file

@ -0,0 +1,66 @@
body {
margin: 0;
padding: 0;
}
main {
max-width: 50rem;
margin: 0 auto;
padding: 0 0.5rem;
font-family: system-ui, sans-serif;
}
header {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
column-gap: 1.25rem;
font-size: 1.125rem;
}
header>label {
cursor: pointer;
}
.htab {
display: none;
}
#htab-file:checked~#tab-link {
display: none;
}
#htab-link:checked~#tab-file {
display: none;
}
.form-footer {
display: flex;
flex-direction: row;
justify-content: space-between;
div {
display: flex;
flex-direction: column;
}
div:last-child {
justify-content: end;
}
label {
display: flex;
flex-direction: row;
align-items: center;
gap: 0.25rem;
}
input[type=radio],
input[type=checkbox] {
margin: 0;
margin-left: 0.25rem;
padding: 0;
}
}

View file

@ -1,11 +1,16 @@
use ntex::web::{self, App};
use ntex_files;
mod pages;
#[ntex::main]
async fn main() -> std::io::Result<()> {
web::server(move || App::new().service(pages::index))
.bind("127.0.0.1:3002")?
.run()
.await
web::server(move || {
App::new()
.service(pages::index)
.service(ntex_files::Files::new("/static", "./static"))
})
.bind("127.0.0.1:3002")?
.run()
.await
}

View file

@ -1,8 +1,13 @@
use ntex::web::{self, HttpResponse};
use yarte::TemplateMin;
#[derive(TemplateMin)]
#[template(path = "index")]
struct MainPageTemplate;
#[web::get("/")]
pub async fn index() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body("<h1>dc09's bin</h1>")
.body(MainPageTemplate {}.to_string())
}

29
static/script.js Normal file
View file

@ -0,0 +1,29 @@
addEventListener('DOMContentLoaded', () => {
// show password while user holds button
const showPswdBtns = document.getElementsByClassName('show-pswd')
for (let el of showPswdBtns) {
const inp = document.getElementById(el.dataset.input)
el.addEventListener('mousedown', () => inp.type = 'text')
el.addEventListener('mouseup', () => inp.type = 'password')
}
// add file input by cloning #file-tmpl-js (see index.hbs)
const filesContainer = document.querySelector('#tab-file>.form-main')
const fileTemplate = document.querySelector('#file-tmpl-js>div')
document.getElementById('add-file').addEventListener('click', () => {
filesContainer.append(fileTemplate.cloneNode(true))
})
// make tabs usable from keyboard:
// when focused on label, space or enter triggers
// click on hidden input[type=radio]
const tabLabels = document.querySelectorAll('header>label')
for (let el of tabLabels) {
const inp = document.getElementById(el.htmlFor)
el.addEventListener('keyup', (ev) => {
if (ev.key == " " || ev.key == "Enter") {
inp.click()
}
})
}
})

3
templates/file.hbs Normal file
View file

@ -0,0 +1,3 @@
<div>
File
</div>

84
templates/index.hbs Normal file
View file

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dc09bin</title>
<link rel="stylesheet" href="/static/style.css">
<script src="/static/script.js"></script>
</head>
<body>
<div id="file-tmpl-js" style="display:none" aria-hidden="true">
{{> file }}
</div>
<main>
<header>
<label for="htab-file" tabindex="0" role="tab">File</label>
<label for="htab-link" tabindex="0" role="tab">Link</label>
</header>
<input type="radio" name="tab" class="htab" id="htab-file" aria-hidden="true" checked>
<input type="radio" name="tab" class="htab" id="htab-link" aria-hidden="true">
<form action="/api/upload" method="post" id="tab-file" role="tabpanel">
{{> no-auto-submit }}
<div class="form-main">
{{> file }}
</div>
<div class="form-footer">
<div>
<span>Encryption:</span>
<label><input type="radio" name="enc" id="enc-off">Off</label>
<label><input type="radio" name="enc" id="enc-random" checked>Random key</label>
<label for="enc-pswd">
<input type="radio" name="enc" id="enc-pswd">
Custom password:
<input type="password" id="enc-pswd-input">
<button type="button" class="show-pswd" data-input="enc-pswd-input">Show</button>
</label>
</div>
<div>
<button type="button" id="add-file">Add file</button>
<button type="submit">Upload</button>
</div>
</div>
</form>
<form action="/api/shorten" method="post" id="tab-link" role="tabpanel">
{{> no-auto-submit }}
<div class="form-main">
{{> link }}
</div>
<div class="form-footer">
<div>
<span>Link ID:</span>
<label for="link-rand">
<input type="radio" name="linkid" id="link-rand" checked>
<div>
<span>Random</span>
</div>
</label>
<label>
<input type="radio" disabled style="opacity:0" aria-hidden="true">
<div>
<label>Length: <input type="number" name="link-rand-len" min="4" max="20" size="5" value="6"></label>
<label>Exclude symbols: <input type="text" size="5" value="lIO"></label>
</div>
</label>
<label for="link-custom">
<input type="radio" name="linkid" id="link-custom">
Custom:
<input type="text" name="link-custom-input" minlength="4" maxlength="30" pattern="^[A-Za-z0-9_-]+$">
</label>
<label for="link-pswd">
<input type="checkbox" id="link-pswd">
Password:
<input type="password" id="link-pswd-input">
<button type="button" class="show-pswd" data-input="link-pswd-input">Show</button>
</label>
</div>
<div>
<button type="submit">Shorten</button>
</div>
</div>
</form>
</main>
</body>
</html>

3
templates/link.hbs Normal file
View file

@ -0,0 +1,3 @@
<div class="link-input-wrapper">
<input type="text" name="long-link" placeholder="paste a long link">
</div>

View file

@ -0,0 +1,2 @@
{{! huge thanks to https://stackoverflow.com/a/51507806 !}}
<button type="submit" disabled style="display:none" aria-hidden="true"></button>