11 Commits

Author SHA1 Message Date
eacbb9e426 feat: add forbidden adjacent pairs 2024-11-23 16:25:29 +01:00
ec152683e0 upgrade dependencies 2024-11-23 16:24:59 +01:00
9979a0f4fe new algorithm 2024-11-23 16:24:59 +01:00
07c9495736 wip : shuffle at the init phase 2024-11-23 16:24:59 +01:00
a1e23c29f3 add logs 2024-11-23 16:24:59 +01:00
qdegrandmaison
04b62ca4dd feat(verif): no need for a DOM node 2024-11-23 16:24:59 +01:00
qdegrandmaison
d7564300e8 feat(verif): add a confirm dialog for tocards 2024-11-23 16:24:59 +01:00
10c1ba6f04 french lang 2024-11-23 16:24:55 +01:00
qdegrandmaison
a17ce6ad8a fix(js): remove test data 2022-11-30 14:08:11 +01:00
qdegrandmaison
4358baa1b7 fix(css): dirty support of multiple viewports 2022-11-30 14:01:11 +01:00
qdegrandmaison
34314cbdfb feat(css): add customization 2022-11-30 13:20:25 +01:00
4 changed files with 1149 additions and 192 deletions

469
Cargo.lock generated
View File

@@ -3,36 +3,104 @@
version = 3
[[package]]
name = "async-trait"
version = "0.1.58"
name = "addr2line"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c"
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
dependencies = [
"proc-macro2",
"quote",
"syn",
"gimli",
]
[[package]]
name = "autocfg"
version = "1.1.0"
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
dependencies = [
"anstyle",
"windows-sys 0.59.0",
]
[[package]]
name = "async-trait"
version = "0.1.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.89",
]
[[package]]
name = "axum"
version = "0.6.0"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "744864363a200a5e724a7e61bc8c11b6628cf2e3ec519c8a1a48e609a8156b40"
checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f"
dependencies = [
"async-trait",
"axum-core",
"bitflags",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"hyper",
"hyper-util",
"itoa",
"matchit",
"memchr",
@@ -44,36 +112,49 @@ dependencies = [
"serde_json",
"serde_path_to_error",
"serde_urlencoded",
"sync_wrapper",
"sync_wrapper 1.0.2",
"tokio",
"tower",
"tower-http",
"tower 0.5.1",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "axum-core"
version = "0.3.0"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b8558f5a0581152dc94dcd289132a1d377494bdeafcd41869b3258e3e2ad92"
checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"mime",
"pin-project-lite",
"rustversion",
"sync_wrapper 1.0.2",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "bitflags"
version = "1.3.2"
name = "backtrace"
version = "0.3.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
dependencies = [
"addr2line",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
"windows-targets",
]
[[package]]
name = "bytes"
@@ -87,6 +168,35 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "env_filter"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d"
dependencies = [
"anstream",
"anstyle",
"env_filter",
"humantime",
"log",
]
[[package]]
name = "fnv"
version = "1.0.7"
@@ -147,19 +257,22 @@ dependencies = [
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
name = "gimli"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "hermit-abi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "http"
version = "0.2.8"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
dependencies = [
"bytes",
"fnv",
@@ -168,20 +281,26 @@ dependencies = [
[[package]]
name = "http-body"
version = "0.4.5"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [
"bytes",
"http",
"pin-project-lite",
]
[[package]]
name = "http-range-header"
version = "0.3.0"
name = "http-body-util"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29"
checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
dependencies = [
"bytes",
"futures-util",
"http",
"http-body",
"pin-project-lite",
]
[[package]]
name = "httparse"
@@ -196,14 +315,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
version = "0.14.23"
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hyper"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"http",
"http-body",
@@ -211,18 +335,38 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"socket2",
"tokio",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "itoa"
version = "1.0.4"
name = "hyper-util"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
dependencies = [
"bytes",
"futures-util",
"http",
"http-body",
"hyper",
"pin-project-lite",
"socket2",
"tokio",
"tower 0.4.13",
"tower-service",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2"
[[package]]
name = "lazy_static"
@@ -232,18 +376,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.137"
version = "0.2.164"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
[[package]]
name = "log"
version = "0.4.17"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "matchers"
@@ -256,9 +397,9 @@ dependencies = [
[[package]]
name = "matchit"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dfc802da7b1cf80aefffa0c7b2f77247c8b32206cc83c270b61264f5b360a80"
checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40"
[[package]]
name = "memchr"
@@ -273,15 +414,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mio"
version = "0.8.5"
name = "miniz_oxide"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler2",
]
[[package]]
name = "mio"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [
"hermit-abi",
"libc",
"log",
"wasi",
"windows-sys",
"windows-sys 0.52.0",
]
[[package]]
@@ -295,20 +445,19 @@ dependencies = [
]
[[package]]
name = "num_cpus"
version = "1.14.0"
name = "object"
version = "0.36.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
dependencies = [
"hermit-abi",
"libc",
"memchr",
]
[[package]]
name = "once_cell"
version = "1.16.0"
version = "1.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
name = "overload"
@@ -339,14 +488,14 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.104",
]
[[package]]
name = "pin-project-lite"
version = "0.2.9"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
[[package]]
name = "pin-utils"
@@ -362,18 +511,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro2"
version = "1.0.47"
version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.21"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
@@ -414,6 +563,8 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
@@ -432,6 +583,12 @@ version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "rustc-demangle"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "rustversion"
version = "1.0.9"
@@ -446,22 +603,22 @@ checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
[[package]]
name = "serde"
version = "1.0.147"
version = "1.0.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.147"
version = "1.0.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.104",
]
[[package]]
@@ -501,6 +658,8 @@ name = "sesan"
version = "0.1.0"
dependencies = [
"axum",
"env_logger",
"log",
"once_cell",
"rand",
"serde",
@@ -525,19 +684,30 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "socket2"
version = "0.4.7"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
dependencies = [
"libc",
"winapi",
"windows-sys 0.52.0",
]
[[package]]
name = "syn"
version = "1.0.103"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
dependencies = [
"proc-macro2",
"quote",
@@ -550,6 +720,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8"
[[package]]
name = "sync_wrapper"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
[[package]]
name = "thread_local"
version = "1.1.4"
@@ -561,29 +737,28 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.22.0"
version = "1.41.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3"
checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33"
dependencies = [
"autocfg",
"backtrace",
"libc",
"mio",
"num_cpus",
"pin-project-lite",
"socket2",
"tokio-macros",
"winapi",
"windows-sys 0.52.0",
]
[[package]]
name = "tokio-macros"
version = "1.8.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484"
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.89",
]
[[package]]
@@ -603,35 +778,32 @@ dependencies = [
]
[[package]]
name = "tower-http"
version = "0.3.4"
name = "tower"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba"
checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f"
dependencies = [
"bitflags",
"bytes",
"futures-core",
"futures-util",
"http",
"http-body",
"http-range-header",
"pin-project-lite",
"tower",
"sync_wrapper 0.1.1",
"tokio",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower-layer"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
[[package]]
name = "tower-service"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
[[package]]
name = "tracing"
@@ -657,20 +829,20 @@ dependencies = [
[[package]]
name = "tracing-log"
version = "0.1.3"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"lazy_static",
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.16"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
dependencies = [
"matchers",
"nu-ansi-term",
@@ -684,34 +856,24 @@ dependencies = [
"tracing-log",
]
[[package]]
name = "try-lock"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "unicode-ident"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "want"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
dependencies = [
"log",
"try-lock",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@@ -742,13 +904,32 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.42.0"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
@@ -757,42 +938,48 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.0"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

View File

@@ -6,9 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
axum = { version = "0.6.0", features = ["http1", "json", "tokio"] }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
axum = { version = "0.7.8", features = ["http1", "json", "tokio"] }
tokio = { version = "1.41", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
serde = { version = "1.0", features = ["derive"] }
once_cell = "1.8.0"
rand = "0.8.4"
once_cell = "1.20"
rand = "0.8.5"
log = "0.4"
env_logger = "0.11"

View File

@@ -1,34 +1,740 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Secret Santa</title>
<!-- Christmas tree from https://codepen.io/lenasta92579651/pen/xxERxBx -->
<!-- CSS snowflakes from https://pajasevi.github.io/CSSnowflakes/ -->
</head>
<body>
<!-- Content -->
<h1>Secret Santa</h1>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<select id="person">
<option selected disabled>Qui es-tu?</option>
__OPTIONS__
</select>
<title>Secret Santa</title>
<h2 id="result"></h2>
<h1>Secret Santa</h1>
<!-- Christmas tree -->
<div id="christmas-container">
<div class="christmas">
<div class="tree">
<div class="chain"></div>
<div class="chain2"></div>
</div>
<div class="lights">
<div class="light1"></div>
<div class="light2"></div>
<div class="light3"></div>
<div class="light4"></div>
<div class="light5"></div>
<div class="light6"></div>
<div class="light7"></div>
<div class="light8"></div>
<div class="light9"></div>
<div class="light10"></div>
</div>
<div class="balls">
<div class="ball1"></div>
</div>
<div class="star"></div>
<div class="gift"></div>
<div class="ribbon"></div>
<div class="gift2"></div>
<div class="ribbon2"></div>
<div class="gift3"></div>
<div class="ribbon3"></div>
<div class="shadow"></div>
</div>
</div>
<select id="person">
<option selected disabled>Who is drawing?</option>
__OPTIONS__
</select>
<!-- Snowflakes -->
<div class="snowflakes" aria-hidden="true">
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
<div class="snowflake"></div>
</div>
<div id="result"></div>
<script>
document.getElementById("person").addEventListener('change', event => {
const options = {
<script>
document.getElementById("person").addEventListener("change", (event) => {
if (
window.confirm(
`Vérification! Tu es ${event.target.value}, c'est bien ça?`
)
) {
const options = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "person": event.target.value })
};
body: JSON.stringify({ person: event.target.value }),
};
console.log(options);
console.log(options);
fetch("api", options)
.then(response => response.text())
.then(text => {
document.getElementById("result").textContent = `Your draw: ${text}`;
fetch("api", options)
.then((response) => response.text())
.then((text) => {
document.getElementById(
"result"
).textContent = `Hoho! Tu as pioché ${text} ;`;
document.getElementById("person").remove();
});
});
</script>
}
});
</script>
</body>
<style>
/** Page settings **/
body {
background-color: #3f69c7;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
margin: 0;
padding: 0;
overflow: hidden;
}
h1 {
color: white;
font-family: Arial, Helvetica, sans-serif;
font-size: 5em;
text-align: center;
z-index: 10;
}
select {
z-index: 10;
}
h2 {
color: white;
font-family: Arial, Helvetica, sans-serif;
font-size: 3em;
text-align: center;
z-index: 10;
background: rgba(0, 0, 0, 0.5);
}
#christmas-container {
position: fixed;
right: 20%;
bottom: 30%;
}
/** Christmas tree **/
.christmas {
position: relative;
}
.tree {
position: relative;
background-color: #685044;
width: 30px;
height: 80px;
top: 100px;
transform-style: preserve-3d;
}
.tree:before {
content: "";
position: relative;
width: 0;
height: 0;
border-left: 90px solid transparent;
border-right: 90px solid transparent;
border-bottom: 270px solid #0e9594;
border-radius: 30px;
top: -250px;
left: -75px;
}
.chain {
width: 85px;
height: 85px;
border: solid 3px #333;
border-radius: 50%;
top: -185px;
left: -35px;
position: absolute;
transform: rotate3d(8, 0.1, -5, 75deg);
box-sizing: border-box;
backface-visibility: visible !important;
z-index: 5;
}
.chain2 {
width: 145px;
height: 135px;
border: solid 3px #333;
border-radius: 50%;
top: -115px;
left: -65px;
position: absolute;
transform: rotate3d(8, 0.1, -5, 75deg);
box-sizing: border-box;
backface-visibility: visible !important;
z-index: 5;
}
.shadow {
background-color: rgba(0, 0, 0, 0.07);
position: absolute;
width: 250px;
height: 30px;
border-radius: 50%;
top: 170px;
left: -115px;
z-index: -1;
}
.star {
margin: 50px 0;
position: absolute;
display: block;
width: 0px;
height: 0px;
border-right: 25px solid transparent;
border-bottom: 17.5px solid #f9dc5c;
border-left: 25px solid transparent;
transform: rotate(35deg);
top: -190px;
left: -9px;
}
.star:before {
border-bottom: 20px solid #f9dc5c;
border-left: 7.5px solid transparent;
border-right: 7.5px solid transparent;
position: absolute;
height: 0;
width: 0;
top: -12.5px;
left: -17.5px;
display: block;
content: "";
transform: rotate(-35deg);
}
.star:after {
position: absolute;
display: block;
top: 0.75px;
left: -26.25px;
width: 0px;
height: 0px;
border-right: 25px solid transparent;
border-bottom: 17.5px solid #f9dc5c;
border-left: 25px solid transparent;
transform: rotate(-70deg);
content: "";
}
.lights {
position: absolute;
}
.light1 {
position: absolute;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
}
.light1 {
background-color: #ff595e;
top: -100px;
left: -35px;
transform: rotate(40deg);
box-shadow: 1px 1px 15px #faf3dd;
}
.light2 {
position: absolute;
background-color: #ffca3a;
top: -95px;
left: -10px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light3 {
position: absolute;
background-color: #6a4c93;
top: -105px;
left: 15px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light4 {
position: absolute;
background-color: #1982c4;
top: -118px;
left: 35px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light5 {
position: absolute;
background-color: #1982c4;
top: 12px;
left: -55px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light6 {
position: absolute;
background-color: #8ac926;
top: 15px;
left: -25px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light7 {
position: absolute;
background-color: #ff595e;
top: 10px;
left: 2px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light8 {
position: absolute;
background-color: #ffca3a;
top: -2px;
left: 27px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light9 {
position: absolute;
background-color: #9e0059;
top: -17px;
left: 50px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.light10 {
position: absolute;
background-color: #4361ee;
top: -40px;
left: 68px;
box-shadow: 1px 1px 15px #faf3dd;
width: 15px;
height: 15px;
border-radius: 10px 150px 30px 150px;
transform: rotate(40deg);
}
.gift {
position: absolute;
width: 60px;
height: 50px;
background-color: #ffc857;
top: 130px;
left: 30px;
box-shadow: inset -8px 0 0 rgba(0, 0, 0, 0.07);
}
.gift:before {
content: "";
position: absolute;
width: 70px;
height: 15px;
background-color: #ffc857;
left: -5px;
box-shadow: inset -8px -4px 0 rgba(0, 0, 0, 0.07);
}
.gift:after {
content: "";
background-color: #db3a34;
width: 10px;
height: 50px;
position: absolute;
left: 25px;
}
.ribbon {
position: absolute;
width: 20px;
height: 10px;
border: 3px solid #db3a34;
border-radius: 50%;
transform: skew(15deg, 15deg);
top: 116px;
left: 35px;
}
.ribbon:before {
content: "";
position: absolute;
width: 20px;
height: 10px;
border: 3px solid #db3a34;
border-radius: 50%;
transform: skew(-15deg, -20deg);
left: 22px;
top: -8px;
}
.gift2 {
position: absolute;
width: 50px;
height: 40px;
background-color: #08bdbd;
top: 140px;
left: -65px;
box-shadow: inset -8px 0 0 rgba(0, 0, 0, 0.07);
}
.gift2:before {
content: "";
position: absolute;
width: 60px;
height: 15px;
background-color: #08bdbd;
left: -5px;
box-shadow: inset -8px -4px 0 rgba(0, 0, 0, 0.07);
}
.gift2:after {
content: "";
background-color: #abff4f;
width: 10px;
height: 40px;
position: absolute;
left: 15px;
}
.gift3 {
position: absolute;
width: 40px;
height: 30px;
background-color: #7678ed;
top: 150px;
left: -85px;
box-shadow: inset -8px 0 0 rgba(0, 0, 0, 0.07);
}
.gift3:before {
content: "";
position: absolute;
width: 50px;
height: 10px;
background-color: #7678ed;
left: -5px;
box-shadow: inset -8px -4px 0 rgba(0, 0, 0, 0.07);
}
.gift3:after {
content: "";
background-color: #f7b801;
width: 7px;
height: 30px;
position: absolute;
left: 15px;
}
.ribbon2 {
position: absolute;
width: 15px;
height: 7px;
border: 3px solid #abff4f;
border-radius: 50%;
transform: skew(15deg, 15deg);
top: 129px;
left: -65px;
}
.ribbon2:before {
content: "";
position: absolute;
width: 15px;
height: 7px;
border: 3px solid #abff4f;
border-radius: 50%;
transform: skew(-15deg, -20deg);
left: 15px;
top: -8px;
}
.ribbon3 {
position: absolute;
width: 12px;
height: 5px;
border: 3px solid #f7b801;
border-radius: 50%;
transform: skew(15deg, 15deg);
top: 142px;
left: -85px;
}
.ribbon3:before {
content: "";
position: absolute;
width: 12px;
height: 5px;
border: 3px solid #f7b801;
border-radius: 50%;
transform: skew(-15deg, -20deg);
left: 15px;
top: -8px;
}
.balls {
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #db3a34;
top: 15px;
left: -15px;
}
.balls:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #ffc857;
top: 35px;
left: -15px;
}
.balls:after {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #f07167;
top: 20px;
left: 45px;
}
.ball1 {
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #fae588;
top: -90px;
left: 20px;
}
.ball1:before {
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #fae588;
content: "";
top: 170px;
left: 50px;
}
.light1,
.light2,
.light3,
.light4,
.light5,
.light6,
.light7,
.light8,
.light9,
.light10 {
-webkit-animation: flash 6s infinite;
}
@-webkit-keyframes flash {
20%,
24%,
55% {
box-shadow: none;
}
0%,
19%,
21%,
23%,
25%,
54%,
56%,
100% {
box-shadow: 0 0 5px #f5de93, 0 0 15px #f5de93, 0 0 20px #f5de93,
0 0 40px #f5de93, 0 0 60px #decea4, 0 0 10px #d6c0a5, 0 0 98px #ff0000;
}
}
/** Snowflakes */
.snowflake {
color: #fff;
font-size: 1em;
font-family: Arial, sans-serif;
text-shadow: 0 0 5px #000;
}
@-webkit-keyframes snowflakes-fall {
0% {
top: -10%;
}
100% {
top: 100%;
}
}
@-webkit-keyframes snowflakes-shake {
0%,
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
50% {
-webkit-transform: translateX(80px);
transform: translateX(80px);
}
}
@keyframes snowflakes-fall {
0% {
top: -10%;
}
100% {
top: 100%;
}
}
@keyframes snowflakes-shake {
0%,
100% {
transform: translateX(0);
}
50% {
transform: translateX(80px);
}
}
.snowflake {
position: fixed;
top: -10%;
z-index: 9999;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: default;
-webkit-animation-name: snowflakes-fall, snowflakes-shake;
-webkit-animation-duration: 10s, 3s;
-webkit-animation-timing-function: linear, ease-in-out;
-webkit-animation-iteration-count: infinite, infinite;
-webkit-animation-play-state: running, running;
animation-name: snowflakes-fall, snowflakes-shake;
animation-duration: 10s, 3s;
animation-timing-function: linear, ease-in-out;
animation-iteration-count: infinite, infinite;
animation-play-state: running, running;
}
.snowflake:nth-of-type(0) {
left: 1%;
-webkit-animation-delay: 0s, 0s;
animation-delay: 0s, 0s;
}
.snowflake:nth-of-type(1) {
left: 10%;
-webkit-animation-delay: 1s, 1s;
animation-delay: 1s, 1s;
}
.snowflake:nth-of-type(2) {
left: 20%;
-webkit-animation-delay: 6s, 0.5s;
animation-delay: 6s, 0.5s;
}
.snowflake:nth-of-type(3) {
left: 30%;
-webkit-animation-delay: 4s, 2s;
animation-delay: 4s, 2s;
}
.snowflake:nth-of-type(4) {
left: 40%;
-webkit-animation-delay: 2s, 2s;
animation-delay: 2s, 2s;
}
.snowflake:nth-of-type(5) {
left: 50%;
-webkit-animation-delay: 8s, 3s;
animation-delay: 8s, 3s;
}
.snowflake:nth-of-type(6) {
left: 60%;
-webkit-animation-delay: 6s, 2s;
animation-delay: 6s, 2s;
}
.snowflake:nth-of-type(7) {
left: 70%;
-webkit-animation-delay: 2.5s, 1s;
animation-delay: 2.5s, 1s;
}
.snowflake:nth-of-type(8) {
left: 80%;
-webkit-animation-delay: 1s, 0s;
animation-delay: 1s, 0s;
}
.snowflake:nth-of-type(9) {
left: 90%;
-webkit-animation-delay: 3s, 1.5s;
animation-delay: 3s, 1.5s;
}
.snowflake:nth-of-type(10) {
left: 25%;
-webkit-animation-delay: 2s, 0s;
animation-delay: 2s, 0s;
}
.snowflake:nth-of-type(11) {
left: 65%;
-webkit-animation-delay: 4s, 2.5s;
animation-delay: 4s, 2.5s;
}
</style>
</html>

View File

@@ -5,14 +5,23 @@ use axum::{
};
use once_cell::sync::Lazy;
use rand::{thread_rng, Rng};
use rand::seq::SliceRandom;
use serde::Deserialize;
use std::net::SocketAddr;
use tokio::sync::Mutex;
use log::debug;
use log::error;
use log::info;
use log::warn;
#[macro_use]
extern crate log;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
env_logger::init();
info!("let's go!");
// build our application with some routes
let app = Router::new()
.route("/", get(|| async { Html(INDEX_HTML.as_str()) }))
@@ -20,8 +29,8 @@ async fn main() {
// run it with hyper
let addr = SocketAddr::from(([127, 0, 0, 1], 3067));
axum::Server::bind(&addr)
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
@@ -38,20 +47,62 @@ static INDEX_HTML: Lazy<String> = Lazy::new(|| {
static STATE: Lazy<Mutex<State>> = Lazy::new(Mutex::default);
struct State {
rem_a: Vec<String>,
rem_b: Vec<String>,
participants: Vec<String>,
remaining: Vec<String>,
}
fn has_forbidden_adjacent(participants: &Vec<String>) -> bool {
let forbidden_pairs = vec![("Alice".into(), "Bob".into())];
// Check pairs of adjacent elements, including the circular pair (last, first)
((1..participants.len()).any(|i| {
match (participants[i - 1].as_str(), participants[i].as_str()) {
// Check if the pair is forbidden
(a, b) if forbidden_pairs.contains(&(a.to_string(), b.to_string())) ||
forbidden_pairs.contains(&(b.to_string(), a.to_string())) => {
info!("forbidden pair detected : {:?}/{:?} in {:?}", a, b, participants.join(" => "));
return true;
},
_ => false,
}
}
) || // Check the pair (last, first) for circular adjacency
match (participants.last().unwrap().as_str(), participants[0].as_str()) {
(a, b) if forbidden_pairs.contains(&(a.to_string(), b.to_string())) ||
forbidden_pairs.contains(&(b.to_string(), a.to_string())) => {
info!("forbidden pair detected : {:?}/{:?} in {:?}", a, b, participants.join(" => "));
return true;
},
_ => false,
}
)
}
fn everyone() -> Vec<String> {
vec!["Alice".into(), "Bob".into(), "Carol".into(), "Dave".into()]
vec!["Alice".into(), "Bob".into(), "Carol".into(), "Dave".into(), "Edgar".into(), "France".into()]
}
impl Default for State {
fn default() -> Self {
Self {
rem_a: everyone(),
rem_b: everyone(),
let mut p = everyone();
let mut tries = 0;
while tries < 100 {
p.shuffle(&mut thread_rng());
if !has_forbidden_adjacent(&p) {
info!("distribution : {:?}", p.join(" => "));
return Self {
participants: p,
remaining: everyone()
}
} else {
}
tries += 1;
}
eprintln!("ERROR (could not generate a correct list)");
std::process::exit(1)
}
}
@@ -63,21 +114,32 @@ struct Input {
async fn input(Json(input): Json<Input>) -> String {
let mut state = STATE.lock().await;
if state.rem_a.is_empty() {
if state.remaining.is_empty() {
return "ERROR (everybody drew already)".into();
}
match state.rem_a.iter().position(|p| input.person == *p) {
Some(pos) => {
state.rem_a.remove(pos);
}
None => return "ERROR (you drew already)".into(),
}
loop {
let num = thread_rng().gen_range(0..state.rem_b.len());
if state.rem_b[num] != input.person {
return state.rem_b.remove(num);
info!("joueurs qui restent : {:?}", state.remaining.join(","));
match state.remaining.iter().position(|p| input.person == *p).map(|e| state.remaining.remove(e)) {
Some(rem) => {
match state.participants.iter().position(|p| input.person == *p) {
Some(pos) => {
info!("joueur qui pioche : {:?}", state.participants[pos]);
return match state.participants.iter().nth(pos+1) {
Some(x) => {
info!("joueur qui suit : {:?}", x);
return x.to_string();
}
None => return match state.participants.first() {
Some(x) => {
info!("joueur qui suit : {:?}", x);
return x.to_string();
}
None => "ERROR".to_string()
}
}
}
None => "ERROR".to_string()
}
}
None => "Vous avez déja pioché !".to_string()
}
}