diff --git a/Cargo.lock b/Cargo.lock index 3814888..fbe7340 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,6 +53,42 @@ dependencies = [ "serde", ] +[[package]] +name = "async-nats" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83a251fa1a4c9d0fe6e816b7acd60549e473e08d14f27a1d992c2675abff05f" +dependencies = [ + "base64", + "bytes", + "futures-util", + "memchr", + "nkeys", + "nuid", + "pin-project", + "portable-atomic", + "rand 0.10.2", + "regex", + "ring", + "rustls-native-certs", + "rustls-pki-types", + "rustls-webpki 0.103.13", + "serde", + "serde_json", + "serde_nanos", + "serde_repr", + "thiserror 2.0.19", + "time", + "tokio", + "tokio-rustls 0.26.4", + "tokio-stream", + "tokio-util", + "tokio-websockets", + "tracing", + "tryhard", + "url", +] + [[package]] name = "async-trait" version = "0.1.91" @@ -108,12 +144,70 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + [[package]] name = "bit-set" version = "0.8.0" @@ -185,6 +279,9 @@ name = "bytes" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +dependencies = [ + "serde", +] [[package]] name = "cast" @@ -313,6 +410,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "core-foundation" version = "0.9.4" @@ -484,6 +587,32 @@ dependencies = [ "cmov", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "darling" version = "0.20.11" @@ -539,6 +668,17 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.5.8" @@ -603,6 +743,28 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "sha2 0.10.9", + "signature", + "subtle", +] + [[package]] name = "either" version = "1.17.0" @@ -659,7 +821,7 @@ dependencies = [ ] [[package]] -name = "ewectionbot" +name = "ewectionbot-discord" version = "0.1.0" dependencies = [ "bitvec", @@ -691,6 +853,12 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -1032,12 +1200,24 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-range-header" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" + [[package]] name = "httparse" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + [[package]] name = "hybrid-array" version = "0.4.13" @@ -1061,6 +1241,7 @@ dependencies = [ "http", "http-body", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -1258,6 +1439,12 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +[[package]] +name = "itoap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" + [[package]] name = "jni" version = "0.22.4" @@ -1402,6 +1589,12 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "md-5" version = "0.11.0" @@ -1464,6 +1657,21 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "nkeys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879011babc47a1c7fdf5a935ae3cfe94f34645ca0cac1c7f6424b36fc743d1bf" +dependencies = [ + "data-encoding", + "ed25519", + "ed25519-dalek", + "getrandom 0.2.17", + "log", + "rand 0.8.7", + "signatory", +] + [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -1473,6 +1681,15 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "nuid" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc895af95856f929163a0aa20c26a78d26bfdc839f51b9d5aa7a5b79e52b7e83" +dependencies = [ + "rand 0.8.7", +] + [[package]] name = "num-conv" version = "0.2.2" @@ -1545,18 +1762,57 @@ dependencies = [ "windows-link", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "pin-project-lite" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.33" @@ -1610,6 +1866,12 @@ dependencies = [ "trim-in-place", ] +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + [[package]] name = "potential_utf" version = "0.1.5" @@ -1936,7 +2198,7 @@ dependencies = [ "tokio-rustls 0.26.4", "tokio-util", "tower", - "tower-http", + "tower-http 0.6.11", "tower-service", "url", "wasm-bindgen", @@ -1978,7 +2240,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.4", "tower", - "tower-http", + "tower-http 0.6.11", "tower-service", "url", "wasm-bindgen", @@ -2268,6 +2530,37 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_nanos" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a93142f0367a4cc53ae0fead1bcda39e85beccfad3dcd717656cacab94b12985" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "serde_spanned" version = "1.1.1" @@ -2401,6 +2694,28 @@ dependencies = [ "libc", ] +[[package]] +name = "signatory" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e303f8205714074f6068773f0e29527e0453937fe837c9717d066635b65f31" +dependencies = [ + "pkcs8", + "rand_core 0.6.4", + "signature", + "zeroize", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "simd-adler32" version = "0.3.10" @@ -2457,6 +2772,16 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "sqlx" version = "0.9.0" @@ -2864,9 +3189,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.53.1" +version = "1.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" dependencies = [ "bytes", "libc", @@ -2952,6 +3277,27 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-websockets" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f591660438b3038dd04d16c938271c79e7e06260ad2ea2885a4861bfb238605d" +dependencies = [ + "base64", + "bytes", + "futures-core", + "futures-sink", + "http", + "httparse", + "rand 0.8.7", + "ring", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.4", + "tokio-util", + "webpki-roots 0.26.11", +] + [[package]] name = "toml" version = "1.1.3+spec-1.1.0" @@ -3004,6 +3350,7 @@ dependencies = [ "tokio", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -3024,6 +3371,31 @@ dependencies = [ "url", ] +[[package]] +name = "tower-http" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -3110,6 +3482,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tryhard" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fe58ebd5edd976e0fe0f8a14d2a04b7c81ef153ea9a54eebc42e67c2c23b4e5" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tungstenite" version = "0.21.0" @@ -3231,6 +3613,38 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "vy" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca9415823937514bbba8aeddee84871f1b137f107878a0fdebf6c8ec2846b3a6" +dependencies = [ + "vy-core", + "vy-macros", +] + +[[package]] +name = "vy-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95c86e70f659b92a9bb20120384e1af5a29eac7f926c484b51fad034e45c8acf" +dependencies = [ + "itoap", + "ryu", +] + +[[package]] +name = "vy-macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567c0fb4cea81da221859fbcffa37f614c0460f8804f058c0973b76b571997db" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "vy-core", +] + [[package]] name = "wait-timeout" version = "0.2.1" @@ -3389,6 +3803,19 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "webvoting" +version = "0.1.0" +dependencies = [ + "async-nats", + "axum", + "tokio", + "tower", + "tower-http 0.7.1", + "tower-layer", + "vy", +] + [[package]] name = "whoami" version = "2.1.2" diff --git a/Cargo.toml b/Cargo.toml index ee6654a..678e0f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,46 +1,11 @@ -[package] -name = "ewectionbot" -version = "0.1.0" -edition = "2024" -license-file = "LICENSE" +[workspace] +resolver = "3" +members = [ + "discord", + "webvoting", +] -[features] -default = [] -resign = [] - -[dependencies] -bitvec = "1.1.1" -futures = "0.3.33" -hashbrown = { version = "0.17.1", features = ["rayon", "serde"] } -itertools = "0.15.0" -mimalloc = "0.1.52" -poise = { version = "0.6.2", default-features = false, features = ["cache", "handle_panics"] } -rand = "0.10.2" -rayon = "1.12.0" -reqwest = { version = "0.13.4", features = ["json"] } -serde = { version = "1.0.229", features = ["derive"] } -serde_json = "1.0.151" -serenity = { version = "0.12.5", default-features = false, features = ["rustls_backend"] } -sqlx = { version = "0.9.0", default-features = false, features = ["macros", "migrate", "runtime-tokio", "sqlite"] } -thiserror = "2.0.19" -time = { version = "0.3.54", features = ["formatting", "macros", "parsing", "serde"] } -tokio = { version = "1.53.1", features = ["full"] } -toml = "1.1.3" -tracing = "0.1.44" -tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } - -[build-dependencies] -time = { version = "0.3.54", features = ["formatting", "macros", "serde"] } - -[dev-dependencies] -criterion = { version = "0.8.2", features = ["html_reports"] } -proptest = "1.11.0" - -[[bench]] -harness = false -name = "pav_bench" - -[lints.clippy] +[workspace.lints.clippy] borrow_as_ptr = "warn" cast_lossless = "warn" derive_partial_eq_without_eq = "warn" diff --git a/README.md b/README.md index 2c1188e..233d68a 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Copyright (C) 2026 Kiran “vavakado” Rubin -This work is licensed under the Cooperative Non-Violent Public License. -See the LICENSE file for full terms. +This work is licensed under the AGPL 3.0-or-later. +See the REUSE.toml and LICENSES/ file for full terms. [badge-license]: https://img.shields.io/badge/License-AGPL-red.svg [license]: https://git.vavakado.xyz/me/ewectionbot/src/branch/mistress/LICENSES/AGPL-3.0-or-later.txt diff --git a/discord/Cargo.toml b/discord/Cargo.toml new file mode 100644 index 0000000..6d64f59 --- /dev/null +++ b/discord/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "ewectionbot-discord" +version = "0.1.0" +edition = "2024" + +[features] +default = [] +resign = [] + +[dependencies] +bitvec = "1.1.1" +futures = "0.3.33" +hashbrown = { version = "0.17.1", features = ["rayon", "serde"] } +itertools = "0.15.0" +mimalloc = "0.1.52" +poise = { version = "0.6.2", default-features = false, features = ["cache", "handle_panics"] } +rand = "0.10.2" +rayon = "1.12.0" +reqwest = { version = "0.13.4", features = ["json"] } +serde = { version = "1.0.229", features = ["derive"] } +serde_json = "1.0.151" +serenity = { version = "0.12.5", default-features = false, features = ["rustls_backend"] } +sqlx = { version = "0.9.0", default-features = false, features = ["macros", "migrate", "runtime-tokio", "sqlite"] } +thiserror = "2.0.19" +time = { version = "0.3.54", features = ["formatting", "macros", "parsing", "serde"] } +tokio = { version = "1.53.1", features = ["full"] } +toml = "1.1.3" +tracing = "0.1.44" +tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } + +[build-dependencies] +time = { version = "0.3.54", features = ["formatting", "macros", "serde"] } + +[dev-dependencies] +criterion = { version = "0.8.2", features = ["html_reports"] } +proptest = "1.11.0" + +[[bin]] +name = "ewectionbot" +path = "src/main.rs" + +[[bench]] +harness = false +name = "pav_bench" + +[lints] +workspace = true diff --git a/Dockerfile b/discord/Dockerfile similarity index 100% rename from Dockerfile rename to discord/Dockerfile diff --git a/benches/pav_bench.rs b/discord/benches/pav_bench.rs similarity index 100% rename from benches/pav_bench.rs rename to discord/benches/pav_bench.rs diff --git a/build.rs b/discord/build.rs similarity index 100% rename from build.rs rename to discord/build.rs diff --git a/migrations/20260725190532_activity.sql b/discord/migrations/20260725190532_activity.sql similarity index 100% rename from migrations/20260725190532_activity.sql rename to discord/migrations/20260725190532_activity.sql diff --git a/migrations/20260726190751_council.sql b/discord/migrations/20260726190751_council.sql similarity index 100% rename from migrations/20260726190751_council.sql rename to discord/migrations/20260726190751_council.sql diff --git a/migrations/20260726204440_elections.down.sql b/discord/migrations/20260726204440_elections.down.sql similarity index 100% rename from migrations/20260726204440_elections.down.sql rename to discord/migrations/20260726204440_elections.down.sql diff --git a/migrations/20260726204440_elections.up.sql b/discord/migrations/20260726204440_elections.up.sql similarity index 100% rename from migrations/20260726204440_elections.up.sql rename to discord/migrations/20260726204440_elections.up.sql diff --git a/migrations/20260729152304_opt-out.down.sql b/discord/migrations/20260729152304_opt-out.down.sql similarity index 100% rename from migrations/20260729152304_opt-out.down.sql rename to discord/migrations/20260729152304_opt-out.down.sql diff --git a/migrations/20260729152304_opt-out.up.sql b/discord/migrations/20260729152304_opt-out.up.sql similarity index 100% rename from migrations/20260729152304_opt-out.up.sql rename to discord/migrations/20260729152304_opt-out.up.sql diff --git a/migrations/20260912124833_mod-actions.down.sql b/discord/migrations/20260912124833_mod-actions.down.sql similarity index 100% rename from migrations/20260912124833_mod-actions.down.sql rename to discord/migrations/20260912124833_mod-actions.down.sql diff --git a/migrations/20260912124833_mod-actions.up.sql b/discord/migrations/20260912124833_mod-actions.up.sql similarity index 100% rename from migrations/20260912124833_mod-actions.up.sql rename to discord/migrations/20260912124833_mod-actions.up.sql diff --git a/src/backfill.rs b/discord/src/backfill.rs similarity index 100% rename from src/backfill.rs rename to discord/src/backfill.rs diff --git a/src/commands.rs b/discord/src/commands.rs similarity index 100% rename from src/commands.rs rename to discord/src/commands.rs diff --git a/src/discord_logger.rs b/discord/src/discord_logger.rs similarity index 100% rename from src/discord_logger.rs rename to discord/src/discord_logger.rs diff --git a/src/lib.rs b/discord/src/lib.rs similarity index 100% rename from src/lib.rs rename to discord/src/lib.rs diff --git a/src/main.rs b/discord/src/main.rs similarity index 100% rename from src/main.rs rename to discord/src/main.rs diff --git a/src/mod_log.rs b/discord/src/mod_log.rs similarity index 100% rename from src/mod_log.rs rename to discord/src/mod_log.rs diff --git a/src/pav.rs b/discord/src/pav.rs similarity index 100% rename from src/pav.rs rename to discord/src/pav.rs diff --git a/webvoting/Cargo.toml b/webvoting/Cargo.toml new file mode 100644 index 0000000..41432a2 --- /dev/null +++ b/webvoting/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "webvoting" +version = "0.1.0" +edition = "2024" + +[dependencies] +async-nats = "0.50.0" +axum = "0.8.9" +tokio = { version = "1.53.3", features = ["full"] } +tower = "0.5.3" +tower-http = { version = "0.7.1", features = ["fs", "normalize-path"] } +tower-layer = "0.3.3" +vy = "0.2.0" + +[lints] +workspace = true diff --git a/webvoting/assets/fonts/fragment-mono-regular.woff2 b/webvoting/assets/fonts/fragment-mono-regular.woff2 new file mode 100644 index 0000000..13525f7 Binary files /dev/null and b/webvoting/assets/fonts/fragment-mono-regular.woff2 differ diff --git a/webvoting/assets/fonts/jost-regular.woff2 b/webvoting/assets/fonts/jost-regular.woff2 new file mode 100644 index 0000000..f6d0b5c Binary files /dev/null and b/webvoting/assets/fonts/jost-regular.woff2 differ diff --git a/webvoting/assets/fonts/prosto-one-regular.woff2 b/webvoting/assets/fonts/prosto-one-regular.woff2 new file mode 100644 index 0000000..ade4745 Binary files /dev/null and b/webvoting/assets/fonts/prosto-one-regular.woff2 differ diff --git a/webvoting/assets/style.css b/webvoting/assets/style.css new file mode 100644 index 0000000..3057cbb --- /dev/null +++ b/webvoting/assets/style.css @@ -0,0 +1,487 @@ +/* SPCTR - systematic postsynaptic computer terminal regime */ +/* vavakado.xyz design system v2 */ + +:root { + color-scheme: light dark; + + /* BACKGROUND */ + --bg: oklch(0.8552 0 0); + --bg-surface: oklch(0.819 0 0); + + /* FOREGROUND */ + --fg: oklch(0.0628 0.0084 271.33); + --fg-muted: oklch(0.1565 0.0084 271.33); + + /* PRIMARY ACCENT - electric blue */ + --primary-accent: oklch(0.2928 0.1679 242.04); + --primary-accent-dark: oklch(0.4342 0.1679 242.04); + + /* SECONDARY ACCENT - cold purple */ + --secondary-accent: oklch(0.2928 0.1679 277.98); + --secondary-accent-dark: oklch(0.4342 0.1679 277.98); + + @media (prefers-color-scheme: dark) { + /* BACKGROUND */ + --bg: oklch(0.1448 0 0); + --bg-surface: oklch(0.181 0 0); + + /* FOREGROUND */ + --fg: oklch(0.9372 0.0084 271.33); + --fg-muted: oklch(0.8435 0.0084 271.33); + + /* PRIMARY ACCENT - electric blue */ + --primary-accent: oklch(0.7072 0.1679 242.04); + --primary-accent-dark: oklch(0.5658 0.1679 242.04); + + /* SECONDARY ACCENT - cold purple */ + --secondary-accent: oklch(0.7072 0.1679 277.98); + --secondary-accent-dark: oklch(0.5658 0.1679 277.98); + } + + /* SPACING - base-6 */ + --s1: 0.375rem; + --s2: 0.75rem; + --s3: 1.125rem; + --s4: 1.5rem; + --s6: 2.25rem; + --s8: 3rem; + + /* TYPOGRAPHY - scale: Perfect Fourth */ + --font-display: "Prosto One", + serif; + --font-body: "Jost", + sans-serif; + --font-mono: "Fragment Mono", + monospace; + + --text-sm: 0.75rem; + --text-base: 1rem; + --text-lg: 1.333rem; + --text-h3: 1.777rem; + --text-h2: 2.369rem; + --text-h1: 3.157rem; + + /* TRANSITIONS */ + --transition: 120ms ease-out; +} + +@font-face { + font-family: 'Fragment Mono'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url('/fonts/fragment-mono-regular.woff2') format('woff2'); +} + +@font-face { + font-family: 'Jost'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url('/fonts/jost-regular.woff2') format('woff2'); +} + +@font-face { + font-family: 'Prosto One'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url('/fonts/prosto-one-regular.woff2') format('woff2'); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +html { + color-scheme: light dark; +} + +body { + background-color: var(--bg); + /* background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cline x1='24' y1='0' x2='24' y2='48' stroke='light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.03))' stroke-width='1'/%3E%3Cline x1='0' y1='24' x2='48' y2='24' stroke='light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.03))' stroke-width='1'/%3E%3Crect x='21.5' y='21.5' width='5' height='5' fill='light-dark(rgba(0,0,0,0.09), rgba(255,255,255,0.09))'/%3E%3C/svg%3E"); */ + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cline x1='24' y1='0' x2='24' y2='48' stroke='rgba(0,0,0,0.03)' stroke-width='1'/%3E%3Cline x1='0' y1='24' x2='48' y2='24' stroke='rgba(0,0,0,0.03)' stroke-width='1'/%3E%3Crect x='21.5' y='21.5' width='5' height='5' fill='rgba(0,0,0,0.09)'/%3E%3C/svg%3E"); + + @media (prefers-color-scheme: dark) { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cline x1='24' y1='0' x2='24' y2='48' stroke='rgba(255,255,255,0.03)' stroke-width='1'/%3E%3Cline x1='0' y1='24' x2='48' y2='24' stroke='rgba(255,255,255,0.03)' stroke-width='1'/%3E%3Crect x='21.5' y='21.5' width='5' height='5' fill='rgba(255,255,255,0.09)'/%3E%3C/svg%3E"); + } + + background-size: var(--s8) var(--s8); + color: var(--fg); + font-family: var(--font-body); + font-size: var(--text-base); + font-weight: 400; + line-height: 1.7; + min-height: 100vh; +} + +main { + max-width: 80ch; +} + +main, +body>footer { + margin-top: var(--s8); + margin-inline: auto; + + @media (width > 480px) { + padding-inline: var(--s4); + } +} + +body>footer { + max-width: 100ch; +} + +footer { + text-align: center; +} + +nav { + margin-inline: var(--s4); +} + +/* index page contact reminder */ +/* TODO: make this into a separate page? maybe */ +.contact { + margin-top: var(--s8); + text-align: center; +} + +/* index page buttons */ +.buttons { + display: grid; + grid-template-columns: repeat(auto-fill, 88px); + /* fine to use pixels here, since the grid is dynamic anyways */ + gap: 2px; + justify-content: center; + + & a { + border: none; + line-height: 0; + } + + & img { + image-rendering: pixelated; + } + + & a:hover img { + filter: brightness(1.2); + } +} + +body>nav { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: var(--s2); +} + +.nav-container { + display: flex; + align-items: center; + gap: var(--s2); + + & a[aria-current="page"] { + font-weight: 600; + } + + & a[aria-disabled="true"] { + color: var(--secondary-accent); + cursor: not-allowed; + } +} + +/* PROJECTS */ +.project-card { + background-color: var(--bg-surface); + margin-top: var(--s4); + + &>header { + display: grid; + grid-template-columns: 1fr auto; + + &>section { + display: flex; + flex-direction: column; + gap: var(--s2); + padding: var(--s3); + + & h3 { + display: flex; + align-items: center; + gap: var(--s1); + + & img { + width: var(--s6); + height: var(--s6); + object-fit: contain; + } + } + } + + &>aside { + border-left: 1px solid; + border-color: var(--fg-muted); + padding: var(--s3) var(--s2); + display: flex; + flex-direction: column; + align-items: center; + gap: var(--s2); + + &>small { + writing-mode: vertical-rl; + transform: rotate(180deg); + } + + & ul { + list-style: none; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + gap: var(--s2); + + & img { + width: var(--s4); + height: var(--s4); + object-fit: contain; + } + } + } + } + + &>footer { + border-top: 1px solid; + border-color: var(--fg-muted); + + padding-block: var(--s1); + padding-inline: var(--s4); + + display: flex; + gap: var(--s1); + } +} + +/* POSTS */ + +.post-toc { + list-style: none; + margin: var(--s3) auto; + max-width: 40ch; + text-align: left; + + & ul { + list-style: none; + margin: var(--s1) 0 0 var(--s3); + padding: 0; + border-left: 2px solid var(--secondary-accent-dark); + + & li { + font-weight: normal; + margin: 0.25em 0; + padding-left: 0.5em; + } + + & li::before { + content: "‣ "; + color: var(--fg-muted); + } + } +} + +.post-body { + line-height: 1.6; + + .note { + background-color: var(--bg-surface); + border-left: 4px solid var(--primary-accent); + padding: var(--s2) var(--s3); + margin: var(--s4) 0; + + &::before { + content: "Note"; + font-weight: 600; + margin-right: 0.6em; + color: var(--secondary-accent); + } + } + + & h1, + & h2, + & h3, + & h4, + & h5, + & h6 { + margin-top: var(--s4); + } + + & p { + margin-top: var(--s2); + } + + & ul, + ol { + margin-top: var(--s2); + padding-left: var(--s6); + } + + & img { + display: block; + max-width: 100%; + max-height: 60ch; + height: auto; + margin: var(--s4) auto; + transition: filter var(--transition); + border: 2px solid var(--fg-muted); + + &:hover { + filter: brightness(1.05); + } + } + + & table { + width: 100%; + border-collapse: collapse; + margin-block: var(--s4); + font-family: var(--font-body); + font-size: var(--text-base); + + display: block; + overflow-x: auto; + + border: 0; + + & th, + & td { + padding: var(--s2) var(--s3); + text-align: left; + border: 1px solid var(--fg-muted); + } + + & th { + font-family: var(--font-display); + font-size: var(--text-sm); + text-transform: uppercase; + letter-spacing: 0.05em; + color: var(--secondary-accent); + background-color: var(--bg-surface); + border-bottom: 2px solid var(--primary-accent); + } + + /* zebra xD */ + & tbody tr:nth-child(even) { + background-color: oklch(from var(--bg-surface) l c h / 0.4); + } + + & .org-right { + font-family: var(--font-mono); + text-align: right; + } + + & .org-left { + font-family: var(--font-mono); + text-align: left; + } + } +} + +/* TYPOGRAPHY */ +h1, +h2, +h3, +h4, +h5, +h6 { + font-family: var(--font-display); + font-weight: 400; + line-height: 1.1; +} + +h1 { + font-size: var(--text-h1); +} + +h2 { + font-size: var(--text-h2); +} + +h3 { + font-size: var(--text-h3); +} + +::selection { + background-color: var(--primary-accent); + color: var(--bg); +} + +b { + font-weight: 600; +} + +small, +.muted, +footer { + font-size: var(--text-sm); + font-weight: 300; + color: var(--fg-muted); +} + +code, +pre, +kbd { + font-family: var(--font-mono); + font-size: var(--text-sm); +} + +pre { + background-color: var(--bg-surface); + padding: var(--s1); + overflow-x: auto; +} + +code:not(pre code) { + background-color: var(--bg-surface); + padding: 0.1em 0.35em; +} + +a { + color: var(--primary-accent); + text-decoration: none; + transition: + color var(--transition), + background-color var(--transition); + + &:hover:not([aria-disabled="true"]) { + color: var(--bg); + background-color: var(--fg); + } +} + + +pre>code { + display: block; + overflow-x: auto; + padding: 1em; +} + +.footnote-definition { + display: flex; + + &>sup::before { + content: "["; + } + + &>sup::after { + content: "]:"; + } +} + +.status-notice { + line-height: 0.9; + color: var(--secondary-accent-dark); +} diff --git a/webvoting/src/main.rs b/webvoting/src/main.rs new file mode 100644 index 0000000..6c61ce9 --- /dev/null +++ b/webvoting/src/main.rs @@ -0,0 +1,42 @@ +use std::env::{self, current_exe}; +use std::net::SocketAddr; +use std::path::PathBuf; +use tower_layer::Layer; + +use axum::extract::Request; +use axum::{ + Router, + response::Html, + routing::{get, get_service}, +}; +use tower_http::{normalize_path::NormalizePathLayer, services::ServeDir}; +use vy::prelude::*; + +use crate::page::Page; + +mod page; + +#[tokio::main] +async fn main() { + let addr = SocketAddr::from(([0, 0, 0, 0], 3000)); + println!("Running at http://{addr}"); + let listner = tokio::net::TcpListener::bind(addr) + .await + .expect("failed to bind to address"); + + let assets_dir = env::var("ASSETS_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| PathBuf::from("webvoting/assets")); + + let app = Router::new() + .route( + "/", + get(async |()| Html(Page::new("mrra", "grraa").into_html().into_string())), + ) + .fallback_service(get_service(ServeDir::new(assets_dir))); + + let app = NormalizePathLayer::trim_trailing_slash().layer(app); + axum::serve(listner, axum::ServiceExt::::into_make_service(app)) + .await + .expect("failed to serve using axum"); +} diff --git a/webvoting/src/page.rs b/webvoting/src/page.rs new file mode 100644 index 0000000..5b0a4e3 --- /dev/null +++ b/webvoting/src/page.rs @@ -0,0 +1,53 @@ +use vy::prelude::*; + +pub struct Page { + title: Option, + content: R, +} + +impl Page { + pub fn new(title: impl Into, content: R) -> Self { + Self { + title: Some(title.into()), + content, + } + } +} + +impl IntoHtml for Page { + fn into_html(self) -> impl IntoHtml { + ( + DOCTYPE, + html!( + head!( + meta!(charset = "UTF-8"), + meta!( + name = "viewport", + content = "width=device-width, initial-scale=1.0" + ), + title!(format!( + "HELL voting | {}", + self.title.clone().unwrap_or_default() + )), + script!( + src = "https://cdn.jsdelivr.net/npm/htmx.org@2.0.11/dist/htmx.min.js", + integrity = "sha384-2OatzQy1H+Zd/IIrjr1TcuDGqLXeHhbooAyJY1KdQMKnr4LZ22k31GBLdYKHmVjg", + crossorigin = "anonymous", + ), + link!(rel = "preconnect", href = "https://fonts.googleapis.com"), + link!( + rel = "preconnect", + href = "https://fonts.gstatic.com", + crossorigin = "anonymous" + ), + link!( + rel = "stylesheet", + href = "https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" + ), + link!(rel = "stylesheet", href = "/style.css"), + ), + body!(main!(self.content.into_html())) + ), + ) + } +}