diff --git a/.sqlx/query-6c494c412486e6b8a03dc02986325c48e8c0b3d7005311129fdd68ab2c4dcd02.json b/.sqlx/query-6c494c412486e6b8a03dc02986325c48e8c0b3d7005311129fdd68ab2c4dcd02.json new file mode 100644 index 0000000..6199570 --- /dev/null +++ b/.sqlx/query-6c494c412486e6b8a03dc02986325c48e8c0b3d7005311129fdd68ab2c4dcd02.json @@ -0,0 +1,50 @@ +{ + "db_name": "SQLite", + "query": "SELECT id, mod_log_id, reason_ask_id FROM mod_actions\n WHERE mod_id = ? AND reason_response_id = ?\n ORDER BY id DESC", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Integer", + "origin": { + "Table": { + "table": "mod_actions", + "name": "id" + } + } + }, + { + "name": "mod_log_id", + "ordinal": 1, + "type_info": "Integer", + "origin": { + "Table": { + "table": "mod_actions", + "name": "mod_log_id" + } + } + }, + { + "name": "reason_ask_id", + "ordinal": 2, + "type_info": "Integer", + "origin": { + "Table": { + "table": "mod_actions", + "name": "reason_ask_id" + } + } + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + true, + true + ] + }, + "hash": "6c494c412486e6b8a03dc02986325c48e8c0b3d7005311129fdd68ab2c4dcd02" +} diff --git a/.sqlx/query-f3d520befae1cf53ca6190159f7cbb036992d0e4d73f8fa4c3f756aa1fa65477.json b/.sqlx/query-a80835b719070df4c5a326a4fe2c8db962089f6171ff516e7edd6c9516732779.json similarity index 78% rename from .sqlx/query-f3d520befae1cf53ca6190159f7cbb036992d0e4d73f8fa4c3f756aa1fa65477.json rename to .sqlx/query-a80835b719070df4c5a326a4fe2c8db962089f6171ff516e7edd6c9516732779.json index 3251136..99be3ed 100644 --- a/.sqlx/query-f3d520befae1cf53ca6190159f7cbb036992d0e4d73f8fa4c3f756aa1fa65477.json +++ b/.sqlx/query-a80835b719070df4c5a326a4fe2c8db962089f6171ff516e7edd6c9516732779.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "SELECT\n e.*,\n (\n SELECT COUNT(*)\n FROM candidates c\n WHERE c.election_id = e.id\n ) AS candidate_count,\n (\n SELECT COUNT(DISTINCT v.voter_id) \n FROM votes v\n WHERE v.election_id = e.id\n ) AS voter_count\n FROM elections e\n ORDER BY e.started_at DESC\n LIMIT 1", + "query": "SELECT\n e.*,\n (\n SELECT COUNT(*)\n FROM candidates c\n WHERE c.election_id = e.id\n ) AS candidate_count,\n (\n SELECT COUNT(DISTINCT v.voter_id)\n FROM votes v\n WHERE v.election_id = e.id\n ) AS voter_count,\n (\n SELECT COUNT(*)\n FROM votes v\n WHERE v.election_id = e.id\n ) AS vote_count\n FROM elections e\n ORDER BY e.started_at DESC\n LIMIT 1", "describe": { "columns": [ { @@ -80,6 +80,12 @@ "ordinal": 7, "type_info": "Integer", "origin": "Expression" + }, + { + "name": "vote_count", + "ordinal": 8, + "type_info": "Integer", + "origin": "Expression" } ], "parameters": { @@ -93,8 +99,9 @@ false, false, false, + false, false ] }, - "hash": "f3d520befae1cf53ca6190159f7cbb036992d0e4d73f8fa4c3f756aa1fa65477" + "hash": "a80835b719070df4c5a326a4fe2c8db962089f6171ff516e7edd6c9516732779" } diff --git a/.sqlx/query-c4042a2e022b60756a97ea1aa1e921af330da85e97df0c7733802db18e3bebf2.json b/.sqlx/query-c4042a2e022b60756a97ea1aa1e921af330da85e97df0c7733802db18e3bebf2.json new file mode 100644 index 0000000..bc77f72 --- /dev/null +++ b/.sqlx/query-c4042a2e022b60756a97ea1aa1e921af330da85e97df0c7733802db18e3bebf2.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE mod_actions SET reason = ?, reason_response_id = ? WHERE id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "c4042a2e022b60756a97ea1aa1e921af330da85e97df0c7733802db18e3bebf2" +} diff --git a/.sqlx/query-c74328cadb06d199340dcb0330f98d3dc68318568c8b0d87d03778b387212520.json b/.sqlx/query-c74328cadb06d199340dcb0330f98d3dc68318568c8b0d87d03778b387212520.json new file mode 100644 index 0000000..7dc1394 --- /dev/null +++ b/.sqlx/query-c74328cadb06d199340dcb0330f98d3dc68318568c8b0d87d03778b387212520.json @@ -0,0 +1,26 @@ +{ + "db_name": "SQLite", + "query": "\n SELECT term_start FROM council_members\n WHERE user_id = ? AND term_end IS NULL\n ", + "describe": { + "columns": [ + { + "name": "term_start", + "ordinal": 0, + "type_info": "Text", + "origin": { + "Table": { + "table": "council_members", + "name": "term_start" + } + } + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + }, + "hash": "c74328cadb06d199340dcb0330f98d3dc68318568c8b0d87d03778b387212520" +} diff --git a/Cargo.lock b/Cargo.lock index fbe7340..27f21ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,42 +53,6 @@ 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" @@ -144,70 +108,12 @@ 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" @@ -279,9 +185,6 @@ name = "bytes" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" -dependencies = [ - "serde", -] [[package]] name = "cast" @@ -410,12 +313,6 @@ 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" @@ -587,32 +484,6 @@ 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" @@ -668,17 +539,6 @@ 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" @@ -743,28 +603,6 @@ 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" @@ -821,7 +659,7 @@ dependencies = [ ] [[package]] -name = "ewectionbot-discord" +name = "ewectionbot" version = "0.1.0" dependencies = [ "bitvec", @@ -834,6 +672,7 @@ dependencies = [ "proptest", "rand 0.10.2", "rayon", + "regex", "reqwest 0.13.4", "serde", "serde_json", @@ -853,12 +692,6 @@ 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" @@ -1200,24 +1033,12 @@ 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" @@ -1241,7 +1062,6 @@ dependencies = [ "http", "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -1439,12 +1259,6 @@ 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" @@ -1589,12 +1403,6 @@ 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" @@ -1657,21 +1465,6 @@ 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" @@ -1681,15 +1474,6 @@ 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" @@ -1762,57 +1546,18 @@ 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" @@ -1866,12 +1611,6 @@ 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" @@ -2198,7 +1937,7 @@ dependencies = [ "tokio-rustls 0.26.4", "tokio-util", "tower", - "tower-http 0.6.11", + "tower-http", "tower-service", "url", "wasm-bindgen", @@ -2240,7 +1979,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.4", "tower", - "tower-http 0.6.11", + "tower-http", "tower-service", "url", "wasm-bindgen", @@ -2530,37 +2269,6 @@ 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" @@ -2694,28 +2402,6 @@ 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" @@ -2772,16 +2458,6 @@ 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" @@ -3189,9 +2865,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.53.3" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "bytes", "libc", @@ -3277,27 +2953,6 @@ 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" @@ -3350,7 +3005,6 @@ dependencies = [ "tokio", "tower-layer", "tower-service", - "tracing", ] [[package]] @@ -3371,31 +3025,6 @@ 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" @@ -3482,16 +3111,6 @@ 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" @@ -3613,38 +3232,6 @@ 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" @@ -3803,19 +3390,6 @@ 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 678e0f2..4b087b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,46 @@ -[workspace] -resolver = "3" -members = [ - "discord", - "webvoting", -] +[package] +name = "ewectionbot" +version = "0.1.0" +edition = "2024" +license-file = "LICENSE" -[workspace.lints.clippy] +[features] +default = [] + +[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" +regex = "1.13.1" +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] borrow_as_ptr = "warn" cast_lossless = "warn" derive_partial_eq_without_eq = "warn" diff --git a/discord/Dockerfile b/Dockerfile similarity index 100% rename from discord/Dockerfile rename to Dockerfile diff --git a/README.md b/README.md index 233d68a..2c1188e 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Copyright (C) 2026 Kiran “vavakado” Rubin -This work is licensed under the AGPL 3.0-or-later. -See the REUSE.toml and LICENSES/ file for full terms. +This work is licensed under the Cooperative Non-Violent Public License. +See the LICENSE 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/benches/pav_bench.rs b/benches/pav_bench.rs similarity index 100% rename from discord/benches/pav_bench.rs rename to benches/pav_bench.rs diff --git a/discord/build.rs b/build.rs similarity index 100% rename from discord/build.rs rename to build.rs diff --git a/discord/Cargo.toml b/discord/Cargo.toml deleted file mode 100644 index 6d64f59..0000000 --- a/discord/Cargo.toml +++ /dev/null @@ -1,47 +0,0 @@ -[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/discord/migrations/20260725190532_activity.sql b/migrations/20260725190532_activity.sql similarity index 100% rename from discord/migrations/20260725190532_activity.sql rename to migrations/20260725190532_activity.sql diff --git a/discord/migrations/20260726190751_council.sql b/migrations/20260726190751_council.sql similarity index 100% rename from discord/migrations/20260726190751_council.sql rename to migrations/20260726190751_council.sql diff --git a/discord/migrations/20260726204440_elections.down.sql b/migrations/20260726204440_elections.down.sql similarity index 100% rename from discord/migrations/20260726204440_elections.down.sql rename to migrations/20260726204440_elections.down.sql diff --git a/discord/migrations/20260726204440_elections.up.sql b/migrations/20260726204440_elections.up.sql similarity index 100% rename from discord/migrations/20260726204440_elections.up.sql rename to migrations/20260726204440_elections.up.sql diff --git a/discord/migrations/20260729152304_opt-out.down.sql b/migrations/20260729152304_opt-out.down.sql similarity index 100% rename from discord/migrations/20260729152304_opt-out.down.sql rename to migrations/20260729152304_opt-out.down.sql diff --git a/discord/migrations/20260729152304_opt-out.up.sql b/migrations/20260729152304_opt-out.up.sql similarity index 100% rename from discord/migrations/20260729152304_opt-out.up.sql rename to migrations/20260729152304_opt-out.up.sql diff --git a/discord/migrations/20260912124833_mod-actions.down.sql b/migrations/20260912124833_mod-actions.down.sql similarity index 100% rename from discord/migrations/20260912124833_mod-actions.down.sql rename to migrations/20260912124833_mod-actions.down.sql diff --git a/discord/migrations/20260912124833_mod-actions.up.sql b/migrations/20260912124833_mod-actions.up.sql similarity index 100% rename from discord/migrations/20260912124833_mod-actions.up.sql rename to migrations/20260912124833_mod-actions.up.sql diff --git a/migrations/20261023225846_add_reason_response_id_to_mod_actions.down.sql b/migrations/20261023225846_add_reason_response_id_to_mod_actions.down.sql new file mode 100644 index 0000000..cb74e2e --- /dev/null +++ b/migrations/20261023225846_add_reason_response_id_to_mod_actions.down.sql @@ -0,0 +1 @@ +ALTER TABLE mod_actions DROP COLUMN reason_response_id; diff --git a/migrations/20261023225846_add_reason_response_id_to_mod_actions.up.sql b/migrations/20261023225846_add_reason_response_id_to_mod_actions.up.sql new file mode 100644 index 0000000..b6df26b --- /dev/null +++ b/migrations/20261023225846_add_reason_response_id_to_mod_actions.up.sql @@ -0,0 +1 @@ +ALTER TABLE mod_actions ADD COLUMN reason_response_id INTEGER; diff --git a/discord/src/backfill.rs b/src/backfill.rs similarity index 100% rename from discord/src/backfill.rs rename to src/backfill.rs diff --git a/discord/src/commands.rs b/src/commands.rs similarity index 87% rename from discord/src/commands.rs rename to src/commands.rs index fc9c73f..c0c5af6 100644 --- a/discord/src/commands.rs +++ b/src/commands.rs @@ -21,10 +21,15 @@ pub async fn election(ctx: Context<'_>) -> Result<(), Error> { WHERE c.election_id = e.id ) AS candidate_count, ( - SELECT COUNT(DISTINCT v.voter_id) + SELECT COUNT(DISTINCT v.voter_id) FROM votes v WHERE v.election_id = e.id - ) AS voter_count + ) AS voter_count, + ( + SELECT COUNT(*) + FROM votes v + WHERE v.election_id = e.id + ) AS vote_count FROM elections e ORDER BY e.started_at DESC LIMIT 1" @@ -63,11 +68,12 @@ pub async fn election(ctx: Context<'_>) -> Result<(), Error> { .color(0x49b3a3); if !election.is_finished && ended_at > now { - embed = embed.footer(CreateEmbedFooter::new("Result's aren't calculated yet!")); + embed = embed.footer(CreateEmbedFooter::new("Results aren't calculated yet!")); } if ended_at < now { embed = embed.field("Voters", election.voter_count.to_string(), true); + embed = embed.field("Votes", election.vote_count.to_string(), true); } embed = embed.field("Kind", election.kind, false); diff --git a/discord/src/discord_logger.rs b/src/discord_logger.rs similarity index 100% rename from discord/src/discord_logger.rs rename to src/discord_logger.rs diff --git a/discord/src/lib.rs b/src/lib.rs similarity index 100% rename from discord/src/lib.rs rename to src/lib.rs diff --git a/discord/src/main.rs b/src/main.rs similarity index 96% rename from discord/src/main.rs rename to src/main.rs index b1ab7d6..c30526b 100644 --- a/discord/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use ::serenity::{ gateway::ActivityData, model::{ channel::MessageType, - id::{ChannelId, GuildId, UserId}, + id::{ChannelId, GuildId, RoleId, UserId}, }, }; use ewectionbot::pav::{self, TieSituation}; @@ -51,6 +51,12 @@ pub struct Config { council: CouncilConfig, union: HashMap, poll: Option, + #[serde(default = "default_max_attach_redownload_size")] // 12 megs + max_attach_redownload_size: u32, // in bytes, stored in memory +} + +fn default_max_attach_redownload_size() -> u32 { + 12681408 } #[derive(Deserialize, Clone)] @@ -220,6 +226,21 @@ async fn handle_event( sleep(StdDuration::from_secs(15)).await; let _ = temporary?.delete(&ctx.http).await; } + } else if let FullEvent::MessageUpdate { + old_if_available: _, + new: _, + event, + } = event + { + let msg = event + .channel_id + .message(&ctx.http(), event.id.get()) + .await?; + + if event.guild_id.is_none() { + mod_log::edit_dm(ctx, &msg, data).await?; + return Ok(()); + } } else if let FullEvent::GuildAuditLogEntryCreate { guild_id, entry } = event && guild_id.get() == config.guild_id { @@ -380,7 +401,6 @@ pub async fn activity( } /// Resign from your Council position -#[cfg(feature = "resign")] #[instrument(skip(ctx), err)] #[poise::command(slash_command, prefix_command)] pub async fn resign(ctx: Context<'_>) -> Result<(), Error> { @@ -433,21 +453,6 @@ pub async fn resign(ctx: Context<'_>) -> Result<(), Error> { Ok(()) } -/// Resign from your Council position -#[cfg(not(feature = "resign"))] -#[instrument(skip(ctx), err)] -#[poise::command(slash_command, prefix_command)] -pub async fn resign(ctx: Context<'_>) -> Result<(), Error> { - ctx.send( - poise::CreateReply::default() - .content("This feature isn't done yet, only available in debug builds") - .ephemeral(true), - ) - .await?; - - Ok(()) -} - /// Get the current Council status #[instrument(skip(ctx), err)] #[poise::command(slash_command, prefix_command)] @@ -635,7 +640,19 @@ async fn handle_resign_component( ), ) .await?; - // TODO: trigger a by-election + + ctx.http + .remove_member_role( + GuildId::from(config.guild_id), + user.id, + RoleId::new(config.council.role_id), + Some("removing resigned council member"), + ) + .await?; + + if let Err(e) = maybe_create_by_election(pool, config, ctx.http.clone()).await { + error!("Failed to trigger a by-election: {e}"); + } } _ => {} } @@ -1307,9 +1324,13 @@ async fn schedule_end_of_election( .await?; for person in people_out { - if let Ok(member) = guild_id.member(&http, person as u64).await { - member.remove_role(&http, config.council.role_id).await?; - } + http.remove_member_role( + guild_id, + UserId::new(person as u64), + RoleId::new(config.council.role_id), + Some("removing former council members"), + ) + .await?; } for winner in winners { @@ -1321,9 +1342,13 @@ async fn schedule_end_of_election( .execute(&mut *tx) .await?; - if let Ok(member) = guild_id.member(&http, winner).await { - member.add_role(&http, config.council.role_id).await?; - } + http.add_member_role( + guild_id, + UserId::new(winner), + RoleId::new(config.council.role_id), + Some("adding new council members"), + ) + .await?; } tx.commit().await?; @@ -2071,9 +2096,13 @@ async fn main() -> Result<(), Box> { .filter(|member| member.roles.contains(&config.council.role_id.into())); for person in fake_council { - if let Ok(member) = guild_id.member(&http, person.user.id.get()).await { - member.remove_role(&http, config.council.role_id).await?; - } + http.remove_member_role( + guild_id, + person.user.id, + RoleId::new(config.council.role_id), + Some("unfucking council: removing all council members"), + ) + .await?; } let real_council = sqlx::query_scalar!( @@ -2086,9 +2115,13 @@ async fn main() -> Result<(), Box> { .await?; for person in &real_council { - if let Ok(member) = guild_id.member(&http, *person as u64).await { - member.add_role(&http, config.council.role_id).await?; - } + http.add_member_role( + guild_id, + UserId::new(*person as u64), + RoleId::new(config.council.role_id), + Some("unfucking council: adding all council members from db"), + ) + .await?; } return Ok(()); diff --git a/discord/src/mod_log.rs b/src/mod_log.rs similarity index 72% rename from discord/src/mod_log.rs rename to src/mod_log.rs index b7486a5..5f856ec 100644 --- a/discord/src/mod_log.rs +++ b/src/mod_log.rs @@ -1,6 +1,11 @@ +use std::sync::LazyLock; + +use regex::Regex; use serenity::{ all::prelude::CacheHttp, - builder::{CreateAllowedMentions, CreateMessage, EditMessage}, + builder::{ + CreateAllowedMentions, CreateAttachment, CreateMessage, EditAttachments, EditMessage, + }, model::{ channel::Message, guild::audit_log::AuditLogEntry, @@ -9,6 +14,10 @@ use serenity::{ }; use tracing::{debug, instrument, warn}; +static QUOTE_CONTENT_RE: LazyLock = LazyLock::new(|| Regex::new(r"«([^»]*)»").unwrap()); +static ZSWPQUOTE_RE: LazyLock = LazyLock::new(|| Regex::new(r"\u{200B}[«»]").unwrap()); +static QUOTE_RE: LazyLock = LazyLock::new(|| Regex::new(r"[«»]").unwrap()); + use crate::{Data, Error}; #[instrument(skip(ctx, data), err)] @@ -245,8 +254,9 @@ pub async fn handle_dm( if let Some(action) = action { sqlx::query!( - "UPDATE mod_actions SET reason = ? WHERE id = ?", + "UPDATE mod_actions SET reason = ?, reason_response_id = ? WHERE id = ?", message.content, + message.id.get() as i64, action.id ) .execute(&pool) @@ -256,11 +266,24 @@ pub async fn handle_dm( let msg = MessageId::new(msg as u64); let channel = ChannelId::new(config.mod_log_id); let log = channel.message(&ctx.http(), msg).await?; + let mut edit_attachs = EditAttachments::new(); + for att in &message.attachments { + if att.size > config.max_attach_redownload_size { + continue; + } + let bytes = att.download().await?; + let attachment = CreateAttachment::bytes(bytes, &att.filename); + edit_attachs = edit_attachs.add(attachment); + } let edit = EditMessage::new() .content(log.content.replace( "no reason specified", - &format!("reason «{}»", message.content.clone()), + &format!( + "reason «{}»", + QUOTE_RE.replace_all(&message.content.clone(), "\u{200B}$0") + ), )) + .attachments(edit_attachs) .allowed_mentions( CreateAllowedMentions::new() .empty_users() @@ -290,3 +313,86 @@ pub async fn handle_dm( Ok(()) } + +#[instrument(skip(ctx, data, message), err)] +pub async fn edit_dm( + ctx: &serenity::client::Context, + message: &Message, + data: &Data, +) -> Result<(), Error> { + let config = data.config.clone(); + let pool = data.pool.clone(); + + let action = sqlx::query!( + r"SELECT id, mod_log_id, reason_ask_id FROM mod_actions + WHERE mod_id = ? AND reason_response_id = ? + ORDER BY id DESC", + message.author.id.get() as i64, + message.id.get() as i64, + ) + .fetch_optional(&pool) + .await?; + + if let Some(action) = action { + sqlx::query!( + "UPDATE mod_actions SET reason = ? WHERE id = ?", + message.content, + action.id + ) + .execute(&pool) + .await?; + + if let Some(msg) = action.mod_log_id { + let msg = MessageId::new(msg as u64); + let channel = ChannelId::new(config.mod_log_id); + let log = channel.message(&ctx.http(), msg).await?; + let mut edit_attachs = EditAttachments::new(); + for att in &message.attachments { + if att.size > config.max_attach_redownload_size { + continue; + } + let bytes = att.download().await?; + let attachment = CreateAttachment::bytes(bytes, &att.filename); + edit_attachs = edit_attachs.add(attachment); + } + let edit = EditMessage::new() + .content(QUOTE_CONTENT_RE.replace( + &ZSWPQUOTE_RE.replace_all(&log.content, ""), + format!( + "«{}»", + QUOTE_RE.replace_all(&message.content.clone(), "\u{200B}$0") + ), + )) + .attachments(edit_attachs) + .allowed_mentions( + CreateAllowedMentions::new() + .empty_users() + .empty_roles() + .everyone(false), + ); + channel.edit_message(&ctx.http(), log, edit).await?; + } else { + warn!("failed to update mod log"); + } + + if let Some(msg) = action.reason_ask_id { + let umsg = msg as u64; + let prev_ask_msg = message.channel_id.message(&ctx.http(), umsg).await?; + + let edit = EditMessage::new().content(format!("{}!", prev_ask_msg.content)); + message + .channel_id + .edit_message(&ctx.http(), umsg, edit) + .await?; + } else { + warn!("failed to update ask"); + } + } else if !message.author.bot { + message + .channel_id + .say(&ctx.http(), "Yo what are you editing about?") + .await?; + } + + Ok(()) +} diff --git a/discord/src/pav.rs b/src/pav.rs similarity index 100% rename from discord/src/pav.rs rename to src/pav.rs diff --git a/webvoting/Cargo.toml b/webvoting/Cargo.toml deleted file mode 100644 index 41432a2..0000000 --- a/webvoting/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[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 deleted file mode 100644 index 13525f7..0000000 Binary files a/webvoting/assets/fonts/fragment-mono-regular.woff2 and /dev/null differ diff --git a/webvoting/assets/fonts/jost-regular.woff2 b/webvoting/assets/fonts/jost-regular.woff2 deleted file mode 100644 index f6d0b5c..0000000 Binary files a/webvoting/assets/fonts/jost-regular.woff2 and /dev/null differ diff --git a/webvoting/assets/fonts/prosto-one-regular.woff2 b/webvoting/assets/fonts/prosto-one-regular.woff2 deleted file mode 100644 index ade4745..0000000 Binary files a/webvoting/assets/fonts/prosto-one-regular.woff2 and /dev/null differ diff --git a/webvoting/assets/style.css b/webvoting/assets/style.css deleted file mode 100644 index 3057cbb..0000000 --- a/webvoting/assets/style.css +++ /dev/null @@ -1,487 +0,0 @@ -/* 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 deleted file mode 100644 index 6c61ce9..0000000 --- a/webvoting/src/main.rs +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index 5b0a4e3..0000000 --- a/webvoting/src/page.rs +++ /dev/null @@ -1,53 +0,0 @@ -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())) - ), - ) - } -}