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

490130e5d8899cefed0a50a163da86b7f8591883Ahmet Kaan GümüşParent: 810b0f6
  • 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+867 -8
@@ -57,6 +57,18 @@ dependencies = [
57 "subtle",57 "subtle",
58 ]58 ]
59 59
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+
60 [[package]]72 [[package]]
61 name = "aho-corasick"73 name = "aho-corasick"
62 version = "1.1.5"74 version = "1.1.5"
@@ -87,6 +99,56 @@ dependencies = [
87 "libc",99 "libc",
88 ]100 ]
89 101
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+
90 [[package]]152 [[package]]
91 name = "antithesis_sdk"153 name = "antithesis_sdk"
92 version = "0.3.0"154 version = "0.3.0"
@@ -109,6 +171,12 @@ version = "1.0.104"
109 source = "registry+https://github.com/rust-lang/crates.io-index"171 source = "registry+https://github.com/rust-lang/crates.io-index"
110 checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"172 checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
111 173
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+
112 [[package]]180 [[package]]
113 name = "arc-swap"181 name = "arc-swap"
114 version = "1.9.3"182 version = "1.9.3"
@@ -292,6 +360,15 @@ dependencies = [
292 "digest 0.11.3",360 "digest 0.11.3",
293 ]361 ]
294 362
363+[[package]]
364+name = "block-buffer"
365+version = "0.10.4"
366+source = "registry+https://github.com/rust-lang/crates.io-index"
367+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
368+dependencies = [
369+ "generic-array",
370+]
371+
295 [[package]]372 [[package]]
296 name = "block-buffer"373 name = "block-buffer"
297 version = "0.12.1"374 version = "0.12.1"
@@ -395,7 +472,7 @@ version = "0.6.0"
395 source = "registry+https://github.com/rust-lang/crates.io-index"472 source = "registry+https://github.com/rust-lang/crates.io-index"
396 checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"473 checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
397 dependencies = [474 dependencies = [
398- "nom",475+ "nom 7.1.3",
399 ]476 ]
400 477
401 [[package]]478 [[package]]
@@ -470,7 +547,7 @@ version = "0.5.2"
470 source = "registry+https://github.com/rust-lang/crates.io-index"547 source = "registry+https://github.com/rust-lang/crates.io-index"
471 checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"548 checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
472 dependencies = [549 dependencies = [
473- "block-buffer",550+ "block-buffer 0.12.1",
474 "crypto-common 0.2.2",551 "crypto-common 0.2.2",
475 "inout 0.2.5",552 "inout 0.2.5",
476 ]553 ]
@@ -486,6 +563,33 @@ dependencies = [
486 "libloading",563 "libloading",
487 ]564 ]
488 565
566+[[package]]
567+name = "clap"
568+version = "4.6.7"
569+source = "registry+https://github.com/rust-lang/crates.io-index"
570+checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
571+dependencies = [
572+ "clap_builder",
573+]
574+
575+[[package]]
576+name = "clap_builder"
577+version = "4.6.7"
578+source = "registry+https://github.com/rust-lang/crates.io-index"
579+checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
580+dependencies = [
581+ "anstream",
582+ "anstyle",
583+ "clap_lex",
584+ "strsim",
585+]
586+
587+[[package]]
588+name = "clap_lex"
589+version = "1.1.1"
590+source = "registry+https://github.com/rust-lang/crates.io-index"
591+checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
592+
489 [[package]]593 [[package]]
490 name = "cmake"594 name = "cmake"
491 version = "0.1.58"595 version = "0.1.58"
@@ -501,6 +605,18 @@ version = "0.5.4"
501 source = "registry+https://github.com/rust-lang/crates.io-index"605 source = "registry+https://github.com/rust-lang/crates.io-index"
502 checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"606 checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
503 607
608+[[package]]
609+name = "codemap"
610+version = "0.1.3"
611+source = "registry+https://github.com/rust-lang/crates.io-index"
612+checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24"
613+
614+[[package]]
615+name = "colorchoice"
616+version = "1.0.5"
617+source = "registry+https://github.com/rust-lang/crates.io-index"
618+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
619+
504 [[package]]620 [[package]]
505 name = "combine"621 name = "combine"
506 version = "4.6.9"622 version = "4.6.9"
@@ -526,6 +642,24 @@ version = "0.10.2"
526 source = "registry+https://github.com/rust-lang/crates.io-index"642 source = "registry+https://github.com/rust-lang/crates.io-index"
527 checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"643 checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
528 644
645+[[package]]
646+name = "cookie"
647+version = "0.18.2"
648+source = "registry+https://github.com/rust-lang/crates.io-index"
649+checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87"
650+dependencies = [
651+ "aes-gcm",
652+ "base64 0.22.1",
653+ "hkdf",
654+ "hmac 0.12.1",
655+ "percent-encoding",
656+ "rand 0.8.8",
657+ "sha2 0.10.9",
658+ "subtle",
659+ "time",
660+ "version_check",
661+]
662+
529 [[package]]663 [[package]]
530 name = "core-foundation"664 name = "core-foundation"
531 version = "0.10.1"665 version = "0.10.1"
@@ -542,6 +676,12 @@ version = "0.8.7"
542 source = "registry+https://github.com/rust-lang/crates.io-index"676 source = "registry+https://github.com/rust-lang/crates.io-index"
543 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"677 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
544 678
679+[[package]]
680+name = "core_detect"
681+version = "1.0.0"
682+source = "registry+https://github.com/rust-lang/crates.io-index"
683+checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
684+
545 [[package]]685 [[package]]
546 name = "cpufeatures"686 name = "cpufeatures"
547 version = "0.2.17"687 version = "0.2.17"
@@ -567,7 +707,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
567 checksum = "e75b2483e97a5a7da73ac68a05b629f9c53cff58d8ed1c77866079e18b00dba5"707 checksum = "e75b2483e97a5a7da73ac68a05b629f9c53cff58d8ed1c77866079e18b00dba5"
568 dependencies = [708 dependencies = [
569 "digest 0.10.7",709 "digest 0.10.7",
570- "spin",710+ "spin 0.10.1",
571 ]711 ]
572 712
573 [[package]]713 [[package]]
@@ -702,6 +842,12 @@ dependencies = [
702 "syn 3.0.9",842 "syn 3.0.9",
703 ]843 ]
704 844
845+[[package]]
846+name = "data-encoding"
847+version = "2.11.1"
848+source = "registry+https://github.com/rust-lang/crates.io-index"
849+checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
850+
705 [[package]]851 [[package]]
706 name = "datasketches"852 name = "datasketches"
707 version = "0.2.0"853 version = "0.2.0"
@@ -723,7 +869,9 @@ version = "0.10.7"
723 source = "registry+https://github.com/rust-lang/crates.io-index"869 source = "registry+https://github.com/rust-lang/crates.io-index"
724 checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"870 checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
725 dependencies = [871 dependencies = [
872+ "block-buffer 0.10.4",
726 "crypto-common 0.1.7",873 "crypto-common 0.1.7",
874+ "subtle",
727 ]875 ]
728 876
729 [[package]]877 [[package]]
@@ -732,7 +880,7 @@ version = "0.11.3"
732 source = "registry+https://github.com/rust-lang/crates.io-index"880 source = "registry+https://github.com/rust-lang/crates.io-index"
733 checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"881 checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
734 dependencies = [882 dependencies = [
735- "block-buffer",883+ "block-buffer 0.12.1",
736 "const-oid",884 "const-oid",
737 "crypto-common 0.2.2",885 "crypto-common 0.2.2",
738 "ctutils",886 "ctutils",
@@ -767,6 +915,45 @@ version = "1.19.0"
767 source = "registry+https://github.com/rust-lang/crates.io-index"915 source = "registry+https://github.com/rust-lang/crates.io-index"
768 checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"916 checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
769 917
918+[[package]]
919+name = "elsa"
920+version = "1.11.2"
921+source = "registry+https://github.com/rust-lang/crates.io-index"
922+checksum = "9abf33c656a7256451ebb7d0082c5a471820c31269e49d807c538c252352186e"
923+dependencies = [
924+ "stable_deref_trait",
925+]
926+
927+[[package]]
928+name = "email-encoding"
929+version = "0.4.2"
930+source = "registry+https://github.com/rust-lang/crates.io-index"
931+checksum = "420b9da095f052ea597503e39073b5b3c522f7db933fbac202d91d24492693fd"
932+dependencies = [
933+ "base64 0.23.1",
934+ "memchr",
935+]
936+
937+[[package]]
938+name = "email_address"
939+version = "0.2.9"
940+source = "registry+https://github.com/rust-lang/crates.io-index"
941+checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449"
942+
943+[[package]]
944+name = "encoding_rs"
945+version = "0.8.42"
946+source = "registry+https://github.com/rust-lang/crates.io-index"
947+checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"
948+dependencies = [
949+ "cfg-if",
950+ "core_detect",
951+ "multiversion_no_op",
952+ "rustversion",
953+ "scopeguard",
954+ "simdutf8",
955+]
956+
770 [[package]]957 [[package]]
771 name = "env_filter"958 name = "env_filter"
772 version = "2.0.0"959 version = "2.0.0"
@@ -1050,6 +1237,31 @@ version = "0.3.4"
1050 source = "registry+https://github.com/rust-lang/crates.io-index"1237 source = "registry+https://github.com/rust-lang/crates.io-index"
1051 checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"1238 checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
1052 1239
1240+[[package]]
1241+name = "grass"
1242+version = "0.13.4"
1243+source = "registry+https://github.com/rust-lang/crates.io-index"
1244+checksum = "f7a68216437ef68f0738e48d6c7bb9e6e6a92237e001b03d838314b068f33c94"
1245+dependencies = [
1246+ "clap",
1247+ "getrandom 0.2.17",
1248+ "grass_compiler",
1249+]
1250+
1251+[[package]]
1252+name = "grass_compiler"
1253+version = "0.13.4"
1254+source = "registry+https://github.com/rust-lang/crates.io-index"
1255+checksum = "2d9e3df7f0222ce5184154973d247c591d9aadc28ce7a73c6cd31100c9facff6"
1256+dependencies = [
1257+ "codemap",
1258+ "indexmap",
1259+ "lasso",
1260+ "once_cell",
1261+ "phf",
1262+ "rand 0.8.8",
1263+]
1264+
1053 [[package]]1265 [[package]]
1054 name = "h2"1266 name = "h2"
1055 version = "0.4.20"1267 version = "0.4.20"
@@ -1069,6 +1281,16 @@ dependencies = [
1069 "tracing",1281 "tracing",
1070 ]1282 ]
1071 1283
1284+[[package]]
1285+name = "hashbrown"
1286+version = "0.14.5"
1287+source = "registry+https://github.com/rust-lang/crates.io-index"
1288+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
1289+dependencies = [
1290+ "ahash",
1291+ "allocator-api2 0.2.21",
1292+]
1293+
1072 [[package]]1294 [[package]]
1073 name = "hashbrown"1295 name = "hashbrown"
1074 version = "0.16.1"1296 version = "0.16.1"
@@ -1104,6 +1326,24 @@ version = "0.4.3"
1104 source = "registry+https://github.com/rust-lang/crates.io-index"1326 source = "registry+https://github.com/rust-lang/crates.io-index"
1105 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"1327 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
1106 1328
1329+[[package]]
1330+name = "hkdf"
1331+version = "0.12.4"
1332+source = "registry+https://github.com/rust-lang/crates.io-index"
1333+checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
1334+dependencies = [
1335+ "hmac 0.12.1",
1336+]
1337+
1338+[[package]]
1339+name = "hmac"
1340+version = "0.12.1"
1341+source = "registry+https://github.com/rust-lang/crates.io-index"
1342+checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
1343+dependencies = [
1344+ "digest 0.10.7",
1345+]
1346+
1107 [[package]]1347 [[package]]
1108 name = "hmac"1348 name = "hmac"
1109 version = "0.13.0"1349 version = "0.13.0"
@@ -1122,6 +1362,17 @@ dependencies = [
1122 "windows-sys 0.61.2",1362 "windows-sys 0.61.2",
1123 ]1363 ]
1124 1364
1365+[[package]]
1366+name = "hostname"
1367+version = "0.4.2"
1368+source = "registry+https://github.com/rust-lang/crates.io-index"
1369+checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd"
1370+dependencies = [
1371+ "cfg-if",
1372+ "libc",
1373+ "windows-link",
1374+]
1375+
1125 [[package]]1376 [[package]]
1126 name = "htmlescape"1377 name = "htmlescape"
1127 version = "0.3.1"1378 version = "0.3.1"
@@ -1167,6 +1418,12 @@ version = "1.10.1"
1167 source = "registry+https://github.com/rust-lang/crates.io-index"1418 source = "registry+https://github.com/rust-lang/crates.io-index"
1168 checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"1419 checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
1169 1420
1421+[[package]]
1422+name = "httpdate"
1423+version = "1.0.3"
1424+source = "registry+https://github.com/rust-lang/crates.io-index"
1425+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
1426+
1170 [[package]]1427 [[package]]
1171 name = "humantime"1428 name = "humantime"
1172 version = "2.4.0"1429 version = "2.4.0"
@@ -1196,6 +1453,7 @@ dependencies = [
1196 "http",1453 "http",
1197 "http-body",1454 "http-body",
1198 "httparse",1455 "httparse",
1456+ "httpdate",
1199 "itoa",1457 "itoa",
1200 "pin-project-lite",1458 "pin-project-lite",
1201 "smallvec",1459 "smallvec",
@@ -1459,13 +1717,13 @@ dependencies = [
1459 "chacha20poly1305",1717 "chacha20poly1305",
1460 "futures-util",1718 "futures-util",
1461 "hex",1719 "hex",
1462- "hmac",1720+ "hmac 0.13.0",
1463 "ipnet",1721 "ipnet",
1464 "object_store",1722 "object_store",
1465 "rand 0.10.3",1723 "rand 0.10.3",
1466 "serde",1724 "serde",
1467 "serde_json",1725 "serde_json",
1468- "sha2",1726+ "sha2 0.11.1",
1469 "subtle",1727 "subtle",
1470 "tempfile",1728 "tempfile",
1471 "thiserror",1729 "thiserror",
@@ -1480,6 +1738,19 @@ dependencies = [
1480 [[package]]1738 [[package]]
1481 name = "in-web"1739 name = "in-web"
1482 version = "0.1.0"1740 version = "0.1.0"
1741+dependencies = [
1742+ "futures-util",
1743+ "grass",
1744+ "hex",
1745+ "http",
1746+ "in-core",
1747+ "sha2 0.11.1",
1748+ "tempfile",
1749+ "tokio",
1750+ "topcoat",
1751+ "tracing",
1752+ "tracing-subscriber",
1753+]
1483 1754
1484 [[package]]1755 [[package]]
1485 name = "indexmap"1756 name = "indexmap"
@@ -1544,6 +1815,12 @@ version = "2.12.2"
1544 source = "registry+https://github.com/rust-lang/crates.io-index"1815 source = "registry+https://github.com/rust-lang/crates.io-index"
1545 checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"1816 checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"
1546 1817
1818+[[package]]
1819+name = "is_terminal_polyfill"
1820+version = "1.70.2"
1821+source = "registry+https://github.com/rust-lang/crates.io-index"
1822+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
1823+
1547 [[package]]1824 [[package]]
1548 name = "itertools"1825 name = "itertools"
1549 version = "0.12.1"1826 version = "0.12.1"
@@ -1647,6 +1924,15 @@ dependencies = [
1647 "wasm-bindgen",1924 "wasm-bindgen",
1648 ]1925 ]
1649 1926
1927+[[package]]
1928+name = "lasso"
1929+version = "0.7.3"
1930+source = "registry+https://github.com/rust-lang/crates.io-index"
1931+checksum = "6e14eda50a3494b3bf7b9ce51c52434a761e383d7238ce1dd5dcec2fbc13e9fb"
1932+dependencies = [
1933+ "hashbrown 0.14.5",
1934+]
1935+
1650 [[package]]1936 [[package]]
1651 name = "lazy_static"1937 name = "lazy_static"
1652 version = "1.5.1"1938 version = "1.5.1"
@@ -1659,6 +1945,23 @@ version = "1.3.0"
1659 source = "registry+https://github.com/rust-lang/crates.io-index"1945 source = "registry+https://github.com/rust-lang/crates.io-index"
1660 checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"1946 checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
1661 1947
1948+[[package]]
1949+name = "lettre"
1950+version = "0.11.23"
1951+source = "registry+https://github.com/rust-lang/crates.io-index"
1952+checksum = "f2c646bd5cc763b1087b15493e29a64be6147ba8f19342004fa52048ee596eae"
1953+dependencies = [
1954+ "email-encoding",
1955+ "email_address",
1956+ "fastrand",
1957+ "hostname",
1958+ "httpdate",
1959+ "idna",
1960+ "mime",
1961+ "nom 8.0.0",
1962+ "quoted_printable",
1963+]
1964+
1662 [[package]]1965 [[package]]
1663 name = "levenshtein_automata"1966 name = "levenshtein_automata"
1664 version = "0.2.1"1967 version = "0.2.1"
@@ -1792,6 +2095,12 @@ dependencies = [
1792 "regex-automata",2095 "regex-automata",
1793 ]2096 ]
1794 2097
2098+[[package]]
2099+name = "matchit"
2100+version = "0.9.2"
2101+source = "registry+https://github.com/rust-lang/crates.io-index"
2102+checksum = "8863b587001c1b9a8a4e36008cebc6b3612cb1226fe2de94858e06092687b608"
2103+
1795 [[package]]2104 [[package]]
1796 name = "md-5"2105 name = "md-5"
1797 version = "0.11.0"2106 version = "0.11.0"
@@ -1866,6 +2175,12 @@ dependencies = [
1866 "libmimalloc-sys",2175 "libmimalloc-sys",
1867 ]2176 ]
1868 2177
2178+[[package]]
2179+name = "mime"
2180+version = "0.3.17"
2181+source = "registry+https://github.com/rust-lang/crates.io-index"
2182+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
2183+
1869 [[package]]2184 [[package]]
1870 name = "minimal-lexical"2185 name = "minimal-lexical"
1871 version = "0.2.1"2186 version = "0.2.1"
@@ -1883,6 +2198,29 @@ dependencies = [
1883 "windows-sys 0.61.2",2198 "windows-sys 0.61.2",
1884 ]2199 ]
1885 2200
2201+[[package]]
2202+name = "multer"
2203+version = "3.1.0"
2204+source = "registry+https://github.com/rust-lang/crates.io-index"
2205+checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b"
2206+dependencies = [
2207+ "bytes",
2208+ "encoding_rs",
2209+ "futures-util",
2210+ "http",
2211+ "httparse",
2212+ "memchr",
2213+ "mime",
2214+ "spin 0.9.9",
2215+ "version_check",
2216+]
2217+
2218+[[package]]
2219+name = "multiversion_no_op"
2220+version = "1.0.0"
2221+source = "registry+https://github.com/rust-lang/crates.io-index"
2222+checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"
2223+
1886 [[package]]2224 [[package]]
1887 name = "murmurhash32"2225 name = "murmurhash32"
1888 version = "0.3.1"2226 version = "0.3.1"
@@ -1911,6 +2249,15 @@ dependencies = [
1911 "minimal-lexical",2249 "minimal-lexical",
1912 ]2250 ]
1913 2251
2252+[[package]]
2253+name = "nom"
2254+version = "8.0.0"
2255+source = "registry+https://github.com/rust-lang/crates.io-index"
2256+checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
2257+dependencies = [
2258+ "memchr",
2259+]
2260+
1914 [[package]]2261 [[package]]
1915 name = "nu-ansi-term"2262 name = "nu-ansi-term"
1916 version = "0.50.3"2263 version = "0.50.3"
@@ -2002,6 +2349,12 @@ version = "1.21.4"
2002 source = "registry+https://github.com/rust-lang/crates.io-index"2349 source = "registry+https://github.com/rust-lang/crates.io-index"
2003 checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"2350 checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
2004 2351
2352+[[package]]
2353+name = "once_cell_polyfill"
2354+version = "1.70.2"
2355+source = "registry+https://github.com/rust-lang/crates.io-index"
2356+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
2357+
2005 [[package]]2358 [[package]]
2006 name = "oneshot"2359 name = "oneshot"
2007 version = "0.1.13"2360 version = "0.1.13"
@@ -2109,6 +2462,48 @@ dependencies = [
2109 "getrandom 0.4.3",2462 "getrandom 0.4.3",
2110 ]2463 ]
2111 2464
2465+[[package]]
2466+name = "phf"
2467+version = "0.11.3"
2468+source = "registry+https://github.com/rust-lang/crates.io-index"
2469+checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
2470+dependencies = [
2471+ "phf_macros",
2472+ "phf_shared",
2473+]
2474+
2475+[[package]]
2476+name = "phf_generator"
2477+version = "0.11.3"
2478+source = "registry+https://github.com/rust-lang/crates.io-index"
2479+checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
2480+dependencies = [
2481+ "phf_shared",
2482+ "rand 0.8.8",
2483+]
2484+
2485+[[package]]
2486+name = "phf_macros"
2487+version = "0.11.3"
2488+source = "registry+https://github.com/rust-lang/crates.io-index"
2489+checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
2490+dependencies = [
2491+ "phf_generator",
2492+ "phf_shared",
2493+ "proc-macro2",
2494+ "quote",
2495+ "syn 2.0.119",
2496+]
2497+
2498+[[package]]
2499+name = "phf_shared"
2500+version = "0.11.3"
2501+source = "registry+https://github.com/rust-lang/crates.io-index"
2502+checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
2503+dependencies = [
2504+ "siphasher",
2505+]
2506+
2112 [[package]]2507 [[package]]
2113 name = "pin-project-lite"2508 name = "pin-project-lite"
2114 version = "0.2.17"2509 version = "0.2.17"
@@ -2203,6 +2598,15 @@ dependencies = [
2203 "syn 3.0.9",2598 "syn 3.0.9",
2204 ]2599 ]
2205 2600
2601+[[package]]
2602+name = "proc-macro-crate"
2603+version = "3.5.0"
2604+source = "registry+https://github.com/rust-lang/crates.io-index"
2605+checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
2606+dependencies = [
2607+ "toml_edit",
2608+]
2609+
2206 [[package]]2610 [[package]]
2207 name = "proc-macro2"2611 name = "proc-macro2"
2208 version = "1.0.107"2612 version = "1.0.107"
@@ -2312,7 +2716,13 @@ dependencies = [
2312 ]2716 ]
2313 2717
2314 [[package]]2718 [[package]]
2315-name = "r-efi"2719+name = "quoted_printable"
2720+version = "0.5.2"
2721+source = "registry+https://github.com/rust-lang/crates.io-index"
2722+checksum = "478e0585659a122aa407eb7e3c0e1fa51b1d8a870038bd29f0cf4a8551eea972"
2723+
2724+[[package]]
2725+name = "r-efi"
2316 version = "5.3.0"2726 version = "5.3.0"
2317 source = "registry+https://github.com/rust-lang/crates.io-index"2727 source = "registry+https://github.com/rust-lang/crates.io-index"
2318 checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"2728 checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
@@ -2461,6 +2871,26 @@ dependencies = [
2461 "bitflags",2871 "bitflags",
2462 ]2872 ]
2463 2873
2874+[[package]]
2875+name = "ref-cast"
2876+version = "1.0.27"
2877+source = "registry+https://github.com/rust-lang/crates.io-index"
2878+checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3"
2879+dependencies = [
2880+ "ref-cast-impl",
2881+]
2882+
2883+[[package]]
2884+name = "ref-cast-impl"
2885+version = "1.0.27"
2886+source = "registry+https://github.com/rust-lang/crates.io-index"
2887+checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
2888+dependencies = [
2889+ "proc-macro2",
2890+ "quote",
2891+ "syn 3.0.9",
2892+]
2893+
2464 [[package]]2894 [[package]]
2465 name = "regex"2895 name = "regex"
2466 version = "1.13.1"2896 version = "1.13.1"
@@ -2809,6 +3239,17 @@ dependencies = [
2809 "zmij",3239 "zmij",
2810 ]3240 ]
2811 3241
3242+[[package]]
3243+name = "serde_path_to_error"
3244+version = "0.1.20"
3245+source = "registry+https://github.com/rust-lang/crates.io-index"
3246+checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457"
3247+dependencies = [
3248+ "itoa",
3249+ "serde",
3250+ "serde_core",
3251+]
3252+
2812 [[package]]3253 [[package]]
2813 name = "serde_spanned"3254 name = "serde_spanned"
2814 version = "1.1.2"3255 version = "1.1.2"
@@ -2830,12 +3271,34 @@ dependencies = [
2830 "serde",3271 "serde",
2831 ]3272 ]
2832 3273
3274+[[package]]
3275+name = "sha1"
3276+version = "0.10.7"
3277+source = "registry+https://github.com/rust-lang/crates.io-index"
3278+checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"
3279+dependencies = [
3280+ "cfg-if",
3281+ "cpufeatures 0.2.17",
3282+ "digest 0.10.7",
3283+]
3284+
2833 [[package]]3285 [[package]]
2834 name = "sha1_smol"3286 name = "sha1_smol"
2835 version = "1.0.1"3287 version = "1.0.1"
2836 source = "registry+https://github.com/rust-lang/crates.io-index"3288 source = "registry+https://github.com/rust-lang/crates.io-index"
2837 checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"3289 checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"
2838 3290
3291+[[package]]
3292+name = "sha2"
3293+version = "0.10.9"
3294+source = "registry+https://github.com/rust-lang/crates.io-index"
3295+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
3296+dependencies = [
3297+ "cfg-if",
3298+ "cpufeatures 0.2.17",
3299+ "digest 0.10.7",
3300+]
3301+
2839 [[package]]3302 [[package]]
2840 name = "sha2"3303 name = "sha2"
2841 version = "0.11.1"3304 version = "0.11.1"
@@ -2888,6 +3351,16 @@ dependencies = [
2888 "tracing",3351 "tracing",
2889 ]3352 ]
2890 3353
3354+[[package]]
3355+name = "signal-hook-registry"
3356+version = "1.4.8"
3357+source = "registry+https://github.com/rust-lang/crates.io-index"
3358+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
3359+dependencies = [
3360+ "errno",
3361+ "libc",
3362+]
3363+
2891 [[package]]3364 [[package]]
2892 name = "simd_cesu8"3365 name = "simd_cesu8"
2893 version = "1.2.0"3366 version = "1.2.0"
@@ -2956,6 +3429,12 @@ version = "0.1.7"
2956 source = "registry+https://github.com/rust-lang/crates.io-index"3429 source = "registry+https://github.com/rust-lang/crates.io-index"
2957 checksum = "c4fdfe13e1c42e45f497416afb8dc4e783bf0e25b7be9077c1c77c5fb14cb998"3430 checksum = "c4fdfe13e1c42e45f497416afb8dc4e783bf0e25b7be9077c1c77c5fb14cb998"
2958 3431
3432+[[package]]
3433+name = "spin"
3434+version = "0.9.9"
3435+source = "registry+https://github.com/rust-lang/crates.io-index"
3436+checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
3437+
2959 [[package]]3438 [[package]]
2960 name = "spin"3439 name = "spin"
2961 version = "0.10.1"3440 version = "0.10.1"
@@ -3159,7 +3638,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3159 checksum = "dfadb8526b6da90704feb293b0701a6aae62ea14983143344be2dc5ce30f1d82"3638 checksum = "dfadb8526b6da90704feb293b0701a6aae62ea14983143344be2dc5ce30f1d82"
3160 dependencies = [3639 dependencies = [
3161 "fnv",3640 "fnv",
3162- "nom",3641+ "nom 7.1.3",
3163 "ordered-float",3642 "ordered-float",
3164 "serde",3643 "serde",
3165 "serde_json",3644 "serde_json",
@@ -3303,6 +3782,7 @@ dependencies = [
3303 "libc",3782 "libc",
3304 "mio",3783 "mio",
3305 "pin-project-lite",3784 "pin-project-lite",
3785+ "signal-hook-registry",
3306 "socket2",3786 "socket2",
3307 "tokio-macros",3787 "tokio-macros",
3308 "windows-sys 0.61.2",3788 "windows-sys 0.61.2",
@@ -3329,6 +3809,18 @@ dependencies = [
3329 "tokio",3809 "tokio",
3330 ]3810 ]
3331 3811
3812+[[package]]
3813+name = "tokio-tungstenite"
3814+version = "0.29.0"
3815+source = "registry+https://github.com/rust-lang/crates.io-index"
3816+checksum = "8f72a05e828585856dacd553fba484c242c46e391fb0e58917c942ee9202915c"
3817+dependencies = [
3818+ "futures-util",
3819+ "log",
3820+ "tokio",
3821+ "tungstenite",
3822+]
3823+
3332 [[package]]3824 [[package]]
3333 name = "tokio-util"3825 name = "tokio-util"
3334 version = "0.7.20"3826 version = "0.7.20"
@@ -3367,6 +3859,18 @@ dependencies = [
3367 "serde_core",3859 "serde_core",
3368 ]3860 ]
3369 3861
3862+[[package]]
3863+name = "toml_edit"
3864+version = "0.25.17+spec-1.1.0"
3865+source = "registry+https://github.com/rust-lang/crates.io-index"
3866+checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c"
3867+dependencies = [
3868+ "indexmap",
3869+ "toml_datetime",
3870+ "toml_parser",
3871+ "winnow",
3872+]
3873+
3370 [[package]]3874 [[package]]
3371 name = "toml_parser"3875 name = "toml_parser"
3372 version = "1.1.5+spec-1.1.0"3876 version = "1.1.5+spec-1.1.0"
@@ -3382,6 +3886,336 @@ version = "1.1.3+spec-1.1.0"
3382 source = "registry+https://github.com/rust-lang/crates.io-index"3886 source = "registry+https://github.com/rust-lang/crates.io-index"
3383 checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770"3887 checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770"
3384 3888
3889+[[package]]
3890+name = "topcoat"
3891+version = "0.11.0"
3892+source = "registry+https://github.com/rust-lang/crates.io-index"
3893+checksum = "70b5093d8133b513742b7461a28d374107b8bf9168aa60f4f567ad89acd2ed9e"
3894+dependencies = [
3895+ "futures-util",
3896+ "inventory",
3897+ "serde",
3898+ "tokio",
3899+ "tokio-tungstenite",
3900+ "topcoat-asset",
3901+ "topcoat-cookie",
3902+ "topcoat-core",
3903+ "topcoat-core-macro",
3904+ "topcoat-font",
3905+ "topcoat-font-macro",
3906+ "topcoat-l10n",
3907+ "topcoat-mail",
3908+ "topcoat-router",
3909+ "topcoat-router-macro",
3910+ "topcoat-runtime",
3911+ "topcoat-runtime-macro",
3912+ "topcoat-session",
3913+ "topcoat-view",
3914+ "topcoat-view-macro",
3915+]
3916+
3917+[[package]]
3918+name = "topcoat-asset"
3919+version = "0.11.0"
3920+source = "registry+https://github.com/rust-lang/crates.io-index"
3921+checksum = "ac70debf9eee62714ce45416eae27b283c3a44a0f9ebcb2ac088fda48b533f3e"
3922+dependencies = [
3923+ "http",
3924+ "memchr",
3925+ "percent-encoding",
3926+ "serde",
3927+ "sha2 0.11.1",
3928+ "thiserror",
3929+ "tokio",
3930+ "toml",
3931+ "topcoat-core",
3932+ "topcoat-router",
3933+ "topcoat-view",
3934+]
3935+
3936+[[package]]
3937+name = "topcoat-cookie"
3938+version = "0.11.0"
3939+source = "registry+https://github.com/rust-lang/crates.io-index"
3940+checksum = "df79aba10192abe21fbd01dfcb46bb04dab5ae64adb4432d9f078eb05f94e6a5"
3941+dependencies = [
3942+ "cookie",
3943+ "getrandom 0.2.17",
3944+ "http",
3945+ "serde",
3946+ "serde_json",
3947+ "topcoat-core",
3948+ "topcoat-router",
3949+]
3950+
3951+[[package]]
3952+name = "topcoat-core"
3953+version = "0.11.0"
3954+source = "registry+https://github.com/rust-lang/crates.io-index"
3955+checksum = "ffff49b885744cdb89ee158c5d81cc8c619692bd9f4ab3cae92ad1adc0ce612e"
3956+dependencies = [
3957+ "anymap3",
3958+ "base64 0.22.1",
3959+ "elsa",
3960+ "http",
3961+ "pin-project-lite",
3962+ "siphasher",
3963+ "thiserror",
3964+ "tokio",
3965+]
3966+
3967+[[package]]
3968+name = "topcoat-core-grammar"
3969+version = "0.11.0"
3970+source = "registry+https://github.com/rust-lang/crates.io-index"
3971+checksum = "b788a2010234cd29fc050268e52ceb393d2124b20f669a83d8f61a9dbf895bb6"
3972+dependencies = [
3973+ "proc-macro-crate",
3974+ "proc-macro2",
3975+ "quote",
3976+ "syn 3.0.9",
3977+]
3978+
3979+[[package]]
3980+name = "topcoat-core-macro"
3981+version = "0.11.0"
3982+source = "registry+https://github.com/rust-lang/crates.io-index"
3983+checksum = "3e3786bf2ee2c8b4f728d3fb53c41f639aa66583788b3135acbd63c11458b25b"
3984+dependencies = [
3985+ "quote",
3986+ "syn 3.0.9",
3987+ "topcoat-core-grammar",
3988+]
3989+
3990+[[package]]
3991+name = "topcoat-font"
3992+version = "0.11.0"
3993+source = "registry+https://github.com/rust-lang/crates.io-index"
3994+checksum = "caa4656294aac116def1e7633f03117a84b65126c503242793ff4adc78577fb8"
3995+dependencies = [
3996+ "heck",
3997+ "inventory",
3998+ "serde",
3999+ "serde_json",
4000+ "topcoat-asset",
4001+ "topcoat-core",
4002+ "topcoat-router",
4003+ "topcoat-view",
4004+ "topcoat-view-macro",
4005+]
4006+
4007+[[package]]
4008+name = "topcoat-font-grammar"
4009+version = "0.11.0"
4010+source = "registry+https://github.com/rust-lang/crates.io-index"
4011+checksum = "b462fae28641a1bb24eab1fa9c473520389ca690331ca53fd6143d5b2746045e"
4012+dependencies = [
4013+ "proc-macro2",
4014+ "quote",
4015+ "syn 3.0.9",
4016+ "topcoat-core-grammar",
4017+ "topcoat-font",
4018+]
4019+
4020+[[package]]
4021+name = "topcoat-font-macro"
4022+version = "0.11.0"
4023+source = "registry+https://github.com/rust-lang/crates.io-index"
4024+checksum = "40776cd3087aaea5e0c8b597126b1c09dbfb0d69833088d7f3b229305bbbb87f"
4025+dependencies = [
4026+ "quote",
4027+ "syn 3.0.9",
4028+ "topcoat-font-grammar",
4029+]
4030+
4031+[[package]]
4032+name = "topcoat-l10n"
4033+version = "0.11.0"
4034+source = "registry+https://github.com/rust-lang/crates.io-index"
4035+checksum = "34da63b3a5aea3d6c243d9fa8c98ca79b181b985f6a0a042f630672f54d12e9e"
4036+dependencies = [
4037+ "icu_locale",
4038+ "icu_locale_core",
4039+ "topcoat-core",
4040+ "topcoat-view",
4041+]
4042+
4043+[[package]]
4044+name = "topcoat-mail"
4045+version = "0.11.0"
4046+source = "registry+https://github.com/rust-lang/crates.io-index"
4047+checksum = "54a13c10c6399d9eb9b0bde38bd3d947eba56ddfaea99d9a4f971b74b6a651db"
4048+dependencies = [
4049+ "lettre",
4050+ "thiserror",
4051+ "time",
4052+ "topcoat-core",
4053+ "topcoat-router",
4054+ "topcoat-view",
4055+]
4056+
4057+[[package]]
4058+name = "topcoat-router"
4059+version = "0.11.0"
4060+source = "registry+https://github.com/rust-lang/crates.io-index"
4061+checksum = "b9488065b08f293208b0f1aeb6667d5836b66c12dfced5e330f9a8f1d7f1ca1a"
4062+dependencies = [
4063+ "bytes",
4064+ "form_urlencoded",
4065+ "futures-core",
4066+ "futures-sink",
4067+ "futures-util",
4068+ "heck",
4069+ "http",
4070+ "http-body",
4071+ "http-body-util",
4072+ "hyper",
4073+ "hyper-util",
4074+ "inventory",
4075+ "ipnet",
4076+ "matchit",
4077+ "multer",
4078+ "percent-encoding",
4079+ "pin-project-lite",
4080+ "ref-cast",
4081+ "serde",
4082+ "serde_json",
4083+ "serde_path_to_error",
4084+ "serde_urlencoded",
4085+ "tokio",
4086+ "tokio-tungstenite",
4087+ "topcoat-core",
4088+ "topcoat-view",
4089+]
4090+
4091+[[package]]
4092+name = "topcoat-router-grammar"
4093+version = "0.11.0"
4094+source = "registry+https://github.com/rust-lang/crates.io-index"
4095+checksum = "ac3f51fa1a1e538bd34e02f88ebba554ac5931e55c688303a58a8e78123dfb04"
4096+dependencies = [
4097+ "heck",
4098+ "proc-macro2",
4099+ "quote",
4100+ "syn 3.0.9",
4101+ "topcoat-core-grammar",
4102+]
4103+
4104+[[package]]
4105+name = "topcoat-router-macro"
4106+version = "0.11.0"
4107+source = "registry+https://github.com/rust-lang/crates.io-index"
4108+checksum = "3c1b56d3bf19d54bddf300d6d57ca754531d7ad5481afca0b2302ac33f5d43af"
4109+dependencies = [
4110+ "quote",
4111+ "syn 3.0.9",
4112+ "topcoat-router-grammar",
4113+]
4114+
4115+[[package]]
4116+name = "topcoat-runtime"
4117+version = "0.11.0"
4118+source = "registry+https://github.com/rust-lang/crates.io-index"
4119+checksum = "03b22136b99694b349a950cd757387a04b080fdb131eecdd51d0511e1a45ebf5"
4120+dependencies = [
4121+ "futures-util",
4122+ "pin-project-lite",
4123+ "ref-cast",
4124+ "serde",
4125+ "serde_json",
4126+ "tokio",
4127+ "topcoat-asset",
4128+ "topcoat-core",
4129+ "topcoat-router",
4130+ "topcoat-view",
4131+ "topcoat-view-macro",
4132+]
4133+
4134+[[package]]
4135+name = "topcoat-runtime-grammar"
4136+version = "0.11.0"
4137+source = "registry+https://github.com/rust-lang/crates.io-index"
4138+checksum = "ab93a83c38a045a4f541c2e548d30ba5dfdd3173c18de8b1c7b049709c29db97"
4139+dependencies = [
4140+ "proc-macro2",
4141+ "quote",
4142+ "serde",
4143+ "serde_json",
4144+ "syn 3.0.9",
4145+ "topcoat-core-grammar",
4146+ "topcoat-router",
4147+ "topcoat-runtime",
4148+]
4149+
4150+[[package]]
4151+name = "topcoat-runtime-macro"
4152+version = "0.11.0"
4153+source = "registry+https://github.com/rust-lang/crates.io-index"
4154+checksum = "5acb1db0bdba3c36e4f80f7ef530945779a1b0294b1087e7d877e33005da6283"
4155+dependencies = [
4156+ "quote",
4157+ "syn 3.0.9",
4158+ "topcoat-runtime-grammar",
4159+]
4160+
4161+[[package]]
4162+name = "topcoat-session"
4163+version = "0.11.0"
4164+source = "registry+https://github.com/rust-lang/crates.io-index"
4165+checksum = "2325c30a484b1b1b6f5012b50bc18994d37c33c6bd2f71be8ff509b591a17457"
4166+dependencies = [
4167+ "base64 0.22.1",
4168+ "getrandom 0.4.3",
4169+ "sha2 0.11.1",
4170+ "thiserror",
4171+ "tokio",
4172+ "topcoat-cookie",
4173+ "topcoat-core",
4174+ "topcoat-router",
4175+ "web-time",
4176+]
4177+
4178+[[package]]
4179+name = "topcoat-view"
4180+version = "0.11.0"
4181+source = "registry+https://github.com/rust-lang/crates.io-index"
4182+checksum = "db4553b91f30e30c71c2bd95ae8e931a33326c6ffb604663b9d214008f12947c"
4183+dependencies = [
4184+ "futures-core",
4185+ "futures-util",
4186+ "http",
4187+ "memchr",
4188+ "pin-project-lite",
4189+ "siphasher",
4190+ "smallvec",
4191+ "topcoat-core",
4192+]
4193+
4194+[[package]]
4195+name = "topcoat-view-grammar"
4196+version = "0.11.0"
4197+source = "registry+https://github.com/rust-lang/crates.io-index"
4198+checksum = "75dd093ffc848370da4cce7670ccdfd4e98eab48e178d5d0da5509f747d85ca6"
4199+dependencies = [
4200+ "heck",
4201+ "proc-macro2",
4202+ "quote",
4203+ "syn 3.0.9",
4204+ "topcoat-core-grammar",
4205+ "topcoat-view",
4206+]
4207+
4208+[[package]]
4209+name = "topcoat-view-macro"
4210+version = "0.11.0"
4211+source = "registry+https://github.com/rust-lang/crates.io-index"
4212+checksum = "ffa1688d165704f08d58c03710453d0d39553292bea61b18be7959a996c3e39b"
4213+dependencies = [
4214+ "quote",
4215+ "syn 3.0.9",
4216+ "topcoat-view-grammar",
4217+]
4218+
3385 [[package]]4219 [[package]]
3386 name = "tower"4220 name = "tower"
3387 version = "0.5.3"4221 version = "0.5.3"
@@ -3507,6 +4341,22 @@ version = "0.2.5"
3507 source = "registry+https://github.com/rust-lang/crates.io-index"4341 source = "registry+https://github.com/rust-lang/crates.io-index"
3508 checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"4342 checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
3509 4343
4344+[[package]]
4345+name = "tungstenite"
4346+version = "0.29.0"
4347+source = "registry+https://github.com/rust-lang/crates.io-index"
4348+checksum = "6c01152af293afb9c7c2a57e4b559c5620b421f6d133261c60dd2d0cdb38e6b8"
4349+dependencies = [
4350+ "bytes",
4351+ "data-encoding",
4352+ "http",
4353+ "httparse",
4354+ "log",
4355+ "rand 0.9.5",
4356+ "sha1",
4357+ "thiserror",
4358+]
4359+
3510 [[package]]4360 [[package]]
3511 name = "turso"4361 name = "turso"
3512 version = "0.8.3"4362 version = "0.8.3"
@@ -3836,6 +4686,12 @@ version = "1.0.4"
3836 source = "registry+https://github.com/rust-lang/crates.io-index"4686 source = "registry+https://github.com/rust-lang/crates.io-index"
3837 checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"4687 checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
3838 4688
4689+[[package]]
4690+name = "utf8parse"
4691+version = "0.2.2"
4692+source = "registry+https://github.com/rust-lang/crates.io-index"
4693+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
4694+
3839 [[package]]4695 [[package]]
3840 name = "uuid"4696 name = "uuid"
3841 version = "1.29.0"4697 version = "1.29.0"
@@ -4191,6 +5047,9 @@ name = "winnow"
4191 version = "1.0.4"5047 version = "1.0.4"
4192 source = "registry+https://github.com/rust-lang/crates.io-index"5048 source = "registry+https://github.com/rust-lang/crates.io-index"
4193 checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"5049 checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
5050+dependencies = [
5051+ "memchr",
5052+]
4194 5053
4195 [[package]]5054 [[package]]
4196 name = "wit-bindgen"5055 name = "wit-bindgen"
Cargo.tomlmodified+5 -0
@@ -46,8 +46,11 @@ base64 = "0.23.1"
46 bytes = "1.12.1"46 bytes = "1.12.1"
47 chacha20poly1305 = "0.11.0"47 chacha20poly1305 = "0.11.0"
48 futures-util = "0.3.34"48 futures-util = "0.3.34"
49+grass = "0.13.4"
49 hex = "0.4.3"50 hex = "0.4.3"
50 hmac = "0.13.0"51 hmac = "0.13.0"
52+http = "1.5.0"
53+in-core = { path = "crates/in-core" }
51 ipnet = "2.12.2"54 ipnet = "2.12.2"
52 object_store = { version = "0.14.2", features = ["aws"] }55 object_store = { version = "0.14.2", features = ["aws"] }
53 rand = "0.10.3"56 rand = "0.10.3"
@@ -60,7 +63,9 @@ thiserror = "2.0.21"
60 time = "0.3.55"63 time = "0.3.55"
61 tokio = "1.54.1"64 tokio = "1.54.1"
62 toml = "1.1.8"65 toml = "1.1.8"
66+topcoat = { version = "0.11.0", default-features = false, features = ["router", "view", "runtime", "cookie", "asset", "serve", "sse", "discover", "multipart"] }
63 tracing = "0.1.44"67 tracing = "0.1.44"
68+tracing-subscriber = "0.3.23"
64 turso = "0.8.3"69 turso = "0.8.3"
65 ulid = "3.0.0"70 ulid = "3.0.0"
66 71
crates/in-web/Cargo.tomlmodified+23 -0
@@ -6,5 +6,28 @@ edition.workspace = true
6 license.workspace = true6 license.workspace = true
7 publish = false7 publish = false
8 8
9+[[bin]]
10+name = "in"
11+path = "src/main.rs"
12+
13+[dependencies]
14+futures-util.workspace = true
15+http.workspace = true
16+in-core.workspace = true
17+# `net` and `signal` for the listener and the shutdown signals, `time` for the probe deadlines, and
18+# `rt-multi-thread` and `macros` for the async entry point and `join!`.
19+tokio = { workspace = true, features = ["net", "signal", "time", "rt-multi-thread", "macros"] }
20+topcoat.workspace = true
21+tracing.workspace = true
22+tracing-subscriber = { workspace = true, features = ["env-filter"] }
23+
24+[dev-dependencies]
25+tempfile.workspace = true
26+
27+[build-dependencies]
28+grass.workspace = true
29+hex.workspace = true
30+sha2.workspace = true
31+
9 [lints]32 [lints]
10 workspace = true33 workspace = true
crates/in-web/assets/nav.jsadded+528 -0
@@ -0,0 +1,528 @@
1+/*
2+ * nav.js: the one script of in. 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/in-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>in · 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>in 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/in-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/in-web/assets/sw.jsadded+46 -0
@@ -0,0 +1,46 @@
1+/*
2+ * sw.js: the service worker of in. 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 = "in-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/in-web/build.rsadded+57 -0
@@ -0,0 +1,57 @@
1+//! Build script of the `in` 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: `IN_MAIN_CSS_V`, `IN_NAV_JS_V`, `IN_PAGES_JS_V` and `IN_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=IN_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("IN_BUILD_SHA").unwrap_or_else(|_| "dev".to_owned());
26+ println!("cargo:rustc-env=IN_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=IN_MAIN_CSS_V={}",
42+ content_version(css.as_bytes())
43+ );
44+
45+ for (var, file) in [
46+ ("IN_NAV_JS_V", "assets/nav.js"),
47+ ("IN_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/in-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/in-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!("IN_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!("IN_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!("IN_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/in-web/src/boot.rsadded+252 -0
@@ -0,0 +1,252 @@
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 the
5+//! pragmas and the migrations), open the blob store the configuration names, build the router, bind
6+//! the listener, and serve until SIGTERM or Ctrl-C. Stored UI overrides are not layered on the file
7+//! yet, because no page writes them.
8+
9+use std::os::unix::fs::PermissionsExt;
10+use std::path::Path;
11+use std::sync::Arc;
12+
13+use in_core::blob::BlobStore;
14+use in_core::blob::local::LocalBlobs;
15+use in_core::blob::s3::{S3Blobs, S3Settings};
16+use in_core::config::{Backend, Config, S3};
17+use in_core::error::{Error, Result};
18+use in_core::secret;
19+use in_core::store::Store;
20+use tokio::net::TcpListener;
21+use tokio::signal::unix::{SignalKind, signal};
22+use tokio::sync::watch;
23+use topcoat::cookie::RouterBuilderCookieExt;
24+use topcoat::router::{Router, RouterBuilderDiscoverExt, RouterService};
25+
26+use crate::live::LiveHub;
27+use crate::pages::not_found::NotFoundLayer;
28+use crate::security::{self, SecurityHeaders};
29+use crate::state::AppState;
30+
31+/// Name of the instance key file inside the data directory.
32+const KEY_FILE: &str = "in.key";
33+
34+/// Directory under the data directory that holds the local blob tree.
35+const BLOB_DIR: &str = "blobs";
36+
37+/// Runs the server until a stop signal arrives. Returns once every connection has finished.
38+pub async fn serve(config_path: &Path) -> Result<()> {
39+ let config = Config::load(config_path)?;
40+ let listen = config.listen;
41+ let state = open_state(config).await?;
42+
43+ let listener = TcpListener::bind(listen).await.map_err(|error| {
44+ std::io::Error::new(error.kind(), format!("cannot bind {listen}: {error}"))
45+ })?;
46+ tracing::info!(
47+ listen = %listen,
48+ data_dir = %state.config.data_dir.display(),
49+ storage = ?state.config.storage.backend,
50+ build = env!("IN_BUILD_SHA"),
51+ "in starting"
52+ );
53+
54+ // One stop flag. The signal task sets it; the server watches it and then drains.
55+ let (stop_tx, stop_rx) = watch::channel(false);
56+ tokio::spawn(async move {
57+ shutdown_signal().await;
58+ tracing::info!("shutdown signal received");
59+ stop_tx.send_replace(true);
60+ });
61+
62+ topcoat::serve_until(
63+ listener,
64+ RouterService::new(router(state)),
65+ wait_stop(stop_rx),
66+ )
67+ .await?;
68+ tracing::info!("in stopped");
69+ Ok(())
70+}
71+
72+/// Creates the data directory and opens the key, the database and the blob store. Everything the
73+/// router needs that touches the disk is ready when this returns.
74+async fn open_state(config: Config) -> Result<AppState> {
75+ std::fs::create_dir_all(&config.data_dir)?;
76+ // The directory holds the instance key. Only this user may enter it.
77+ std::fs::set_permissions(&config.data_dir, std::fs::Permissions::from_mode(0o700))?;
78+ let data_dir = config.data_dir.canonicalize()?;
79+ if let Some(parent) = config
80+ .database
81+ .parent()
82+ .filter(|p| !p.as_os_str().is_empty())
83+ {
84+ std::fs::create_dir_all(parent)?;
85+ }
86+ let key = secret::load_or_create_key(&data_dir.join(KEY_FILE))?;
87+ let store = Store::open(&config.database).await?;
88+ let blobs = open_blobs(&config, &data_dir)?;
89+ Ok(AppState {
90+ config: Arc::new(config),
91+ store,
92+ blobs,
93+ key: Arc::new(key),
94+ live: Arc::new(LiveHub::default()),
95+ })
96+}
97+
98+/// Builds the blob store the configuration names. The local backend keeps its tree under
99+/// `data_dir/blobs`. The S3 backend reads its credentials from the files the configuration names; no
100+/// request is made here, so a wrong bucket shows on the first use.
101+pub fn open_blobs(config: &Config, data_dir: &Path) -> Result<Arc<dyn BlobStore>> {
102+ match config.storage.backend {
103+ Backend::Local => Ok(Arc::new(LocalBlobs::new(data_dir.join(BLOB_DIR))?)),
104+ Backend::S3 => {
105+ let s3 = config
106+ .storage
107+ .s3
108+ .as_ref()
109+ .ok_or_else(|| Error::Config("storage.s3 is missing".into()))?;
110+ Ok(Arc::new(S3Blobs::new(&s3_settings(s3)?)?))
111+ }
112+ }
113+}
114+
115+/// Turns the `[storage.s3]` table and its credential files into the client settings. Without an
116+/// endpoint the AWS endpoint of the region is used. Plain http is allowed only when the configured
117+/// endpoint says so.
118+fn s3_settings(s3: &S3) -> Result<S3Settings> {
119+ let endpoint = s3
120+ .endpoint
121+ .clone()
122+ .unwrap_or_else(|| format!("https://s3.{}.amazonaws.com", s3.region));
123+ Ok(S3Settings {
124+ allow_http: endpoint.starts_with("http://"),
125+ endpoint,
126+ region: s3.region.clone(),
127+ bucket: s3.bucket.clone(),
128+ access_key_id: read_secret(&s3.access_key_id_file)?,
129+ secret_access_key: read_secret(&s3.secret_access_key_file)?,
130+ })
131+}
132+
133+/// Reads a credential file and drops the trailing newline. An empty file is a configuration error.
134+fn read_secret(path: &Path) -> Result<String> {
135+ let text = std::fs::read_to_string(path)
136+ .map_err(|e| Error::Config(format!("cannot read {}: {e}", path.display())))?;
137+ let value = text.trim().to_owned();
138+ if value.is_empty() {
139+ return Err(Error::Config(format!("{} is empty", path.display())));
140+ }
141+ Ok(value)
142+}
143+
144+/// The router of the server: every route and page found by `discover`, the cookie jar, the security
145+/// headers on every response, and the styled 404 for browsers.
146+pub fn router(state: AppState) -> Router {
147+ let security = SecurityHeaders::new(security::headers_for(&state.config.base_url));
148+ Router::builder()
149+ .discover()
150+ .app_context(state)
151+ .cookies()
152+ .layer(security)
153+ .layer(NotFoundLayer)
154+ .build()
155+}
156+
157+/// Resolves when the shared stop flag is set.
158+async fn wait_stop(mut stop: watch::Receiver<bool>) {
159+ let _ = stop.wait_for(|stopped| *stopped).await;
160+}
161+
162+/// Resolves on Ctrl-C or SIGTERM. A handler that cannot be installed is logged and never resolves,
163+/// so the other one still works.
164+async fn shutdown_signal() {
165+ let ctrl_c = async {
166+ if let Err(error) = tokio::signal::ctrl_c().await {
167+ tracing::error!(error = %error, "cannot listen for Ctrl-C");
168+ std::future::pending::<()>().await;
169+ }
170+ };
171+ let terminate = async {
172+ match signal(SignalKind::terminate()) {
173+ Ok(mut term) => {
174+ term.recv().await;
175+ }
176+ Err(error) => {
177+ tracing::error!(error = %error, "cannot listen for SIGTERM");
178+ std::future::pending::<()>().await;
179+ }
180+ }
181+ };
182+ tokio::select! {
183+ () = ctrl_c => {}
184+ () = terminate => {}
185+ }
186+}
187+
188+#[cfg(test)]
189+pub(crate) use tests::test_state;
190+
191+#[cfg(test)]
192+mod tests {
193+ use super::*;
194+ use std::net::SocketAddr;
195+ use http::header::{ACCEPT, CONTENT_SECURITY_POLICY, X_CONTENT_TYPE_OPTIONS};
196+ use topcoat::router::response::Response;
197+ use topcoat::router::{Body, to_bytes};
198+
199+ /// An app state over a fresh temp directory: the database, the key and the blobs live there, and
200+ /// nothing is written outside it. The directory is returned so it lives as long as the state.
201+ pub(crate) async fn test_state() -> (tempfile::TempDir, AppState) {
202+ let dir = tempfile::tempdir().expect("temp dir");
203+ let config = Config {
204+ database: dir.path().join("in.db"),
205+ data_dir: dir.path().to_path_buf(),
206+ listen: SocketAddr::from(([127, 0, 0, 1], 17650)),
207+ ..Config::default()
208+ };
209+ let key = secret::load_or_create_key(&dir.path().join(KEY_FILE)).expect("key");
210+ let store = Store::open(&config.database).await.expect("store");
211+ let blobs = open_blobs(&config, dir.path()).expect("blobs");
212+ let state = AppState {
213+ config: Arc::new(config),
214+ store,
215+ blobs,
216+ key: Arc::new(key),
217+ live: Arc::new(LiveHub::default()),
218+ };
219+ (dir, state)
220+ }
221+
222+ async fn get(state: AppState, path: &str, accept: Option<&str>) -> Response {
223+ let mut request = http::Request::get(path);
224+ if let Some(accept) = accept {
225+ request = request.header(ACCEPT, accept);
226+ }
227+ let request = request.body(Body::empty()).expect("request");
228+ router(state).handle(request).await
229+ }
230+
231+ #[tokio::test]
232+ async fn an_unknown_path_gets_the_styled_404_with_the_security_headers() {
233+ let (_dir, state) = test_state().await;
234+ let response = get(state, "/no/such/page", Some("text/html")).await;
235+ assert_eq!(response.status(), 404);
236+ assert_eq!(
237+ response.headers()[CONTENT_SECURITY_POLICY]
238+ .to_str()
239+ .expect("ascii"),
240+ security::CSP
241+ );
242+ assert_eq!(response.headers()[X_CONTENT_TYPE_OPTIONS], "nosniff");
243+ let body = to_bytes(response.into_body(), 64 * 1024)
244+ .await
245+ .expect("body");
246+ let html = String::from_utf8_lossy(&body);
247+ assert!(
248+ html.contains("Page not found"),
249+ "styled 404 body, got: {html}"
250+ );
251+ }
252+}
crates/in-web/src/health.rsadded+97 -0
@@ -0,0 +1,97 @@
1+//! `GET /healthz`, the probe of `docs/contracts.md` section 4.1.
2+//!
3+//! It answers `200` with `ok <build sha>` when both the database and the blob store answer within one
4+//! second. A failed part is named in a `503` body: `fail database`, `fail blobs`, or both joined by a
5+//! space. It needs no login and reads no user data.
6+
7+use std::time::Duration;
8+
9+use in_core::blob::BlobStore;
10+use in_core::error::Result as CoreResult;
11+use in_core::store::{col_int, fetch_opt};
12+use topcoat::Result;
13+use topcoat::context::{Cx, app_context};
14+use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, route};
15+
16+use crate::state::AppState;
17+
18+/// The longest each probe may take. A lock held by a long write, or a slow bucket, shows up as a
19+/// failed probe.
20+const PROBE_DEADLINE: Duration = Duration::from_secs(1);
21+
22+/// The blob key that the probe asks for. Blob keys start with `files/`, `thumbs/` or `objects/`, so
23+/// no stored blob has this key and the answer is "absent" whenever the store is reachable.
24+const BLOB_PROBE_KEY: &str = "healthz";
25+
26+/// `GET /healthz`.
27+#[route(GET "/healthz")]
28+async fn healthz(cx: &Cx) -> Result<(StatusCode, HeaderMap, String)> {
29+ let state = app_context::<AppState>(cx);
30+ let (database, blobs) = tokio::join!(
31+ tokio::time::timeout(PROBE_DEADLINE, probe_database(state)),
32+ tokio::time::timeout(PROBE_DEADLINE, probe_blobs(state.blobs.as_ref())),
33+ );
34+ let mut failed = Vec::new();
35+ if !matches!(database, Ok(Ok(()))) {
36+ tracing::error!("healthz: the database probe failed or timed out");
37+ failed.push("database");
38+ }
39+ if !matches!(blobs, Ok(Ok(()))) {
40+ tracing::error!("healthz: the blob store probe failed or timed out");
41+ failed.push("blobs");
42+ }
43+ let (status, body) = if failed.is_empty() {
44+ (StatusCode::OK, format!("ok {}", env!("IN_BUILD_SHA")))
45+ } else {
46+ (
47+ StatusCode::SERVICE_UNAVAILABLE,
48+ format!("fail {}", failed.join(" ")),
49+ )
50+ };
51+ let mut headers = HeaderMap::new();
52+ headers.insert(
53+ header::CONTENT_TYPE,
54+ HeaderValue::from_static("text/plain; charset=utf-8"),
55+ );
56+ Ok((status, headers, body))
57+}
58+
59+/// Runs `SELECT 1` on a pooled reader.
60+async fn probe_database(state: &AppState) -> CoreResult<()> {
61+ let conn = state.store.read_conn().await;
62+ fetch_opt(&conn, "SELECT 1", (), |row| col_int(row, 0))
63+ .await?
64+ .map(|_| ())
65+ .ok_or(in_core::error::Error::NotFound)
66+}
67+
68+/// Asks the blob store for the size of a key that does not exist. Any answer other than an I/O error
69+/// (`None` for absent) shows that the store is reachable.
70+async fn probe_blobs(blobs: &dyn BlobStore) -> CoreResult<()> {
71+ blobs.size(BLOB_PROBE_KEY).await.map(|_| ())
72+}
73+
74+#[cfg(test)]
75+mod tests {
76+ use http::Request;
77+ use topcoat::router::Body;
78+
79+ use crate::boot::{router, test_state};
80+
81+ #[tokio::test]
82+ async fn healthz_answers_ok_with_the_build_sha() {
83+ let (_dir, state) = test_state().await;
84+ let request = Request::get("/healthz")
85+ .body(Body::empty())
86+ .expect("request");
87+ let response = router(state).handle(request).await;
88+ assert_eq!(response.status(), 200);
89+ let body = topcoat::router::to_bytes(response.into_body(), 1024)
90+ .await
91+ .expect("body");
92+ assert_eq!(
93+ body.as_ref(),
94+ format!("ok {}", env!("IN_BUILD_SHA")).as_bytes()
95+ );
96+ }
97+}
crates/in-web/src/i18n/mod.rsadded+116 -0
@@ -0,0 +1,116 @@
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+}
93+
94+#[cfg(test)]
95+mod tests {
96+ use super::*;
97+
98+ fn accept(value: &str) -> HeaderMap {
99+ let mut headers = HeaderMap::new();
100+ headers.insert(
101+ header::ACCEPT_LANGUAGE,
102+ value.parse().expect("header value"),
103+ );
104+ headers
105+ }
106+
107+ #[test]
108+ fn the_stored_language_wins_then_accept_language_then_english() {
109+ assert_eq!(resolve(Some("tr"), &accept("en")), Lang::Tr);
110+ assert_eq!(resolve(None, &accept("en;q=0.2, tr;q=0.9")), Lang::Tr);
111+ assert_eq!(resolve(None, &accept("tr-TR,tr;q=0.9,en;q=0.8")), Lang::Tr);
112+ assert_eq!(resolve(None, &accept("fr, de;q=0.5")), Lang::En);
113+ assert_eq!(resolve(Some("auto"), &accept("tr;q=0")), Lang::En);
114+ assert_eq!(resolve(None, &HeaderMap::new()), Lang::En);
115+ }
116+}
crates/in-web/src/i18n/shell.rsadded+51 -0
@@ -0,0 +1,51 @@
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 bar shown while the server cannot be reached.
18+ ServerRestarting,
19+ /// The accessible name of the service switcher.
20+ Services,
21+ /// The first link on every page, which jumps past the topbar.
22+ SkipToContent,
23+ /// The heading of the start page for a visitor who is not signed in.
24+ SignedOutTitle,
25+ /// The sentence under the signed-out heading on the start page.
26+ SignedOutBody,
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::ServerRestarting, Lang::En) => "The server is restarting. Reconnecting…",
41+ (K::ServerRestarting, Lang::Tr) => "Sunucu yeniden başlatılıyor. Yeniden bağlanılıyor…",
42+ (K::Services, Lang::En) => "Services",
43+ (K::Services, Lang::Tr) => "Hizmetler",
44+ (K::SkipToContent, Lang::En) => "Skip to content",
45+ (K::SkipToContent, Lang::Tr) => "İçeriğe geç",
46+ (K::SignedOutTitle, Lang::En) => "Sign in to open your files",
47+ (K::SignedOutTitle, Lang::Tr) => "Dosyalarınızı açmak için oturum açın",
48+ (K::SignedOutBody, Lang::En) => "You are signed out. Sign-in is not part of this build yet.",
49+ (K::SignedOutBody, Lang::Tr) => "Oturumunuz kapalı. Oturum açma bu sürümde henüz yok.",
50+ }
51+}
crates/in-web/src/live.rsadded+203 -0
@@ -0,0 +1,203 @@
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.
37+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
38+pub enum Topic {
39+ /// A person's own account: sessions and preferences. Keyed by user sub. Streamed only to that person.
40+ Account(String),
41+ /// A person's own drive: folder listings and trash. Keyed by owner sub. Streamed only to the owner.
42+ Drive(String),
43+ /// Items shared with a person. Keyed by grantee sub. Streamed only to that person.
44+ Shared(String),
45+ /// The audit log: an entry was written. Global. Admin pages only.
46+ AdminAudit,
47+}
48+
49+/// The change counters of all open topics. Cheap to share: every clone of the app state holds the
50+/// same `Arc<LiveHub>`.
51+#[derive(Default)]
52+pub struct LiveHub {
53+ topics: Mutex<HashMap<Topic, watch::Sender<u64>>>,
54+}
55+
56+impl LiveHub {
57+ /// Locks the map. A panic in another holder must not stop every live page, so a poisoned lock
58+ /// is used as it is.
59+ fn topics(&self) -> MutexGuard<'_, HashMap<Topic, watch::Sender<u64>>> {
60+ self.topics.lock().unwrap_or_else(PoisonError::into_inner)
61+ }
62+
63+ /// Subscribes to `topic`. The receiver starts as seen, so a bump after this call wakes it.
64+ /// Subscribe before reading the state: a change between the two is then not lost. Topics that
65+ /// nobody holds any more are dropped here, so the map stays small.
66+ pub fn subscribe(&self, topic: &Topic) -> watch::Receiver<u64> {
67+ let mut topics = self.topics();
68+ topics.retain(|_, sender| sender.receiver_count() > 0);
69+ topics
70+ .entry(topic.clone())
71+ .or_insert_with(|| watch::channel(0).0)
72+ .subscribe()
73+ }
74+
75+ /// Wakes the subscribers of `topic`. Does nothing when nobody listens.
76+ pub fn bump(&self, topic: &Topic) {
77+ let mut topics = self.topics();
78+ let Some(sender) = topics.get(topic) else {
79+ return;
80+ };
81+ sender.send_modify(|generation| *generation = generation.wrapping_add(1));
82+ if sender.receiver_count() == 0 {
83+ topics.remove(topic);
84+ }
85+ }
86+}
87+
88+/// The state a stream carries between wakes.
89+struct Follow<F> {
90+ wakes: Vec<watch::Receiver<u64>>,
91+ fingerprint: F,
92+ last: String,
93+}
94+
95+/// Opens the `changed` stream for `topics`. The stream sends an event only when `fingerprint`
96+/// differs from the value it last sent, so a bump that changes nothing the viewer sees sends
97+/// nothing. Nothing is sent on connect: the page already shows the state that `fingerprint` read.
98+///
99+/// `fingerprint` must be cheap and must describe everything the page shows. A read that fails ends
100+/// the stream, and the browser reconnects.
101+pub async fn stream_changes<F, Fut>(
102+ cx: &Cx,
103+ hub: &LiveHub,
104+ topics: &[Topic],
105+ fingerprint: F,
106+) -> Result<Response>
107+where
108+ F: Fn() -> Fut + Send + 'static,
109+ Fut: Future<Output = Result<String>> + Send,
110+{
111+ // Subscribed before the first read, so a change in between still wakes the stream.
112+ let wakes: Vec<watch::Receiver<u64>> =
113+ topics.iter().map(|topic| hub.subscribe(topic)).collect();
114+ let last = fingerprint().await?;
115+ let follow = Follow {
116+ wakes,
117+ fingerprint,
118+ last,
119+ };
120+ let events = stream::unfold(follow, |mut follow| async move {
121+ loop {
122+ if !wait_any(&mut follow.wakes).await {
123+ return None;
124+ }
125+ match (follow.fingerprint)().await {
126+ Ok(now) if now != follow.last => {
127+ follow.last = now;
128+ return Some((changed_event(), follow));
129+ }
130+ Ok(_) => continue,
131+ Err(error) => {
132+ tracing::error!(error = %error, "live: could not read the page state");
133+ return None;
134+ }
135+ }
136+ }
137+ });
138+ events_response(cx, events)
139+}
140+
141+/// The data-less `changed` event.
142+fn changed_event() -> Result<Event> {
143+ Ok(Event::new().event("changed").data("1"))
144+}
145+
146+/// Resolves when one of `wakes` changes. False when that topic is gone, which ends the stream.
147+/// With no topics at all it never resolves: the stream then only sends keep-alives.
148+async fn wait_any(wakes: &mut [watch::Receiver<u64>]) -> bool {
149+ if wakes.is_empty() {
150+ std::future::pending::<()>().await;
151+ }
152+ let waits = wakes.iter_mut().map(|wake| Box::pin(wake.changed()));
153+ let (result, _, _) = select_all(waits).await;
154+ result.is_ok()
155+}
156+
157+/// The response of a live stream: `retry` once, then the events, with keep-alives while idle.
158+/// `X-Accel-Buffering: no` stops a reverse proxy from holding the events back.
159+pub fn events_response(
160+ cx: &Cx,
161+ events: impl Stream<Item = Result<Event>> + Send + 'static,
162+) -> Result<Response> {
163+ let retry = stream::once(std::future::ready(Ok(Event::new().retry(STREAM_RETRY))));
164+ let stream = Sse::new(retry.chain(events))
165+ .keep_alive(KeepAlive::new().interval(KEEP_ALIVE).text("keepalive"));
166+ let mut response = stream.into_response(cx)?;
167+ response
168+ .headers_mut()
169+ .insert("x-accel-buffering", HeaderValue::from_static("no"));
170+ Ok(response)
171+}
172+
173+/// `GET /-/alive`. Every page holds this stream, so the browser learns when the server stops and
174+/// starts again. Anonymous viewers may hold it, and it reveals nothing: for now it sends only the
175+/// `retry` hint and keep-alives.
176+#[route(GET "/-/alive")]
177+async fn alive(cx: &Cx) -> Result<Response> {
178+ events_response(cx, stream::pending::<Result<Event>>())
179+}
180+
181+#[cfg(test)]
182+mod tests {
183+ use std::time::Duration;
184+
185+ use super::*;
186+
187+ #[tokio::test]
188+ async fn a_bump_wakes_only_the_subscribers_of_its_topic() {
189+ let hub = LiveHub::default();
190+ let mine = Topic::Account("user-a".to_owned());
191+ let other = Topic::Account("user-b".to_owned());
192+ let mut wake_mine = hub.subscribe(&mine);
193+ let wake_other = hub.subscribe(&other);
194+
195+ hub.bump(&mine);
196+
197+ tokio::time::timeout(Duration::from_secs(1), wake_mine.changed())
198+ .await
199+ .expect("woken")
200+ .expect("open");
201+ assert!(!wake_other.has_changed().expect("open"));
202+ }
203+}
crates/in-web/src/main.rsmodified+99 -4
@@ -1,6 +1,101 @@
1-//! Entry point of the `in` binary. This is a placeholder until the boot sequence exists; it only1+//! The `in` binary: the command line, logging and the process lifetime.
2-//! proves that the workspace builds.2+//!
3+//! `in [--config <path>] [serve]` runs the server; a bare `in` does the same. `in admin ...` is the
4+//! operator command line, which is not built yet. The configuration file is the `--config` path,
5+//! then `IN_CONFIG`, then `config/in.toml`. Exit status 0 is success, 1 a failure, 2 a usage error.
3 6
4-fn main() {7+mod assets;
5- println!("in");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: in [--config <path>] [serve]";
24+
25+/// The configuration file when neither `--config` nor `IN_CONFIG` names one.
26+const DEFAULT_CONFIG: &str = "config/in.toml";
27+
28+/// The environment variable that names the configuration file.
29+const CONFIG_ENV: &str = "IN_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 `IN_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, "in 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!("in: {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!("in: admin commands are not implemented yet");
94+ ExitCode::from(2)
95+ }
96+ _ => {
97+ eprintln!("in: unknown command\n{USAGE}");
98+ ExitCode::from(2)
99+ }
100+ }
6 }101 }
crates/in-web/src/pages/home.rsadded+26 -0
@@ -0,0 +1,26 @@
1+//! The start page. For now it is a placeholder that shows the signed-out state; it becomes the
2+//! account home (the drive redirect) once sign-in exists.
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::{notice, 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">"in"</p>
21+ <h1>(t(lang, K::SignedOutTitle))</h1>
22+ notice(message: t(lang, K::SignedOutBody))
23+ </section>
24+ )
25+ })
26+}
crates/in-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/in-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/in-web/src/security.rsadded+85 -0
@@ -0,0 +1,85 @@
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/in-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+}
71+
72+#[cfg(test)]
73+mod tests {
74+ use super::*;
75+
76+ #[test]
77+ fn hsts_only_for_https_origins() {
78+ assert!(
79+ headers_for("https://in.example.com").contains_key(header::STRICT_TRANSPORT_SECURITY)
80+ );
81+ assert!(
82+ !headers_for("http://127.0.0.1:7650").contains_key(header::STRICT_TRANSPORT_SECURITY)
83+ );
84+ }
85+}
crates/in-web/src/state.rsadded+25 -0
@@ -0,0 +1,25 @@
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 in_core::blob::BlobStore;
6+use in_core::config::Config;
7+use in_core::store::Store;
8+
9+use crate::live::LiveHub;
10+
11+/// Everything a request handler reaches through the app context. Every field is cheap to clone.
12+#[allow(dead_code)] // The key and the hub are read by the sign-in and live pages that come next.
13+#[derive(Clone)]
14+pub struct AppState {
15+ /// The configuration the process booted with.
16+ pub config: Arc<Config>,
17+ /// The database. Reads go to a pooled reader and writes to the single writer.
18+ pub store: Store,
19+ /// The blob store the configuration names: the local blob tree or an S3-compatible bucket.
20+ pub blobs: Arc<dyn BlobStore>,
21+ /// The instance key (`in.key`). Seals secrets at rest.
22+ pub key: Arc<[u8; 32]>,
23+ /// The change counters of the live pages.
24+ pub live: Arc<LiveHub>,
25+}
crates/in-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} in");
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="/">"in"</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 `in`. `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";