forge
Explore
Log in

Don't you dare go Hollow

Web scaffold: boot, shell, assets, nav.js, live hub, security headers, healthz, 404

Browse files at this commit

832b437192257ebd9ad2c5285c3c13ac7f37c5e7Ahmet Kaan GümüşParent: 76964b1
  • feat
    • web scaffold: boot, shell, assets, nav.js, live hub, security headers, healthz, 404
Show full message
✨ feat: web scaffold: boot, shell, assets, nav.js, live hub, security headers, healthz, 404
Cargo.lockmodified+1075 -15
@@ -57,6 +57,18 @@ dependencies = [
5757 "subtle",
5858 ]
5959
60+[[package]]
61+name = "ahash"
62+version = "0.8.12"
63+source = "registry+https://github.com/rust-lang/crates.io-index"
64+checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
65+dependencies = [
66+ "cfg-if",
67+ "once_cell",
68+ "version_check",
69+ "zerocopy",
70+]
71+
6072 [[package]]
6173 name = "aho-corasick"
6274 version = "1.1.5"
@@ -87,6 +99,56 @@ dependencies = [
8799 "libc",
88100 ]
89101
102+[[package]]
103+name = "anstream"
104+version = "1.0.0"
105+source = "registry+https://github.com/rust-lang/crates.io-index"
106+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
107+dependencies = [
108+ "anstyle",
109+ "anstyle-parse",
110+ "anstyle-query",
111+ "anstyle-wincon",
112+ "colorchoice",
113+ "is_terminal_polyfill",
114+ "utf8parse",
115+]
116+
117+[[package]]
118+name = "anstyle"
119+version = "1.0.14"
120+source = "registry+https://github.com/rust-lang/crates.io-index"
121+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
122+
123+[[package]]
124+name = "anstyle-parse"
125+version = "1.0.0"
126+source = "registry+https://github.com/rust-lang/crates.io-index"
127+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
128+dependencies = [
129+ "utf8parse",
130+]
131+
132+[[package]]
133+name = "anstyle-query"
134+version = "1.1.5"
135+source = "registry+https://github.com/rust-lang/crates.io-index"
136+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
137+dependencies = [
138+ "windows-sys 0.61.2",
139+]
140+
141+[[package]]
142+name = "anstyle-wincon"
143+version = "3.0.11"
144+source = "registry+https://github.com/rust-lang/crates.io-index"
145+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
146+dependencies = [
147+ "anstyle",
148+ "once_cell_polyfill",
149+ "windows-sys 0.61.2",
150+]
151+
90152 [[package]]
91153 name = "antithesis_sdk"
92154 version = "0.3.0"
@@ -109,6 +171,12 @@ version = "1.0.104"
109171 source = "registry+https://github.com/rust-lang/crates.io-index"
110172 checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
111173
174+[[package]]
175+name = "anymap3"
176+version = "1.1.0"
177+source = "registry+https://github.com/rust-lang/crates.io-index"
178+checksum = "fb5dfbc6d8d2675589ccbe4d0fd61df2419075625f8c1a62325e718e2b0049f9"
179+
112180 [[package]]
113181 name = "arc-swap"
114182 version = "1.9.3"
@@ -155,6 +223,12 @@ dependencies = [
155223 "syn 3.0.9",
156224 ]
157225
226+[[package]]
227+name = "atomic-waker"
228+version = "1.1.2"
229+source = "registry+https://github.com/rust-lang/crates.io-index"
230+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
231+
158232 [[package]]
159233 name = "autocfg"
160234 version = "1.5.1"
@@ -242,6 +316,15 @@ dependencies = [
242316 "wyz",
243317 ]
244318
319+[[package]]
320+name = "block-buffer"
321+version = "0.10.4"
322+source = "registry+https://github.com/rust-lang/crates.io-index"
323+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
324+dependencies = [
325+ "generic-array",
326+]
327+
245328 [[package]]
246329 name = "block-buffer"
247330 version = "0.12.1"
@@ -345,7 +428,7 @@ version = "0.6.0"
345428 source = "registry+https://github.com/rust-lang/crates.io-index"
346429 checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
347430 dependencies = [
348- "nom",
431+ "nom 7.1.3",
349432 ]
350433
351434 [[package]]
@@ -419,7 +502,7 @@ version = "0.5.2"
419502 source = "registry+https://github.com/rust-lang/crates.io-index"
420503 checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
421504 dependencies = [
422- "block-buffer",
505+ "block-buffer 0.12.1",
423506 "crypto-common 0.2.2",
424507 "inout 0.2.5",
425508 ]
@@ -435,12 +518,51 @@ dependencies = [
435518 "libloading",
436519 ]
437520
521+[[package]]
522+name = "clap"
523+version = "4.6.7"
524+source = "registry+https://github.com/rust-lang/crates.io-index"
525+checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
526+dependencies = [
527+ "clap_builder",
528+]
529+
530+[[package]]
531+name = "clap_builder"
532+version = "4.6.7"
533+source = "registry+https://github.com/rust-lang/crates.io-index"
534+checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
535+dependencies = [
536+ "anstream",
537+ "anstyle",
538+ "clap_lex",
539+ "strsim",
540+]
541+
542+[[package]]
543+name = "clap_lex"
544+version = "1.1.1"
545+source = "registry+https://github.com/rust-lang/crates.io-index"
546+checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
547+
438548 [[package]]
439549 name = "cmov"
440550 version = "0.5.4"
441551 source = "registry+https://github.com/rust-lang/crates.io-index"
442552 checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
443553
554+[[package]]
555+name = "codemap"
556+version = "0.1.3"
557+source = "registry+https://github.com/rust-lang/crates.io-index"
558+checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24"
559+
560+[[package]]
561+name = "colorchoice"
562+version = "1.0.5"
563+source = "registry+https://github.com/rust-lang/crates.io-index"
564+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
565+
444566 [[package]]
445567 name = "concurrent-queue"
446568 version = "2.5.0"
@@ -456,12 +578,36 @@ version = "0.10.2"
456578 source = "registry+https://github.com/rust-lang/crates.io-index"
457579 checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
458580
581+[[package]]
582+name = "cookie"
583+version = "0.18.2"
584+source = "registry+https://github.com/rust-lang/crates.io-index"
585+checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87"
586+dependencies = [
587+ "aes-gcm",
588+ "base64 0.22.1",
589+ "hkdf",
590+ "hmac",
591+ "percent-encoding",
592+ "rand 0.8.8",
593+ "sha2 0.10.9",
594+ "subtle",
595+ "time",
596+ "version_check",
597+]
598+
459599 [[package]]
460600 name = "core-foundation-sys"
461601 version = "0.8.7"
462602 source = "registry+https://github.com/rust-lang/crates.io-index"
463603 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
464604
605+[[package]]
606+name = "core_detect"
607+version = "1.0.0"
608+source = "registry+https://github.com/rust-lang/crates.io-index"
609+checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
610+
465611 [[package]]
466612 name = "cpufeatures"
467613 version = "0.2.17"
@@ -612,6 +758,12 @@ dependencies = [
612758 "syn 3.0.9",
613759 ]
614760
761+[[package]]
762+name = "data-encoding"
763+version = "2.11.1"
764+source = "registry+https://github.com/rust-lang/crates.io-index"
765+checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
766+
615767 [[package]]
616768 name = "datasketches"
617769 version = "0.2.0"
@@ -658,13 +810,24 @@ dependencies = [
658810 "serde_core",
659811 ]
660812
813+[[package]]
814+name = "digest"
815+version = "0.10.7"
816+source = "registry+https://github.com/rust-lang/crates.io-index"
817+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
818+dependencies = [
819+ "block-buffer 0.10.4",
820+ "crypto-common 0.1.7",
821+ "subtle",
822+]
823+
661824 [[package]]
662825 name = "digest"
663826 version = "0.11.3"
664827 source = "registry+https://github.com/rust-lang/crates.io-index"
665828 checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
666829 dependencies = [
667- "block-buffer",
830+ "block-buffer 0.12.1",
668831 "const-oid",
669832 "crypto-common 0.2.2",
670833 ]
@@ -692,6 +855,45 @@ version = "1.19.0"
692855 source = "registry+https://github.com/rust-lang/crates.io-index"
693856 checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
694857
858+[[package]]
859+name = "elsa"
860+version = "1.11.2"
861+source = "registry+https://github.com/rust-lang/crates.io-index"
862+checksum = "9abf33c656a7256451ebb7d0082c5a471820c31269e49d807c538c252352186e"
863+dependencies = [
864+ "stable_deref_trait",
865+]
866+
867+[[package]]
868+name = "email-encoding"
869+version = "0.4.2"
870+source = "registry+https://github.com/rust-lang/crates.io-index"
871+checksum = "420b9da095f052ea597503e39073b5b3c522f7db933fbac202d91d24492693fd"
872+dependencies = [
873+ "base64 0.23.1",
874+ "memchr",
875+]
876+
877+[[package]]
878+name = "email_address"
879+version = "0.2.9"
880+source = "registry+https://github.com/rust-lang/crates.io-index"
881+checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449"
882+
883+[[package]]
884+name = "encoding_rs"
885+version = "0.8.42"
886+source = "registry+https://github.com/rust-lang/crates.io-index"
887+checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"
888+dependencies = [
889+ "cfg-if",
890+ "core_detect",
891+ "multiversion_no_op",
892+ "rustversion",
893+ "scopeguard",
894+ "simdutf8",
895+]
896+
695897 [[package]]
696898 name = "env_filter"
697899 version = "2.0.0"
@@ -786,6 +988,15 @@ version = "0.2.0"
786988 source = "registry+https://github.com/rust-lang/crates.io-index"
787989 checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
788990
991+[[package]]
992+name = "form_urlencoded"
993+version = "1.2.2"
994+source = "registry+https://github.com/rust-lang/crates.io-index"
995+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
996+dependencies = [
997+ "percent-encoding",
998+]
999+
7891000 [[package]]
7901001 name = "fs4"
7911002 version = "0.13.1"
@@ -802,6 +1013,15 @@ version = "2.0.0"
8021013 source = "registry+https://github.com/rust-lang/crates.io-index"
8031014 checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
8041015
1016+[[package]]
1017+name = "futures-channel"
1018+version = "0.3.34"
1019+source = "registry+https://github.com/rust-lang/crates.io-index"
1020+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
1021+dependencies = [
1022+ "futures-core",
1023+]
1024+
8051025 [[package]]
8061026 name = "futures-core"
8071027 version = "0.3.34"
@@ -819,6 +1039,12 @@ dependencies = [
8191039 "syn 3.0.9",
8201040 ]
8211041
1042+[[package]]
1043+name = "futures-sink"
1044+version = "0.3.34"
1045+source = "registry+https://github.com/rust-lang/crates.io-index"
1046+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"
1047+
8221048 [[package]]
8231049 name = "futures-task"
8241050 version = "0.3.34"
@@ -833,6 +1059,7 @@ checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
8331059 dependencies = [
8341060 "futures-core",
8351061 "futures-macro",
1062+ "futures-sink",
8361063 "futures-task",
8371064 "pin-project-lite",
8381065 "slab",
@@ -935,6 +1162,60 @@ version = "0.3.4"
9351162 source = "registry+https://github.com/rust-lang/crates.io-index"
9361163 checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
9371164
1165+[[package]]
1166+name = "grass"
1167+version = "0.13.4"
1168+source = "registry+https://github.com/rust-lang/crates.io-index"
1169+checksum = "f7a68216437ef68f0738e48d6c7bb9e6e6a92237e001b03d838314b068f33c94"
1170+dependencies = [
1171+ "clap",
1172+ "getrandom 0.2.17",
1173+ "grass_compiler",
1174+]
1175+
1176+[[package]]
1177+name = "grass_compiler"
1178+version = "0.13.4"
1179+source = "registry+https://github.com/rust-lang/crates.io-index"
1180+checksum = "2d9e3df7f0222ce5184154973d247c591d9aadc28ce7a73c6cd31100c9facff6"
1181+dependencies = [
1182+ "codemap",
1183+ "indexmap",
1184+ "lasso",
1185+ "once_cell",
1186+ "phf",
1187+ "rand 0.8.8",
1188+]
1189+
1190+[[package]]
1191+name = "h2"
1192+version = "0.4.20"
1193+source = "registry+https://github.com/rust-lang/crates.io-index"
1194+checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118"
1195+dependencies = [
1196+ "atomic-waker",
1197+ "bytes",
1198+ "fnv",
1199+ "futures-core",
1200+ "futures-sink",
1201+ "http",
1202+ "indexmap",
1203+ "slab",
1204+ "tokio",
1205+ "tokio-util",
1206+ "tracing",
1207+]
1208+
1209+[[package]]
1210+name = "hashbrown"
1211+version = "0.14.5"
1212+source = "registry+https://github.com/rust-lang/crates.io-index"
1213+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
1214+dependencies = [
1215+ "ahash",
1216+ "allocator-api2 0.2.21",
1217+]
1218+
9381219 [[package]]
9391220 name = "hashbrown"
9401221 version = "0.16.1"
@@ -970,6 +1251,24 @@ version = "0.4.3"
9701251 source = "registry+https://github.com/rust-lang/crates.io-index"
9711252 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
9721253
1254+[[package]]
1255+name = "hkdf"
1256+version = "0.12.4"
1257+source = "registry+https://github.com/rust-lang/crates.io-index"
1258+checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
1259+dependencies = [
1260+ "hmac",
1261+]
1262+
1263+[[package]]
1264+name = "hmac"
1265+version = "0.12.1"
1266+source = "registry+https://github.com/rust-lang/crates.io-index"
1267+checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
1268+dependencies = [
1269+ "digest 0.10.7",
1270+]
1271+
9731272 [[package]]
9741273 name = "home"
9751274 version = "0.5.12"
@@ -979,6 +1278,17 @@ dependencies = [
9791278 "windows-sys 0.61.2",
9801279 ]
9811280
1281+[[package]]
1282+name = "hostname"
1283+version = "0.4.2"
1284+source = "registry+https://github.com/rust-lang/crates.io-index"
1285+checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd"
1286+dependencies = [
1287+ "cfg-if",
1288+ "libc",
1289+ "windows-link",
1290+]
1291+
9821292 [[package]]
9831293 name = "htmlescape"
9841294 version = "0.3.1"
@@ -995,6 +1305,41 @@ dependencies = [
9951305 "itoa",
9961306 ]
9971307
1308+[[package]]
1309+name = "http-body"
1310+version = "1.1.0"
1311+source = "registry+https://github.com/rust-lang/crates.io-index"
1312+checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"
1313+dependencies = [
1314+ "bytes",
1315+ "http",
1316+]
1317+
1318+[[package]]
1319+name = "http-body-util"
1320+version = "0.1.5"
1321+source = "registry+https://github.com/rust-lang/crates.io-index"
1322+checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c"
1323+dependencies = [
1324+ "bytes",
1325+ "futures-core",
1326+ "http",
1327+ "http-body",
1328+ "pin-project-lite",
1329+]
1330+
1331+[[package]]
1332+name = "httparse"
1333+version = "1.10.1"
1334+source = "registry+https://github.com/rust-lang/crates.io-index"
1335+checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
1336+
1337+[[package]]
1338+name = "httpdate"
1339+version = "1.0.3"
1340+source = "registry+https://github.com/rust-lang/crates.io-index"
1341+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
1342+
9981343 [[package]]
9991344 name = "hybrid-array"
10001345 version = "0.4.15"
@@ -1004,6 +1349,41 @@ dependencies = [
10041349 "typenum",
10051350 ]
10061351
1352+[[package]]
1353+name = "hyper"
1354+version = "1.12.0"
1355+source = "registry+https://github.com/rust-lang/crates.io-index"
1356+checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"
1357+dependencies = [
1358+ "atomic-waker",
1359+ "bytes",
1360+ "futures-channel",
1361+ "futures-core",
1362+ "h2",
1363+ "http",
1364+ "http-body",
1365+ "httparse",
1366+ "httpdate",
1367+ "itoa",
1368+ "pin-project-lite",
1369+ "smallvec",
1370+ "tokio",
1371+]
1372+
1373+[[package]]
1374+name = "hyper-util"
1375+version = "0.1.21"
1376+source = "registry+https://github.com/rust-lang/crates.io-index"
1377+checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"
1378+dependencies = [
1379+ "bytes",
1380+ "http",
1381+ "http-body",
1382+ "hyper",
1383+ "pin-project-lite",
1384+ "tokio",
1385+]
1386+
10071387 [[package]]
10081388 name = "iana-time-zone"
10091389 version = "0.1.65"
@@ -1190,22 +1570,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
11901570 checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
11911571
11921572 [[package]]
1193-name = "indexmap"
1194-version = "2.14.2"
1573+name = "idna"
1574+version = "1.1.0"
11951575 source = "registry+https://github.com/rust-lang/crates.io-index"
1196-checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
1576+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
11971577 dependencies = [
1198- "equivalent",
1199- "hashbrown 0.17.1",
1578+ "idna_adapter",
1579+ "smallvec",
1580+ "utf8_iter",
12001581 ]
12011582
12021583 [[package]]
1203-name = "inout"
1204-version = "0.1.4"
1584+name = "idna_adapter"
1585+version = "1.2.2"
12051586 source = "registry+https://github.com/rust-lang/crates.io-index"
1206-checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
1587+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
12071588 dependencies = [
1208- "generic-array",
1589+ "icu_normalizer",
1590+ "icu_properties",
1591+]
1592+
1593+[[package]]
1594+name = "indexmap"
1595+version = "2.14.2"
1596+source = "registry+https://github.com/rust-lang/crates.io-index"
1597+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
1598+dependencies = [
1599+ "equivalent",
1600+ "hashbrown 0.17.1",
1601+]
1602+
1603+[[package]]
1604+name = "inout"
1605+version = "0.1.4"
1606+source = "registry+https://github.com/rust-lang/crates.io-index"
1607+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
1608+dependencies = [
1609+ "generic-array",
12091610 ]
12101611
12111612 [[package]]
@@ -1252,6 +1653,12 @@ version = "2.12.2"
12521653 source = "registry+https://github.com/rust-lang/crates.io-index"
12531654 checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"
12541655
1656+[[package]]
1657+name = "is_terminal_polyfill"
1658+version = "1.70.2"
1659+source = "registry+https://github.com/rust-lang/crates.io-index"
1660+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
1661+
12551662 [[package]]
12561663 name = "itertools"
12571664 version = "0.12.1"
@@ -1288,7 +1695,7 @@ dependencies = [
12881695 "rand 0.10.3",
12891696 "serde",
12901697 "serde_json",
1291- "sha2",
1698+ "sha2 0.11.1",
12921699 "subtle",
12931700 "tempfile",
12941701 "thiserror",
@@ -1303,6 +1710,19 @@ dependencies = [
13031710 [[package]]
13041711 name = "iz-web"
13051712 version = "0.1.0"
1713+dependencies = [
1714+ "futures-util",
1715+ "grass",
1716+ "hex",
1717+ "http",
1718+ "iz-core",
1719+ "sha2 0.11.1",
1720+ "tempfile",
1721+ "tokio",
1722+ "topcoat",
1723+ "tracing",
1724+ "tracing-subscriber",
1725+]
13061726
13071727 [[package]]
13081728 name = "jiff"
@@ -1369,6 +1789,15 @@ dependencies = [
13691789 "wasm-bindgen",
13701790 ]
13711791
1792+[[package]]
1793+name = "lasso"
1794+version = "0.7.3"
1795+source = "registry+https://github.com/rust-lang/crates.io-index"
1796+checksum = "6e14eda50a3494b3bf7b9ce51c52434a761e383d7238ce1dd5dcec2fbc13e9fb"
1797+dependencies = [
1798+ "hashbrown 0.14.5",
1799+]
1800+
13721801 [[package]]
13731802 name = "lazy_static"
13741803 version = "1.5.1"
@@ -1381,6 +1810,23 @@ version = "1.3.0"
13811810 source = "registry+https://github.com/rust-lang/crates.io-index"
13821811 checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
13831812
1813+[[package]]
1814+name = "lettre"
1815+version = "0.11.23"
1816+source = "registry+https://github.com/rust-lang/crates.io-index"
1817+checksum = "f2c646bd5cc763b1087b15493e29a64be6147ba8f19342004fa52048ee596eae"
1818+dependencies = [
1819+ "email-encoding",
1820+ "email_address",
1821+ "fastrand",
1822+ "hostname",
1823+ "httpdate",
1824+ "idna",
1825+ "mime",
1826+ "nom 8.0.0",
1827+ "quoted_printable",
1828+]
1829+
13841830 [[package]]
13851831 name = "levenshtein_automata"
13861832 version = "0.2.1"
@@ -1508,6 +1954,12 @@ dependencies = [
15081954 "regex-automata",
15091955 ]
15101956
1957+[[package]]
1958+name = "matchit"
1959+version = "0.9.2"
1960+source = "registry+https://github.com/rust-lang/crates.io-index"
1961+checksum = "8863b587001c1b9a8a4e36008cebc6b3612cb1226fe2de94858e06092687b608"
1962+
15111963 [[package]]
15121964 name = "measure_time"
15131965 version = "0.9.0"
@@ -1572,12 +2024,52 @@ dependencies = [
15722024 "libmimalloc-sys",
15732025 ]
15742026
2027+[[package]]
2028+name = "mime"
2029+version = "0.3.17"
2030+source = "registry+https://github.com/rust-lang/crates.io-index"
2031+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
2032+
15752033 [[package]]
15762034 name = "minimal-lexical"
15772035 version = "0.2.1"
15782036 source = "registry+https://github.com/rust-lang/crates.io-index"
15792037 checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
15802038
2039+[[package]]
2040+name = "mio"
2041+version = "1.2.4"
2042+source = "registry+https://github.com/rust-lang/crates.io-index"
2043+checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
2044+dependencies = [
2045+ "libc",
2046+ "wasi",
2047+ "windows-sys 0.61.2",
2048+]
2049+
2050+[[package]]
2051+name = "multer"
2052+version = "3.1.0"
2053+source = "registry+https://github.com/rust-lang/crates.io-index"
2054+checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b"
2055+dependencies = [
2056+ "bytes",
2057+ "encoding_rs",
2058+ "futures-util",
2059+ "http",
2060+ "httparse",
2061+ "memchr",
2062+ "mime",
2063+ "spin",
2064+ "version_check",
2065+]
2066+
2067+[[package]]
2068+name = "multiversion_no_op"
2069+version = "1.0.0"
2070+source = "registry+https://github.com/rust-lang/crates.io-index"
2071+checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"
2072+
15812073 [[package]]
15822074 name = "murmurhash32"
15832075 version = "0.3.1"
@@ -1594,6 +2086,15 @@ dependencies = [
15942086 "minimal-lexical",
15952087 ]
15962088
2089+[[package]]
2090+name = "nom"
2091+version = "8.0.0"
2092+source = "registry+https://github.com/rust-lang/crates.io-index"
2093+checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
2094+dependencies = [
2095+ "memchr",
2096+]
2097+
15972098 [[package]]
15982099 name = "nu-ansi-term"
15992100 version = "0.50.3"
@@ -1643,6 +2144,12 @@ version = "1.21.4"
16432144 source = "registry+https://github.com/rust-lang/crates.io-index"
16442145 checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
16452146
2147+[[package]]
2148+name = "once_cell_polyfill"
2149+version = "1.70.2"
2150+source = "registry+https://github.com/rust-lang/crates.io-index"
2151+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
2152+
16462153 [[package]]
16472154 name = "oneshot"
16482155 version = "0.1.13"
@@ -1717,6 +2224,54 @@ version = "0.2.3"
17172224 source = "registry+https://github.com/rust-lang/crates.io-index"
17182225 checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
17192226
2227+[[package]]
2228+name = "percent-encoding"
2229+version = "2.3.2"
2230+source = "registry+https://github.com/rust-lang/crates.io-index"
2231+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
2232+
2233+[[package]]
2234+name = "phf"
2235+version = "0.11.3"
2236+source = "registry+https://github.com/rust-lang/crates.io-index"
2237+checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
2238+dependencies = [
2239+ "phf_macros",
2240+ "phf_shared",
2241+]
2242+
2243+[[package]]
2244+name = "phf_generator"
2245+version = "0.11.3"
2246+source = "registry+https://github.com/rust-lang/crates.io-index"
2247+checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
2248+dependencies = [
2249+ "phf_shared",
2250+ "rand 0.8.8",
2251+]
2252+
2253+[[package]]
2254+name = "phf_macros"
2255+version = "0.11.3"
2256+source = "registry+https://github.com/rust-lang/crates.io-index"
2257+checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
2258+dependencies = [
2259+ "phf_generator",
2260+ "phf_shared",
2261+ "proc-macro2",
2262+ "quote",
2263+ "syn 2.0.119",
2264+]
2265+
2266+[[package]]
2267+name = "phf_shared"
2268+version = "0.11.3"
2269+source = "registry+https://github.com/rust-lang/crates.io-index"
2270+checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
2271+dependencies = [
2272+ "siphasher",
2273+]
2274+
17202275 [[package]]
17212276 name = "pin-project-lite"
17222277 version = "0.2.17"
@@ -1826,6 +2381,15 @@ dependencies = [
18262381 "syn 3.0.9",
18272382 ]
18282383
2384+[[package]]
2385+name = "proc-macro-crate"
2386+version = "3.5.0"
2387+source = "registry+https://github.com/rust-lang/crates.io-index"
2388+checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
2389+dependencies = [
2390+ "toml_edit",
2391+]
2392+
18292393 [[package]]
18302394 name = "proc-macro2"
18312395 version = "1.0.107"
@@ -1867,6 +2431,12 @@ dependencies = [
18672431 "proc-macro2",
18682432 ]
18692433
2434+[[package]]
2435+name = "quoted_printable"
2436+version = "0.5.2"
2437+source = "registry+https://github.com/rust-lang/crates.io-index"
2438+checksum = "478e0585659a122aa407eb7e3c0e1fa51b1d8a870038bd29f0cf4a8551eea972"
2439+
18702440 [[package]]
18712441 name = "r-efi"
18722442 version = "5.3.0"
@@ -2008,6 +2578,26 @@ dependencies = [
20082578 "bitflags 2.13.2",
20092579 ]
20102580
2581+[[package]]
2582+name = "ref-cast"
2583+version = "1.0.27"
2584+source = "registry+https://github.com/rust-lang/crates.io-index"
2585+checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3"
2586+dependencies = [
2587+ "ref-cast-impl",
2588+]
2589+
2590+[[package]]
2591+name = "ref-cast-impl"
2592+version = "1.0.27"
2593+source = "registry+https://github.com/rust-lang/crates.io-index"
2594+checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
2595+dependencies = [
2596+ "proc-macro2",
2597+ "quote",
2598+ "syn 3.0.9",
2599+]
2600+
20112601 [[package]]
20122602 name = "regex"
20132603 version = "1.13.1"
@@ -2187,6 +2777,17 @@ dependencies = [
21872777 "zmij",
21882778 ]
21892779
2780+[[package]]
2781+name = "serde_path_to_error"
2782+version = "0.1.20"
2783+source = "registry+https://github.com/rust-lang/crates.io-index"
2784+checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457"
2785+dependencies = [
2786+ "itoa",
2787+ "serde",
2788+ "serde_core",
2789+]
2790+
21902791 [[package]]
21912792 name = "serde_spanned"
21922793 version = "1.1.2"
@@ -2196,12 +2797,46 @@ dependencies = [
21962797 "serde_core",
21972798 ]
21982799
2800+[[package]]
2801+name = "serde_urlencoded"
2802+version = "0.7.1"
2803+source = "registry+https://github.com/rust-lang/crates.io-index"
2804+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
2805+dependencies = [
2806+ "form_urlencoded",
2807+ "itoa",
2808+ "ryu",
2809+ "serde",
2810+]
2811+
2812+[[package]]
2813+name = "sha1"
2814+version = "0.10.7"
2815+source = "registry+https://github.com/rust-lang/crates.io-index"
2816+checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"
2817+dependencies = [
2818+ "cfg-if",
2819+ "cpufeatures 0.2.17",
2820+ "digest 0.10.7",
2821+]
2822+
21992823 [[package]]
22002824 name = "sha1_smol"
22012825 version = "1.0.1"
22022826 source = "registry+https://github.com/rust-lang/crates.io-index"
22032827 checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"
22042828
2829+[[package]]
2830+name = "sha2"
2831+version = "0.10.9"
2832+source = "registry+https://github.com/rust-lang/crates.io-index"
2833+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
2834+dependencies = [
2835+ "cfg-if",
2836+ "cpufeatures 0.2.17",
2837+ "digest 0.10.7",
2838+]
2839+
22052840 [[package]]
22062841 name = "sha2"
22072842 version = "0.11.1"
@@ -2210,7 +2845,7 @@ checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"
22102845 dependencies = [
22112846 "cfg-if",
22122847 "cpufeatures 0.3.1",
2213- "digest",
2848+ "digest 0.11.3",
22142849 ]
22152850
22162851 [[package]]
@@ -2254,6 +2889,16 @@ dependencies = [
22542889 "tracing",
22552890 ]
22562891
2892+[[package]]
2893+name = "signal-hook-registry"
2894+version = "1.4.8"
2895+source = "registry+https://github.com/rust-lang/crates.io-index"
2896+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
2897+dependencies = [
2898+ "errno",
2899+ "libc",
2900+]
2901+
22572902 [[package]]
22582903 name = "simdutf8"
22592904 version = "0.1.5"
@@ -2296,12 +2941,28 @@ version = "1.16.4"
22962941 source = "registry+https://github.com/rust-lang/crates.io-index"
22972942 checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8"
22982943
2944+[[package]]
2945+name = "socket2"
2946+version = "0.6.5"
2947+source = "registry+https://github.com/rust-lang/crates.io-index"
2948+checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
2949+dependencies = [
2950+ "libc",
2951+ "windows-sys 0.61.2",
2952+]
2953+
22992954 [[package]]
23002955 name = "softaes"
23012956 version = "0.1.7"
23022957 source = "registry+https://github.com/rust-lang/crates.io-index"
23032958 checksum = "c4fdfe13e1c42e45f497416afb8dc4e783bf0e25b7be9077c1c77c5fb14cb998"
23042959
2960+[[package]]
2961+name = "spin"
2962+version = "0.9.9"
2963+source = "registry+https://github.com/rust-lang/crates.io-index"
2964+checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
2965+
23052966 [[package]]
23062967 name = "stable_deref_trait"
23072968 version = "1.2.1"
@@ -2490,7 +3151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
24903151 checksum = "dfadb8526b6da90704feb293b0701a6aae62ea14983143344be2dc5ce30f1d82"
24913152 dependencies = [
24923153 "fnv",
2493- "nom",
3154+ "nom 7.1.3",
24943155 "ordered-float",
24953156 "serde",
24963157 "serde_json",
@@ -2624,8 +3285,14 @@ version = "1.54.1"
26243285 source = "registry+https://github.com/rust-lang/crates.io-index"
26253286 checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
26263287 dependencies = [
3288+ "bytes",
3289+ "libc",
3290+ "mio",
26273291 "pin-project-lite",
3292+ "signal-hook-registry",
3293+ "socket2",
26283294 "tokio-macros",
3295+ "windows-sys 0.61.2",
26293296 ]
26303297
26313298 [[package]]
@@ -2639,6 +3306,32 @@ dependencies = [
26393306 "syn 3.0.9",
26403307 ]
26413308
3309+[[package]]
3310+name = "tokio-tungstenite"
3311+version = "0.29.0"
3312+source = "registry+https://github.com/rust-lang/crates.io-index"
3313+checksum = "8f72a05e828585856dacd553fba484c242c46e391fb0e58917c942ee9202915c"
3314+dependencies = [
3315+ "futures-util",
3316+ "log",
3317+ "tokio",
3318+ "tungstenite",
3319+]
3320+
3321+[[package]]
3322+name = "tokio-util"
3323+version = "0.7.20"
3324+source = "registry+https://github.com/rust-lang/crates.io-index"
3325+checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b"
3326+dependencies = [
3327+ "bytes",
3328+ "futures-core",
3329+ "futures-sink",
3330+ "libc",
3331+ "pin-project-lite",
3332+ "tokio",
3333+]
3334+
26423335 [[package]]
26433336 name = "toml"
26443337 version = "1.1.8+spec-1.1.0"
@@ -2663,6 +3356,18 @@ dependencies = [
26633356 "serde_core",
26643357 ]
26653358
3359+[[package]]
3360+name = "toml_edit"
3361+version = "0.25.17+spec-1.1.0"
3362+source = "registry+https://github.com/rust-lang/crates.io-index"
3363+checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c"
3364+dependencies = [
3365+ "indexmap",
3366+ "toml_datetime",
3367+ "toml_parser",
3368+ "winnow",
3369+]
3370+
26663371 [[package]]
26673372 name = "toml_parser"
26683373 version = "1.1.5+spec-1.1.0"
@@ -2678,6 +3383,336 @@ version = "1.1.3+spec-1.1.0"
26783383 source = "registry+https://github.com/rust-lang/crates.io-index"
26793384 checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770"
26803385
3386+[[package]]
3387+name = "topcoat"
3388+version = "0.11.0"
3389+source = "registry+https://github.com/rust-lang/crates.io-index"
3390+checksum = "70b5093d8133b513742b7461a28d374107b8bf9168aa60f4f567ad89acd2ed9e"
3391+dependencies = [
3392+ "futures-util",
3393+ "inventory",
3394+ "serde",
3395+ "tokio",
3396+ "tokio-tungstenite",
3397+ "topcoat-asset",
3398+ "topcoat-cookie",
3399+ "topcoat-core",
3400+ "topcoat-core-macro",
3401+ "topcoat-font",
3402+ "topcoat-font-macro",
3403+ "topcoat-l10n",
3404+ "topcoat-mail",
3405+ "topcoat-router",
3406+ "topcoat-router-macro",
3407+ "topcoat-runtime",
3408+ "topcoat-runtime-macro",
3409+ "topcoat-session",
3410+ "topcoat-view",
3411+ "topcoat-view-macro",
3412+]
3413+
3414+[[package]]
3415+name = "topcoat-asset"
3416+version = "0.11.0"
3417+source = "registry+https://github.com/rust-lang/crates.io-index"
3418+checksum = "ac70debf9eee62714ce45416eae27b283c3a44a0f9ebcb2ac088fda48b533f3e"
3419+dependencies = [
3420+ "http",
3421+ "memchr",
3422+ "percent-encoding",
3423+ "serde",
3424+ "sha2 0.11.1",
3425+ "thiserror",
3426+ "tokio",
3427+ "toml",
3428+ "topcoat-core",
3429+ "topcoat-router",
3430+ "topcoat-view",
3431+]
3432+
3433+[[package]]
3434+name = "topcoat-cookie"
3435+version = "0.11.0"
3436+source = "registry+https://github.com/rust-lang/crates.io-index"
3437+checksum = "df79aba10192abe21fbd01dfcb46bb04dab5ae64adb4432d9f078eb05f94e6a5"
3438+dependencies = [
3439+ "cookie",
3440+ "getrandom 0.2.17",
3441+ "http",
3442+ "serde",
3443+ "serde_json",
3444+ "topcoat-core",
3445+ "topcoat-router",
3446+]
3447+
3448+[[package]]
3449+name = "topcoat-core"
3450+version = "0.11.0"
3451+source = "registry+https://github.com/rust-lang/crates.io-index"
3452+checksum = "ffff49b885744cdb89ee158c5d81cc8c619692bd9f4ab3cae92ad1adc0ce612e"
3453+dependencies = [
3454+ "anymap3",
3455+ "base64 0.22.1",
3456+ "elsa",
3457+ "http",
3458+ "pin-project-lite",
3459+ "siphasher",
3460+ "thiserror",
3461+ "tokio",
3462+]
3463+
3464+[[package]]
3465+name = "topcoat-core-grammar"
3466+version = "0.11.0"
3467+source = "registry+https://github.com/rust-lang/crates.io-index"
3468+checksum = "b788a2010234cd29fc050268e52ceb393d2124b20f669a83d8f61a9dbf895bb6"
3469+dependencies = [
3470+ "proc-macro-crate",
3471+ "proc-macro2",
3472+ "quote",
3473+ "syn 3.0.9",
3474+]
3475+
3476+[[package]]
3477+name = "topcoat-core-macro"
3478+version = "0.11.0"
3479+source = "registry+https://github.com/rust-lang/crates.io-index"
3480+checksum = "3e3786bf2ee2c8b4f728d3fb53c41f639aa66583788b3135acbd63c11458b25b"
3481+dependencies = [
3482+ "quote",
3483+ "syn 3.0.9",
3484+ "topcoat-core-grammar",
3485+]
3486+
3487+[[package]]
3488+name = "topcoat-font"
3489+version = "0.11.0"
3490+source = "registry+https://github.com/rust-lang/crates.io-index"
3491+checksum = "caa4656294aac116def1e7633f03117a84b65126c503242793ff4adc78577fb8"
3492+dependencies = [
3493+ "heck",
3494+ "inventory",
3495+ "serde",
3496+ "serde_json",
3497+ "topcoat-asset",
3498+ "topcoat-core",
3499+ "topcoat-router",
3500+ "topcoat-view",
3501+ "topcoat-view-macro",
3502+]
3503+
3504+[[package]]
3505+name = "topcoat-font-grammar"
3506+version = "0.11.0"
3507+source = "registry+https://github.com/rust-lang/crates.io-index"
3508+checksum = "b462fae28641a1bb24eab1fa9c473520389ca690331ca53fd6143d5b2746045e"
3509+dependencies = [
3510+ "proc-macro2",
3511+ "quote",
3512+ "syn 3.0.9",
3513+ "topcoat-core-grammar",
3514+ "topcoat-font",
3515+]
3516+
3517+[[package]]
3518+name = "topcoat-font-macro"
3519+version = "0.11.0"
3520+source = "registry+https://github.com/rust-lang/crates.io-index"
3521+checksum = "40776cd3087aaea5e0c8b597126b1c09dbfb0d69833088d7f3b229305bbbb87f"
3522+dependencies = [
3523+ "quote",
3524+ "syn 3.0.9",
3525+ "topcoat-font-grammar",
3526+]
3527+
3528+[[package]]
3529+name = "topcoat-l10n"
3530+version = "0.11.0"
3531+source = "registry+https://github.com/rust-lang/crates.io-index"
3532+checksum = "34da63b3a5aea3d6c243d9fa8c98ca79b181b985f6a0a042f630672f54d12e9e"
3533+dependencies = [
3534+ "icu_locale",
3535+ "icu_locale_core",
3536+ "topcoat-core",
3537+ "topcoat-view",
3538+]
3539+
3540+[[package]]
3541+name = "topcoat-mail"
3542+version = "0.11.0"
3543+source = "registry+https://github.com/rust-lang/crates.io-index"
3544+checksum = "54a13c10c6399d9eb9b0bde38bd3d947eba56ddfaea99d9a4f971b74b6a651db"
3545+dependencies = [
3546+ "lettre",
3547+ "thiserror",
3548+ "time",
3549+ "topcoat-core",
3550+ "topcoat-router",
3551+ "topcoat-view",
3552+]
3553+
3554+[[package]]
3555+name = "topcoat-router"
3556+version = "0.11.0"
3557+source = "registry+https://github.com/rust-lang/crates.io-index"
3558+checksum = "b9488065b08f293208b0f1aeb6667d5836b66c12dfced5e330f9a8f1d7f1ca1a"
3559+dependencies = [
3560+ "bytes",
3561+ "form_urlencoded",
3562+ "futures-core",
3563+ "futures-sink",
3564+ "futures-util",
3565+ "heck",
3566+ "http",
3567+ "http-body",
3568+ "http-body-util",
3569+ "hyper",
3570+ "hyper-util",
3571+ "inventory",
3572+ "ipnet",
3573+ "matchit",
3574+ "multer",
3575+ "percent-encoding",
3576+ "pin-project-lite",
3577+ "ref-cast",
3578+ "serde",
3579+ "serde_json",
3580+ "serde_path_to_error",
3581+ "serde_urlencoded",
3582+ "tokio",
3583+ "tokio-tungstenite",
3584+ "topcoat-core",
3585+ "topcoat-view",
3586+]
3587+
3588+[[package]]
3589+name = "topcoat-router-grammar"
3590+version = "0.11.0"
3591+source = "registry+https://github.com/rust-lang/crates.io-index"
3592+checksum = "ac3f51fa1a1e538bd34e02f88ebba554ac5931e55c688303a58a8e78123dfb04"
3593+dependencies = [
3594+ "heck",
3595+ "proc-macro2",
3596+ "quote",
3597+ "syn 3.0.9",
3598+ "topcoat-core-grammar",
3599+]
3600+
3601+[[package]]
3602+name = "topcoat-router-macro"
3603+version = "0.11.0"
3604+source = "registry+https://github.com/rust-lang/crates.io-index"
3605+checksum = "3c1b56d3bf19d54bddf300d6d57ca754531d7ad5481afca0b2302ac33f5d43af"
3606+dependencies = [
3607+ "quote",
3608+ "syn 3.0.9",
3609+ "topcoat-router-grammar",
3610+]
3611+
3612+[[package]]
3613+name = "topcoat-runtime"
3614+version = "0.11.0"
3615+source = "registry+https://github.com/rust-lang/crates.io-index"
3616+checksum = "03b22136b99694b349a950cd757387a04b080fdb131eecdd51d0511e1a45ebf5"
3617+dependencies = [
3618+ "futures-util",
3619+ "pin-project-lite",
3620+ "ref-cast",
3621+ "serde",
3622+ "serde_json",
3623+ "tokio",
3624+ "topcoat-asset",
3625+ "topcoat-core",
3626+ "topcoat-router",
3627+ "topcoat-view",
3628+ "topcoat-view-macro",
3629+]
3630+
3631+[[package]]
3632+name = "topcoat-runtime-grammar"
3633+version = "0.11.0"
3634+source = "registry+https://github.com/rust-lang/crates.io-index"
3635+checksum = "ab93a83c38a045a4f541c2e548d30ba5dfdd3173c18de8b1c7b049709c29db97"
3636+dependencies = [
3637+ "proc-macro2",
3638+ "quote",
3639+ "serde",
3640+ "serde_json",
3641+ "syn 3.0.9",
3642+ "topcoat-core-grammar",
3643+ "topcoat-router",
3644+ "topcoat-runtime",
3645+]
3646+
3647+[[package]]
3648+name = "topcoat-runtime-macro"
3649+version = "0.11.0"
3650+source = "registry+https://github.com/rust-lang/crates.io-index"
3651+checksum = "5acb1db0bdba3c36e4f80f7ef530945779a1b0294b1087e7d877e33005da6283"
3652+dependencies = [
3653+ "quote",
3654+ "syn 3.0.9",
3655+ "topcoat-runtime-grammar",
3656+]
3657+
3658+[[package]]
3659+name = "topcoat-session"
3660+version = "0.11.0"
3661+source = "registry+https://github.com/rust-lang/crates.io-index"
3662+checksum = "2325c30a484b1b1b6f5012b50bc18994d37c33c6bd2f71be8ff509b591a17457"
3663+dependencies = [
3664+ "base64 0.22.1",
3665+ "getrandom 0.4.3",
3666+ "sha2 0.11.1",
3667+ "thiserror",
3668+ "tokio",
3669+ "topcoat-cookie",
3670+ "topcoat-core",
3671+ "topcoat-router",
3672+ "web-time",
3673+]
3674+
3675+[[package]]
3676+name = "topcoat-view"
3677+version = "0.11.0"
3678+source = "registry+https://github.com/rust-lang/crates.io-index"
3679+checksum = "db4553b91f30e30c71c2bd95ae8e931a33326c6ffb604663b9d214008f12947c"
3680+dependencies = [
3681+ "futures-core",
3682+ "futures-util",
3683+ "http",
3684+ "memchr",
3685+ "pin-project-lite",
3686+ "siphasher",
3687+ "smallvec",
3688+ "topcoat-core",
3689+]
3690+
3691+[[package]]
3692+name = "topcoat-view-grammar"
3693+version = "0.11.0"
3694+source = "registry+https://github.com/rust-lang/crates.io-index"
3695+checksum = "75dd093ffc848370da4cce7670ccdfd4e98eab48e178d5d0da5509f747d85ca6"
3696+dependencies = [
3697+ "heck",
3698+ "proc-macro2",
3699+ "quote",
3700+ "syn 3.0.9",
3701+ "topcoat-core-grammar",
3702+ "topcoat-view",
3703+]
3704+
3705+[[package]]
3706+name = "topcoat-view-macro"
3707+version = "0.11.0"
3708+source = "registry+https://github.com/rust-lang/crates.io-index"
3709+checksum = "ffa1688d165704f08d58c03710453d0d39553292bea61b18be7959a996c3e39b"
3710+dependencies = [
3711+ "quote",
3712+ "syn 3.0.9",
3713+ "topcoat-view-grammar",
3714+]
3715+
26813716 [[package]]
26823717 name = "tracing"
26833718 version = "0.1.44"
@@ -2752,6 +3787,22 @@ dependencies = [
27523787 "tracing-log",
27533788 ]
27543789
3790+[[package]]
3791+name = "tungstenite"
3792+version = "0.29.0"
3793+source = "registry+https://github.com/rust-lang/crates.io-index"
3794+checksum = "6c01152af293afb9c7c2a57e4b559c5620b421f6d133261c60dd2d0cdb38e6b8"
3795+dependencies = [
3796+ "bytes",
3797+ "data-encoding",
3798+ "http",
3799+ "httparse",
3800+ "log",
3801+ "rand 0.9.5",
3802+ "sha1",
3803+ "thiserror",
3804+]
3805+
27553806 [[package]]
27563807 name = "turso"
27573808 version = "0.8.3"
@@ -3063,6 +4114,12 @@ version = "1.0.4"
30634114 source = "registry+https://github.com/rust-lang/crates.io-index"
30644115 checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
30654116
4117+[[package]]
4118+name = "utf8parse"
4119+version = "0.2.2"
4120+source = "registry+https://github.com/rust-lang/crates.io-index"
4121+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
4122+
30664123 [[package]]
30674124 name = "uuid"
30684125 version = "1.29.0"
@@ -3338,6 +4395,9 @@ name = "winnow"
33384395 version = "1.0.4"
33394396 source = "registry+https://github.com/rust-lang/crates.io-index"
33404397 checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
4398+dependencies = [
4399+ "memchr",
4400+]
33414401
33424402 [[package]]
33434403 name = "wit-bindgen"
Cargo.tomlmodified+8 -1
@@ -13,6 +13,9 @@ license = "AGPL-3.0-or-later"
1313 [workspace.dependencies]
1414 # external crates (versions are the latest releases when added)
1515 base64 = "0.23.1"
16+futures-util = "0.3.34"
17+grass = "0.13.4"
18+http = "1.5.0"
1619 chacha20poly1305 = "0.11.0"
1720 hex = "0.4.3"
1821 ipnet = "2.12.2"
@@ -25,12 +28,16 @@ subtle = "2.6.1"
2528 tempfile = "3.27.0"
2629 thiserror = "2.0.21"
2730 time = { version = "0.3.55", features = ["formatting", "parsing", "macros"] }
28-tokio = { version = "1.54.1", features = ["macros", "rt", "sync"] }
31+tokio = { version = "1.54.1", features = ["macros", "rt", "rt-multi-thread", "sync"] }
2932 toml = "1.1.8"
3033 tracing = "0.1.44"
34+tracing-subscriber = "0.3.23"
3135 turso = "0.8.3"
3236 ulid = "3.0.0"
3337
38+# web framework
39+topcoat = { version = "0.11.0", default-features = false, features = ["router", "view", "runtime", "cookie", "asset", "serve", "sse", "discover", "multipart"] }
40+
3441 # internal crates
3542 iz-core = { path = "crates/iz-core" }
3643
crates/iz-core/src/store/mod.rsmodified+11 -0
@@ -120,6 +120,17 @@ impl Store {
120120 .map_err(db_err)?;
121121 Ok(())
122122 }
123+
124+ /// Runs `SELECT 1` on a pooled reader and fails when the database does not answer. The health
125+ /// route calls it with a deadline, so a stuck lock shows up as a failed probe.
126+ pub async fn ping(&self) -> Result<()> {
127+ let conn = self.read_conn().await;
128+ let value = fetch_opt(&conn, "SELECT 1", (), |row| col_int(row, 0)).await?;
129+ match value {
130+ Some(_) => Ok(()),
131+ None => Err(Error::Database("expected a row that is not there".into())),
132+ }
133+ }
123134 }
124135
125136 // ---- helpers ----
crates/iz-web/Cargo.tomlmodified+18 -0
@@ -10,5 +10,23 @@ publish = false
1010 name = "iz"
1111 path = "src/main.rs"
1212
13+[dependencies]
14+futures-util.workspace = true
15+http.workspace = true
16+iz-core.workspace = true
17+# `net` and `signal` for the listener and the shutdown signals, `time` for the database probe timeout.
18+tokio = { workspace = true, features = ["net", "signal", "time"] }
19+topcoat.workspace = true
20+tracing.workspace = true
21+tracing-subscriber = { workspace = true, features = ["env-filter"] }
22+
23+[dev-dependencies]
24+tempfile.workspace = true
25+
26+[build-dependencies]
27+grass.workspace = true
28+hex.workspace = true
29+sha2.workspace = true
30+
1331 [lints]
1432 workspace = true
crates/iz-web/assets/nav.jsadded+528 -0
@@ -0,0 +1,528 @@
1+/*
2+ * nav.js: the one script of iz. Everything in it is progressive enhancement. A page works without
3+ * it as plain HTML; this file only makes the same pages feel like one application.
4+ *
5+ * What it does:
6+ * - Soft navigation. A click on a same-origin link, or a submit of a same-origin form, is fetched
7+ * with fetch(). The <main> element and the <title> of the answer replace the current ones, and
8+ * the URL goes into the history. Back and forward fetch the page again and restore the scroll.
9+ * - Live refresh. Each distinct data-live URL on the page gets one EventSource. A `changed` event
10+ * re-fetches the current page after a short debounce. A refresh keeps the scroll position, the
11+ * focused control and the fields the user edited, so a page that changes under the user does not
12+ * lose their typing.
13+ * - Server restarting. /-/alive is held open on every page. While it is down, or while a form POST
14+ * got no answer, a bar says so. The bar text comes from data-restart-text on <body>, so the
15+ * server translates it.
16+ * - Offline pages. Registers /assets/sw.js, which answers failed page loads with the offline page.
17+ *
18+ * What it never does: send a POST twice. A POST that got no answer is not repeated. Its form stays
19+ * as the user left it, and the bar says the server could not be reached.
20+ *
21+ * The file is one IIFE with no globals. It is loaded with `defer`, so <main> and the data-live
22+ * attributes exist when it runs.
23+ */
24+(function () {
25+ "use strict";
26+
27+ // Without these the page is plain HTML, which is the behaviour we want anyway.
28+ if (!window.fetch || !window.DOMParser || !window.EventSource || !window.history) {
29+ return;
30+ }
31+
32+ /** The server-held stream that tells the page the server is up. */
33+ const ALIVE_PATH = "/-/alive";
34+
35+ /** Paths that always do a full page load. Assets are static; the API is not for pages. */
36+ const HARD_PREFIXES = ["/assets/", "/api/"];
37+
38+ /** Milliseconds between a `changed` event and the refresh it causes. Coalesces a burst of events. */
39+ const REFRESH_DEBOUNCE_MS = 250;
40+
41+ /** Reconnect delays for a stream the browser gave up on. The last value repeats. */
42+ const RECONNECT_MS = [1000, 2000, 3000];
43+
44+ /** Asks for HTML, so the server answers with a page and not with JSON. */
45+ const ACCEPT = "text/html, application/xhtml+xml";
46+
47+ /** Input types whose value must never be kept or replayed by this script. */
48+ const SKIPPED_TYPES = ["password", "file", "hidden", "submit", "button", "reset", "image"];
49+
50+ /** Newest navigation (link, form, history move). An older answer that arrives later is dropped. */
51+ let navSeq = 0;
52+
53+ /** Page-changing requests in flight. A live refresh waits until there are none. */
54+ let busy = 0;
55+
56+ /** The URL the page currently shows, without caring about its hash. */
57+ let currentHref = location.href;
58+
59+ /** Set while /-/alive is unreachable. */
60+ let serverDown = false;
61+
62+ /** Set when a form POST got no answer. Cleared by the next answer. */
63+ let postUnanswered = false;
64+
65+ /** The timer of the pending live refresh. */
66+ let refreshTimer = 0;
67+
68+ /** The restart bar, created the first time it is needed. */
69+ let restartBar = null;
70+
71+ /** Open live streams, by absolute URL. Each value is what hold() returned. */
72+ const streams = new Map();
73+
74+ // ---------------------------------------------------------------------------------------------
75+ // Which links and forms are ours to handle.
76+
77+ /** Parses `href` against the current page. Null when it is not a URL. */
78+ function parseUrl(href) {
79+ try {
80+ return new URL(href, location.href);
81+ } catch (error) {
82+ return null;
83+ }
84+ }
85+
86+ /** True when `url` may be fetched and swapped in: same origin, and not an asset or API path. */
87+ function isSoftTarget(url) {
88+ if (!url || url.origin !== location.origin) {
89+ return false;
90+ }
91+ return !HARD_PREFIXES.some((prefix) => url.pathname.startsWith(prefix));
92+ }
93+
94+ /** The URL without its fragment. A change of only the fragment is a same-page jump, not a load. */
95+ function withoutHash(href) {
96+ return href.split("#")[0];
97+ }
98+
99+ // ---------------------------------------------------------------------------------------------
100+ // The restart bar.
101+
102+ /** Shows or hides the bar, as the union of "server down" and "a POST got no answer". */
103+ function updateRestartBar() {
104+ const show = serverDown || postUnanswered;
105+ if (show && !restartBar) {
106+ restartBar = document.createElement("div");
107+ restartBar.className = "restart-bar";
108+ restartBar.setAttribute("role", "status");
109+ restartBar.textContent = document.body.dataset.restartText || "";
110+ document.body.appendChild(restartBar);
111+ }
112+ if (restartBar) {
113+ restartBar.hidden = !show;
114+ }
115+ }
116+
117+ /** Counts page-changing requests so the page can dim while one is running. */
118+ function addBusy(delta) {
119+ busy += delta;
120+ document.body.classList.toggle("is-loading", busy > 0);
121+ }
122+
123+ // ---------------------------------------------------------------------------------------------
124+ // Streams: one EventSource per URL, kept open with reconnects.
125+
126+ /**
127+ * Opens an EventSource to `url` and keeps it open. The browser reconnects by itself while it
128+ * still tries; once it gives up (readyState CLOSED), this reopens the stream after 1, 2 and then
129+ * 3 seconds. `hooks.events` maps event names to handlers, `hooks.lost` runs when the connection
130+ * drops, and `hooks.back` runs when it opens again after a drop. Returns a handle with close().
131+ */
132+ function hold(url, hooks) {
133+ const link = { source: null, failures: 0, timer: 0, lost: false, closed: false };
134+
135+ const connect = () => {
136+ const source = new EventSource(url);
137+ link.source = source;
138+ source.addEventListener("open", () => {
139+ link.failures = 0;
140+ if (link.lost) {
141+ link.lost = false;
142+ if (hooks.back) hooks.back();
143+ }
144+ });
145+ for (const [name, handler] of Object.entries(hooks.events || {})) {
146+ source.addEventListener(name, handler);
147+ }
148+ source.addEventListener("error", () => {
149+ if (link.closed) return;
150+ if (!link.lost) {
151+ link.lost = true;
152+ if (hooks.lost) hooks.lost();
153+ }
154+ if (source.readyState !== EventSource.CLOSED) return;
155+ source.close();
156+ const delay = RECONNECT_MS[Math.min(link.failures, RECONNECT_MS.length - 1)];
157+ link.failures += 1;
158+ link.timer = setTimeout(connect, delay);
159+ });
160+ };
161+
162+ connect();
163+ return {
164+ close() {
165+ link.closed = true;
166+ clearTimeout(link.timer);
167+ if (link.source) link.source.close();
168+ },
169+ };
170+ }
171+
172+ /** Holds /-/alive. It only drives the restart bar; the server sends nothing else on it yet. */
173+ function holdAlive() {
174+ hold(ALIVE_PATH, {
175+ lost: () => {
176+ serverDown = true;
177+ updateRestartBar();
178+ },
179+ back: () => {
180+ serverDown = false;
181+ updateRestartBar();
182+ },
183+ });
184+ }
185+
186+ /**
187+ * Makes the open streams match the data-live URLs of the page: one stream per distinct URL, and
188+ * a stream whose URL is no longer on the page is closed.
189+ */
190+ function syncStreams() {
191+ const wanted = new Set();
192+ for (const el of document.querySelectorAll("[data-live]")) {
193+ const url = parseUrl(el.getAttribute("data-live"));
194+ if (isSoftTarget(url)) {
195+ wanted.add(url.href);
196+ }
197+ }
198+ for (const [href, handle] of streams) {
199+ if (!wanted.has(href)) {
200+ handle.close();
201+ streams.delete(href);
202+ }
203+ }
204+ for (const href of wanted) {
205+ if (!streams.has(href)) {
206+ streams.set(
207+ href,
208+ hold(href, {
209+ events: { changed: () => scheduleRefresh() },
210+ // Changes made while the stream was down are caught up by one refresh.
211+ back: () => scheduleRefresh(),
212+ })
213+ );
214+ }
215+ }
216+ }
217+
218+ /** Re-fetches the current page soon. Several `changed` events in a row make one refresh. */
219+ function scheduleRefresh() {
220+ clearTimeout(refreshTimer);
221+ refreshTimer = setTimeout(() => {
222+ refreshTimer = 0;
223+ navigate(location.href, "refresh", 0);
224+ }, REFRESH_DEBOUNCE_MS);
225+ }
226+
227+ // ---------------------------------------------------------------------------------------------
228+ // Form fields and focus, kept across a live refresh.
229+
230+ /** The named controls of `root` whose value the script may keep. */
231+ function keepableControls(root) {
232+ return Array.from(root.querySelectorAll("input, textarea, select")).filter(
233+ (el) => el.name && !SKIPPED_TYPES.includes(el.type)
234+ );
235+ }
236+
237+ /** True when the user changed the control, so its server value is not the one shown. */
238+ function isDirty(el) {
239+ if (el.type === "checkbox" || el.type === "radio") {
240+ return el.checked !== el.defaultChecked;
241+ }
242+ if (el.tagName === "SELECT") {
243+ return Array.from(el.options).some((o) => o.selected !== o.defaultSelected);
244+ }
245+ return el.value !== el.defaultValue;
246+ }
247+
248+ /**
249+ * A key that finds the same control in a re-rendered <main>: its id, or its name plus its index
250+ * among the controls with that name. Null for an element with neither.
251+ */
252+ function keyOf(el, root) {
253+ if (el.id) return JSON.stringify(["id", el.id]);
254+ if (!el.name) return null;
255+ const same = Array.from(root.querySelectorAll("[name]")).filter((n) => n.name === el.name);
256+ return JSON.stringify(["name", el.name, same.indexOf(el)]);
257+ }
258+
259+ /** The element that `key` names in `root`, or null. */
260+ function findByKey(key, root) {
261+ if (!key) return null;
262+ const [kind, value, index] = JSON.parse(key);
263+ if (kind === "id") {
264+ return Array.from(root.querySelectorAll("[id]")).find((n) => n.id === value) || null;
265+ }
266+ const same = Array.from(root.querySelectorAll("[name]")).filter((n) => n.name === value);
267+ return same[index] || null;
268+ }
269+
270+ /** What a refresh must put back: the scroll, the focused control and the fields the user changed. */
271+ function captureState() {
272+ const main = document.querySelector("main");
273+ const active = document.activeElement;
274+ const dirty = main
275+ ? keepableControls(main)
276+ .filter(isDirty)
277+ .map((el) => ({
278+ key: keyOf(el, main),
279+ checked: el.checked,
280+ value: el.value,
281+ }))
282+ : [];
283+ return {
284+ y: window.scrollY,
285+ focus: main && active && main.contains(active) ? keyOf(active, main) : null,
286+ fields: dirty,
287+ };
288+ }
289+
290+ /** Puts back what captureState() saw. Fields the server no longer renders are skipped. */
291+ function restoreState(state) {
292+ const main = document.querySelector("main");
293+ if (!main || !state) return;
294+ for (const saved of state.fields) {
295+ const el = findByKey(saved.key, main);
296+ if (!el || !keepableControls(main).includes(el)) continue;
297+ if (el.type === "checkbox" || el.type === "radio") {
298+ el.checked = saved.checked;
299+ } else {
300+ el.value = saved.value;
301+ }
302+ }
303+ const focused = findByKey(state.focus, main);
304+ if (focused) focused.focus({ preventScroll: true });
305+ window.scrollTo(0, state.y);
306+ }
307+
308+ // ---------------------------------------------------------------------------------------------
309+ // Swapping the page in.
310+
311+ /**
312+ * Replaces <main> and the title with the ones of `doc`, and syncs the live streams. Returns false
313+ * when `doc` has no <main>, so the caller can fall back to a full load.
314+ */
315+ function swapIn(doc) {
316+ const fresh = doc.querySelector("main");
317+ const old = document.querySelector("main");
318+ if (!fresh || !old) return false;
319+ document.title = doc.title;
320+ const lang = doc.documentElement.getAttribute("lang");
321+ if (lang) document.documentElement.setAttribute("lang", lang);
322+ old.replaceWith(document.adoptNode(fresh));
323+ syncStreams();
324+ return true;
325+ }
326+
327+ /** Remembers the scroll position of the page being left, so Back can return to it. */
328+ function saveScroll() {
329+ history.replaceState(Object.assign({}, history.state, { y: window.scrollY }), "");
330+ }
331+
332+ /**
333+ * Fetches `href` with a GET. Resolves to the response and its text, or to null when the request
334+ * failed before any answer. Non-HTML answers come back with `text` set to null.
335+ */
336+ async function getPage(href) {
337+ try {
338+ const res = await fetch(href, { headers: { Accept: ACCEPT }, credentials: "same-origin" });
339+ const isHtml = (res.headers.get("content-type") || "").includes("text/html");
340+ return { res, text: isHtml ? await res.text() : null };
341+ } catch (error) {
342+ // The connection failed, or the body was cut off. Either way there is no page to show.
343+ return null;
344+ }
345+ }
346+
347+ /**
348+ * Shows a fetched page. `mode` is "push" (a new history entry), "pop" (Back or Forward) or
349+ * "refresh" (a live refresh in place). `finalHref` is the URL after redirects.
350+ */
351+ function show(text, finalHref, mode, state) {
352+ const doc = new DOMParser().parseFromString(text, "text/html");
353+ if (!swapIn(doc)) {
354+ location.assign(finalHref);
355+ return;
356+ }
357+ currentHref = finalHref;
358+ const main = document.querySelector("main");
359+ if (mode === "refresh") {
360+ restoreState(state);
361+ return;
362+ }
363+ if (mode === "push") {
364+ history.pushState({ y: 0 }, "", finalHref);
365+ const hash = new URL(finalHref).hash.slice(1);
366+ const target = hash ? document.getElementById(hash) : null;
367+ if (target) {
368+ target.scrollIntoView();
369+ } else {
370+ window.scrollTo(0, 0);
371+ }
372+ }
373+ if (mode === "pop") {
374+ window.scrollTo(0, state);
375+ }
376+ if (main) {
377+ main.setAttribute("tabindex", "-1");
378+ main.focus({ preventScroll: true });
379+ }
380+ }
381+
382+ // ---------------------------------------------------------------------------------------------
383+ // Navigation: links, GET forms, POST forms, Back and Forward, and live refresh.
384+
385+ /**
386+ * Loads `href` into the page. `mode` is "push", "pop" or "refresh" (see show()). `y` is the scroll
387+ * to restore on "pop". A failed GET for a link or a history move falls back to a full load, which
388+ * shows the browser's own error. A failed refresh does nothing: the bar covers a dead server.
389+ */
390+ async function navigate(href, mode, y) {
391+ const refresh = mode === "refresh";
392+ if (refresh && busy > 0) return;
393+ const seq = refresh ? navSeq : ++navSeq;
394+ const state = refresh ? captureState() : y;
395+ if (mode === "push") saveScroll();
396+
397+ addBusy(1);
398+ const answer = await getPage(href);
399+ addBusy(-1);
400+
401+ // A newer navigation started, or a refresh was superseded: this answer is out of date.
402+ if (seq !== navSeq) return;
403+ if (!answer) {
404+ if (!refresh) location.assign(href);
405+ return;
406+ }
407+ postUnanswered = false;
408+ updateRestartBar();
409+ if (answer.text === null) {
410+ // A download or another non-page answer: let the browser handle that URL.
411+ if (!refresh) location.assign(answer.res.url || href);
412+ return;
413+ }
414+ show(answer.text, answer.res.url || href, mode, state);
415+ }
416+
417+ /**
418+ * Sends a form. A GET form becomes a navigation to the URL with the form's fields. A POST is sent
419+ * once with fetch(); when it gets no answer the form is kept and the bar is shown. It is never
420+ * sent again by this script.
421+ */
422+ async function submitForm(form, submitter, action, method) {
423+ const data = new FormData(form, submitter || undefined);
424+ if (method === "get") {
425+ const url = new URL(action.href);
426+ url.search = new URLSearchParams(data).toString();
427+ navigate(url.href, "push", 0);
428+ return;
429+ }
430+
431+ // A form that is already sending is not sent twice by a second submit.
432+ form.dataset.sending = "1";
433+ const enctype = (submitter && submitter.getAttribute("formenctype")) || form.enctype || "";
434+ const body = enctype.startsWith("multipart/") ? data : new URLSearchParams(data);
435+
436+ const seq = ++navSeq;
437+ addBusy(1);
438+ let res = null;
439+ let text = null;
440+ try {
441+ res = await fetch(action.href, {
442+ method: "POST",
443+ body,
444+ headers: { Accept: ACCEPT },
445+ credentials: "same-origin",
446+ redirect: "follow",
447+ });
448+ if ((res.headers.get("content-type") || "").includes("text/html")) {
449+ text = await res.text();
450+ }
451+ } catch (error) {
452+ // No answer. The request may or may not have reached the server, so it is not repeated.
453+ res = null;
454+ }
455+ addBusy(-1);
456+ delete form.dataset.sending;
457+
458+ if (seq !== navSeq) return;
459+ if (!res) {
460+ postUnanswered = true;
461+ updateRestartBar();
462+ return;
463+ }
464+ postUnanswered = false;
465+ updateRestartBar();
466+ if (text === null) {
467+ // The POST was answered with a download or another non-page. Show its final URL with a GET.
468+ location.assign(res.url || action.href);
469+ return;
470+ }
471+ show(text, res.url || action.href, "push", 0);
472+ }
473+
474+ // Links. A click on a link we handle is taken over; anything else is left to the browser.
475+ document.addEventListener("click", (event) => {
476+ if (event.defaultPrevented || event.button !== 0) return;
477+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
478+ const link = event.target instanceof Element ? event.target.closest("a[href]") : null;
479+ if (!link || link.hasAttribute("data-hard") || link.hasAttribute("download")) return;
480+ if (link.target && link.target !== "_self") return;
481+ const raw = link.getAttribute("href");
482+ if (raw.startsWith("//")) return;
483+ const url = parseUrl(raw);
484+ if (!isSoftTarget(url)) return;
485+ // A link to a fragment of this page is an ordinary scroll.
486+ if (withoutHash(url.href) === withoutHash(location.href) && url.hash) return;
487+ event.preventDefault();
488+ navigate(url.href, "push", 0);
489+ });
490+
491+ // Forms. A submit we handle is taken over; the browser does not send it.
492+ document.addEventListener("submit", (event) => {
493+ const form = event.target;
494+ if (!(form instanceof HTMLFormElement) || event.defaultPrevented) return;
495+ if (form.hasAttribute("data-hard") || (form.target && form.target !== "_self")) return;
496+ const method = (form.getAttribute("method") || "get").toLowerCase();
497+ if (method !== "get" && method !== "post") return;
498+ const action = parseUrl(form.getAttribute("action") || location.href);
499+ if (!isSoftTarget(action)) return;
500+ if (form.dataset.sending) {
501+ event.preventDefault();
502+ return;
503+ }
504+ event.preventDefault();
505+ submitForm(form, event.submitter, action, method);
506+ });
507+
508+ // Back and Forward. A jump inside the page only moves the scroll; anything else is fetched.
509+ window.addEventListener("popstate", (event) => {
510+ if (withoutHash(location.href) === withoutHash(currentHref)) {
511+ currentHref = location.href;
512+ return;
513+ }
514+ const y = event.state && typeof event.state.y === "number" ? event.state.y : 0;
515+ navigate(location.href, "pop", y);
516+ });
517+
518+ // ---------------------------------------------------------------------------------------------
519+ // Start.
520+
521+ holdAlive();
522+ syncStreams();
523+
524+ // The worker only answers failed page loads. It is registered at the root so it can.
525+ if ("serviceWorker" in navigator) {
526+ navigator.serviceWorker.register("/assets/sw.js", { scope: "/" }).catch(() => {});
527+ }
528+})();
crates/iz-web/assets/offline.htmladded+20 -0
@@ -0,0 +1,20 @@
1+<!DOCTYPE html>
2+<html lang="en">
3+<head>
4+<meta charset="utf-8">
5+<meta name="viewport" content="width=device-width, initial-scale=1">
6+<meta name="robots" content="noindex">
7+<meta http-equiv="refresh" content="5">
8+<title>iz · offline</title>
9+<link rel="stylesheet" href="/assets/main.css">
10+</head>
11+<body>
12+<main class="page">
13+<section class="empty-state">
14+<h1>iz is offline</h1>
15+<p>The server is not answering. This page checks again every 5 seconds.</p>
16+<p lang="tr">Sunucu yanıt vermiyor. Bu sayfa her 5 saniyede bir yeniden dener.</p>
17+</section>
18+</main>
19+</body>
20+</html>
crates/iz-web/assets/pages.jsadded+9 -0
@@ -0,0 +1,9 @@
1+/*
2+ * pages.js: small behaviours of individual pages (a dropdown search, a copy button and so on). It
3+ * is empty for now. The file exists so the shell can load it and its content hash is already in the
4+ * page links. Each behaviour, when it is added, does nothing unless its own data attribute is on the
5+ * page. Like nav.js, it is one IIFE with no globals.
6+ */
7+(function () {
8+ "use strict";
9+})();
crates/iz-web/assets/sw.jsadded+46 -0
@@ -0,0 +1,46 @@
1+/*
2+ * sw.js: the service worker of iz. It does one thing. When a page load fails because the server
3+ * cannot be reached, it answers with /assets/offline.html, which checks again every few seconds.
4+ * Everything else goes to the network untouched, so a page never shows data that is out of date.
5+ */
6+
7+/** The cache that holds the offline page. Bump the number when offline.html changes. */
8+const CACHE = "iz-offline-1";
9+
10+/** The page answered when a navigation fails. */
11+const OFFLINE_PAGE = "/assets/offline.html";
12+
13+self.addEventListener("install", (event) => {
14+ event.waitUntil(
15+ caches
16+ .open(CACHE)
17+ .then((cache) => cache.add(OFFLINE_PAGE))
18+ .then(() => self.skipWaiting())
19+ );
20+});
21+
22+self.addEventListener("activate", (event) => {
23+ // Drop the caches of earlier versions, then take control of the open pages.
24+ event.waitUntil(
25+ caches
26+ .keys()
27+ .then((keys) => Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key))))
28+ .then(() => self.clients.claim())
29+ );
30+});
31+
32+self.addEventListener("fetch", (event) => {
33+ const request = event.request;
34+ // Only a GET navigation is answered. Retrying a POST here would send the form a second time.
35+ if (request.mode !== "navigate" || request.method !== "GET") {
36+ return;
37+ }
38+ event.respondWith(
39+ fetch(request).catch(() =>
40+ caches
41+ .open(CACHE)
42+ .then((cache) => cache.match(OFFLINE_PAGE))
43+ .then((page) => page || Response.error())
44+ )
45+ );
46+});
crates/iz-web/build.rsadded+57 -0
@@ -0,0 +1,57 @@
1+//! Build script of the `iz` binary. It compiles `style/main.scss` into `OUT_DIR/main.css`, and it
2+//! emits the build identity and the content hashes that the page links use as cache-busting
3+//! queries: `IZ_MAIN_CSS_V`, `IZ_NAV_JS_V`, `IZ_PAGES_JS_V` and `IZ_BUILD_SHA`.
4+//!
5+//! It does not decide what is served: `src/assets.rs` embeds the files. It does not decide what a
6+//! page links to either: `src/assets.rs` builds the `?v=` URLs from these values. It only compiles
7+//! and hashes, so a changed file gets a new hash and an unchanged file keeps its URL.
8+
9+use std::{env, fs, path::PathBuf};
10+
11+use hex::encode;
12+use sha2::{Digest, Sha256};
13+
14+/// Number of hex characters of the SHA-256 that make a content version. Twelve characters are 48
15+/// bits, which is plenty to tell two builds of one file apart.
16+const VERSION_HEX_LEN: usize = 12;
17+
18+fn main() {
19+ println!("cargo:rerun-if-env-changed=IZ_BUILD_SHA");
20+ println!("cargo:rerun-if-changed=../../style");
21+ println!("cargo:rerun-if-changed=assets");
22+ println!("cargo:rerun-if-changed=build.rs");
23+
24+ // The commit identity shown by `/healthz`. The release script sets it; a local build says `dev`.
25+ let sha = env::var("IZ_BUILD_SHA").unwrap_or_else(|_| "dev".to_owned());
26+ println!("cargo:rustc-env=IZ_BUILD_SHA={sha}");
27+
28+ let manifest =
29+ PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("cargo sets the manifest dir"));
30+ let out = PathBuf::from(env::var("OUT_DIR").expect("cargo sets OUT_DIR"));
31+
32+ // The stylesheet is compiled from the repository-level `style/` directory. Its partials are
33+ // `@use`d relative to `main.scss`, so no load path is needed.
34+ let css = grass::from_path(
35+ manifest.join("../../style/main.scss"),
36+ &grass::Options::default(),
37+ )
38+ .unwrap_or_else(|e| panic!("compiling style/main.scss: {e}"));
39+ fs::write(out.join("main.css"), &css).expect("writing the compiled stylesheet to OUT_DIR");
40+ println!(
41+ "cargo:rustc-env=IZ_MAIN_CSS_V={}",
42+ content_version(css.as_bytes())
43+ );
44+
45+ for (var, file) in [
46+ ("IZ_NAV_JS_V", "assets/nav.js"),
47+ ("IZ_PAGES_JS_V", "assets/pages.js"),
48+ ] {
49+ let bytes = fs::read(manifest.join(file)).unwrap_or_else(|e| panic!("reading {file}: {e}"));
50+ println!("cargo:rustc-env={var}={}", content_version(&bytes));
51+ }
52+}
53+
54+/// The first `VERSION_HEX_LEN` hex characters of the SHA-256 of `bytes`.
55+fn content_version(bytes: &[u8]) -> String {
56+ encode(Sha256::digest(bytes))[..VERSION_HEX_LEN].to_owned()
57+}
crates/iz-web/src/assets.rsadded+75 -0
@@ -0,0 +1,75 @@
1+//! The static files of the UI, compiled into the binary and served from `/assets/`.
2+//!
3+//! The CSS is compiled from `style/` by `build.rs`. The scripts and the offline page are in
4+//! `crates/iz-web/assets/`. Each link to a file that changes with a build carries the first 12
5+//! hex digits of its SHA-256 as `?v=`, so a changed file gets a new URL and an unchanged one keeps
6+//! its cache entry. Files whose URL does not change (the service worker and the offline page) are
7+//! served with `no-cache`.
8+
9+use topcoat::Result;
10+use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, route};
11+
12+/// Link to the stylesheet, with its content version.
13+pub const MAIN_CSS_HREF: &str = concat!("/assets/main.css?v=", env!("IZ_MAIN_CSS_V"));
14+
15+/// Link to the script that makes navigation soft and drives the live pages.
16+pub const NAV_JS_HREF: &str = concat!("/assets/nav.js?v=", env!("IZ_NAV_JS_V"));
17+
18+/// Link to the script of individual pages.
19+pub const PAGES_JS_HREF: &str = concat!("/assets/pages.js?v=", env!("IZ_PAGES_JS_V"));
20+
21+const MAIN_CSS: &str = include_str!(concat!(env!("OUT_DIR"), "/main.css"));
22+const NAV_JS: &str = include_str!("../assets/nav.js");
23+const PAGES_JS: &str = include_str!("../assets/pages.js");
24+const OFFLINE_HTML: &str = include_str!("../assets/offline.html");
25+const SW_JS: &str = include_str!("../assets/sw.js");
26+
27+/// A content-versioned file. The URL changes with the bytes, so the browser may keep it for a year.
28+const IMMUTABLE: &str = "public, max-age=31536000, immutable";
29+
30+/// A file whose URL stays the same across builds. The browser must ask again each time.
31+const REVALIDATE: &str = "no-cache";
32+
33+/// The status, headers and body of an asset answer.
34+type Asset = (StatusCode, HeaderMap, &'static str);
35+
36+/// Builds the answer for one asset: the content type and the cache policy.
37+fn asset(content_type: &'static str, cache: &'static str, body: &'static str) -> Asset {
38+ let mut headers = HeaderMap::new();
39+ headers.insert(header::CONTENT_TYPE, HeaderValue::from_static(content_type));
40+ headers.insert(header::CACHE_CONTROL, HeaderValue::from_static(cache));
41+ (StatusCode::OK, headers, body)
42+}
43+
44+/// `GET /assets/main.css`.
45+#[route(GET "/assets/main.css")]
46+async fn main_css() -> Result<Asset> {
47+ Ok(asset("text/css; charset=utf-8", IMMUTABLE, MAIN_CSS))
48+}
49+
50+/// `GET /assets/nav.js`.
51+#[route(GET "/assets/nav.js")]
52+async fn nav_js() -> Result<Asset> {
53+ Ok(asset("text/javascript; charset=utf-8", IMMUTABLE, NAV_JS))
54+}
55+
56+/// `GET /assets/pages.js`.
57+#[route(GET "/assets/pages.js")]
58+async fn pages_js() -> Result<Asset> {
59+ Ok(asset("text/javascript; charset=utf-8", IMMUTABLE, PAGES_JS))
60+}
61+
62+/// `GET /assets/offline.html`. Also precached by the service worker.
63+#[route(GET "/assets/offline.html")]
64+async fn offline_html() -> Result<Asset> {
65+ Ok(asset("text/html; charset=utf-8", REVALIDATE, OFFLINE_HTML))
66+}
67+
68+/// `GET /assets/sw.js`. It is served at the root scope, which needs the `Service-Worker-Allowed`
69+/// header; without it the browser would limit the worker to `/assets/`.
70+#[route(GET "/assets/sw.js")]
71+async fn sw_js() -> Result<Asset> {
72+ let (status, mut headers, body) = asset("text/javascript; charset=utf-8", REVALIDATE, SW_JS);
73+ headers.insert("service-worker-allowed", HeaderValue::from_static("/"));
74+ Ok((status, headers, body))
75+}
crates/iz-web/src/boot.rsadded+192 -0
@@ -0,0 +1,192 @@
1+//! Boot: the order in which the server comes up, the router it serves, and the shutdown.
2+//!
3+//! The order follows `docs/conventions.md` section 2: load the configuration, create the data
4+//! directory with mode 0700, load or create the instance key, open the database (which applies
5+//! the pragmas and the migrations), build the router, bind the listener, and serve until SIGTERM or
6+//! Ctrl-C. Stored UI overrides are not layered on the file yet, because no page writes them.
7+
8+use std::os::unix::fs::PermissionsExt;
9+use std::path::Path;
10+use std::sync::Arc;
11+
12+use iz_core::config::Config;
13+use iz_core::secret;
14+use iz_core::store::Store;
15+use tokio::net::TcpListener;
16+use tokio::signal::unix::{SignalKind, signal};
17+use tokio::sync::watch;
18+use topcoat::cookie::RouterBuilderCookieExt;
19+use topcoat::router::{Router, RouterBuilderDiscoverExt, RouterService};
20+
21+use crate::live::LiveHub;
22+use crate::pages::not_found::NotFoundLayer;
23+use crate::security::{self, SecurityHeaders};
24+use crate::state::AppState;
25+
26+/// Name of the instance key file inside the data directory.
27+const KEY_FILE: &str = "iz.key";
28+
29+/// Runs the server until a stop signal arrives. Returns once every connection has finished.
30+pub async fn serve(config_path: &Path) -> iz_core::Result<()> {
31+ let config = Config::load(config_path)?;
32+ let listen = config.listen;
33+ let state = open_state(config).await?;
34+
35+ let listener = TcpListener::bind(listen).await.map_err(|error| {
36+ std::io::Error::new(error.kind(), format!("cannot bind {listen}: {error}"))
37+ })?;
38+ tracing::info!(
39+ listen = %listen,
40+ data_dir = %state.config.data_dir.display(),
41+ build = env!("IZ_BUILD_SHA"),
42+ "iz starting"
43+ );
44+
45+ // One stop flag. The signal task sets it; the server watches it and then drains.
46+ let (stop_tx, stop_rx) = watch::channel(false);
47+ tokio::spawn(async move {
48+ shutdown_signal().await;
49+ tracing::info!("shutdown signal received");
50+ stop_tx.send_replace(true);
51+ });
52+
53+ topcoat::serve_until(
54+ listener,
55+ RouterService::new(router(state)),
56+ wait_stop(stop_rx),
57+ )
58+ .await?;
59+ tracing::info!("iz stopped");
60+ Ok(())
61+}
62+
63+/// Creates the data directory and opens the key and the database. Everything the router needs
64+/// that touches the disk is ready when this returns.
65+async fn open_state(config: Config) -> iz_core::Result<AppState> {
66+ std::fs::create_dir_all(&config.data_dir)?;
67+ // The directory holds the instance key. Only this user may enter it.
68+ std::fs::set_permissions(&config.data_dir, std::fs::Permissions::from_mode(0o700))?;
69+ let data_dir = config.data_dir.canonicalize()?;
70+ if let Some(parent) = config
71+ .database
72+ .parent()
73+ .filter(|p| !p.as_os_str().is_empty())
74+ {
75+ std::fs::create_dir_all(parent)?;
76+ }
77+ let key = secret::load_or_create_key(&data_dir.join(KEY_FILE))?;
78+ let store = Store::open(&config.database).await?;
79+ Ok(AppState {
80+ config: Arc::new(config),
81+ store,
82+ key: Arc::new(key),
83+ live: Arc::new(LiveHub::default()),
84+ })
85+}
86+
87+/// The router of the server: every route and page found by `discover`, the cookie jar, the security
88+/// headers on every response, and the styled 404 for browsers.
89+pub fn router(state: AppState) -> Router {
90+ let security = SecurityHeaders::new(security::headers_for(&state.config.base_url));
91+ Router::builder()
92+ .discover()
93+ .app_context(state)
94+ .cookies()
95+ .layer(security)
96+ .layer(NotFoundLayer)
97+ .build()
98+}
99+
100+/// Resolves when the shared stop flag is set.
101+async fn wait_stop(mut stop: watch::Receiver<bool>) {
102+ let _ = stop.wait_for(|stopped| *stopped).await;
103+}
104+
105+/// Resolves on Ctrl-C or SIGTERM. A handler that cannot be installed is logged and never resolves,
106+/// so the other one still works.
107+async fn shutdown_signal() {
108+ let ctrl_c = async {
109+ if let Err(error) = tokio::signal::ctrl_c().await {
110+ tracing::error!(error = %error, "cannot listen for Ctrl-C");
111+ std::future::pending::<()>().await;
112+ }
113+ };
114+ let terminate = async {
115+ match signal(SignalKind::terminate()) {
116+ Ok(mut term) => {
117+ term.recv().await;
118+ }
119+ Err(error) => {
120+ tracing::error!(error = %error, "cannot listen for SIGTERM");
121+ std::future::pending::<()>().await;
122+ }
123+ }
124+ };
125+ tokio::select! {
126+ () = ctrl_c => {}
127+ () = terminate => {}
128+ }
129+}
130+
131+#[cfg(test)]
132+pub(crate) use tests::test_state;
133+
134+#[cfg(test)]
135+mod tests {
136+ use super::*;
137+ use http::header::{ACCEPT, CONTENT_SECURITY_POLICY, X_CONTENT_TYPE_OPTIONS};
138+ use topcoat::router::response::Response;
139+ use topcoat::router::{Body, to_bytes};
140+
141+ /// An app state over a fresh temp directory: the database and the key live there, and nothing
142+ /// is written outside it. The directory is returned so it lives as long as the state.
143+ pub(crate) async fn test_state() -> (tempfile::TempDir, AppState) {
144+ let dir = tempfile::tempdir().expect("temp dir");
145+ let text = format!(
146+ "database = \"{}\"\ndata_dir = \"{}\"\nlisten = \"127.0.0.1:7654\"\nbase_url = \"http://127.0.0.1:7654\"\n",
147+ dir.path().join("iz.db").display(),
148+ dir.path().display(),
149+ );
150+ let config = Config::parse(&text).expect("test config");
151+ let key = secret::load_or_create_key(&dir.path().join(KEY_FILE)).expect("key");
152+ let store = Store::open(&config.database).await.expect("store");
153+ let state = AppState {
154+ config: Arc::new(config),
155+ store,
156+ key: Arc::new(key),
157+ live: Arc::new(LiveHub::default()),
158+ };
159+ (dir, state)
160+ }
161+
162+ async fn get(state: AppState, path: &str, accept: Option<&str>) -> Response {
163+ let mut request = http::Request::get(path);
164+ if let Some(accept) = accept {
165+ request = request.header(ACCEPT, accept);
166+ }
167+ let request = request.body(Body::empty()).expect("request");
168+ router(state).handle(request).await
169+ }
170+
171+ #[tokio::test]
172+ async fn an_unknown_path_gets_the_styled_404_with_the_security_headers() {
173+ let (_dir, state) = test_state().await;
174+ let response = get(state, "/no/such/page", Some("text/html")).await;
175+ assert_eq!(response.status(), 404);
176+ assert_eq!(
177+ response.headers()[CONTENT_SECURITY_POLICY]
178+ .to_str()
179+ .expect("ascii"),
180+ security::CSP
181+ );
182+ assert_eq!(response.headers()[X_CONTENT_TYPE_OPTIONS], "nosniff");
183+ let body = to_bytes(response.into_body(), 64 * 1024)
184+ .await
185+ .expect("body");
186+ let html = String::from_utf8_lossy(&body);
187+ assert!(
188+ html.contains("Page not found"),
189+ "styled 404 body, got: {html}"
190+ );
191+ }
192+}
crates/iz-web/src/health.rsadded+63 -0
@@ -0,0 +1,63 @@
1+//! `GET /healthz`, the probe of `docs/contracts.md` section 4.1.
2+//!
3+//! It answers `200` with `ok <build sha>` when the database answers `SELECT 1` within one second,
4+//! and `503` with `fail database` otherwise. It needs no login and reads no user data.
5+
6+use std::time::Duration;
7+
8+use topcoat::Result;
9+use topcoat::context::{Cx, app_context};
10+use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, route};
11+
12+use crate::state::AppState;
13+
14+/// The longest the database probe may take. A lock held by a long write shows up as a failed probe.
15+const PROBE_DEADLINE: Duration = Duration::from_secs(1);
16+
17+/// `GET /healthz`.
18+#[route(GET "/healthz")]
19+async fn healthz(cx: &Cx) -> Result<(StatusCode, HeaderMap, String)> {
20+ let state = app_context::<AppState>(cx);
21+ let (status, body) = match tokio::time::timeout(PROBE_DEADLINE, state.store.ping()).await {
22+ Ok(Ok(())) => (StatusCode::OK, format!("ok {}", env!("IZ_BUILD_SHA"))),
23+ Ok(Err(error)) => {
24+ tracing::error!(error = %error, "healthz: the database probe failed");
25+ (StatusCode::SERVICE_UNAVAILABLE, "fail database".to_owned())
26+ }
27+ Err(_) => {
28+ tracing::error!("healthz: the database probe took longer than one second");
29+ (StatusCode::SERVICE_UNAVAILABLE, "fail database".to_owned())
30+ }
31+ };
32+ let mut headers = HeaderMap::new();
33+ headers.insert(
34+ header::CONTENT_TYPE,
35+ HeaderValue::from_static("text/plain; charset=utf-8"),
36+ );
37+ Ok((status, headers, body))
38+}
39+
40+#[cfg(test)]
41+mod tests {
42+ use http::Request;
43+ use topcoat::router::Body;
44+
45+ use crate::boot::{router, test_state};
46+
47+ #[tokio::test]
48+ async fn healthz_answers_ok_with_the_build_sha() {
49+ let (_dir, state) = test_state().await;
50+ let request = Request::get("/healthz")
51+ .body(Body::empty())
52+ .expect("request");
53+ let response = router(state).handle(request).await;
54+ assert_eq!(response.status(), 200);
55+ let body = topcoat::router::to_bytes(response.into_body(), 1024)
56+ .await
57+ .expect("body");
58+ assert_eq!(
59+ body.as_ref(),
60+ format!("ok {}", env!("IZ_BUILD_SHA")).as_bytes()
61+ );
62+ }
63+}
crates/iz-web/src/i18n/mod.rsadded+92 -0
@@ -0,0 +1,92 @@
1+//! Languages of the UI and how a request picks one. English and Turkish are the only ones.
2+//!
3+//! Every visible string is keyed by an enum in an area module (`shell.rs` for now), and each
4+//! module's `t` function matches on `(key, lang)` exhaustively. A key without a Turkish text
5+//! therefore fails to compile instead of showing English on a Turkish page.
6+//!
7+//! This module decides the language. It does not format sentences with values; those get small
8+//! helper functions next to their keys.
9+
10+pub mod shell;
11+
12+use topcoat::context::Cx;
13+use topcoat::router::request::headers;
14+use topcoat::router::{HeaderMap, header};
15+
16+/// A UI language.
17+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
18+pub enum Lang {
19+ En,
20+ Tr,
21+}
22+
23+impl Lang {
24+ /// Parses a stored language code. Anything other than `en` or `tr` is `None`, which means "no
25+ /// preference" to the caller.
26+ pub fn from_code(code: &str) -> Option<Lang> {
27+ match code {
28+ "en" => Some(Lang::En),
29+ "tr" => Some(Lang::Tr),
30+ _ => None,
31+ }
32+ }
33+
34+ /// The language of a `Accept-Language` tag such as `tr-TR`, by its primary subtag. None for a
35+ /// language this build has no text for.
36+ fn from_tag(tag: &str) -> Option<Lang> {
37+ let primary = tag.split('-').next()?.trim();
38+ Lang::from_code(&primary.to_ascii_lowercase())
39+ }
40+
41+ /// The value of `<html lang>`.
42+ pub fn code(self) -> &'static str {
43+ match self {
44+ Lang::En => "en",
45+ Lang::Tr => "tr",
46+ }
47+ }
48+}
49+
50+/// The language of the current request. See [`resolve`].
51+pub fn lang(cx: &Cx, user_locale: Option<&str>) -> Lang {
52+ resolve(user_locale, headers(cx))
53+}
54+
55+/// The user's stored language when it names one, else the best `Accept-Language` entry this build
56+/// can serve, else English.
57+///
58+/// `user_locale` is the stored value of the account (`en`, `tr`, or nothing for "automatic").
59+pub fn resolve(user_locale: Option<&str>, request_headers: &HeaderMap) -> Lang {
60+ user_locale
61+ .and_then(Lang::from_code)
62+ .or_else(|| accept_language(request_headers))
63+ .unwrap_or(Lang::En)
64+}
65+
66+/// The supported entry with the highest quality. Ties keep the first one listed. Entries with
67+/// `q=0`, an unreadable quality, or a language this build does not have are skipped.
68+fn accept_language(request_headers: &HeaderMap) -> Option<Lang> {
69+ let mut best: Option<(f32, Lang)> = None;
70+ for value in request_headers.get_all(header::ACCEPT_LANGUAGE) {
71+ let Ok(text) = value.to_str() else {
72+ continue;
73+ };
74+ for item in text.split(',') {
75+ let mut parts = item.split(';');
76+ let tag = parts.next().unwrap_or_default().trim();
77+ let quality = parts
78+ .find_map(|part| part.trim().strip_prefix("q="))
79+ .map_or(Some(1.0), |q| q.parse::<f32>().ok());
80+ let Some(quality) = quality.filter(|q| *q > 0.0) else {
81+ continue;
82+ };
83+ let Some(lang) = Lang::from_tag(tag) else {
84+ continue;
85+ };
86+ if best.is_none_or(|(best_quality, _)| quality > best_quality) {
87+ best = Some((quality, lang));
88+ }
89+ }
90+ }
91+ best.map(|(_, lang)| lang)
92+}
crates/iz-web/src/i18n/shell.rsadded+53 -0
@@ -0,0 +1,53 @@
1+//! Strings of the shell and of the first pages: the topbar, the restart bar, the 404 page and the
2+//! start page. Area modules hold their own strings as they arrive.
3+
4+use super::Lang;
5+
6+/// One variant per phrase. Add a variant, then its English and Turkish texts in [`t`].
7+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8+pub enum K {
9+ /// The badge shown beside an administrator's name.
10+ Admin,
11+ /// The link on the 404 page that returns to the start page.
12+ BackHome,
13+ /// The sentence under the 404 title.
14+ NotFoundBody,
15+ /// The title of the 404 page.
16+ NotFoundTitle,
17+ /// The sentence on the signed-out start page.
18+ SignedOutBody,
19+ /// The title of the start page: the app name, shown big.
20+ SignedOutTitle,
21+ /// The bar shown while the server cannot be reached.
22+ ServerRestarting,
23+ /// The accessible name of the service switcher.
24+ Services,
25+ /// The first link on every page, which jumps past the topbar.
26+ SkipToContent,
27+}
28+
29+/// The text of `key` in `lang`.
30+pub fn t(lang: Lang, key: K) -> &'static str {
31+ match (key, lang) {
32+ (K::Admin, Lang::En) => "Admin",
33+ (K::Admin, Lang::Tr) => "Yönetici",
34+ (K::BackHome, Lang::En) => "Back to the start",
35+ (K::BackHome, Lang::Tr) => "Başlangıca dön",
36+ (K::NotFoundBody, Lang::En) => "The page does not exist, or you do not have access to it.",
37+ (K::NotFoundBody, Lang::Tr) => "Sayfa yok ya da bu sayfayı görme izniniz yok.",
38+ (K::NotFoundTitle, Lang::En) => "Page not found",
39+ (K::NotFoundTitle, Lang::Tr) => "Sayfa bulunamadı",
40+ (K::SignedOutBody, Lang::En) => {
41+ "You are signed out. Sign-in is not part of this build yet."
42+ }
43+ (K::SignedOutBody, Lang::Tr) => "Oturumunuz kapalı. Oturum açma bu sürümde henüz yok.",
44+ (K::SignedOutTitle, Lang::En) => "iz",
45+ (K::SignedOutTitle, Lang::Tr) => "iz",
46+ (K::ServerRestarting, Lang::En) => "The server is restarting. Reconnecting…",
47+ (K::ServerRestarting, Lang::Tr) => "Sunucu yeniden başlatılıyor. Yeniden bağlanılıyor…",
48+ (K::Services, Lang::En) => "Services",
49+ (K::Services, Lang::Tr) => "Hizmetler",
50+ (K::SkipToContent, Lang::En) => "Skip to content",
51+ (K::SkipToContent, Lang::Tr) => "İçeriğe geç",
52+ }
53+}
crates/iz-web/src/live.rsadded+197 -0
@@ -0,0 +1,197 @@
1+//! Live updates: a change counter per topic, and the server-sent event stream that carries it to
2+//! the browser.
3+//!
4+//! A write that changes what a page shows calls [`LiveHub::bump`] after it commits. A stream that
5+//! subscribed to that topic wakes and sends one `changed` event without data. The browser then
6+//! fetches the page again (`nav.js`), so an event carries no state and a missed one cannot leave the
7+//! page wrong for long. Nothing polls, and a topic nobody listens to is dropped.
8+//!
9+//! The hub is not a queue and not an authorisation check. Each route that opens a stream
10+//! authenticates and authorises first, then calls [`stream_changes`].
11+//!
12+//! Nothing bumps a topic or opens [`stream_changes`] yet, so the items here are kept ahead of the
13+//! pages that use them.
14+
15+#![allow(dead_code)] // The hub and its topics wait for the pages that bump and follow them.
16+
17+use std::collections::HashMap;
18+use std::future::Future;
19+use std::sync::{Mutex, MutexGuard, PoisonError};
20+use std::time::Duration;
21+
22+use futures_util::{Stream, StreamExt, future::select_all, stream};
23+use tokio::sync::watch;
24+use topcoat::Result;
25+use topcoat::context::Cx;
26+use topcoat::router::content::sse::{Event, KeepAlive, Sse};
27+use topcoat::router::response::{IntoResponse, Response};
28+use topcoat::router::{HeaderValue, route};
29+
30+/// How long a client waits before it reconnects when a stream ends. Sent once, at the start.
31+pub const STREAM_RETRY: Duration = Duration::from_millis(1000);
32+
33+/// Silence after which the server sends a keep-alive comment, so proxies keep the stream open.
34+pub const KEEP_ALIVE: Duration = Duration::from_secs(30);
35+
36+/// What a live page follows. Each variant is a thing a page is about, so a write bumps exactly the
37+/// pages that show it (`docs/architecture.md` section 9).
38+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
39+pub enum Topic {
40+ /// The board: any card change, column or project change. Global to the one board.
41+ Board(String),
42+ /// A task's modal: its fields, comments, activity and files. Keyed by task id.
43+ Task(String),
44+ /// A person's card: counts and recent activity. Keyed by user id.
45+ Person(String),
46+ /// An admin page section. Admin pages only.
47+ Admin(AdminSection),
48+ /// A user's own settings, sessions or sign-ins. Keyed by user id. Streamed only to that user.
49+ Account(String),
50+}
51+
52+/// The admin pages that stream changes.
53+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
54+pub enum AdminSection {
55+ /// The mail outbox.
56+ Outbox,
57+ /// The mail decisions ledger.
58+ Decisions,
59+ /// The activity log.
60+ Activity,
61+ /// The settings page.
62+ Settings,
63+ /// The members and roles list.
64+ Members,
65+}
66+
67+/// The change counters of all open topics. Cheap to share: every clone of the app state holds the
68+/// same `Arc<LiveHub>`.
69+#[derive(Default)]
70+pub struct LiveHub {
71+ topics: Mutex<HashMap<Topic, watch::Sender<u64>>>,
72+}
73+
74+impl LiveHub {
75+ /// Locks the map. A panic in another holder must not stop every live page, so a poisoned lock
76+ /// is used as it is.
77+ fn topics(&self) -> MutexGuard<'_, HashMap<Topic, watch::Sender<u64>>> {
78+ self.topics.lock().unwrap_or_else(PoisonError::into_inner)
79+ }
80+
81+ /// Subscribes to `topic`. The receiver starts as seen, so a bump after this call wakes it.
82+ /// Subscribe before reading the state: a change between the two is then not lost. Topics that
83+ /// nobody holds any more are dropped here, so the map stays small.
84+ pub fn subscribe(&self, topic: &Topic) -> watch::Receiver<u64> {
85+ let mut topics = self.topics();
86+ topics.retain(|_, sender| sender.receiver_count() > 0);
87+ topics
88+ .entry(topic.clone())
89+ .or_insert_with(|| watch::channel(0).0)
90+ .subscribe()
91+ }
92+
93+ /// Wakes the subscribers of `topic`. Does nothing when nobody listens.
94+ pub fn bump(&self, topic: &Topic) {
95+ let mut topics = self.topics();
96+ let Some(sender) = topics.get(topic) else {
97+ return;
98+ };
99+ sender.send_modify(|generation| *generation = generation.wrapping_add(1));
100+ if sender.receiver_count() == 0 {
101+ topics.remove(topic);
102+ }
103+ }
104+}
105+
106+/// The state a stream carries between wakes.
107+struct Follow<F> {
108+ wakes: Vec<watch::Receiver<u64>>,
109+ fingerprint: F,
110+ last: String,
111+}
112+
113+/// Opens the `changed` stream for `topics`. The stream sends an event only when `fingerprint`
114+/// differs from the value it last sent, so a bump that changes nothing the viewer sees sends
115+/// nothing. Nothing is sent on connect: the page already shows the state that `fingerprint` read.
116+///
117+/// `fingerprint` must be cheap and must describe everything the page shows. A read that fails ends
118+/// the stream, and the browser reconnects.
119+pub async fn stream_changes<F, Fut>(
120+ cx: &Cx,
121+ hub: &LiveHub,
122+ topics: &[Topic],
123+ fingerprint: F,
124+) -> Result<Response>
125+where
126+ F: Fn() -> Fut + Send + 'static,
127+ Fut: Future<Output = Result<String>> + Send,
128+{
129+ // Subscribed before the first read, so a change in between still wakes the stream.
130+ let wakes: Vec<watch::Receiver<u64>> =
131+ topics.iter().map(|topic| hub.subscribe(topic)).collect();
132+ let last = fingerprint().await?;
133+ let follow = Follow {
134+ wakes,
135+ fingerprint,
136+ last,
137+ };
138+ let events = stream::unfold(follow, |mut follow| async move {
139+ loop {
140+ if !wait_any(&mut follow.wakes).await {
141+ return None;
142+ }
143+ match (follow.fingerprint)().await {
144+ Ok(now) if now != follow.last => {
145+ follow.last = now;
146+ return Some((changed_event(), follow));
147+ }
148+ Ok(_) => continue,
149+ Err(error) => {
150+ tracing::error!(error = %error, "live: could not read the page state");
151+ return None;
152+ }
153+ }
154+ }
155+ });
156+ events_response(cx, events)
157+}
158+
159+/// The data-less `changed` event.
160+fn changed_event() -> Result<Event> {
161+ Ok(Event::new().event("changed").data("1"))
162+}
163+
164+/// Resolves when one of `wakes` changes. False when that topic is gone, which ends the stream.
165+/// With no topics at all it never resolves: the stream then only sends keep-alives.
166+async fn wait_any(wakes: &mut [watch::Receiver<u64>]) -> bool {
167+ if wakes.is_empty() {
168+ std::future::pending::<()>().await;
169+ }
170+ let waits = wakes.iter_mut().map(|wake| Box::pin(wake.changed()));
171+ let (result, _, _) = select_all(waits).await;
172+ result.is_ok()
173+}
174+
175+/// The response of a live stream: `retry` once, then the events, with keep-alives while idle.
176+/// `X-Accel-Buffering: no` stops a reverse proxy from holding the events back.
177+pub fn events_response(
178+ cx: &Cx,
179+ events: impl Stream<Item = Result<Event>> + Send + 'static,
180+) -> Result<Response> {
181+ let retry = stream::once(std::future::ready(Ok(Event::new().retry(STREAM_RETRY))));
182+ let stream = Sse::new(retry.chain(events))
183+ .keep_alive(KeepAlive::new().interval(KEEP_ALIVE).text("keepalive"));
184+ let mut response = stream.into_response(cx)?;
185+ response
186+ .headers_mut()
187+ .insert("x-accel-buffering", HeaderValue::from_static("no"));
188+ Ok(response)
189+}
190+
191+/// `GET /-/alive`. Every page holds this stream, so the browser learns when the server stops and
192+/// starts again. Anonymous viewers may hold it, and it reveals nothing: for now it sends only the
193+/// `retry` hint and keep-alives.
194+#[route(GET "/-/alive")]
195+async fn alive(cx: &Cx) -> Result<Response> {
196+ events_response(cx, stream::pending::<Result<Event>>())
197+}
crates/iz-web/src/main.rsmodified+99 -3
@@ -1,5 +1,101 @@
1-//! Entry point of the `iz` binary. This step only prints the name; the boot sequence comes later.
1+//! The `iz` binary: the command line, logging and the process lifetime.
2+//!
3+//! `iz [--config <path>] [serve]` runs the server; a bare `iz` does the same. `iz admin ...` is the
4+//! operator command line, which is not built yet. The configuration file is the `--config` path,
5+//! then `IZ_CONFIG`, then `config/iz.toml`. Exit status 0 is success, 1 a failure, 2 a usage error.
26
3-fn main() {
4- println!("iz");
7+mod assets;
8+mod boot;
9+mod health;
10+mod i18n;
11+mod live;
12+mod pages;
13+mod security;
14+mod state;
15+mod views;
16+
17+use std::path::{Path, PathBuf};
18+use std::process::ExitCode;
19+
20+use tracing_subscriber::EnvFilter;
21+
22+/// Printed with a usage error.
23+const USAGE: &str = "usage: iz [--config <path>] [serve]";
24+
25+/// The configuration file when neither `--config` nor `IZ_CONFIG` names one.
26+const DEFAULT_CONFIG: &str = "config/iz.toml";
27+
28+/// The environment variable that names the configuration file.
29+const CONFIG_ENV: &str = "IZ_CONFIG";
30+
31+/// The parsed command line: the `--config` path and the positional words.
32+struct Cli {
33+ config: Option<PathBuf>,
34+ words: Vec<String>,
35+}
36+
37+/// Splits the arguments into the `--config <path>` pair and the positional words.
38+fn parse_args(args: impl Iterator<Item = String>) -> Result<Cli, String> {
39+ let mut config = None;
40+ let mut words = Vec::new();
41+ let mut args = args;
42+ while let Some(arg) = args.next() {
43+ if arg == "--config" {
44+ let path = args.next().ok_or("--config needs a path")?;
45+ config = Some(PathBuf::from(path));
46+ } else {
47+ words.push(arg);
48+ }
49+ }
50+ Ok(Cli { config, words })
51+}
52+
53+/// The configuration path: the flag, else `IZ_CONFIG`, else the default.
54+fn config_path(flag: Option<PathBuf>) -> PathBuf {
55+ flag.or_else(|| std::env::var_os(CONFIG_ENV).map(PathBuf::from))
56+ .unwrap_or_else(|| PathBuf::from(DEFAULT_CONFIG))
57+}
58+
59+/// Logs to stderr. The level comes from `RUST_LOG`, and defaults to `info`.
60+fn init_logging() {
61+ let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
62+ tracing_subscriber::fmt()
63+ .with_env_filter(filter)
64+ .with_writer(std::io::stderr)
65+ .init();
66+}
67+
68+/// Runs the server and maps its outcome to an exit status.
69+async fn serve(config: &Path) -> ExitCode {
70+ match boot::serve(config).await {
71+ Ok(()) => ExitCode::SUCCESS,
72+ Err(error) => {
73+ tracing::error!(error = %error, "iz stopped with an error");
74+ ExitCode::FAILURE
75+ }
76+ }
77+}
78+
79+#[tokio::main]
80+async fn main() -> ExitCode {
81+ init_logging();
82+ let cli = match parse_args(std::env::args().skip(1)) {
83+ Ok(cli) => cli,
84+ Err(message) => {
85+ eprintln!("iz: {message}\n{USAGE}");
86+ return ExitCode::from(2);
87+ }
88+ };
89+ let words: Vec<&str> = cli.words.iter().map(String::as_str).collect();
90+ match words.as_slice() {
91+ [] | ["serve"] => serve(&config_path(cli.config)).await,
92+ ["admin", ..] => {
93+ eprintln!("iz: admin commands are not implemented yet");
94+ ExitCode::from(2)
95+ }
96+ _ => {
97+ eprintln!("iz: unknown command\n{USAGE}");
98+ ExitCode::from(2)
99+ }
100+ }
5101 }
crates/iz-web/src/pages/home.rsadded+26 -0
@@ -0,0 +1,26 @@
1+//! The start page. Until sign-in exists every visitor is signed out, so it shows the app name and
2+//! that the viewer is not signed in.
3+
4+use topcoat::Result;
5+use topcoat::context::Cx;
6+use topcoat::router::page;
7+use topcoat::view::{View, view};
8+
9+use crate::i18n::lang;
10+use crate::i18n::shell::{K, t};
11+use crate::views::shell;
12+
13+/// `GET /`.
14+#[page("/")]
15+async fn home(cx: &Cx) -> Result<impl View> {
16+ let lang = lang(cx, None);
17+ Ok(view! {
18+ shell(title: t(lang, K::SignedOutTitle), lang: lang, viewer: None,
19+ <section class="card">
20+ <p class="kicker">"iz"</p>
21+ <h1>(t(lang, K::SignedOutTitle))</h1>
22+ <p>(t(lang, K::SignedOutBody))</p>
23+ </section>
24+ )
25+ })
26+}
crates/iz-web/src/pages/mod.rsadded+4 -0
@@ -0,0 +1,4 @@
1+//! The pages and the page-level layers. One file per page.
2+
3+pub mod home;
4+pub mod not_found;
crates/iz-web/src/pages/not_found.rsadded+74 -0
@@ -0,0 +1,74 @@
1+//! The styled 404 page. Topcoat answers an unknown path with a bare text body. For a browser
2+//! (`Accept` names `text/html`) the layer below rewrites that answer to a page in the regular
3+//! shell. Other clients keep the plain 404, and so does any request whose path exists.
4+
5+use http::header::ACCEPT;
6+use topcoat::Result;
7+use topcoat::context::Cx;
8+use topcoat::router::error::{NotFoundError, rewrite};
9+use topcoat::router::page;
10+use topcoat::router::request::headers;
11+use topcoat::router::response::Response;
12+use topcoat::router::{Body, Layer, LayerFuture, Method, Next, Path, StatusCode};
13+use topcoat::view::{View, component, view};
14+
15+use crate::i18n::shell::{K, t};
16+use crate::i18n::{Lang, lang};
17+use crate::views::{empty_state, shell};
18+
19+/// Where a browser's 404 is sent. The page below answers with status 404 itself.
20+const NOT_FOUND_PATH: &str = "/-/not-found";
21+
22+/// Rewrites a 404 for a browser to the styled page. Pathless, so it sees every request.
23+pub struct NotFoundLayer;
24+
25+impl Layer for NotFoundLayer {
26+ fn path(&self) -> Option<&Path> {
27+ None
28+ }
29+
30+ fn handle<'a>(&'a self, cx: &'a Cx, body: Body, next: Next<'a>) -> LayerFuture<'a> {
31+ Box::pin(styled_not_found(cx, body, next))
32+ }
33+}
34+
35+/// Runs the rest of the chain. If it ended in a 404 and the client asked for HTML, the request is
36+/// rewritten to [`NOT_FOUND_PATH`]. Every other outcome is returned unchanged.
37+async fn styled_not_found(cx: &Cx, body: Body, next: Next<'_>) -> Result<Response> {
38+ let result = next.run(cx, body).await;
39+ let missing = matches!(&result, Err(error) if error.downcast_ref::<NotFoundError>().is_some());
40+ let wants_html = headers(cx)
41+ .get(ACCEPT)
42+ .and_then(|value| value.to_str().ok())
43+ .is_some_and(|value| value.contains("text/html"));
44+ if !missing || !wants_html {
45+ return result;
46+ }
47+ Err(rewrite(NOT_FOUND_PATH, Body::empty())
48+ .method(Method::GET)
49+ .into())
50+}
51+
52+/// The 404 page itself.
53+#[page("/-/not-found")]
54+async fn not_found_page(cx: &Cx) -> Result<impl View> {
55+ let lang = lang(cx, None);
56+ Ok(view! {
57+ (StatusCode::NOT_FOUND)
58+ shell(title: t(lang, K::NotFoundTitle), lang: lang, viewer: None, not_found_body(lang: lang))
59+ })
60+}
61+
62+/// The 404 content: the code, then the empty-state card with the explanation and a way back.
63+#[component]
64+async fn not_found_body(lang: Lang) -> Result<impl View> {
65+ Ok(view! {
66+ <section class="not-found">
67+ <p class="not-found-code">"404"</p>
68+ empty_state(title: t(lang, K::NotFoundTitle),
69+ <p>(t(lang, K::NotFoundBody))</p>
70+ <a class="button primary" href="/">(t(lang, K::BackHome))</a>
71+ )
72+ </section>
73+ })
74+}
crates/iz-web/src/security.rsadded+70 -0
@@ -0,0 +1,70 @@
1+//! The security headers of every response, and the Content-Security-Policy they carry.
2+//!
3+//! The policy allows scripts and styles from the origin itself and nothing else. No page may use an
4+//! inline script, an inline style or an inline event handler: all behaviour lives in
5+//! `crates/iz-web/assets/*.js`. Changing [`CSP`] is a security change, so keep it in step with
6+//! `docs/conventions.md` section 5.
7+
8+use topcoat::context::Cx;
9+use topcoat::router::response::response_headers;
10+use topcoat::router::{Body, HeaderMap, HeaderValue, Layer, LayerFuture, Next, Path, header};
11+
12+/// The Content-Security-Policy of every response.
13+pub const CSP: &str = "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; \
14+ form-action 'self'; frame-ancestors 'none'; base-uri 'none'";
15+
16+/// One year, in seconds. Sent only when the public origin is https.
17+const HSTS: &str = "max-age=31536000";
18+
19+/// The headers that every response carries, for an instance at `base_url`.
20+pub fn headers_for(base_url: &str) -> HeaderMap {
21+ let mut headers = HeaderMap::new();
22+ headers.insert(
23+ header::X_CONTENT_TYPE_OPTIONS,
24+ HeaderValue::from_static("nosniff"),
25+ );
26+ headers.insert(header::X_FRAME_OPTIONS, HeaderValue::from_static("DENY"));
27+ headers.insert(
28+ header::REFERRER_POLICY,
29+ HeaderValue::from_static("same-origin"),
30+ );
31+ headers.insert(
32+ header::CONTENT_SECURITY_POLICY,
33+ HeaderValue::from_static(CSP),
34+ );
35+ if base_url.starts_with("https://") {
36+ headers.insert(
37+ header::STRICT_TRANSPORT_SECURITY,
38+ HeaderValue::from_static(HSTS),
39+ );
40+ }
41+ headers
42+}
43+
44+/// Adds a fixed set of headers to every response of the router.
45+///
46+/// It uses the per-request response headers, which the router applies after the layers have run,
47+/// so error responses (404, 500) carry them as well.
48+pub struct SecurityHeaders {
49+ headers: HeaderMap,
50+}
51+
52+impl SecurityHeaders {
53+ /// A layer that adds `headers` to every response.
54+ pub fn new(headers: HeaderMap) -> Self {
55+ Self { headers }
56+ }
57+}
58+
59+impl Layer for SecurityHeaders {
60+ fn path(&self) -> Option<&Path> {
61+ None
62+ }
63+
64+ fn handle<'a>(&'a self, cx: &'a Cx, body: Body, next: Next<'a>) -> LayerFuture<'a> {
65+ Box::pin(async move {
66+ response_headers(cx).extend(self.headers.clone());
67+ next.run(cx, body).await
68+ })
69+ }
70+}
crates/iz-web/src/state.rsadded+22 -0
@@ -0,0 +1,22 @@
1+//! The state shared by every route. Topcoat hands it to each handler through the app context.
2+
3+use std::sync::Arc;
4+
5+use iz_core::config::Config;
6+use iz_core::store::Store;
7+
8+use crate::live::LiveHub;
9+
10+/// Everything a request handler reaches through the app context. Every field is cheap to clone.
11+#[allow(dead_code)] // The key and the hub are read by the sign-in and live pages that come next.
12+#[derive(Clone)]
13+pub struct AppState {
14+ /// The configuration the process booted with.
15+ pub config: Arc<Config>,
16+ /// The database. Reads go to a pooled reader and writes to the single writer.
17+ pub store: Store,
18+ /// The instance key (`iz.key`). Seals secrets at rest.
19+ pub key: Arc<[u8; 32]>,
20+ /// The change counters of the live pages.
21+ pub live: Arc<LiveHub>,
22+}
crates/iz-web/src/views/mod.rsadded+89 -0
@@ -0,0 +1,89 @@
1+//! Shared page chrome: the HTML shell and the small components every page is built from.
2+//!
3+//! `view!` escapes text and attribute values, so user data is safe in it by default. Nothing here
4+//! emits an inline script, style or event handler; see `security.rs`.
5+
6+use topcoat::Result;
7+use topcoat::view::{Child, View, component, view};
8+
9+use crate::assets::{MAIN_CSS_HREF, NAV_JS_HREF, PAGES_JS_HREF};
10+use crate::i18n::Lang;
11+use crate::i18n::shell::{K, t};
12+
13+/// What the shell shows about the signed-in person. Nothing signs a person in yet, so every page
14+/// is built for an anonymous viewer.
15+#[allow(dead_code)] // Built by the sign-in code, which comes next.
16+pub struct ViewerInfo {
17+ /// The name shown in the topbar.
18+ pub name: String,
19+ /// Whether the topbar shows the administrator badge.
20+ pub is_admin: bool,
21+}
22+
23+/// The HTML document around a page. `title` is the page's own title; the document title adds the
24+/// app name. `child` is the page, placed in `<main>`.
25+///
26+/// The topbar has the wordmark on the left, the service switcher in the middle (empty for now) and
27+/// the viewer's name on the right. `nav.js` reads the restart text from `<body data-restart-text>`.
28+#[component]
29+pub async fn shell(
30+ title: &str,
31+ lang: Lang,
32+ viewer: Option<&ViewerInfo>,
33+ #[default] child: Child<'_>,
34+) -> Result<impl View> {
35+ let document_title = format!("{title} \u{b7} iz");
36+ Ok(view! {
37+ <!DOCTYPE html>
38+ <html lang=(lang.code()) data-theme="system">
39+ <head>
40+ <meta charset="utf-8">
41+ <meta name="viewport" content="width=device-width, initial-scale=1">
42+ <title>(document_title)</title>
43+ <link rel="stylesheet" href=(MAIN_CSS_HREF)>
44+ <script src=(NAV_JS_HREF) defer=""></script>
45+ <script src=(PAGES_JS_HREF) defer=""></script>
46+ </head>
47+ <body data-restart-text=(t(lang, K::ServerRestarting))>
48+ <a class="skip-link" href="#main">(t(lang, K::SkipToContent))</a>
49+ <header class="topbar">
50+ <a class="topbar-brand" href="/">"iz"</a>
51+ <nav class="switcher" aria-label=(t(lang, K::Services))></nav>
52+ <div class="topbar-end">
53+ if let Some(viewer) = viewer {
54+ <span>(viewer.name.as_str())</span>
55+ if viewer.is_admin {
56+ <span class="badge accent">(t(lang, K::Admin))</span>
57+ }
58+ }
59+ </div>
60+ </header>
61+ <main id="main">(child)</main>
62+ </body>
63+ </html>
64+ })
65+}
66+
67+/// An error message for a failed action. Forms show it above their fields.
68+#[allow(dead_code)] // The first form that can fail a check uses it.
69+#[component]
70+pub async fn alert(message: &str) -> Result<impl View> {
71+ Ok(view! { <div class="alert" role="alert">(message)</div> })
72+}
73+
74+/// A plain message that is not an error, such as a confirmation or a hint.
75+#[component]
76+pub async fn notice(message: &str) -> Result<impl View> {
77+ Ok(view! { <div class="notice" role="status">(message)</div> })
78+}
79+
80+/// A section with nothing in it yet: a title, then what to do next.
81+#[component]
82+pub async fn empty_state(title: &str, #[default] child: Child<'_>) -> Result<impl View> {
83+ Ok(view! {
84+ <section class="empty-state">
85+ <h2>(title)</h2>
86+ (child)
87+ </section>
88+ })
89+}
style/_base.scssadded+117 -0
@@ -0,0 +1,117 @@
1+//! Element defaults: the reset, the body type, links, headings and focus. Nothing here is a class;
2+//! a page gets its look from elements it writes plainly, and from the component classes.
3+
4+*,
5+*::before,
6+*::after {
7+ box-sizing: border-box;
8+}
9+
10+html {
11+ -webkit-text-size-adjust: 100%;
12+ text-size-adjust: 100%;
13+}
14+
15+body {
16+ margin: 0;
17+ background: var(--bg);
18+ color: var(--text);
19+ font-family: var(--font-sans);
20+ font-size: 1rem;
21+ line-height: 1.55;
22+ -webkit-font-smoothing: antialiased;
23+}
24+
25+h1,
26+h2,
27+h3 {
28+ line-height: 1.25;
29+ margin: 0 0 var(--space-3);
30+ font-weight: 650;
31+ letter-spacing: -0.01em;
32+}
33+
34+h1 {
35+ font-size: var(--text-xl);
36+}
37+
38+h2 {
39+ font-size: var(--text-lg);
40+}
41+
42+h3 {
43+ font-size: 1rem;
44+}
45+
46+p {
47+ margin: 0 0 var(--space-3);
48+}
49+
50+a {
51+ color: var(--accent);
52+ text-decoration-thickness: 1px;
53+ text-underline-offset: 0.2em;
54+}
55+
56+a:hover {
57+ color: var(--accent-strong);
58+}
59+
60+img,
61+svg {
62+ display: block;
63+ max-width: 100%;
64+}
65+
66+code,
67+kbd,
68+pre {
69+ font-family: var(--font-mono);
70+ font-size: 0.92em;
71+}
72+
73+:focus-visible {
74+ outline: 2px solid var(--focus);
75+ outline-offset: 2px;
76+ border-radius: 2px;
77+}
78+
79+::selection {
80+ background: var(--accent-soft);
81+}
82+
83+// The `hidden` attribute must win over any display rule a component sets.
84+[hidden] {
85+ display: none !important;
86+}
87+
88+// Visible only to screen readers.
89+.sr-only {
90+ position: absolute;
91+ width: 1px;
92+ height: 1px;
93+ padding: 0;
94+ margin: -1px;
95+ overflow: hidden;
96+ clip: rect(0, 0, 0, 0);
97+ white-space: nowrap;
98+ border: 0;
99+}
100+
101+// The first focusable element. It is off screen until a keyboard user tabs to it.
102+.skip-link {
103+ position: absolute;
104+ top: var(--space-2);
105+ left: var(--space-2);
106+ z-index: 100;
107+ padding: var(--space-2) var(--space-3);
108+ background: var(--surface);
109+ color: var(--text);
110+ border-radius: var(--radius-sm);
111+ box-shadow: var(--shadow-lift);
112+ transform: translateY(-200%);
113+}
114+
115+.skip-link:focus {
116+ transform: none;
117+}
style/_components.scssadded+315 -0
@@ -0,0 +1,315 @@
1+//! Components: buttons, form controls, cards, alerts, tables, badges, the empty state, the 404 page
2+//! and the "server restarting" bar. Each is one class (or one element) with its states.
3+
4+// --- Buttons -----------------------------------------------------------------------------------
5+
6+.button {
7+ display: inline-flex;
8+ align-items: center;
9+ justify-content: center;
10+ gap: var(--space-2);
11+ min-height: 2.25rem;
12+ padding: var(--space-2) var(--space-4);
13+ border: 1px solid var(--border);
14+ border-radius: var(--radius-sm);
15+ background: var(--surface);
16+ color: var(--text);
17+ font: inherit;
18+ font-weight: 550;
19+ text-decoration: none;
20+ cursor: pointer;
21+ box-shadow: var(--shadow);
22+ transition: background-color 120ms ease, border-color 120ms ease;
23+}
24+
25+.button:hover {
26+ background: var(--surface-2);
27+ color: var(--text);
28+}
29+
30+.button:disabled,
31+.button[aria-disabled="true"] {
32+ opacity: 0.55;
33+ cursor: not-allowed;
34+}
35+
36+.button.primary {
37+ background: var(--accent);
38+ border-color: var(--accent);
39+ color: var(--accent-text);
40+}
41+
42+.button.primary:hover {
43+ background: var(--accent-strong);
44+ border-color: var(--accent-strong);
45+ color: var(--accent-text);
46+}
47+
48+.button.danger {
49+ color: var(--danger);
50+ border-color: var(--danger);
51+}
52+
53+.button.ghost {
54+ background: transparent;
55+ box-shadow: none;
56+ border-color: transparent;
57+}
58+
59+// --- Form controls ----------------------------------------------------------------------------
60+
61+label {
62+ display: block;
63+ font-weight: 550;
64+ font-size: var(--text-sm);
65+ margin-bottom: var(--space-1);
66+}
67+
68+input:not([type="checkbox"]):not([type="radio"]),
69+select,
70+textarea {
71+ width: 100%;
72+ min-height: 2.25rem;
73+ padding: var(--space-2) var(--space-3);
74+ border: 1px solid var(--border);
75+ border-radius: var(--radius-sm);
76+ background: var(--surface);
77+ color: var(--text);
78+ font: inherit;
79+}
80+
81+textarea {
82+ min-height: 6rem;
83+ resize: vertical;
84+}
85+
86+input:focus,
87+select:focus,
88+textarea:focus {
89+ outline: 2px solid var(--focus);
90+ outline-offset: 0;
91+ border-color: transparent;
92+}
93+
94+input::placeholder,
95+textarea::placeholder {
96+ color: var(--muted);
97+ opacity: 0.8;
98+}
99+
100+.field {
101+ display: grid;
102+ gap: var(--space-1);
103+}
104+
105+.field + .field {
106+ margin-top: var(--space-4);
107+}
108+
109+.field-hint {
110+ color: var(--muted);
111+ font-size: var(--text-sm);
112+}
113+
114+// --- Cards and text ---------------------------------------------------------------------------
115+
116+.card {
117+ padding: var(--space-6);
118+ background: var(--surface);
119+ border: 1px solid var(--border);
120+ border-radius: var(--radius);
121+ box-shadow: var(--shadow);
122+}
123+
124+.card > :last-child {
125+ margin-bottom: 0;
126+}
127+
128+.card-title {
129+ margin-bottom: var(--space-2);
130+}
131+
132+.muted {
133+ color: var(--muted);
134+}
135+
136+.kicker {
137+ margin-bottom: var(--space-2);
138+ color: var(--muted);
139+ font-size: var(--text-sm);
140+ font-weight: 600;
141+ letter-spacing: 0.04em;
142+ text-transform: uppercase;
143+}
144+
145+// --- Alerts -----------------------------------------------------------------------------------
146+
147+.alert,
148+.notice {
149+ padding: var(--space-3) var(--space-4);
150+ border-radius: var(--radius-sm);
151+ border: 1px solid transparent;
152+}
153+
154+.alert {
155+ background: var(--danger-soft);
156+ color: var(--danger);
157+ border-color: var(--danger);
158+}
159+
160+.notice {
161+ background: var(--accent-soft);
162+ color: var(--text);
163+ border-color: var(--accent-soft);
164+}
165+
166+// --- Tables and badges ------------------------------------------------------------------------
167+
168+.table-wrap {
169+ overflow-x: auto;
170+ border: 1px solid var(--border);
171+ border-radius: var(--radius);
172+ background: var(--surface);
173+}
174+
175+.table {
176+ width: 100%;
177+ border-collapse: collapse;
178+ font-size: var(--text-sm);
179+}
180+
181+.table th,
182+.table td {
183+ padding: var(--space-2) var(--space-3);
184+ text-align: left;
185+ border-bottom: 1px solid var(--border);
186+ vertical-align: top;
187+}
188+
189+.table th {
190+ color: var(--muted);
191+ font-weight: 600;
192+ background: var(--surface-2);
193+}
194+
195+.table tr:last-child td {
196+ border-bottom: 0;
197+}
198+
199+.badge {
200+ display: inline-block;
201+ padding: 0.1rem var(--space-2);
202+ border-radius: 999px;
203+ background: var(--surface-2);
204+ color: var(--muted);
205+ font-size: 0.8rem;
206+ font-weight: 600;
207+ white-space: nowrap;
208+}
209+
210+.badge.accent {
211+ background: var(--accent-soft);
212+ color: var(--accent-strong);
213+}
214+
215+// --- Empty state and the 404 page -------------------------------------------------------------
216+
217+.empty-state {
218+ display: grid;
219+ justify-items: center;
220+ gap: var(--space-3);
221+ padding: var(--space-8) var(--space-6);
222+ text-align: center;
223+ color: var(--muted);
224+ border: 1px dashed var(--border);
225+ border-radius: var(--radius);
226+}
227+
228+.empty-state h2 {
229+ margin: 0;
230+ color: var(--text);
231+}
232+
233+.empty-state p {
234+ margin: 0;
235+ max-width: 34rem;
236+}
237+
238+.not-found {
239+ text-align: center;
240+ padding-block: var(--space-8);
241+}
242+
243+.not-found-code {
244+ margin: 0;
245+ font-size: 3.5rem;
246+ font-weight: 700;
247+ letter-spacing: -0.03em;
248+ color: var(--accent);
249+ line-height: 1;
250+}
251+
252+// --- Server restarting bar --------------------------------------------------------------------
253+
254+// Pinned to the bottom edge. nav.js creates it only while the server is unreachable, so a page
255+// that never loses the server never shows it.
256+.restart-bar {
257+ position: fixed;
258+ left: 50%;
259+ bottom: var(--space-4);
260+ z-index: 50;
261+ transform: translateX(-50%);
262+ display: flex;
263+ align-items: center;
264+ gap: var(--space-3);
265+ max-width: calc(100vw - 2 * var(--space-4));
266+ padding: var(--space-2) var(--space-4);
267+ border-radius: 999px;
268+ background: var(--warn-soft);
269+ color: var(--warn);
270+ border: 1px solid var(--warn);
271+ box-shadow: var(--shadow-lift);
272+ font-size: var(--text-sm);
273+ font-weight: 550;
274+ animation: restart-in 180ms ease-out;
275+}
276+
277+.restart-bar::before {
278+ content: "";
279+ width: 0.55rem;
280+ height: 0.55rem;
281+ border-radius: 50%;
282+ background: currentColor;
283+ animation: restart-pulse 1.2s ease-in-out infinite;
284+}
285+
286+@keyframes restart-in {
287+ from {
288+ opacity: 0;
289+ transform: translate(-50%, 0.5rem);
290+ }
291+}
292+
293+@keyframes restart-pulse {
294+ 50% {
295+ opacity: 0.25;
296+ }
297+}
298+
299+// While the page is loading a soft navigation or a refresh, its content dims a little.
300+.is-loading main {
301+ opacity: 0.6;
302+ transition: opacity 120ms ease;
303+}
304+
305+@media (prefers-reduced-motion: reduce) {
306+ .restart-bar,
307+ .restart-bar::before {
308+ animation: none;
309+ }
310+
311+ .is-loading main,
312+ .button {
313+ transition: none;
314+ }
315+}
style/_layout.scssadded+110 -0
@@ -0,0 +1,110 @@
1+//! Page frame: the sticky top bar (wordmark, service switcher, right-hand slot) and the main column.
2+//! Below 720 px the top bar wraps onto two rows and the card grid goes to one column.
3+
4+.topbar {
5+ position: sticky;
6+ top: 0;
7+ z-index: 20;
8+ display: flex;
9+ align-items: center;
10+ gap: var(--space-4);
11+ min-height: 3.25rem;
12+ padding: var(--space-2) var(--space-6);
13+ background: var(--topbar);
14+ backdrop-filter: saturate(1.4) blur(8px);
15+ border-bottom: 1px solid var(--border);
16+}
17+
18+.topbar-brand {
19+ display: inline-flex;
20+ align-items: baseline;
21+ gap: var(--space-2);
22+ color: var(--text);
23+ font-weight: 700;
24+ font-size: var(--text-lg);
25+ text-decoration: none;
26+ letter-spacing: -0.02em;
27+}
28+
29+.topbar-brand:hover {
30+ color: var(--accent);
31+}
32+
33+// The service switcher fills the middle of the bar. It is empty until there are services to list.
34+.switcher {
35+ display: flex;
36+ align-items: center;
37+ flex: 1 1 auto;
38+ gap: var(--space-1);
39+ min-width: 0;
40+ overflow-x: auto;
41+}
42+
43+.switcher:empty {
44+ display: none;
45+}
46+
47+.switcher a {
48+ padding: var(--space-1) var(--space-3);
49+ border-radius: var(--radius-sm);
50+ color: var(--muted);
51+ text-decoration: none;
52+ white-space: nowrap;
53+}
54+
55+.switcher a[aria-current="page"],
56+.switcher a:hover {
57+ background: var(--surface-2);
58+ color: var(--text);
59+}
60+
61+.topbar-end {
62+ display: flex;
63+ align-items: center;
64+ gap: var(--space-3);
65+ margin-left: auto;
66+ color: var(--muted);
67+ font-size: var(--text-sm);
68+}
69+
70+.page {
71+ width: 100%;
72+ max-width: var(--content-width);
73+ margin: 0 auto;
74+ padding: var(--space-8) var(--space-6) var(--space-8);
75+}
76+
77+.page > * + * {
78+ margin-top: var(--space-6);
79+}
80+
81+.grid-cards {
82+ display: grid;
83+ grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
84+ gap: var(--space-4);
85+}
86+
87+@media (max-width: 720px) {
88+ .topbar {
89+ flex-wrap: wrap;
90+ gap: var(--space-2) var(--space-3);
91+ padding: var(--space-2) var(--space-4);
92+ }
93+
94+ .switcher {
95+ order: 3;
96+ flex-basis: 100%;
97+ }
98+
99+ .topbar-end {
100+ margin-left: 0;
101+ }
102+
103+ .page {
104+ padding: var(--space-6) var(--space-4);
105+ }
106+
107+ .grid-cards {
108+ grid-template-columns: 1fr;
109+ }
110+}
style/_tokens.scssadded+90 -0
@@ -0,0 +1,90 @@
1+//! Design tokens: the colours of the light and dark themes, spacing, radii and type. Every other
2+//! partial reads these custom properties, so a theme changes in one place.
3+//!
4+//! Dark applies in two cases. The OS asks for it (`prefers-color-scheme: dark`) and the page is not
5+//! forced to light, or the page sets `data-theme="dark"`. `data-theme="light"` forces light whatever
6+//! the OS says. The dark rules carry one more attribute than the light ones, so they win on the same
7+//! element without `!important`.
8+
9+/// The light palette. Contrast of `--text` on `--bg` and `--surface` is above 7:1.
10+@mixin light-tokens {
11+ --bg: #f5f5f2;
12+ --surface: #ffffff;
13+ --surface-2: #eeeeea;
14+ --text: #1c1e22;
15+ --muted: #5b6070;
16+ --border: #d9dbe0;
17+ --accent: #3350c4;
18+ --accent-strong: #2a43a8;
19+ --accent-text: #ffffff;
20+ --accent-soft: #e6ebff;
21+ --danger: #b42318;
22+ --danger-soft: #fdecea;
23+ --warn: #7a4f00;
24+ --warn-soft: #fff4d6;
25+ --ok: #1e7a3a;
26+ --ok-soft: #e4f4ea;
27+ --focus: #3350c4;
28+ --topbar: #ffffffe6;
29+}
30+
31+/// The dark palette. Same roles as the light one.
32+@mixin dark-tokens {
33+ --bg: #111215;
34+ --surface: #1a1c21;
35+ --surface-2: #22252c;
36+ --text: #e8eaef;
37+ --muted: #a1a7b5;
38+ --border: #2d3139;
39+ --accent: #9fb2ff;
40+ --accent-strong: #c2d0ff;
41+ --accent-text: #0d1220;
42+ --accent-soft: #1f2a4f;
43+ --danger: #ff8a80;
44+ --danger-soft: #3a1d1b;
45+ --warn: #f2c265;
46+ --warn-soft: #3a2e10;
47+ --ok: #7fd09a;
48+ --ok-soft: #173424;
49+ --focus: #9fb2ff;
50+ --topbar: #1a1c21e6;
51+}
52+
53+:root {
54+ color-scheme: light;
55+ @include light-tokens;
56+
57+ --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
58+ sans-serif;
59+ --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
60+
61+ --radius: 10px;
62+ --radius-sm: 6px;
63+ --shadow: 0 1px 2px rgb(0 0 0 / 0.06);
64+ --shadow-lift: 0 4px 14px rgb(0 0 0 / 0.08);
65+
66+ --space-1: 0.25rem;
67+ --space-2: 0.5rem;
68+ --space-3: 0.75rem;
69+ --space-4: 1rem;
70+ --space-6: 1.5rem;
71+ --space-8: 2rem;
72+
73+ --text-sm: 0.875rem;
74+ --text-lg: 1.125rem;
75+ --text-xl: 1.5rem;
76+
77+ --content-width: 56rem;
78+}
79+
80+@media (prefers-color-scheme: dark) {
81+ :root:not([data-theme="light"]) {
82+ color-scheme: dark;
83+ @include dark-tokens;
84+ }
85+}
86+
87+:root[data-theme="dark"] {
88+ color-scheme: dark;
89+ @include dark-tokens;
90+}
style/main.scssadded+8 -0
@@ -0,0 +1,8 @@
1+//! The stylesheet of `iz`. `build.rs` compiles this file with grass into `OUT_DIR/main.css`, and the
2+//! binary embeds the result. The order matters: tokens first, then the element defaults, the layout
3+//! and the components that use the tokens.
4+
5+@use "tokens";
6+@use "base";
7+@use "layout";
8+@use "components";