rewrite backend in rust #32

Merged
lbailly merged 14 commits from rewrite into master 2024-06-13 13:20:05 +02:00
9 changed files with 568 additions and 216 deletions
Showing only changes of commit 9ebf7b0f0a - Show all commits

320
Cargo.lock generated
View file

@ -101,12 +101,27 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.5.0" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.16.0" version = "1.16.0"
@ -142,6 +157,40 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "cpufeatures"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
dependencies = [
"libc",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]] [[package]]
name = "deranged" name = "deranged"
version = "0.3.11" version = "0.3.11"
@ -177,13 +226,23 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35b50dba0afdca80b187392b24f2499a88c336d5a8493e4b4ccfb608708be56a" checksum = "35b50dba0afdca80b187392b24f2499a88c336d5a8493e4b4ccfb608708be56a"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.5.0",
"proc-macro2", "proc-macro2",
"proc-macro2-diagnostics", "proc-macro2-diagnostics",
"quote", "quote",
"syn", "syn",
] ]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.11.0" version = "1.11.0"
@ -235,12 +294,33 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "filetime"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd"
dependencies = [
"cfg-if",
"libc",
"redox_syscall 0.4.1",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "fsevent-sys"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.30" version = "0.3.30"
@ -319,6 +399,16 @@ dependencies = [
"windows", "windows",
] ]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.15" version = "0.2.15"
@ -361,6 +451,20 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "handlebars"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225"
dependencies = [
"log",
"pest",
"pest_derive",
"serde",
"serde_json",
"thiserror",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.5" version = "0.14.5"
@ -448,6 +552,26 @@ version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb"
[[package]]
name = "inotify"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
dependencies = [
"bitflags 1.3.2",
"inotify-sys",
"libc",
]
[[package]]
name = "inotify-sys"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "is-terminal" name = "is-terminal"
version = "0.4.12" version = "0.4.12"
@ -465,6 +589,26 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "kqueue"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c"
dependencies = [
"kqueue-sys",
"libc",
]
[[package]]
name = "kqueue-sys"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
dependencies = [
"bitflags 1.3.2",
"libc",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -551,6 +695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
dependencies = [ dependencies = [
"libc", "libc",
"log",
"wasi", "wasi",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
@ -575,6 +720,34 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "normpath"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "notify"
version = "6.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d"
dependencies = [
"bitflags 2.5.0",
"crossbeam-channel",
"filetime",
"fsevent-sys",
"inotify",
"kqueue",
"libc",
"log",
"mio",
"walkdir",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.46.0" version = "0.46.0"
@ -640,7 +813,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"redox_syscall", "redox_syscall 0.5.1",
"smallvec", "smallvec",
"windows-targets 0.52.5", "windows-targets 0.52.5",
] ]
@ -674,6 +847,51 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "pest"
version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8"
dependencies = [
"memchr",
"thiserror",
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "pest_meta"
version = "2.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd"
dependencies = [
"once_cell",
"pest",
"sha2",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.14" version = "0.2.14"
@ -759,13 +977,22 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.1" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.5.0",
] ]
[[package]] [[package]]
@ -886,6 +1113,19 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "rocket_dyn_templates"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04bfc006e547e4f72b760ab861f5943b688aed8a82c4977b5500c98f5d17dbfa"
dependencies = [
"handlebars",
"normpath",
"notify",
"rocket",
"walkdir",
]
[[package]] [[package]]
name = "rocket_http" name = "rocket_http"
version = "0.5.0" version = "0.5.0"
@ -925,7 +1165,7 @@ version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.5.0",
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
@ -944,6 +1184,15 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "1.0.1" version = "1.0.1"
@ -996,6 +1245,17 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "sha2"
version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]] [[package]]
name = "sharded-slab" name = "sharded-slab"
version = "0.1.7" version = "0.1.7"
@ -1086,6 +1346,26 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "thiserror"
version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.8" version = "1.1.8"
@ -1286,6 +1566,7 @@ name = "traque"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"rocket", "rocket",
"rocket_dyn_templates",
] ]
[[package]] [[package]]
@ -1294,6 +1575,12 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]] [[package]]
name = "ubyte" name = "ubyte"
version = "0.10.4" version = "0.10.4"
@ -1303,6 +1590,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "ucd-trie"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]] [[package]]
name = "uncased" name = "uncased"
version = "0.9.10" version = "0.9.10"
@ -1337,6 +1630,16 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]] [[package]]
name = "want" name = "want"
version = "0.3.1" version = "0.3.1"
@ -1368,6 +1671,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"

View file

@ -7,3 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
rocket = "0.5.0" rocket = "0.5.0"
[dependencies.rocket_dyn_templates]
version = "0.1.0"
features = ["handlebars"]

View file

@ -1,4 +1,50 @@
#[macro_use] extern crate rocket; #[macro_use] extern crate rocket;
use rocket::fs::{FileServer, relative};
use rocket::State;
use std::{
collections::HashMap,
sync::RwLock,
};
use rocket_dyn_templates::{Template, context};
enum TrackedState {
Conscrit {
invisible: bool,
blurred: bool,
captured: bool,
malette: bool,
invisibility_codes: u32,
blur_codes: u32,
},
Vieux {
color: u8,
invisible: bool,
}
}
struct Tracked {
name: String,
pos: (f32, f32),
state: TrackedState,
}
type Tracking = RwLock<HashMap<String, RwLock<Tracked>>>;
#[get("/track/conscrit")]
fn conscrit() -> Template{
Template::render("conscrit", context!{
name: "un nom",
id: "ID",
gpslog: "no"
})
}
#[put("/track/<id>?<lat>&<long>")]
fn store_pos(id: String, lat: f32, long: f32, tracking: &State<Tracking>){
if let Some(tracked) = tracking.read().unwrap().get(&id) {
tracked.write().unwrap().pos = (lat, long);
}
}
#[get("/")] #[get("/")]
fn index() -> &'static str { fn index() -> &'static str {
@ -7,5 +53,11 @@ fn index() -> &'static str {
#[launch] #[launch]
fn rocket() -> _ { fn rocket() -> _ {
rocket::build().mount("/", routes![index]) let tracking = HashMap::<String, RwLock<Tracked>>::from([
]);
rocket::build()
.attach(Template::fairing())
.manage(RwLock::new(tracking))
.mount("/", routes![index, store_pos, conscrit])
.mount("/", FileServer::from(relative!("static")))
} }

View file

@ -1,76 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Traque | Client conscrit</title>
<!-- LEAFLET INCLUDE -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
crossorigin=""></script>
<!-- SOCKET.IO INCLUDE -->
<script src="/socket.io/socket.io.js"></script>
<style type="text/css">
#map { height: 600px; }
#codes {
position: fixed;
bottom: 0px;
z-index: 10000;
background-color: white;
width: 100%;
}
</style>
<script type="text/javascript" src="/utils.js"></script>
</head>
<body>
<div id="map"></div><br/>
<div id="codes"></div>
<div id="thanks">
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=50px /></a><br/>
<span style="font-size: 0.8em">Merci à la <a href="https://dgnum.eu">Délégation Générale NUMérique de l'ENS</a>, qui héberge ce site.</span>
</div>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////////////
// SETUP MAP
setup_map();
//////////////////////////////////////////////////////////////////////////////
// SOCKET
id = "%ID"; // %ID will be replaced by the real id.
socket = io({rejectUnauthorized: false, auth: {id: id, type:"conscrit"}});
setup_socket_common();
//////////////////////////////////////////////////////////////////////////////
// SETTINGS -- CODE
socket.on('setCodes', function(codes){
var code_buttons = "";
if(codes.invisibility > 0)
code_buttons += `<button onclick="socket.emit('useCode', 'invisibility')">
Invisibilité
</button>`;
if(codes.blurred > 0)
code_buttons += `<button onclick="socket.emit('useCode', 'blurred')">
Brouillage
</button>`;
document.getElementById(`codes`).innerHTML = code_buttons;
});
//////////////////////////////////////////////////////////////////////////////
// GEOLOCALISATION
if(%GPSLOG) setup_geoLoc();
</script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Équipe %ID inconnue ! </title>
</head>
<body>
<h1> Équipe %ID inconnue ! </h1>
Utilise bien les urls qu'on te donne petit conscrit.
<br/><br/>
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=50px /></a><br/>
<span style="font-size: 0.8em">Merci à la <a href="https://dgnum.eu">Délégation Générale NUMérique de l'ENS</a>, qui héberge ce site.</span>
</body>
</html>

View file

@ -1,119 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Traque | Client vieilleux</title>
<!-- LEAFLET INCLUDE -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
crossorigin=""></script>
<!-- SOCKET.IO INCLUDE -->
<script src="/socket.io/socket.io.js"></script>
<style type="text/css">
#map { height: 600px; }
#below {
position: fixed;
bottom: 0px;
z-index: 10000;
background-color: white;
width: 100%;
}
</style>
<script type="text/javascript" src="/utils.js"></script>
</head>
<body>
<div id="map"></div><br/>
<div id="below">
<form id="state">
<input type="checkbox" id="invisibility" name="invisibility" checked onclick='sendState()' />
<label for="invisibility">Invisible</label>
<input type="checkbox" id="blurred" name="blurred" onclick='sendState()' />
<label for="blurred">Brouillé</label></br>
<input type="radio" id="npc0" name="npc" value=0 onclick='sendState()' />
<label for="npc0">Traqueur</label>
<input type="radio" id="npc1" name="npc" value=1 checked onclick='sendState()' />
<label for="npc1"><img src="/icons/3.png" height=15px></label>
<input type="radio" id="npc2" name="npc" value=2 checked onclick='sendState()' />
<label for="npc2"><img src="/icons/4.png" height=15px></label>
<input type="radio" id="npc3" name="npc" value=3 checked onclick='sendState()' />
<label for="npc3"><img src="/icons/5.png" height=15px></label>
<input type="radio" id="npc4" name="npc" value=4 checked onclick='sendState()' />
<label for="npc4"><img src="/icons/6.png" height=15px></label>
<input type="radio" id="npc5" name="npc" value=5 checked onclick='sendState()' />
<label for="npc5"><img src="/icons/7.png" height=15px></label>
<input type="radio" id="npc6" name="npc" value=6 checked onclick='sendState()' />
<label for="npc6"><img src="/icons/8.png" height=15px></label>
<input type="radio" id="npc7" name="npc" value=7 checked onclick='sendState()' />
<label for="npc7"><img src="/icons/9.png" height=15px></label>
<input type="radio" id="npc8" name="npc" value=8 checked onclick='sendState()' />
<label for="npc8"><img src="/icons/10.png" height=15px></label>
<input type="radio" id="npc9" name="npc" value=9 checked onclick='sendState()' />
<label for="npc9"><img src="/icons/11.png" height=15px></label>
</form><br/>
<br/>
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=50px /></a><br/>
<span style="font-size: 0.8em">Merci à la <a href="https://dgnum.eu">Délégation Générale NUMérique de l'ENS</a>, qui héberge ce site.</span>
</div>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////////////
// SETUP MAP
setup_map();
//////////////////////////////////////////////////////////////////////////////
// UPDATE MAP
id = "%ID"; // %ID will be replaced by the real id.
socket = io({rejectUnauthorized: false, auth: {id: id, type:"vieux"}});
setup_socket_common();
//////////////////////////////////////////////////////////////////////////////
// SETTINGS -- State
var form = document.querySelector("#state");
function sendState(){
const data = new FormData(form);
var nState = {};
for(entry of data)
nState[entry[0]] = entry[1];
nState.invisibility = "invisibility" in nState;
nState.blurred = "blurred" in nState;
nState.tracker = nState.npc == 0;
socket.emit('changeState', nState);
}
socket.on('newState', function(state){
document.querySelector("#invisibility").checked = state.invisibility;
document.querySelector("#blurred").checked = state.blurred;
document.querySelector("#npc0").checked = state.npc == 0;
document.querySelector("#npc1").checked = state.npc == 1;
document.querySelector("#npc2").checked = state.npc == 2;
document.querySelector("#npc3").checked = state.npc == 3;
document.querySelector("#npc4").checked = state.npc == 4;
document.querySelector("#npc5").checked = state.npc == 5;
document.querySelector("#npc6").checked = state.npc == 6;
document.querySelector("#npc7").checked = state.npc == 7;
document.querySelector("#npc8").checked = state.npc == 8;
document.querySelector("#npc9").checked = state.npc == 9;
});
//////////////////////////////////////////////////////////////////////////////
// GEOLOCALISATION
if(%GPSLOG) setup_geoLoc();
</script>
</body>
</html>

View file

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Traque -- {{name}} | Client conscrit</title>
<!-- LEAFLET INCLUDE -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
crossorigin=""></script>
<!-- SOCKET.IO INCLUDE -->
<script src="/socket.io/socket.io.js"></script>
<style type="text/css">
#map { height: 600px; }
#codes {
position: fixed;
bottom: 0px;
z-index: 10000;
background-color: white;
width: 100%;
}
</style>
<script type="text/javascript" src="/utils.js"></script>
</head>
<body>
<div id="map"></div><br/>
<div id="codes"></div>
<div id="thanks">
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=50px /></a><br/>
<span style="font-size: 0.8em">Merci à la <a href="https://dgnum.eu">Délégation Générale NUMérique de l'ENS</a>, qui héberge ce site.</span>
</div>
<script type="text/javascript">
// //////////////////////////////////////////////////////////////////////////////
// // SETUP MAP
// setup_map();
// //////////////////////////////////////////////////////////////////////////////
// // SOCKET
// id = "{{id}}";
// socket = io({rejectUnauthorized: false, auth: {id: id, type:"conscrit"}});
// setup_socket_common();
// //////////////////////////////////////////////////////////////////////////////
// // SETTINGS -- CODE
// socket.on('setCodes', function(codes){
// var code_buttons = "";
// if(codes.invisibility > 0)
// code_buttons += `<button onclick="socket.emit('useCode', 'invisibility')">
// Invisibilité
// </button>`;
// if(codes.blurred > 0)
// code_buttons += `<button onclick="socket.emit('useCode', 'blurred')">
// Brouillage
// </button>`;
// document.getElementById(`codes`).innerHTML = code_buttons;
// });
// //////////////////////////////////////////////////////////////////////////////
// // GEOLOCALISATION
// if({{gpslog}}) setup_geoLoc();
</script>
</body>
</html>

119
templates/vieux.html.hbs Normal file
View file

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Traque -- {{name}} | Client vieilleux</title>
<!-- LEAFLET INCLUDE -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
crossorigin=""></script>
<!-- SOCKET.IO INCLUDE -->
<script src="/socket.io/socket.io.js"></script>
<style type="text/css">
#map { height: 600px; }
#below {
position: fixed;
bottom: 0px;
z-index: 10000;
background-color: white;
width: 100%;
}
</style>
<script type="text/javascript" src="/utils.js"></script>
</head>
<body>
<div id="map"></div><br/>
<div id="below">
<form id="state">
<input type="checkbox" id="invisibility" name="invisibility" checked onclick='sendState()' />
<label for="invisibility">Invisible</label>
<input type="checkbox" id="blurred" name="blurred" onclick='sendState()' />
<label for="blurred">Brouillé</label></br>
<input type="radio" id="npc0" name="npc" value=0 onclick='sendState()' />
<label for="npc0">Traqueur</label>
<input type="radio" id="npc1" name="npc" value=1 checked onclick='sendState()' />
<label for="npc1"><img src="/icons/3.png" height=15px></label>
<input type="radio" id="npc2" name="npc" value=2 checked onclick='sendState()' />
<label for="npc2"><img src="/icons/4.png" height=15px></label>
<input type="radio" id="npc3" name="npc" value=3 checked onclick='sendState()' />
<label for="npc3"><img src="/icons/5.png" height=15px></label>
<input type="radio" id="npc4" name="npc" value=4 checked onclick='sendState()' />
<label for="npc4"><img src="/icons/6.png" height=15px></label>
<input type="radio" id="npc5" name="npc" value=5 checked onclick='sendState()' />
<label for="npc5"><img src="/icons/7.png" height=15px></label>
<input type="radio" id="npc6" name="npc" value=6 checked onclick='sendState()' />
<label for="npc6"><img src="/icons/8.png" height=15px></label>
<input type="radio" id="npc7" name="npc" value=7 checked onclick='sendState()' />
<label for="npc7"><img src="/icons/9.png" height=15px></label>
<input type="radio" id="npc8" name="npc" value=8 checked onclick='sendState()' />
<label for="npc8"><img src="/icons/10.png" height=15px></label>
<input type="radio" id="npc9" name="npc" value=9 checked onclick='sendState()' />
<label for="npc9"><img src="/icons/11.png" height=15px></label>
</form><br/>
<br/>
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=50px /></a><br/>
<span style="font-size: 0.8em">Merci à la <a href="https://dgnum.eu">Délégation Générale NUMérique de l'ENS</a>, qui héberge ce site.</span>
</div>
<script type="text/javascript">
// //////////////////////////////////////////////////////////////////////////////
// // SETUP MAP
// setup_map();
//
// //////////////////////////////////////////////////////////////////////////////
// // UPDATE MAP
// id = "{{id}}";
// socket = io({rejectUnauthorized: false, auth: {id: id, type:"vieux"}});
// setup_socket_common();
// //////////////////////////////////////////////////////////////////////////////
// // SETTINGS -- State
// var form = document.querySelector("#state");
// function sendState(){
// const data = new FormData(form);
// var nState = {};
// for(entry of data)
// nState[entry[0]] = entry[1];
// nState.invisibility = "invisibility" in nState;
// nState.blurred = "blurred" in nState;
// nState.tracker = nState.npc == 0;
// socket.emit('changeState', nState);
// }
// socket.on('newState', function(state){
// document.querySelector("#invisibility").checked = state.invisibility;
// document.querySelector("#blurred").checked = state.blurred;
// document.querySelector("#npc0").checked = state.npc == 0;
// document.querySelector("#npc1").checked = state.npc == 1;
// document.querySelector("#npc2").checked = state.npc == 2;
// document.querySelector("#npc3").checked = state.npc == 3;
// document.querySelector("#npc4").checked = state.npc == 4;
// document.querySelector("#npc5").checked = state.npc == 5;
// document.querySelector("#npc6").checked = state.npc == 6;
// document.querySelector("#npc7").checked = state.npc == 7;
// document.querySelector("#npc8").checked = state.npc == 8;
// document.querySelector("#npc9").checked = state.npc == 9;
// });
// //////////////////////////////////////////////////////////////////////////////
// // GEOLOCALISATION
// if({{gpslog}}) setup_geoLoc();
</script>
</body>
</html>