Bump remaining crates to latest
Browse files at this commitb88da93a2780e7d6cceb7f4c73fb1bacf282c612Parent: 68db38e- chore
- bump remaining crates to latest
28 changed files +1121 -913
- Cargo.lock +223 -152
- Cargo.toml +5 -5
- crates/iz-client/Cargo.toml +8 -9
- crates/iz-client/src/lib.rs +11 -12
- crates/iz-core/src/board.rs +1 -1
- crates/iz-core/src/config.rs +2 -2
- crates/iz-core/src/store/mod.rs +1 -0
- crates/iz-core/src/store/reconcile.rs +7 -7
- crates/iz-core/src/store/schema.rs +24 -12
- crates/iz-core/src/store/secret.rs +4 -4
- crates/iz-core/src/store/turso_store.rs +43 -46
- crates/iz-core/tests/store.rs +50 -43
- crates/iz-web/Cargo.toml +4 -4
- crates/iz-web/src/board.rs +75 -55
- crates/iz-web/src/detail.rs +294 -240
- crates/iz-web/src/dropdown.rs +3 -3
- crates/iz-web/src/files.rs +14 -10
- crates/iz-web/src/layout.rs +74 -68
- crates/iz-web/src/logs.rs +60 -54
- crates/iz-web/src/main.rs +13 -7
- crates/iz-web/src/pages.rs +12 -15
- crates/iz-web/src/people.rs +11 -10
- crates/iz-web/src/rules.rs +46 -42
- crates/iz-web/src/server.rs +5 -1
- crates/iz-web/src/settings.rs +35 -29
- crates/iz-web/src/slides.rs +35 -44
- crates/iz-web/src/tags.rs +37 -23
- crates/iz-web/tests/http.rs +24 -15
Cargo.lockmodified+223 -152
| @@ -18,6 +18,16 @@ dependencies = [ | |||
| 18 | "generic-array", | 18 | "generic-array", |
| 19 | ] | 19 | ] |
| 20 | 20 | ||
| 21 | +[[package]] | ||
| 22 | +name = "aead" | ||
| 23 | +version = "0.6.1" | ||
| 24 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 25 | +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" | ||
| 26 | +dependencies = [ | ||
| 27 | + "crypto-common 0.2.2", | ||
| 28 | + "inout 0.2.2", | ||
| 29 | +] | ||
| 30 | + | ||
| 21 | [[package]] | 31 | [[package]] |
| 22 | name = "aegis" | 32 | name = "aegis" |
| 23 | version = "0.9.15" | 33 | version = "0.9.15" |
| @@ -35,7 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 35 | checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" | 45 | checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" |
| 36 | dependencies = [ | 46 | dependencies = [ |
| 37 | "cfg-if", | 47 | "cfg-if", |
| 38 | - "cipher", | 48 | + "cipher 0.4.4", |
| 39 | "cpufeatures 0.2.17", | 49 | "cpufeatures 0.2.17", |
| 40 | ] | 50 | ] |
| 41 | 51 | ||
| @@ -45,9 +55,9 @@ version = "0.10.3" | |||
| 45 | source = "registry+https://github.com/rust-lang/crates.io-index" | 55 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 46 | checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" | 56 | checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" |
| 47 | dependencies = [ | 57 | dependencies = [ |
| 48 | - "aead", | 58 | + "aead 0.5.2", |
| 49 | "aes", | 59 | "aes", |
| 50 | - "cipher", | 60 | + "cipher 0.4.4", |
| 51 | "ctr", | 61 | "ctr", |
| 52 | "ghash", | 62 | "ghash", |
| 53 | "subtle", | 63 | "subtle", |
| @@ -291,6 +301,12 @@ dependencies = [ | |||
| 291 | "pkg-config", | 301 | "pkg-config", |
| 292 | ] | 302 | ] |
| 293 | 303 | ||
| 304 | +[[package]] | ||
| 305 | +name = "base16ct" | ||
| 306 | +version = "1.0.0" | ||
| 307 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 308 | +checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" | ||
| 309 | + | ||
| 294 | [[package]] | 310 | [[package]] |
| 295 | name = "base64" | 311 | name = "base64" |
| 296 | version = "0.22.1" | 312 | version = "0.22.1" |
| @@ -493,9 +509,9 @@ dependencies = [ | |||
| 493 | "encoding_rs", | 509 | "encoding_rs", |
| 494 | "fast-float2", | 510 | "fast-float2", |
| 495 | "log", | 511 | "log", |
| 496 | - "quick-xml", | 512 | + "quick-xml 0.41.0", |
| 497 | "serde", | 513 | "serde", |
| 498 | - "zip", | 514 | + "zip 8.6.0", |
| 499 | ] | 515 | ] |
| 500 | 516 | ||
| 501 | [[package]] | 517 | [[package]] |
| @@ -543,17 +559,6 @@ version = "0.1.1" | |||
| 543 | source = "registry+https://github.com/rust-lang/crates.io-index" | 559 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 544 | checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487" | 560 | checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487" |
| 545 | 561 | ||
| 546 | -[[package]] | ||
| 547 | -name = "chacha20" | ||
| 548 | -version = "0.9.1" | ||
| 549 | -source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 550 | -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" | ||
| 551 | -dependencies = [ | ||
| 552 | - "cfg-if", | ||
| 553 | - "cipher", | ||
| 554 | - "cpufeatures 0.2.17", | ||
| 555 | -] | ||
| 556 | - | ||
| 557 | [[package]] | 562 | [[package]] |
| 558 | name = "chacha20" | 563 | name = "chacha20" |
| 559 | version = "0.10.2" | 564 | version = "0.10.2" |
| @@ -561,21 +566,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 561 | checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" | 566 | checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" |
| 562 | dependencies = [ | 567 | dependencies = [ |
| 563 | "cfg-if", | 568 | "cfg-if", |
| 569 | + "cipher 0.5.2", | ||
| 564 | "cpufeatures 0.3.1", | 570 | "cpufeatures 0.3.1", |
| 565 | "rand_core 0.10.1", | 571 | "rand_core 0.10.1", |
| 566 | ] | 572 | ] |
| 567 | 573 | ||
| 568 | [[package]] | 574 | [[package]] |
| 569 | name = "chacha20poly1305" | 575 | name = "chacha20poly1305" |
| 570 | -version = "0.10.1" | 576 | +version = "0.11.0" |
| 571 | source = "registry+https://github.com/rust-lang/crates.io-index" | 577 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 572 | -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" | 578 | +checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" |
| 573 | dependencies = [ | 579 | dependencies = [ |
| 574 | - "aead", | 580 | + "aead 0.6.1", |
| 575 | - "chacha20 0.9.1", | 581 | + "chacha20", |
| 576 | - "cipher", | 582 | + "cipher 0.5.2", |
| 577 | "poly1305", | 583 | "poly1305", |
| 578 | - "zeroize", | ||
| 579 | ] | 584 | ] |
| 580 | 585 | ||
| 581 | [[package]] | 586 | [[package]] |
| @@ -598,8 +603,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 598 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" | 603 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" |
| 599 | dependencies = [ | 604 | dependencies = [ |
| 600 | "crypto-common 0.1.7", | 605 | "crypto-common 0.1.7", |
| 601 | - "inout", | 606 | + "inout 0.1.4", |
| 602 | - "zeroize", | 607 | +] |
| 608 | + | ||
| 609 | +[[package]] | ||
| 610 | +name = "cipher" | ||
| 611 | +version = "0.5.2" | ||
| 612 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 613 | +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" | ||
| 614 | +dependencies = [ | ||
| 615 | + "block-buffer 0.12.1", | ||
| 616 | + "crypto-common 0.2.2", | ||
| 617 | + "inout 0.2.2", | ||
| 603 | ] | 618 | ] |
| 604 | 619 | ||
| 605 | [[package]] | 620 | [[package]] |
| @@ -649,6 +664,12 @@ dependencies = [ | |||
| 649 | "cc", | 664 | "cc", |
| 650 | ] | 665 | ] |
| 651 | 666 | ||
| 667 | +[[package]] | ||
| 668 | +name = "cmov" | ||
| 669 | +version = "0.5.4" | ||
| 670 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 671 | +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" | ||
| 672 | + | ||
| 652 | [[package]] | 673 | [[package]] |
| 653 | name = "codemap" | 674 | name = "codemap" |
| 654 | version = "0.1.3" | 675 | version = "0.1.3" |
| @@ -707,12 +728,6 @@ dependencies = [ | |||
| 707 | "crossbeam-utils", | 728 | "crossbeam-utils", |
| 708 | ] | 729 | ] |
| 709 | 730 | ||
| 710 | -[[package]] | ||
| 711 | -name = "const-oid" | ||
| 712 | -version = "0.9.6" | ||
| 713 | -source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 714 | -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" | ||
| 715 | - | ||
| 716 | [[package]] | 731 | [[package]] |
| 717 | name = "const-oid" | 732 | name = "const-oid" |
| 718 | version = "0.10.2" | 733 | version = "0.10.2" |
| @@ -759,6 +774,12 @@ version = "1.0.0" | |||
| 759 | source = "registry+https://github.com/rust-lang/crates.io-index" | 774 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 760 | checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" | 775 | checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" |
| 761 | 776 | ||
| 777 | +[[package]] | ||
| 778 | +name = "cpubits" | ||
| 779 | +version = "0.1.1" | ||
| 780 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 781 | +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" | ||
| 782 | + | ||
| 762 | [[package]] | 783 | [[package]] |
| 763 | name = "cpufeatures" | 784 | name = "cpufeatures" |
| 764 | version = "0.2.17" | 785 | version = "0.2.17" |
| @@ -835,6 +856,20 @@ version = "0.2.4" | |||
| 835 | source = "registry+https://github.com/rust-lang/crates.io-index" | 856 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 836 | checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" | 857 | checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" |
| 837 | 858 | ||
| 859 | +[[package]] | ||
| 860 | +name = "crypto-bigint" | ||
| 861 | +version = "0.7.5" | ||
| 862 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 863 | +checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271" | ||
| 864 | +dependencies = [ | ||
| 865 | + "cpubits", | ||
| 866 | + "ctutils", | ||
| 867 | + "num-traits", | ||
| 868 | + "rand_core 0.10.1", | ||
| 869 | + "serdect", | ||
| 870 | + "zeroize", | ||
| 871 | +] | ||
| 872 | + | ||
| 838 | [[package]] | 873 | [[package]] |
| 839 | name = "crypto-common" | 874 | name = "crypto-common" |
| 840 | version = "0.1.7" | 875 | version = "0.1.7" |
| @@ -852,7 +887,19 @@ version = "0.2.2" | |||
| 852 | source = "registry+https://github.com/rust-lang/crates.io-index" | 887 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 853 | checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" | 888 | checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" |
| 854 | dependencies = [ | 889 | dependencies = [ |
| 890 | + "getrandom 0.4.3", | ||
| 855 | "hybrid-array", | 891 | "hybrid-array", |
| 892 | + "rand_core 0.10.1", | ||
| 893 | +] | ||
| 894 | + | ||
| 895 | +[[package]] | ||
| 896 | +name = "crypto-primes" | ||
| 897 | +version = "0.7.2" | ||
| 898 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 899 | +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" | ||
| 900 | +dependencies = [ | ||
| 901 | + "crypto-bigint", | ||
| 902 | + "rand_core 0.10.1", | ||
| 856 | ] | 903 | ] |
| 857 | 904 | ||
| 858 | [[package]] | 905 | [[package]] |
| @@ -861,7 +908,16 @@ version = "0.9.2" | |||
| 861 | source = "registry+https://github.com/rust-lang/crates.io-index" | 908 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 862 | checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" | 909 | checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" |
| 863 | dependencies = [ | 910 | dependencies = [ |
| 864 | - "cipher", | 911 | + "cipher 0.4.4", |
| 912 | +] | ||
| 913 | + | ||
| 914 | +[[package]] | ||
| 915 | +name = "ctutils" | ||
| 916 | +version = "0.4.2" | ||
| 917 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 918 | +checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" | ||
| 919 | +dependencies = [ | ||
| 920 | + "cmov", | ||
| 865 | ] | 921 | ] |
| 866 | 922 | ||
| 867 | [[package]] | 923 | [[package]] |
| @@ -918,11 +974,11 @@ checksum = "7eed2c4702fa172d1ce21078faa7c5203e69f5394d48cc436d25928394a867a2" | |||
| 918 | 974 | ||
| 919 | [[package]] | 975 | [[package]] |
| 920 | name = "der" | 976 | name = "der" |
| 921 | -version = "0.7.10" | 977 | +version = "0.8.2" |
| 922 | source = "registry+https://github.com/rust-lang/crates.io-index" | 978 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 923 | -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" | 979 | +checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" |
| 924 | dependencies = [ | 980 | dependencies = [ |
| 925 | - "const-oid 0.9.6", | 981 | + "const-oid", |
| 926 | "pem-rfc7468", | 982 | "pem-rfc7468", |
| 927 | "zeroize", | 983 | "zeroize", |
| 928 | ] | 984 | ] |
| @@ -943,7 +999,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 943 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" | 999 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" |
| 944 | dependencies = [ | 1000 | dependencies = [ |
| 945 | "block-buffer 0.10.4", | 1001 | "block-buffer 0.10.4", |
| 946 | - "const-oid 0.9.6", | ||
| 947 | "crypto-common 0.1.7", | 1002 | "crypto-common 0.1.7", |
| 948 | "subtle", | 1003 | "subtle", |
| 949 | ] | 1004 | ] |
| @@ -955,7 +1010,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 955 | checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" | 1010 | checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" |
| 956 | dependencies = [ | 1011 | dependencies = [ |
| 957 | "block-buffer 0.12.1", | 1012 | "block-buffer 0.12.1", |
| 958 | - "const-oid 0.10.2", | 1013 | + "const-oid", |
| 959 | "crypto-common 0.2.2", | 1014 | "crypto-common 0.2.2", |
| 960 | ] | 1015 | ] |
| 961 | 1016 | ||
| @@ -1783,16 +1838,15 @@ dependencies = [ | |||
| 1783 | [[package]] | 1838 | [[package]] |
| 1784 | name = "im-client" | 1839 | name = "im-client" |
| 1785 | version = "0.1.0" | 1840 | version = "0.1.0" |
| 1786 | -source = "git+https://github.com/DizeyLab/im?rev=509d0e7#509d0e7b19104ad3ae2e1dc82c65e1f38dfe7d9b" | 1841 | +source = "git+https://github.com/DizeyLab/im?rev=25140f3#25140f308a711d4090fa75bb29558a3f5335587c" |
| 1787 | dependencies = [ | 1842 | dependencies = [ |
| 1788 | - "base64 0.22.1", | 1843 | + "base64 0.23.1", |
| 1789 | "chacha20poly1305", | 1844 | "chacha20poly1305", |
| 1790 | "rand 0.10.2", | 1845 | "rand 0.10.2", |
| 1791 | "reqwest", | 1846 | "reqwest", |
| 1792 | "rsa", | 1847 | "rsa", |
| 1793 | "serde", | 1848 | "serde", |
| 1794 | "serde_json", | 1849 | "serde_json", |
| 1795 | - "sha2 0.10.9", | ||
| 1796 | "sha2 0.11.0", | 1850 | "sha2 0.11.0", |
| 1797 | "subtle", | 1851 | "subtle", |
| 1798 | "thiserror", | 1852 | "thiserror", |
| @@ -1820,6 +1874,15 @@ dependencies = [ | |||
| 1820 | "generic-array", | 1874 | "generic-array", |
| 1821 | ] | 1875 | ] |
| 1822 | 1876 | ||
| 1877 | +[[package]] | ||
| 1878 | +name = "inout" | ||
| 1879 | +version = "0.2.2" | ||
| 1880 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1881 | +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" | ||
| 1882 | +dependencies = [ | ||
| 1883 | + "hybrid-array", | ||
| 1884 | +] | ||
| 1885 | + | ||
| 1823 | [[package]] | 1886 | [[package]] |
| 1824 | name = "intrusive-collections" | 1887 | name = "intrusive-collections" |
| 1825 | version = "0.9.7" | 1888 | version = "0.9.7" |
| @@ -1889,16 +1952,15 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" | |||
| 1889 | name = "iz-client" | 1952 | name = "iz-client" |
| 1890 | version = "0.1.0" | 1953 | version = "0.1.0" |
| 1891 | dependencies = [ | 1954 | dependencies = [ |
| 1892 | - "base64 0.22.1", | 1955 | + "base64 0.23.1", |
| 1893 | "chacha20poly1305", | 1956 | "chacha20poly1305", |
| 1894 | "http", | 1957 | "http", |
| 1895 | "rand 0.10.2", | 1958 | "rand 0.10.2", |
| 1896 | - "rand_core 0.6.4", | 1959 | + "rand_core 0.10.1", |
| 1897 | "reqwest", | 1960 | "reqwest", |
| 1898 | "rsa", | 1961 | "rsa", |
| 1899 | "serde", | 1962 | "serde", |
| 1900 | "serde_json", | 1963 | "serde_json", |
| 1901 | - "sha2 0.10.9", | ||
| 1902 | "sha2 0.11.0", | 1964 | "sha2 0.11.0", |
| 1903 | "subtle", | 1965 | "subtle", |
| 1904 | "thiserror", | 1966 | "thiserror", |
| @@ -1912,7 +1974,7 @@ name = "iz-core" | |||
| 1912 | version = "0.1.0" | 1974 | version = "0.1.0" |
| 1913 | dependencies = [ | 1975 | dependencies = [ |
| 1914 | "async-trait", | 1976 | "async-trait", |
| 1915 | - "base64 0.22.1", | 1977 | + "base64 0.23.1", |
| 1916 | "chacha20poly1305", | 1978 | "chacha20poly1305", |
| 1917 | "rand 0.10.2", | 1979 | "rand 0.10.2", |
| 1918 | "serde", | 1980 | "serde", |
| @@ -1924,7 +1986,7 @@ dependencies = [ | |||
| 1924 | "toml", | 1986 | "toml", |
| 1925 | "turso", | 1987 | "turso", |
| 1926 | "ulid", | 1988 | "ulid", |
| 1927 | - "zip", | 1989 | + "zip 9.0.0-pre3", |
| 1928 | ] | 1990 | ] |
| 1929 | 1991 | ||
| 1930 | [[package]] | 1992 | [[package]] |
| @@ -1942,17 +2004,17 @@ dependencies = [ | |||
| 1942 | "iz-core", | 2004 | "iz-core", |
| 1943 | "lettre", | 2005 | "lettre", |
| 1944 | "parking_lot", | 2006 | "parking_lot", |
| 1945 | - "quick-xml", | 2007 | + "quick-xml 0.42.0", |
| 1946 | "reqwest", | 2008 | "reqwest", |
| 1947 | "serde", | 2009 | "serde", |
| 1948 | "serde_json", | 2010 | "serde_json", |
| 1949 | - "sha2 0.10.9", | 2011 | + "sha2 0.11.0", |
| 1950 | "thiserror", | 2012 | "thiserror", |
| 1951 | "time", | 2013 | "time", |
| 1952 | "tokio", | 2014 | "tokio", |
| 1953 | "topcoat", | 2015 | "topcoat", |
| 1954 | "ulid", | 2016 | "ulid", |
| 1955 | - "zip", | 2017 | + "zip 9.0.0-pre3", |
| 1956 | ] | 2018 | ] |
| 1957 | 2019 | ||
| 1958 | [[package]] | 2020 | [[package]] |
| @@ -2039,9 +2101,6 @@ name = "lazy_static" | |||
| 2039 | version = "1.5.0" | 2101 | version = "1.5.0" |
| 2040 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2102 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2041 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" | 2103 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" |
| 2042 | -dependencies = [ | ||
| 2043 | - "spin", | ||
| 2044 | -] | ||
| 2045 | 2104 | ||
| 2046 | [[package]] | 2105 | [[package]] |
| 2047 | name = "lazycell" | 2106 | name = "lazycell" |
| @@ -2411,22 +2470,6 @@ dependencies = [ | |||
| 2411 | "num-traits", | 2470 | "num-traits", |
| 2412 | ] | 2471 | ] |
| 2413 | 2472 | ||
| 2414 | -[[package]] | ||
| 2415 | -name = "num-bigint-dig" | ||
| 2416 | -version = "0.8.6" | ||
| 2417 | -source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 2418 | -checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" | ||
| 2419 | -dependencies = [ | ||
| 2420 | - "lazy_static", | ||
| 2421 | - "libm", | ||
| 2422 | - "num-integer", | ||
| 2423 | - "num-iter", | ||
| 2424 | - "num-traits", | ||
| 2425 | - "rand 0.8.8", | ||
| 2426 | - "smallvec", | ||
| 2427 | - "zeroize", | ||
| 2428 | -] | ||
| 2429 | - | ||
| 2430 | [[package]] | 2473 | [[package]] |
| 2431 | name = "num-conv" | 2474 | name = "num-conv" |
| 2432 | version = "0.2.2" | 2475 | version = "0.2.2" |
| @@ -2442,16 +2485,6 @@ dependencies = [ | |||
| 2442 | "num-traits", | 2485 | "num-traits", |
| 2443 | ] | 2486 | ] |
| 2444 | 2487 | ||
| 2445 | -[[package]] | ||
| 2446 | -name = "num-iter" | ||
| 2447 | -version = "0.1.46" | ||
| 2448 | -source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 2449 | -checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" | ||
| 2450 | -dependencies = [ | ||
| 2451 | - "num-integer", | ||
| 2452 | - "num-traits", | ||
| 2453 | -] | ||
| 2454 | - | ||
| 2455 | [[package]] | 2488 | [[package]] |
| 2456 | name = "num-traits" | 2489 | name = "num-traits" |
| 2457 | version = "0.2.19" | 2490 | version = "0.2.19" |
| @@ -2459,7 +2492,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 2459 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" | 2492 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" |
| 2460 | dependencies = [ | 2493 | dependencies = [ |
| 2461 | "autocfg", | 2494 | "autocfg", |
| 2462 | - "libm", | ||
| 2463 | ] | 2495 | ] |
| 2464 | 2496 | ||
| 2465 | [[package]] | 2497 | [[package]] |
| @@ -2556,9 +2588,9 @@ checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" | |||
| 2556 | 2588 | ||
| 2557 | [[package]] | 2589 | [[package]] |
| 2558 | name = "pem-rfc7468" | 2590 | name = "pem-rfc7468" |
| 2559 | -version = "0.7.0" | 2591 | +version = "1.0.0" |
| 2560 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2592 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2561 | -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" | 2593 | +checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" |
| 2562 | dependencies = [ | 2594 | dependencies = [ |
| 2563 | "base64ct", | 2595 | "base64ct", |
| 2564 | ] | 2596 | ] |
| @@ -2619,20 +2651,19 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" | |||
| 2619 | 2651 | ||
| 2620 | [[package]] | 2652 | [[package]] |
| 2621 | name = "pkcs1" | 2653 | name = "pkcs1" |
| 2622 | -version = "0.7.5" | 2654 | +version = "0.8.0-rc.4" |
| 2623 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2655 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2624 | -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" | 2656 | +checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e" |
| 2625 | dependencies = [ | 2657 | dependencies = [ |
| 2626 | "der", | 2658 | "der", |
| 2627 | - "pkcs8", | ||
| 2628 | "spki", | 2659 | "spki", |
| 2629 | ] | 2660 | ] |
| 2630 | 2661 | ||
| 2631 | [[package]] | 2662 | [[package]] |
| 2632 | name = "pkcs8" | 2663 | name = "pkcs8" |
| 2633 | -version = "0.10.2" | 2664 | +version = "0.11.0" |
| 2634 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2665 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2635 | -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" | 2666 | +checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" |
| 2636 | dependencies = [ | 2667 | dependencies = [ |
| 2637 | "der", | 2668 | "der", |
| 2638 | "spki", | 2669 | "spki", |
| @@ -2660,13 +2691,12 @@ dependencies = [ | |||
| 2660 | 2691 | ||
| 2661 | [[package]] | 2692 | [[package]] |
| 2662 | name = "poly1305" | 2693 | name = "poly1305" |
| 2663 | -version = "0.8.0" | 2694 | +version = "0.9.1" |
| 2664 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2695 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2665 | -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" | 2696 | +checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c" |
| 2666 | dependencies = [ | 2697 | dependencies = [ |
| 2667 | - "cpufeatures 0.2.17", | 2698 | + "cpufeatures 0.3.1", |
| 2668 | - "opaque-debug", | 2699 | + "universal-hash 0.6.1", |
| 2669 | - "universal-hash", | ||
| 2670 | ] | 2700 | ] |
| 2671 | 2701 | ||
| 2672 | [[package]] | 2702 | [[package]] |
| @@ -2678,7 +2708,7 @@ dependencies = [ | |||
| 2678 | "cfg-if", | 2708 | "cfg-if", |
| 2679 | "cpufeatures 0.2.17", | 2709 | "cpufeatures 0.2.17", |
| 2680 | "opaque-debug", | 2710 | "opaque-debug", |
| 2681 | - "universal-hash", | 2711 | + "universal-hash 0.5.1", |
| 2682 | ] | 2712 | ] |
| 2683 | 2713 | ||
| 2684 | [[package]] | 2714 | [[package]] |
| @@ -2778,6 +2808,15 @@ dependencies = [ | |||
| 2778 | "memchr", | 2808 | "memchr", |
| 2779 | ] | 2809 | ] |
| 2780 | 2810 | ||
| 2811 | +[[package]] | ||
| 2812 | +name = "quick-xml" | ||
| 2813 | +version = "0.42.0" | ||
| 2814 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 2815 | +checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b" | ||
| 2816 | +dependencies = [ | ||
| 2817 | + "memchr", | ||
| 2818 | +] | ||
| 2819 | + | ||
| 2781 | [[package]] | 2820 | [[package]] |
| 2782 | name = "quinn" | 2821 | name = "quinn" |
| 2783 | version = "0.11.11" | 2822 | version = "0.11.11" |
| @@ -2895,7 +2934,7 @@ version = "0.10.2" | |||
| 2895 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2934 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2896 | checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" | 2935 | checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" |
| 2897 | dependencies = [ | 2936 | dependencies = [ |
| 2898 | - "chacha20 0.10.2", | 2937 | + "chacha20", |
| 2899 | "getrandom 0.4.3", | 2938 | "getrandom 0.4.3", |
| 2900 | "rand_core 0.10.1", | 2939 | "rand_core 0.10.1", |
| 2901 | ] | 2940 | ] |
| @@ -3115,21 +3154,19 @@ dependencies = [ | |||
| 3115 | 3154 | ||
| 3116 | [[package]] | 3155 | [[package]] |
| 3117 | name = "rsa" | 3156 | name = "rsa" |
| 3118 | -version = "0.9.10" | 3157 | +version = "0.10.0-rc.18" |
| 3119 | source = "registry+https://github.com/rust-lang/crates.io-index" | 3158 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3120 | -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" | 3159 | +checksum = "30b2aa4ba0d89f73d1e332df05be0eeab8840351c36ca5654341dfdb57bb3caf" |
| 3121 | dependencies = [ | 3160 | dependencies = [ |
| 3122 | - "const-oid 0.9.6", | 3161 | + "const-oid", |
| 3123 | - "digest 0.10.7", | 3162 | + "crypto-bigint", |
| 3124 | - "num-bigint-dig", | 3163 | + "crypto-primes", |
| 3125 | - "num-integer", | 3164 | + "digest 0.11.3", |
| 3126 | - "num-traits", | ||
| 3127 | "pkcs1", | 3165 | "pkcs1", |
| 3128 | "pkcs8", | 3166 | "pkcs8", |
| 3129 | - "rand_core 0.6.4", | 3167 | + "rand_core 0.10.1", |
| 3130 | "signature", | 3168 | "signature", |
| 3131 | "spki", | 3169 | "spki", |
| 3132 | - "subtle", | ||
| 3133 | "zeroize", | 3170 | "zeroize", |
| 3134 | ] | 3171 | ] |
| 3135 | 3172 | ||
| @@ -3423,6 +3460,16 @@ dependencies = [ | |||
| 3423 | "serde", | 3460 | "serde", |
| 3424 | ] | 3461 | ] |
| 3425 | 3462 | ||
| 3463 | +[[package]] | ||
| 3464 | +name = "serdect" | ||
| 3465 | +version = "0.4.3" | ||
| 3466 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 3467 | +checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" | ||
| 3468 | +dependencies = [ | ||
| 3469 | + "base16ct", | ||
| 3470 | + "serde", | ||
| 3471 | +] | ||
| 3472 | + | ||
| 3426 | [[package]] | 3473 | [[package]] |
| 3427 | name = "sha1" | 3474 | name = "sha1" |
| 3428 | version = "0.10.7" | 3475 | version = "0.10.7" |
| @@ -3515,12 +3562,12 @@ dependencies = [ | |||
| 3515 | 3562 | ||
| 3516 | [[package]] | 3563 | [[package]] |
| 3517 | name = "signature" | 3564 | name = "signature" |
| 3518 | -version = "2.2.0" | 3565 | +version = "3.0.0" |
| 3519 | source = "registry+https://github.com/rust-lang/crates.io-index" | 3566 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3520 | -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" | 3567 | +checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" |
| 3521 | dependencies = [ | 3568 | dependencies = [ |
| 3522 | - "digest 0.10.7", | 3569 | + "digest 0.11.3", |
| 3523 | - "rand_core 0.6.4", | 3570 | + "rand_core 0.10.1", |
| 3524 | ] | 3571 | ] |
| 3525 | 3572 | ||
| 3526 | [[package]] | 3573 | [[package]] |
| @@ -3605,9 +3652,9 @@ checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" | |||
| 3605 | 3652 | ||
| 3606 | [[package]] | 3653 | [[package]] |
| 3607 | name = "spki" | 3654 | name = "spki" |
| 3608 | -version = "0.7.3" | 3655 | +version = "0.8.0" |
| 3609 | source = "registry+https://github.com/rust-lang/crates.io-index" | 3656 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3610 | -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" | 3657 | +checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f" |
| 3611 | dependencies = [ | 3658 | dependencies = [ |
| 3612 | "base64ct", | 3659 | "base64ct", |
| 3613 | "der", | 3660 | "der", |
| @@ -4070,14 +4117,13 @@ checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" | |||
| 4070 | 4117 | ||
| 4071 | [[package]] | 4118 | [[package]] |
| 4072 | name = "topcoat" | 4119 | name = "topcoat" |
| 4073 | -version = "0.6.2" | 4120 | +version = "0.8.0" |
| 4074 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4121 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4075 | -checksum = "050c11e7b0e146a2b1eb15855abd5fa03e2754eb880922f8b6cab5ec71cac5aa" | 4122 | +checksum = "f3c199295b1c52e0a9c88a2b0518f6bc7522503cd0bb06d9f4742c515ac4df0a" |
| 4076 | dependencies = [ | 4123 | dependencies = [ |
| 4077 | "futures-util", | 4124 | "futures-util", |
| 4078 | "inventory", | 4125 | "inventory", |
| 4079 | "serde", | 4126 | "serde", |
| 4080 | - "serde_urlencoded", | ||
| 4081 | "tokio", | 4127 | "tokio", |
| 4082 | "tokio-tungstenite", | 4128 | "tokio-tungstenite", |
| 4083 | "topcoat-asset", | 4129 | "topcoat-asset", |
| @@ -4098,9 +4144,9 @@ dependencies = [ | |||
| 4098 | 4144 | ||
| 4099 | [[package]] | 4145 | [[package]] |
| 4100 | name = "topcoat-asset" | 4146 | name = "topcoat-asset" |
| 4101 | -version = "0.6.2" | 4147 | +version = "0.8.0" |
| 4102 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4148 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4103 | -checksum = "a72e4ba8cb6a9d29613a25c2151e72d887b4a79b3f179b497734eed0e65ea702" | 4149 | +checksum = "fba199ae779d0409672929e7c32711ac35e87c9e39e0823d0b33b6293e3e0011" |
| 4104 | dependencies = [ | 4150 | dependencies = [ |
| 4105 | "http", | 4151 | "http", |
| 4106 | "memchr", | 4152 | "memchr", |
| @@ -4116,9 +4162,9 @@ dependencies = [ | |||
| 4116 | 4162 | ||
| 4117 | [[package]] | 4163 | [[package]] |
| 4118 | name = "topcoat-cookie" | 4164 | name = "topcoat-cookie" |
| 4119 | -version = "0.6.2" | 4165 | +version = "0.8.0" |
| 4120 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4166 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4121 | -checksum = "f68c83654c4bf075f667d39463cd38ef0be9fee057054454b06612efe16e7a37" | 4167 | +checksum = "3cb0bf2f95c1931d32d579389695e8cf221d114f9629a57fc005d7a0bb459c0d" |
| 4122 | dependencies = [ | 4168 | dependencies = [ |
| 4123 | "cookie", | 4169 | "cookie", |
| 4124 | "getrandom 0.2.17", | 4170 | "getrandom 0.2.17", |
| @@ -4131,9 +4177,9 @@ dependencies = [ | |||
| 4131 | 4177 | ||
| 4132 | [[package]] | 4178 | [[package]] |
| 4133 | name = "topcoat-core" | 4179 | name = "topcoat-core" |
| 4134 | -version = "0.6.2" | 4180 | +version = "0.8.0" |
| 4135 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4181 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4136 | -checksum = "42f94adaa301d7a4b949d650fa803323c00cc8ffa8bf1984511c1ec5d390b6c6" | 4182 | +checksum = "d88c5ed693dd383ba8a4112f5b665bdb7e979ada413a7b5f9ede6935fe18e8e6" |
| 4137 | dependencies = [ | 4183 | dependencies = [ |
| 4138 | "anyhow", | 4184 | "anyhow", |
| 4139 | "anymap3", | 4185 | "anymap3", |
| @@ -4147,9 +4193,9 @@ dependencies = [ | |||
| 4147 | 4193 | ||
| 4148 | [[package]] | 4194 | [[package]] |
| 4149 | name = "topcoat-core-grammar" | 4195 | name = "topcoat-core-grammar" |
| 4150 | -version = "0.6.2" | 4196 | +version = "0.8.0" |
| 4151 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4197 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4152 | -checksum = "0756aa9285794c155624494bc563d56859e35205313db883a89d7dabfa6d0393" | 4198 | +checksum = "ce257f5c2248b4d7bf1bbd76a0e71709221f06d690462a49aad5929732c42001" |
| 4153 | dependencies = [ | 4199 | dependencies = [ |
| 4154 | "proc-macro-crate", | 4200 | "proc-macro-crate", |
| 4155 | "proc-macro2", | 4201 | "proc-macro2", |
| @@ -4159,9 +4205,9 @@ dependencies = [ | |||
| 4159 | 4205 | ||
| 4160 | [[package]] | 4206 | [[package]] |
| 4161 | name = "topcoat-core-macro" | 4207 | name = "topcoat-core-macro" |
| 4162 | -version = "0.6.2" | 4208 | +version = "0.8.0" |
| 4163 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4209 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4164 | -checksum = "e4908dba6268c8592be73e9059cdefa053066e1b1bc879c1c9a5d8d3b6e97aad" | 4210 | +checksum = "5d239098a8c674f16120e7bfcba6f670865c807eec2a0e2648cb319d300fab39" |
| 4165 | dependencies = [ | 4211 | dependencies = [ |
| 4166 | "quote", | 4212 | "quote", |
| 4167 | "syn 2.0.119", | 4213 | "syn 2.0.119", |
| @@ -4170,9 +4216,9 @@ dependencies = [ | |||
| 4170 | 4216 | ||
| 4171 | [[package]] | 4217 | [[package]] |
| 4172 | name = "topcoat-font" | 4218 | name = "topcoat-font" |
| 4173 | -version = "0.6.2" | 4219 | +version = "0.8.0" |
| 4174 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4220 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4175 | -checksum = "e7b8308aff65f46bbe2f58371fc9823db596236bd0ea3c9d87de6534fd977e60" | 4221 | +checksum = "8ccc2da492bfdcf2d23d761b60338eb20ad178fd754ef19570abe6030663137d" |
| 4176 | dependencies = [ | 4222 | dependencies = [ |
| 4177 | "heck", | 4223 | "heck", |
| 4178 | "inventory", | 4224 | "inventory", |
| @@ -4187,9 +4233,9 @@ dependencies = [ | |||
| 4187 | 4233 | ||
| 4188 | [[package]] | 4234 | [[package]] |
| 4189 | name = "topcoat-font-grammar" | 4235 | name = "topcoat-font-grammar" |
| 4190 | -version = "0.6.2" | 4236 | +version = "0.8.0" |
| 4191 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4237 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4192 | -checksum = "5b7d68e226827fb7531d0dba69cb74fa7b82515f8428fd1a75f556f5a2bf87c1" | 4238 | +checksum = "6125e270bb16bf826a54e4b40b41484682b2b660af4803688887f64a9918745a" |
| 4193 | dependencies = [ | 4239 | dependencies = [ |
| 4194 | "proc-macro2", | 4240 | "proc-macro2", |
| 4195 | "quote", | 4241 | "quote", |
| @@ -4200,9 +4246,9 @@ dependencies = [ | |||
| 4200 | 4246 | ||
| 4201 | [[package]] | 4247 | [[package]] |
| 4202 | name = "topcoat-font-macro" | 4248 | name = "topcoat-font-macro" |
| 4203 | -version = "0.6.2" | 4249 | +version = "0.8.0" |
| 4204 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4250 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4205 | -checksum = "e655c430bcb380f879603ea750c6222ade2ff3ade33869d9eaa32e3fc49f5469" | 4251 | +checksum = "5f46d0a9c08e7bf774683c05add490824af80a844f410e6ffc9fdaf00c88d7be" |
| 4206 | dependencies = [ | 4252 | dependencies = [ |
| 4207 | "quote", | 4253 | "quote", |
| 4208 | "syn 2.0.119", | 4254 | "syn 2.0.119", |
| @@ -4211,9 +4257,9 @@ dependencies = [ | |||
| 4211 | 4257 | ||
| 4212 | [[package]] | 4258 | [[package]] |
| 4213 | name = "topcoat-mail" | 4259 | name = "topcoat-mail" |
| 4214 | -version = "0.6.2" | 4260 | +version = "0.8.0" |
| 4215 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4261 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4216 | -checksum = "959c9c32172ad3840f94c589a29bd143c072661c9abf2215a68fd76440ed2300" | 4262 | +checksum = "1b8fa0e1ad5a4f4419c50b783ac565426df5c30dfa3dc9ca9602c8cd1c3535a3" |
| 4217 | dependencies = [ | 4263 | dependencies = [ |
| 4218 | "lettre", | 4264 | "lettre", |
| 4219 | "thiserror", | 4265 | "thiserror", |
| @@ -4225,9 +4271,9 @@ dependencies = [ | |||
| 4225 | 4271 | ||
| 4226 | [[package]] | 4272 | [[package]] |
| 4227 | name = "topcoat-router" | 4273 | name = "topcoat-router" |
| 4228 | -version = "0.6.2" | 4274 | +version = "0.8.0" |
| 4229 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4275 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4230 | -checksum = "e062bd348df5647f6904f4f4045b3c92c08c4a8826196e8e91a51aade00b5764" | 4276 | +checksum = "9f452945373fac2b61a4050639681829e99afeea872faebc93ef0b03c4211335" |
| 4231 | dependencies = [ | 4277 | dependencies = [ |
| 4232 | "bytes", | 4278 | "bytes", |
| 4233 | "form_urlencoded", | 4279 | "form_urlencoded", |
| @@ -4243,6 +4289,7 @@ dependencies = [ | |||
| 4243 | "matchit", | 4289 | "matchit", |
| 4244 | "multer", | 4290 | "multer", |
| 4245 | "percent-encoding", | 4291 | "percent-encoding", |
| 4292 | + "pin-project-lite", | ||
| 4246 | "ref-cast", | 4293 | "ref-cast", |
| 4247 | "serde", | 4294 | "serde", |
| 4248 | "serde_json", | 4295 | "serde_json", |
| @@ -4257,9 +4304,9 @@ dependencies = [ | |||
| 4257 | 4304 | ||
| 4258 | [[package]] | 4305 | [[package]] |
| 4259 | name = "topcoat-router-grammar" | 4306 | name = "topcoat-router-grammar" |
| 4260 | -version = "0.6.2" | 4307 | +version = "0.8.0" |
| 4261 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4308 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4262 | -checksum = "c052423d2aa4039036f1ac5567d1e2dac48897602d34561b3024a87830e5bdce" | 4309 | +checksum = "188df45ec401d790e3dd84564580c5c436a456331a187bdbfb7441f8e48fa1ca" |
| 4263 | dependencies = [ | 4310 | dependencies = [ |
| 4264 | "heck", | 4311 | "heck", |
| 4265 | "proc-macro2", | 4312 | "proc-macro2", |
| @@ -4270,9 +4317,9 @@ dependencies = [ | |||
| 4270 | 4317 | ||
| 4271 | [[package]] | 4318 | [[package]] |
| 4272 | name = "topcoat-router-macro" | 4319 | name = "topcoat-router-macro" |
| 4273 | -version = "0.6.2" | 4320 | +version = "0.8.0" |
| 4274 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4321 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4275 | -checksum = "cea98692b786bab3adda35a60d71981f60b2a98c6e7105ac92e582b7c9ce9cab" | 4322 | +checksum = "ac6f9a61d3ecfe1252b861795070c4317aca6b816382919d9c941eccad2fe42d" |
| 4276 | dependencies = [ | 4323 | dependencies = [ |
| 4277 | "quote", | 4324 | "quote", |
| 4278 | "syn 2.0.119", | 4325 | "syn 2.0.119", |
| @@ -4281,9 +4328,9 @@ dependencies = [ | |||
| 4281 | 4328 | ||
| 4282 | [[package]] | 4329 | [[package]] |
| 4283 | name = "topcoat-runtime" | 4330 | name = "topcoat-runtime" |
| 4284 | -version = "0.6.2" | 4331 | +version = "0.8.0" |
| 4285 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4332 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4286 | -checksum = "5dea200c86ca554bab7410f09cae8790a8adcbfd8f306eb78db7092ca71f8aae" | 4333 | +checksum = "b75367a6fb32878f28bb1e42fe97385c9b14f1d3455b0bb69afb399260a8995a" |
| 4287 | dependencies = [ | 4334 | dependencies = [ |
| 4288 | "inventory", | 4335 | "inventory", |
| 4289 | "ref-cast", | 4336 | "ref-cast", |
| @@ -4293,14 +4340,13 @@ dependencies = [ | |||
| 4293 | "topcoat-core", | 4340 | "topcoat-core", |
| 4294 | "topcoat-router", | 4341 | "topcoat-router", |
| 4295 | "topcoat-view", | 4342 | "topcoat-view", |
| 4296 | - "uuid", | ||
| 4297 | ] | 4343 | ] |
| 4298 | 4344 | ||
| 4299 | [[package]] | 4345 | [[package]] |
| 4300 | name = "topcoat-runtime-grammar" | 4346 | name = "topcoat-runtime-grammar" |
| 4301 | -version = "0.6.2" | 4347 | +version = "0.8.0" |
| 4302 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4348 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4303 | -checksum = "87b73f7e4e10f49e006a71dd43e8ee629c76c08451acbc51faa7ec5b6952c53c" | 4349 | +checksum = "c19d5cf0ad59525a9fdd0a6ada36448833b39b85602736df16d32712f6c3a3c8" |
| 4304 | dependencies = [ | 4350 | dependencies = [ |
| 4305 | "proc-macro2", | 4351 | "proc-macro2", |
| 4306 | "quote", | 4352 | "quote", |
| @@ -4314,9 +4360,9 @@ dependencies = [ | |||
| 4314 | 4360 | ||
| 4315 | [[package]] | 4361 | [[package]] |
| 4316 | name = "topcoat-runtime-macro" | 4362 | name = "topcoat-runtime-macro" |
| 4317 | -version = "0.6.2" | 4363 | +version = "0.8.0" |
| 4318 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4364 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4319 | -checksum = "5dc3e4e245abcaea6af780437cae072e8f2157c9852ec5b3058a658c61b9e0bf" | 4365 | +checksum = "3504cd2966788c4cb6f417a9f73faf3ae2631c5aa415bc0d37d142ba597d5c42" |
| 4320 | dependencies = [ | 4366 | dependencies = [ |
| 4321 | "quote", | 4367 | "quote", |
| 4322 | "syn 2.0.119", | 4368 | "syn 2.0.119", |
| @@ -4325,9 +4371,9 @@ dependencies = [ | |||
| 4325 | 4371 | ||
| 4326 | [[package]] | 4372 | [[package]] |
| 4327 | name = "topcoat-session" | 4373 | name = "topcoat-session" |
| 4328 | -version = "0.6.2" | 4374 | +version = "0.8.0" |
| 4329 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4375 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4330 | -checksum = "e079e8c5a63987d7f929ab05a75922feab1fe390a9cfa2c101eb35829e67eac2" | 4376 | +checksum = "d432a276f3d7e4e0af0f9789ee0c919fbfbf8d2025d0dac7f8072a918521cf6d" |
| 4331 | dependencies = [ | 4377 | dependencies = [ |
| 4332 | "base64 0.22.1", | 4378 | "base64 0.22.1", |
| 4333 | "getrandom 0.4.3", | 4379 | "getrandom 0.4.3", |
| @@ -4342,25 +4388,26 @@ dependencies = [ | |||
| 4342 | 4388 | ||
| 4343 | [[package]] | 4389 | [[package]] |
| 4344 | name = "topcoat-view" | 4390 | name = "topcoat-view" |
| 4345 | -version = "0.6.2" | 4391 | +version = "0.8.0" |
| 4346 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4392 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4347 | -checksum = "5904449bd6f633759d187fa621ded68178b551428c297959fd53d8fb91f3e6f6" | 4393 | +checksum = "4acc959c83729cb4b967c2e7de8ee78a2fc3216cceb1be650ee9524fabd26baa" |
| 4348 | dependencies = [ | 4394 | dependencies = [ |
| 4395 | + "base64 0.22.1", | ||
| 4349 | "futures-core", | 4396 | "futures-core", |
| 4350 | "futures-util", | 4397 | "futures-util", |
| 4351 | "http", | 4398 | "http", |
| 4352 | - "itoa", | ||
| 4353 | "memchr", | 4399 | "memchr", |
| 4354 | "pin-project-lite", | 4400 | "pin-project-lite", |
| 4401 | + "siphasher", | ||
| 4355 | "smallvec", | 4402 | "smallvec", |
| 4356 | "topcoat-core", | 4403 | "topcoat-core", |
| 4357 | ] | 4404 | ] |
| 4358 | 4405 | ||
| 4359 | [[package]] | 4406 | [[package]] |
| 4360 | name = "topcoat-view-grammar" | 4407 | name = "topcoat-view-grammar" |
| 4361 | -version = "0.6.2" | 4408 | +version = "0.8.0" |
| 4362 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4409 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4363 | -checksum = "1bf4293156d7c5fa7960edc573b686eb27426dcd888bfbe9e532304178cdda24" | 4410 | +checksum = "fa71393a00dba3ce203d3236e24311851134721f5bfae6a17bfacd709a983660" |
| 4364 | dependencies = [ | 4411 | dependencies = [ |
| 4365 | "heck", | 4412 | "heck", |
| 4366 | "proc-macro2", | 4413 | "proc-macro2", |
| @@ -4372,9 +4419,9 @@ dependencies = [ | |||
| 4372 | 4419 | ||
| 4373 | [[package]] | 4420 | [[package]] |
| 4374 | name = "topcoat-view-macro" | 4421 | name = "topcoat-view-macro" |
| 4375 | -version = "0.6.2" | 4422 | +version = "0.8.0" |
| 4376 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4423 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4377 | -checksum = "58ab2b200eda4516abdb543f307006d83fedd3681b871d2042c17106c688f716" | 4424 | +checksum = "2a625be243364f6674204ba412700d9eed2a1c9168f7add3b1020be4825f0e49" |
| 4378 | dependencies = [ | 4425 | dependencies = [ |
| 4379 | "quote", | 4426 | "quote", |
| 4380 | "syn 2.0.119", | 4427 | "syn 2.0.119", |
| @@ -4792,11 +4839,11 @@ dependencies = [ | |||
| 4792 | 4839 | ||
| 4793 | [[package]] | 4840 | [[package]] |
| 4794 | name = "ulid" | 4841 | name = "ulid" |
| 4795 | -version = "1.2.1" | 4842 | +version = "3.0.0" |
| 4796 | source = "registry+https://github.com/rust-lang/crates.io-index" | 4843 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4797 | -checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe" | 4844 | +checksum = "947dde63b6d514cc5e044edad4e0ca7261afd1099d16c83d942cb2b2f348689c" |
| 4798 | dependencies = [ | 4845 | dependencies = [ |
| 4799 | - "rand 0.9.5", | 4846 | + "rand 0.10.2", |
| 4800 | "web-time", | 4847 | "web-time", |
| 4801 | ] | 4848 | ] |
| 4802 | 4849 | ||
| @@ -4837,6 +4884,16 @@ dependencies = [ | |||
| 4837 | "subtle", | 4884 | "subtle", |
| 4838 | ] | 4885 | ] |
| 4839 | 4886 | ||
| 4887 | +[[package]] | ||
| 4888 | +name = "universal-hash" | ||
| 4889 | +version = "0.6.1" | ||
| 4890 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 4891 | +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" | ||
| 4892 | +dependencies = [ | ||
| 4893 | + "crypto-common 0.2.2", | ||
| 4894 | + "ctutils", | ||
| 4895 | +] | ||
| 4896 | + | ||
| 4840 | [[package]] | 4897 | [[package]] |
| 4841 | name = "untrusted" | 4898 | name = "untrusted" |
| 4842 | version = "0.9.0" | 4899 | version = "0.9.0" |
| @@ -5379,6 +5436,20 @@ dependencies = [ | |||
| 5379 | "zopfli", | 5436 | "zopfli", |
| 5380 | ] | 5437 | ] |
| 5381 | 5438 | ||
| 5439 | +[[package]] | ||
| 5440 | +name = "zip" | ||
| 5441 | +version = "9.0.0-pre3" | ||
| 5442 | +source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 5443 | +checksum = "58e8082c6efe6dbccc7e8ea3ebf6afe46a04847f2e0bcf772c8aebc933dd2ccf" | ||
| 5444 | +dependencies = [ | ||
| 5445 | + "crc32fast", | ||
| 5446 | + "flate2", | ||
| 5447 | + "indexmap", | ||
| 5448 | + "memchr", | ||
| 5449 | + "typed-path", | ||
| 5450 | + "zopfli", | ||
| 5451 | +] | ||
| 5452 | + | ||
| 5382 | [[package]] | 5453 | [[package]] |
| 5383 | name = "zlib-rs" | 5454 | name = "zlib-rs" |
| 5384 | version = "0.6.7" | 5455 | version = "0.6.7" |
Cargo.tomlmodified+5 -5
| @@ -11,21 +11,21 @@ repository = "https://github.com/DizeyLab/iz" | |||
| 11 | [workspace.dependencies] | 11 | [workspace.dependencies] |
| 12 | iz-core = { path = "crates/iz-core", default-features = false } | 12 | iz-core = { path = "crates/iz-core", default-features = false } |
| 13 | iz-client = { path = "crates/iz-client" } | 13 | iz-client = { path = "crates/iz-client" } |
| 14 | -im-client = { git = "https://github.com/DizeyLab/im", rev = "509d0e7", default-features = false } | 14 | +im-client = { git = "https://github.com/DizeyLab/im", rev = "25140f3", default-features = false } |
| 15 | serde = { version = "1.0.229", features = ["derive"] } | 15 | serde = { version = "1.0.229", features = ["derive"] } |
| 16 | serde_json = "1.0.151" | 16 | serde_json = "1.0.151" |
| 17 | thiserror = "2.0.20" | 17 | thiserror = "2.0.20" |
| 18 | -ulid = "1" | 18 | +ulid = "3" |
| 19 | time = { version = "0.3.55", features = ["serde", "formatting", "parsing", "macros"] } | 19 | time = { version = "0.3.55", features = ["serde", "formatting", "parsing", "macros"] } |
| 20 | tokio = { version = "1.53.1", features = ["full"] } | 20 | tokio = { version = "1.53.1", features = ["full"] } |
| 21 | turso = "=0.8.0-pre.10" | 21 | turso = "=0.8.0-pre.10" |
| 22 | rand = "0.10.2" | 22 | rand = "0.10.2" |
| 23 | sha2 = "0.11.0" | 23 | sha2 = "0.11.0" |
| 24 | subtle = "2.6.1" | 24 | subtle = "2.6.1" |
| 25 | -chacha20poly1305 = "0.10.1" | 25 | +chacha20poly1305 = "0.11.0" |
| 26 | -base64 = "0.22.1" | 26 | +base64 = "0.23.1" |
| 27 | toml = "1" | 27 | toml = "1" |
| 28 | -zip = { version = "8.6.0", default-features = false, features = ["deflate"] } | 28 | +zip = { version = "9.0.0-pre3", default-features = false, features = ["deflate"] } |
| 29 | 29 | ||
| 30 | [profile.release] | 30 | [profile.release] |
| 31 | codegen-units = 1 | 31 | codegen-units = 1 |
crates/iz-client/Cargo.tomlmodified+8 -9
| @@ -7,7 +7,7 @@ repository.workspace = true | |||
| 7 | description = "Drop-in OIDC client for topcoat apps authenticating against im (vendored from im-client via in-client)" | 7 | description = "Drop-in OIDC client for topcoat apps authenticating against im (vendored from im-client via in-client)" |
| 8 | 8 | ||
| 9 | [dependencies] | 9 | [dependencies] |
| 10 | -topcoat = { version = "0.6.2", default-features = false, features = [ | 10 | +topcoat = { version = "0.8.0", default-features = false, features = [ |
| 11 | "router", | 11 | "router", |
| 12 | "cookie", | 12 | "cookie", |
| 13 | ] } | 13 | ] } |
| @@ -21,10 +21,9 @@ rand.workspace = true | |||
| 21 | sha2.workspace = true | 21 | sha2.workspace = true |
| 22 | subtle.workspace = true | 22 | subtle.workspace = true |
| 23 | chacha20poly1305.workspace = true | 23 | chacha20poly1305.workspace = true |
| 24 | -# rsa 0.9 verifies through the digest 0.10 traits, so its hasher comes from | 24 | +# rsa 0.10 verifies through the digest 0.11 traits, so its hasher is the |
| 25 | -# the sha2 0.10 line; the workspace sha2 0.11 stays for PKCE. | 25 | +# workspace sha2 0.11 that PKCE already uses. |
| 26 | -sha2-for-rsa = { package = "sha2", version = "0.10", features = ["oid"] } | 26 | +rsa = "0.10.0-rc.18" |
| 27 | -rsa = "0.9.10" | ||
| 28 | reqwest = { version = "0.13.5", default-features = false, features = [ | 27 | reqwest = { version = "0.13.5", default-features = false, features = [ |
| 29 | "rustls", | 28 | "rustls", |
| 30 | "json", | 29 | "json", |
| @@ -36,7 +35,7 @@ reqwest = { version = "0.13.5", default-features = false, features = [ | |||
| 36 | test-seam = [] | 35 | test-seam = [] |
| 37 | 36 | ||
| 38 | [dev-dependencies] | 37 | [dev-dependencies] |
| 39 | -topcoat = { version = "0.6.2", default-features = false, features = [ | 38 | +topcoat = { version = "0.8.0", default-features = false, features = [ |
| 40 | "router", | 39 | "router", |
| 41 | "cookie", | 40 | "cookie", |
| 42 | "view", | 41 | "view", |
| @@ -44,9 +43,9 @@ topcoat = { version = "0.6.2", default-features = false, features = [ | |||
| 44 | "discover", | 43 | "discover", |
| 45 | ] } | 44 | ] } |
| 46 | http = "1.5" | 45 | http = "1.5" |
| 47 | -# Tests generate their own RSA keys, and rsa 0.9's RNG is the rand_core 0.6 | 46 | +# Tests generate their own RSA keys, and rsa 0.10's RNG is the rand_core 0.10 |
| 48 | -# line. | 47 | +# line that the workspace rand 0.10 provides. |
| 49 | -rand_core06 = { package = "rand_core", version = "0.6.4", features = ["getrandom"] } | 48 | +rand_core010 = { package = "rand_core", version = "0.10.1" } |
| 50 | 49 | ||
| 51 | [[example]] | 50 | [[example]] |
| 52 | name = "mint" | 51 | name = "mint" |
crates/iz-client/src/lib.rsmodified+11 -12
| @@ -350,7 +350,7 @@ fn seal(key: &[u8; 32], plaintext: &[u8]) -> String { | |||
| 350 | let mut nonce_bytes = [0u8; 24]; | 350 | let mut nonce_bytes = [0u8; 24]; |
| 351 | rand::rng().fill_bytes(&mut nonce_bytes); | 351 | rand::rng().fill_bytes(&mut nonce_bytes); |
| 352 | let ciphertext = cipher | 352 | let ciphertext = cipher |
| 353 | - .encrypt(XNonce::from_slice(&nonce_bytes), plaintext) | 353 | + .encrypt(&XNonce::from(nonce_bytes), plaintext) |
| 354 | .expect("XChaCha20-Poly1305 cannot fail on a payload this small"); | 354 | .expect("XChaCha20-Poly1305 cannot fail on a payload this small"); |
| 355 | let mut payload = nonce_bytes.to_vec(); | 355 | let mut payload = nonce_bytes.to_vec(); |
| 356 | payload.extend_from_slice(&ciphertext); | 356 | payload.extend_from_slice(&ciphertext); |
| @@ -364,9 +364,8 @@ fn open(key: &[u8; 32], sealed: &str) -> Option<Vec<u8>> { | |||
| 364 | } | 364 | } |
| 365 | let (nonce_bytes, ciphertext) = payload.split_at(24); | 365 | let (nonce_bytes, ciphertext) = payload.split_at(24); |
| 366 | let cipher = XChaCha20Poly1305::new(key.into()); | 366 | let cipher = XChaCha20Poly1305::new(key.into()); |
| 367 | - cipher | 367 | + let nonce: &XNonce = nonce_bytes.try_into().ok()?; |
| 368 | - .decrypt(XNonce::from_slice(nonce_bytes), ciphertext) | 368 | + cipher.decrypt(nonce, ciphertext).ok() |
| 369 | - .ok() | ||
| 370 | } | 369 | } |
| 371 | 370 | ||
| 372 | fn seal_json<T: Serialize>(key: &[u8; 32], value: &T) -> String { | 371 | fn seal_json<T: Serialize>(key: &[u8; 32], value: &T) -> String { |
| @@ -737,7 +736,7 @@ fn verify_claims( | |||
| 737 | .map_err(|e| Error::Token(e.to_string()))?; | 736 | .map_err(|e| Error::Token(e.to_string()))?; |
| 738 | let signature = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice()) | 737 | let signature = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice()) |
| 739 | .map_err(|e| Error::Token(e.to_string()))?; | 738 | .map_err(|e| Error::Token(e.to_string()))?; |
| 740 | - let verifying = rsa::pkcs1v15::VerifyingKey::<sha2_for_rsa::Sha256>::new(key.clone()); | 739 | + let verifying = rsa::pkcs1v15::VerifyingKey::<sha2::Sha256>::new(key.clone()); |
| 741 | verifying | 740 | verifying |
| 742 | .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature) | 741 | .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature) |
| 743 | .map_err(|_| Error::Token("bad signature".into()))?; | 742 | .map_err(|_| Error::Token("bad signature".into()))?; |
| @@ -798,8 +797,8 @@ async fn refetch_jwks(state: &IzClient) -> Result<()> { | |||
| 798 | continue; | 797 | continue; |
| 799 | }; | 798 | }; |
| 800 | let key = rsa::RsaPublicKey::new( | 799 | let key = rsa::RsaPublicKey::new( |
| 801 | - rsa::BigUint::from_bytes_be(&n), | 800 | + rsa::BoxedUint::from_be_slice_vartime(&n), |
| 802 | - rsa::BigUint::from_bytes_be(&e), | 801 | + rsa::BoxedUint::from_be_slice_vartime(&e), |
| 803 | ) | 802 | ) |
| 804 | .map_err(|err| Error::Token(format!("bad jwk {kid}: {err}")))?; | 803 | .map_err(|err| Error::Token(format!("bad jwk {kid}: {err}")))?; |
| 805 | keys.push((kid.to_string(), key)); | 804 | keys.push((kid.to_string(), key)); |
| @@ -821,8 +820,8 @@ mod tests { | |||
| 821 | 820 | ||
| 822 | fn keypair() -> (rsa::RsaPrivateKey, rsa::RsaPublicKey) { | 821 | fn keypair() -> (rsa::RsaPrivateKey, rsa::RsaPublicKey) { |
| 823 | // 2048-bit generation is slow for a unit test; 1024 is the smallest | 822 | // 2048-bit generation is slow for a unit test; 1024 is the smallest |
| 824 | - // rsa 0.9 accepts and the signature math under test is identical. | 823 | + // rsa accepts and the signature math under test is identical. |
| 825 | - let private = rsa::RsaPrivateKey::new(&mut rand_core06::OsRng, 1024).unwrap(); | 824 | + let private = rsa::RsaPrivateKey::new(&mut rand::rng(), 1024).unwrap(); |
| 826 | let public = private.to_public_key(); | 825 | let public = private.to_public_key(); |
| 827 | (private, public) | 826 | (private, public) |
| 828 | } | 827 | } |
| @@ -832,7 +831,7 @@ mod tests { | |||
| 832 | let mut out = b64url.encode(header.to_string()); | 831 | let mut out = b64url.encode(header.to_string()); |
| 833 | out.push('.'); | 832 | out.push('.'); |
| 834 | out.push_str(&b64url.encode(claims.to_string())); | 833 | out.push_str(&b64url.encode(claims.to_string())); |
| 835 | - let signing = rsa::pkcs1v15::SigningKey::<sha2_for_rsa::Sha256>::new(key.clone()); | 834 | + let signing = rsa::pkcs1v15::SigningKey::<sha2::Sha256>::new(key.clone()); |
| 836 | let signature = signing.sign(out.as_bytes()); | 835 | let signature = signing.sign(out.as_bytes()); |
| 837 | format!("{}.{}", out, b64url.encode(signature.to_bytes())) | 836 | format!("{}.{}", out, b64url.encode(signature.to_bytes())) |
| 838 | } | 837 | } |
| @@ -1206,8 +1205,8 @@ mod tests { | |||
| 1206 | serde_json::json!({ | 1205 | serde_json::json!({ |
| 1207 | "kty": "RSA", | 1206 | "kty": "RSA", |
| 1208 | "kid": kid, | 1207 | "kid": kid, |
| 1209 | - "n": b64url.encode(public.n().to_bytes_be()), | 1208 | + "n": b64url.encode(public.n().to_be_bytes_trimmed_vartime()), |
| 1210 | - "e": b64url.encode(public.e().to_bytes_be()), | 1209 | + "e": b64url.encode(public.e().to_be_bytes_trimmed_vartime()), |
| 1211 | }) | 1210 | }) |
| 1212 | } | 1211 | } |
| 1213 | 1212 | ||
crates/iz-core/src/board.rsmodified+1 -1
| @@ -315,7 +315,7 @@ impl BoardView { | |||
| 315 | for column in &mut self.columns { | 315 | for column in &mut self.columns { |
| 316 | column.cards.retain(|card| match assignee { | 316 | column.cards.retain(|card| match assignee { |
| 317 | "none" => card.assignees.is_empty(), | 317 | "none" => card.assignees.is_empty(), |
| 318 | - id => card.assignees.iter().any(|person| &person.id == id), | 318 | + id => card.assignees.iter().any(|person| person.id == id), |
| 319 | }); | 319 | }); |
| 320 | } | 320 | } |
| 321 | } | 321 | } |
crates/iz-core/src/config.rsmodified+2 -2
| @@ -679,7 +679,7 @@ mod tests { | |||
| 679 | std::fs::create_dir_all(dir.join("config")).unwrap(); | 679 | std::fs::create_dir_all(dir.join("config")).unwrap(); |
| 680 | std::fs::write( | 680 | std::fs::write( |
| 681 | dir.join(FILE_NAME), | 681 | dir.join(FILE_NAME), |
| 682 | - &format!("# mine\ndatabase = \"state/iz.db\"\n{OIDC}"), | 682 | + format!("# mine\ndatabase = \"state/iz.db\"\n{OIDC}"), |
| 683 | ) | 683 | ) |
| 684 | .unwrap(); | 684 | .unwrap(); |
| 685 | 685 | ||
| @@ -1059,7 +1059,7 @@ mod tests { | |||
| 1059 | std::fs::create_dir_all(dir.join("config")).unwrap(); | 1059 | std::fs::create_dir_all(dir.join("config")).unwrap(); |
| 1060 | std::fs::write( | 1060 | std::fs::write( |
| 1061 | dir.join(FILE_NAME), | 1061 | dir.join(FILE_NAME), |
| 1062 | - &format!("database = \"iz.db\"\n{OIDC}"), | 1062 | + format!("database = \"iz.db\"\n{OIDC}"), |
| 1063 | ) | 1063 | ) |
| 1064 | .unwrap(); | 1064 | .unwrap(); |
| 1065 | Config::load_from(&dir).unwrap(); | 1065 | Config::load_from(&dir).unwrap(); |
crates/iz-core/src/store/mod.rsmodified+1 -0
| @@ -1046,6 +1046,7 @@ pub trait Store: BoardReads + DetailReads + 'static { | |||
| 1046 | /// saved, and records one activity line per field that actually changed. | 1046 | /// saved, and records one activity line per field that actually changed. |
| 1047 | /// Returns the ids of the activity rows it wrote, in write order — empty | 1047 | /// Returns the ids of the activity rows it wrote, in write order — empty |
| 1048 | /// when nothing changed — so the caller can hand each to the mail engine. | 1048 | /// when nothing changed — so the caller can hand each to the mail engine. |
| 1049 | + #[allow(clippy::too_many_arguments)] | ||
| 1049 | async fn save_task( | 1050 | async fn save_task( |
| 1050 | &self, | 1051 | &self, |
| 1051 | task_id: &str, | 1052 | task_id: &str, |
crates/iz-core/src/store/reconcile.rsmodified+7 -7
| @@ -129,8 +129,8 @@ pub async fn reconcile( | |||
| 129 | // Best-effort undo so the live file is not gone. If this also fails, | 129 | // Best-effort undo so the live file is not gone. If this also fails, |
| 130 | // the caller has both the backup and the rebuilt file to recover from. | 130 | // the caller has both the backup and the rebuilt file to recover from. |
| 131 | let _ = std::fs::rename(&backup_path, path); | 131 | let _ = std::fs::rename(&backup_path, path); |
| 132 | - let _ = rename_sibling(&backup_path, path, "-wal"); | 132 | + rename_sibling(&backup_path, path, "-wal"); |
| 133 | - let _ = rename_sibling(&backup_path, path, "-shm"); | 133 | + rename_sibling(&backup_path, path, "-shm"); |
| 134 | return Err(StoreError::Backend(format!( | 134 | return Err(StoreError::Backend(format!( |
| 135 | "failed to move rebuilt database into place {}: {}", | 135 | "failed to move rebuilt database into place {}: {}", |
| 136 | rebuilt_path, e | 136 | rebuilt_path, e |
| @@ -242,7 +242,7 @@ async fn seed_general_tags(new_conn: &Connection) -> Result<()> { | |||
| 242 | boards.push((board_id, created_at)); | 242 | boards.push((board_id, created_at)); |
| 243 | } | 243 | } |
| 244 | for (board_id, created_at) in boards { | 244 | for (board_id, created_at) in boards { |
| 245 | - let id = Ulid::new().to_string(); | 245 | + let id = Ulid::generate().to_string(); |
| 246 | new_conn | 246 | new_conn |
| 247 | .execute( | 247 | .execute( |
| 248 | "INSERT INTO main.tag (id, board_id, name, position, is_default, created_at) \ | 248 | "INSERT INTO main.tag (id, board_id, name, position, is_default, created_at) \ |
| @@ -650,7 +650,7 @@ async fn extract_column( | |||
| 650 | /// renamed onto the final name, so a reader of the final name never sees a | 650 | /// renamed onto the final name, so a reader of the final name never sees a |
| 651 | /// partial file. | 651 | /// partial file. |
| 652 | fn write_blob(dir: &std::path::Path, id: &str, bytes: &[u8]) -> std::io::Result<()> { | 652 | fn write_blob(dir: &std::path::Path, id: &str, bytes: &[u8]) -> std::io::Result<()> { |
| 653 | - let temp = dir.join(format!(".{}.tmp-{}", id, Ulid::new())); | 653 | + let temp = dir.join(format!(".{}.tmp-{}", id, Ulid::generate())); |
| 654 | std::fs::write(&temp, bytes)?; | 654 | std::fs::write(&temp, bytes)?; |
| 655 | match std::fs::rename(&temp, dir.join(id)) { | 655 | match std::fs::rename(&temp, dir.join(id)) { |
| 656 | Ok(()) => Ok(()), | 656 | Ok(()) => Ok(()), |
| @@ -1074,7 +1074,7 @@ mod tests { | |||
| 1074 | 1074 | ||
| 1075 | #[tokio::test] | 1075 | #[tokio::test] |
| 1076 | async fn validate_maps_refuses_a_declared_table_without_a_map() { | 1076 | async fn validate_maps_refuses_a_declared_table_without_a_map() { |
| 1077 | - let dir = std::env::temp_dir().join(format!("iz-validate-{}", Ulid::new())); | 1077 | + let dir = std::env::temp_dir().join(format!("iz-validate-{}", Ulid::generate())); |
| 1078 | std::fs::create_dir_all(&dir).unwrap(); | 1078 | std::fs::create_dir_all(&dir).unwrap(); |
| 1079 | let path = dir.join("iz.db").to_str().unwrap().to_string(); | 1079 | let path = dir.join("iz.db").to_str().unwrap().to_string(); |
| 1080 | let db = Builder::new_local(&path).build().await.unwrap(); | 1080 | let db = Builder::new_local(&path).build().await.unwrap(); |
| @@ -1235,7 +1235,7 @@ mod tests { | |||
| 1235 | /// column any more. | 1235 | /// column any more. |
| 1236 | #[tokio::test] | 1236 | #[tokio::test] |
| 1237 | async fn an_old_shaped_database_extracts_its_blobs_to_the_storage_dir() { | 1237 | async fn an_old_shaped_database_extracts_its_blobs_to_the_storage_dir() { |
| 1238 | - let dir = std::env::temp_dir().join(format!("iz-reconcile-{}", Ulid::new())); | 1238 | + let dir = std::env::temp_dir().join(format!("iz-reconcile-{}", Ulid::generate())); |
| 1239 | std::fs::create_dir_all(&dir).unwrap(); | 1239 | std::fs::create_dir_all(&dir).unwrap(); |
| 1240 | let path = dir.join("iz.db").to_str().unwrap().to_string(); | 1240 | let path = dir.join("iz.db").to_str().unwrap().to_string(); |
| 1241 | let (attachment_bytes, photo_bytes) = old_shape_database(&path).await; | 1241 | let (attachment_bytes, photo_bytes) = old_shape_database(&path).await; |
| @@ -1322,7 +1322,7 @@ mod tests { | |||
| 1322 | /// leaves the original file in place with nothing staged beside it. | 1322 | /// leaves the original file in place with nothing staged beside it. |
| 1323 | #[tokio::test] | 1323 | #[tokio::test] |
| 1324 | async fn a_rebuild_without_storage_refuses_to_drop_blobs() { | 1324 | async fn a_rebuild_without_storage_refuses_to_drop_blobs() { |
| 1325 | - let dir = std::env::temp_dir().join(format!("iz-reconcile-{}", Ulid::new())); | 1325 | + let dir = std::env::temp_dir().join(format!("iz-reconcile-{}", Ulid::generate())); |
| 1326 | std::fs::create_dir_all(&dir).unwrap(); | 1326 | std::fs::create_dir_all(&dir).unwrap(); |
| 1327 | let path = dir.join("iz.db").to_str().unwrap().to_string(); | 1327 | let path = dir.join("iz.db").to_str().unwrap().to_string(); |
| 1328 | old_shape_database(&path).await; | 1328 | old_shape_database(&path).await; |
crates/iz-core/src/store/schema.rsmodified+24 -12
| @@ -52,11 +52,14 @@ pub async fn fingerprint(conn: &Connection) -> Result<String> { | |||
| 52 | .map_err(|e| StoreError::Backend(e.to_string()))?; | 52 | .map_err(|e| StoreError::Backend(e.to_string()))?; |
| 53 | 53 | ||
| 54 | let mut out = String::new(); | 54 | let mut out = String::new(); |
| 55 | - while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? { | 55 | + while let Some(row) = rows |
| 56 | + .next() | ||
| 57 | + .await | ||
| 58 | + .map_err(|e| StoreError::Backend(e.to_string()))? | ||
| 59 | + { | ||
| 56 | let t: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?; | 60 | let t: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?; |
| 57 | let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?; | 61 | let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?; |
| 58 | - let sql: Option<String> = | 62 | + let sql: Option<String> = row.get(2).map_err(|e| StoreError::Backend(e.to_string()))?; |
| 59 | - row.get(2).map_err(|e| StoreError::Backend(e.to_string()))?; | ||
| 60 | out.push_str(&t); | 63 | out.push_str(&t); |
| 61 | out.push('|'); | 64 | out.push('|'); |
| 62 | out.push_str(&name); | 65 | out.push_str(&name); |
| @@ -75,7 +78,9 @@ pub async fn declared_fingerprint() -> Result<String> { | |||
| 75 | .build() | 78 | .build() |
| 76 | .await | 79 | .await |
| 77 | .map_err(|e| StoreError::Backend(e.to_string()))?; | 80 | .map_err(|e| StoreError::Backend(e.to_string()))?; |
| 78 | - let conn = db.connect().map_err(|e| StoreError::Backend(e.to_string()))?; | 81 | + let conn = db |
| 82 | + .connect() | ||
| 83 | + .map_err(|e| StoreError::Backend(e.to_string()))?; | ||
| 79 | conn.execute_batch(&schema_sql()) | 84 | conn.execute_batch(&schema_sql()) |
| 80 | .await | 85 | .await |
| 81 | .map_err(|e| StoreError::Backend(e.to_string()))?; | 86 | .map_err(|e| StoreError::Backend(e.to_string()))?; |
| @@ -115,14 +120,20 @@ pub(crate) fn diff_report(old: &str, new: &str) -> String { | |||
| 115 | let mut changed = Vec::new(); | 120 | let mut changed = Vec::new(); |
| 116 | 121 | ||
| 117 | for old_obj in &old_objs { | 122 | for old_obj in &old_objs { |
| 118 | - match new_objs.iter().find(|n| n.kind == old_obj.kind && n.name == old_obj.name) { | 123 | + match new_objs |
| 124 | + .iter() | ||
| 125 | + .find(|n| n.kind == old_obj.kind && n.name == old_obj.name) | ||
| 126 | + { | ||
| 119 | Some(new_obj) if new_obj.sql != old_obj.sql => changed.push((old_obj, new_obj)), | 127 | Some(new_obj) if new_obj.sql != old_obj.sql => changed.push((old_obj, new_obj)), |
| 120 | Some(_) => {} | 128 | Some(_) => {} |
| 121 | None => missing.push(old_obj), | 129 | None => missing.push(old_obj), |
| 122 | } | 130 | } |
| 123 | } | 131 | } |
| 124 | for new_obj in &new_objs { | 132 | for new_obj in &new_objs { |
| 125 | - if !old_objs.iter().any(|o| o.kind == new_obj.kind && o.name == new_obj.name) { | 133 | + if !old_objs |
| 134 | + .iter() | ||
| 135 | + .any(|o| o.kind == new_obj.kind && o.name == new_obj.name) | ||
| 136 | + { | ||
| 126 | extra.push(new_obj); | 137 | extra.push(new_obj); |
| 127 | } | 138 | } |
| 128 | } | 139 | } |
| @@ -204,10 +215,10 @@ fn extract_column_names(sql: &str) -> Vec<String> { | |||
| 204 | _ => current.push(ch), | 215 | _ => current.push(ch), |
| 205 | } | 216 | } |
| 206 | } | 217 | } |
| 207 | - if !current.is_empty() { | 218 | + if !current.is_empty() |
| 208 | - if let Some(col) = first_identifier(¤t) { | 219 | + && let Some(col) = first_identifier(¤t) |
| 209 | - cols.push(col); | 220 | + { |
| 210 | - } | 221 | + cols.push(col); |
| 211 | } | 222 | } |
| 212 | cols | 223 | cols |
| 213 | } | 224 | } |
| @@ -263,7 +274,7 @@ fn normalize_schema(sql: &str) -> String { | |||
| 263 | 274 | ||
| 264 | if ch == '-' && chars.peek() == Some(&'-') { | 275 | if ch == '-' && chars.peek() == Some(&'-') { |
| 265 | chars.next(); | 276 | chars.next(); |
| 266 | - while let Some(c) = chars.next() { | 277 | + for c in chars.by_ref() { |
| 267 | if c == '\n' { | 278 | if c == '\n' { |
| 268 | break; | 279 | break; |
| 269 | } | 280 | } |
| @@ -364,7 +375,8 @@ mod tests { | |||
| 364 | fn if_not_exists_does_not_corrupt_identifiers() { | 375 | fn if_not_exists_does_not_corrupt_identifiers() { |
| 365 | // The stripper looks for whole tokens; words that merely appear | 376 | // The stripper looks for whole tokens; words that merely appear |
| 366 | // inside identifiers or string literals must stay put. | 377 | // inside identifiers or string literals must stay put. |
| 367 | - let a = "CREATE TABLE IF NOT EXISTS notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; | 378 | + let a = |
| 379 | + "CREATE TABLE IF NOT EXISTS notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; | ||
| 368 | let b = "CREATE TABLE notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; | 380 | let b = "CREATE TABLE notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; |
| 369 | assert_eq!(normalize_schema(a), normalize_schema(b)); | 381 | assert_eq!(normalize_schema(a), normalize_schema(b)); |
| 370 | } | 382 | } |
crates/iz-core/src/store/secret.rsmodified+4 -4
| @@ -26,8 +26,8 @@ | |||
| 26 | use std::io; | 26 | use std::io; |
| 27 | use std::path::Path; | 27 | use std::path::Path; |
| 28 | 28 | ||
| 29 | -use base64::Engine; | ||
| 30 | use base64::engine::general_purpose::STANDARD as base64; | 29 | use base64::engine::general_purpose::STANDARD as base64; |
| 30 | +use base64::Engine; | ||
| 31 | use chacha20poly1305::aead::Aead; | 31 | use chacha20poly1305::aead::Aead; |
| 32 | use chacha20poly1305::{KeyInit, XChaCha20Poly1305, XNonce}; | 32 | use chacha20poly1305::{KeyInit, XChaCha20Poly1305, XNonce}; |
| 33 | use rand::Rng; | 33 | use rand::Rng; |
| @@ -57,9 +57,9 @@ pub fn seal(key: &Key, plaintext: &str) -> String { | |||
| 57 | let cipher = XChaCha20Poly1305::new(key.into()); | 57 | let cipher = XChaCha20Poly1305::new(key.into()); |
| 58 | let mut nonce_bytes = [0u8; NONCE_BYTES]; | 58 | let mut nonce_bytes = [0u8; NONCE_BYTES]; |
| 59 | rand::rng().fill_bytes(&mut nonce_bytes); | 59 | rand::rng().fill_bytes(&mut nonce_bytes); |
| 60 | - let nonce = XNonce::from_slice(&nonce_bytes); | 60 | + let nonce = XNonce::from(nonce_bytes); |
| 61 | let ciphertext = cipher | 61 | let ciphertext = cipher |
| 62 | - .encrypt(nonce, plaintext.as_bytes()) | 62 | + .encrypt(&nonce, plaintext.as_bytes()) |
| 63 | .expect("XChaCha20-Poly1305 cannot fail to encrypt a plaintext this small"); | 63 | .expect("XChaCha20-Poly1305 cannot fail to encrypt a plaintext this small"); |
| 64 | let mut payload = Vec::with_capacity(NONCE_BYTES + ciphertext.len()); | 64 | let mut payload = Vec::with_capacity(NONCE_BYTES + ciphertext.len()); |
| 65 | payload.extend_from_slice(&nonce_bytes); | 65 | payload.extend_from_slice(&nonce_bytes); |
| @@ -80,7 +80,7 @@ pub fn open(key: &Key, sealed: &str) -> Option<String> { | |||
| 80 | } | 80 | } |
| 81 | let (nonce_bytes, ciphertext) = payload.split_at(NONCE_BYTES); | 81 | let (nonce_bytes, ciphertext) = payload.split_at(NONCE_BYTES); |
| 82 | let cipher = XChaCha20Poly1305::new(key.into()); | 82 | let cipher = XChaCha20Poly1305::new(key.into()); |
| 83 | - let nonce = XNonce::from_slice(nonce_bytes); | 83 | + let nonce: &XNonce = nonce_bytes.try_into().ok()?; |
| 84 | let plaintext = cipher.decrypt(nonce, ciphertext).ok()?; | 84 | let plaintext = cipher.decrypt(nonce, ciphertext).ok()?; |
| 85 | String::from_utf8(plaintext).ok() | 85 | String::from_utf8(plaintext).ok() |
| 86 | } | 86 | } |
crates/iz-core/src/store/turso_store.rsmodified+43 -46
| @@ -818,7 +818,7 @@ impl TursoStore { | |||
| 818 | subject, body) \ | 818 | subject, body) \ |
| 819 | VALUES (?1, ?2, ?3, 'pending', 0, ?4, ?5, 'reminder', ?6, ?7)", | 819 | VALUES (?1, ?2, ?3, 'pending', 0, ?4, ?5, 'reminder', ?6, ?7)", |
| 820 | params![ | 820 | params![ |
| 821 | - Ulid::new().to_string(), | 821 | + Ulid::generate().to_string(), |
| 822 | task_id, | 822 | task_id, |
| 823 | email, | 823 | email, |
| 824 | stamp(now)?, | 824 | stamp(now)?, |
| @@ -1067,7 +1067,7 @@ fn ensure_storage_dirs(storage: &std::path::Path) -> Result<()> { | |||
| 1067 | /// is exactly what the boot sweep deletes. | 1067 | /// is exactly what the boot sweep deletes. |
| 1068 | fn write_file_atomic(path: &std::path::Path, bytes: &[u8]) -> std::io::Result<()> { | 1068 | fn write_file_atomic(path: &std::path::Path, bytes: &[u8]) -> std::io::Result<()> { |
| 1069 | use std::io::Write as _; | 1069 | use std::io::Write as _; |
| 1070 | - let tmp = path.with_extension(format!("{}.tmp", Ulid::new())); | 1070 | + let tmp = path.with_extension(format!("{}.tmp", Ulid::generate())); |
| 1071 | let mut file = std::fs::File::create(&tmp)?; | 1071 | let mut file = std::fs::File::create(&tmp)?; |
| 1072 | file.write_all(bytes)?; | 1072 | file.write_all(bytes)?; |
| 1073 | file.sync_all()?; | 1073 | file.sync_all()?; |
| @@ -1500,8 +1500,8 @@ impl Store for TursoStore { | |||
| 1500 | // The first sign-in is the whole setup: the workspace | 1500 | // The first sign-in is the whole setup: the workspace |
| 1501 | // and the board it is never without, the way the old | 1501 | // and the board it is never without, the way the old |
| 1502 | // claim screen built them with the first account. | 1502 | // claim screen built them with the first account. |
| 1503 | - let workspace_id = Ulid::new().to_string(); | 1503 | + let workspace_id = Ulid::generate().to_string(); |
| 1504 | - let board_id = Ulid::new().to_string(); | 1504 | + let board_id = Ulid::generate().to_string(); |
| 1505 | tx.execute( | 1505 | tx.execute( |
| 1506 | "INSERT INTO workspace (id, name, created_at) VALUES (?1, 'iz', ?2)", | 1506 | "INSERT INTO workspace (id, name, created_at) VALUES (?1, 'iz', ?2)", |
| 1507 | params![workspace_id.clone(), now.clone()], | 1507 | params![workspace_id.clone(), now.clone()], |
| @@ -1525,7 +1525,7 @@ impl Store for TursoStore { | |||
| 1525 | "INSERT INTO board_column (id, board_id, name, position, is_done) \ | 1525 | "INSERT INTO board_column (id, board_id, name, position, is_done) \ |
| 1526 | VALUES (?1, ?2, ?3, ?4, ?5)", | 1526 | VALUES (?1, ?2, ?3, ?4, ?5)", |
| 1527 | params![ | 1527 | params![ |
| 1528 | - Ulid::new().to_string(), | 1528 | + Ulid::generate().to_string(), |
| 1529 | board_id.clone(), | 1529 | board_id.clone(), |
| 1530 | *name, | 1530 | *name, |
| 1531 | position as i64, | 1531 | position as i64, |
| @@ -1538,14 +1538,14 @@ impl Store for TursoStore { | |||
| 1538 | tx.execute( | 1538 | tx.execute( |
| 1539 | "INSERT INTO tag (id, board_id, name, position, is_default, created_at) \ | 1539 | "INSERT INTO tag (id, board_id, name, position, is_default, created_at) \ |
| 1540 | VALUES (?1, ?2, 'General', 0, 1, ?3)", | 1540 | VALUES (?1, ?2, 'General', 0, 1, ?3)", |
| 1541 | - params![Ulid::new().to_string(), board_id.clone(), now.clone()], | 1541 | + params![Ulid::generate().to_string(), board_id.clone(), now.clone()], |
| 1542 | ) | 1542 | ) |
| 1543 | .await | 1543 | .await |
| 1544 | .map_err(backend)?; | 1544 | .map_err(backend)?; |
| 1545 | workspace_id | 1545 | workspace_id |
| 1546 | } | 1546 | } |
| 1547 | }; | 1547 | }; |
| 1548 | - let id = Ulid::new().to_string(); | 1548 | + let id = Ulid::generate().to_string(); |
| 1549 | tx.execute( | 1549 | tx.execute( |
| 1550 | "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, role, \ | 1550 | "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, role, \ |
| 1551 | disabled, created_at, last_signed_in_at) \ | 1551 | disabled, created_at, last_signed_in_at) \ |
| @@ -1700,7 +1700,7 @@ impl Store for TursoStore { | |||
| 1700 | // Born linked: the directory vouches the subject, so | 1700 | // Born linked: the directory vouches the subject, so |
| 1701 | // the row never waits unclaimed — assignment, mail | 1701 | // the row never waits unclaimed — assignment, mail |
| 1702 | // and the avatar proxy work before the first visit. | 1702 | // and the avatar proxy work before the first visit. |
| 1703 | - let id = Ulid::new().to_string(); | 1703 | + let id = Ulid::generate().to_string(); |
| 1704 | let role = if im_admin { Role::Admin } else { Role::Member }; | 1704 | let role = if im_admin { Role::Admin } else { Role::Member }; |
| 1705 | tx.execute( | 1705 | tx.execute( |
| 1706 | "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, \ | 1706 | "INSERT INTO user (id, workspace_id, oidc_sub, email, display_name, \ |
| @@ -1790,7 +1790,7 @@ impl Store for TursoStore { | |||
| 1790 | if seen.is_some() { | 1790 | if seen.is_some() { |
| 1791 | return Err(StoreError::Conflict("member")); | 1791 | return Err(StoreError::Conflict("member")); |
| 1792 | } | 1792 | } |
| 1793 | - let id = Ulid::new().to_string(); | 1793 | + let id = Ulid::generate().to_string(); |
| 1794 | let now = now_text()?; | 1794 | let now = now_text()?; |
| 1795 | let conn = self.conn.lock().await; | 1795 | let conn = self.conn.lock().await; |
| 1796 | // Unclaimed: no sub, never signed in. The guards read such a row | 1796 | // Unclaimed: no sub, never signed in. The guards read such a row |
| @@ -2196,7 +2196,7 @@ impl Store for TursoStore { | |||
| 2196 | is_done: bool, | 2196 | is_done: bool, |
| 2197 | ) -> Result<Column> { | 2197 | ) -> Result<Column> { |
| 2198 | let conn = self.conn.lock().await; | 2198 | let conn = self.conn.lock().await; |
| 2199 | - let id = Ulid::new().to_string(); | 2199 | + let id = Ulid::generate().to_string(); |
| 2200 | conn.execute( | 2200 | conn.execute( |
| 2201 | "INSERT INTO board_column (id, board_id, name, position, is_done) \ | 2201 | "INSERT INTO board_column (id, board_id, name, position, is_done) \ |
| 2202 | VALUES (?1, ?2, ?3, ?4, ?5)", | 2202 | VALUES (?1, ?2, ?3, ?4, ?5)", |
| @@ -2215,9 +2215,9 @@ impl Store for TursoStore { | |||
| 2215 | } | 2215 | } |
| 2216 | 2216 | ||
| 2217 | async fn create_task(&self, new: NewTask<'_>) -> Result<TaskCreated> { | 2217 | async fn create_task(&self, new: NewTask<'_>) -> Result<TaskCreated> { |
| 2218 | - let id = Ulid::new().to_string(); | 2218 | + let id = Ulid::generate().to_string(); |
| 2219 | - let activity_id = Ulid::new().to_string(); | 2219 | + let activity_id = Ulid::generate().to_string(); |
| 2220 | - let transition_id = Ulid::new().to_string(); | 2220 | + let transition_id = Ulid::generate().to_string(); |
| 2221 | let at = OffsetDateTime::now_utc(); | 2221 | let at = OffsetDateTime::now_utc(); |
| 2222 | let now = stamp(at)?; | 2222 | let now = stamp(at)?; |
| 2223 | let deadline = new.deadline.map(day_text).transpose()?; | 2223 | let deadline = new.deadline.map(day_text).transpose()?; |
| @@ -2772,8 +2772,8 @@ impl Store for TursoStore { | |||
| 2772 | body: &str, | 2772 | body: &str, |
| 2773 | at: OffsetDateTime, | 2773 | at: OffsetDateTime, |
| 2774 | ) -> Result<CommentWritten> { | 2774 | ) -> Result<CommentWritten> { |
| 2775 | - let comment_id = Ulid::new().to_string(); | 2775 | + let comment_id = Ulid::generate().to_string(); |
| 2776 | - let activity_id = Ulid::new().to_string(); | 2776 | + let activity_id = Ulid::generate().to_string(); |
| 2777 | let when = stamp(at)?; | 2777 | let when = stamp(at)?; |
| 2778 | 2778 | ||
| 2779 | let mut conn = self.tx_conn().await?; | 2779 | let mut conn = self.tx_conn().await?; |
| @@ -2824,7 +2824,7 @@ impl Store for TursoStore { | |||
| 2824 | // deletes, never a row pointing at nothing. If the row write fails, | 2824 | // deletes, never a row pointing at nothing. If the row write fails, |
| 2825 | // the file is unlinked best-effort — the row was never born, so the | 2825 | // the file is unlinked best-effort — the row was never born, so the |
| 2826 | // bytes must not outlive it under a name nothing points at. | 2826 | // bytes must not outlive it under a name nothing points at. |
| 2827 | - let id = Ulid::new().to_string(); | 2827 | + let id = Ulid::generate().to_string(); |
| 2828 | let size = new.bytes.len() as i64; | 2828 | let size = new.bytes.len() as i64; |
| 2829 | let path = attachment_file(&self.storage, &id); | 2829 | let path = attachment_file(&self.storage, &id); |
| 2830 | write_file_atomic(&path, &new.bytes).map_err(|e| StoreError::Backend(e.to_string()))?; | 2830 | write_file_atomic(&path, &new.bytes).map_err(|e| StoreError::Backend(e.to_string()))?; |
| @@ -3136,7 +3136,7 @@ impl Store for TursoStore { | |||
| 3136 | } | 3136 | } |
| 3137 | let mut ids = Vec::with_capacity(lines.len()); | 3137 | let mut ids = Vec::with_capacity(lines.len()); |
| 3138 | for (kind, detail) in lines { | 3138 | for (kind, detail) in lines { |
| 3139 | - let id = Ulid::new().to_string(); | 3139 | + let id = Ulid::generate().to_string(); |
| 3140 | tx.execute( | 3140 | tx.execute( |
| 3141 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ | 3141 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ |
| 3142 | VALUES (?1, ?2, ?3, NULL, ?4, ?5, ?6)", | 3142 | VALUES (?1, ?2, ?3, NULL, ?4, ?5, ?6)", |
| @@ -3194,7 +3194,7 @@ impl Store for TursoStore { | |||
| 3194 | at: OffsetDateTime, | 3194 | at: OffsetDateTime, |
| 3195 | ) -> Result<Moved> { | 3195 | ) -> Result<Moved> { |
| 3196 | let stamp = stamp(at)?; | 3196 | let stamp = stamp(at)?; |
| 3197 | - let transition_id = Ulid::new().to_string(); | 3197 | + let transition_id = Ulid::generate().to_string(); |
| 3198 | 3198 | ||
| 3199 | // Dropping a card back where it came from is not a move. Answer before | 3199 | // Dropping a card back where it came from is not a move. Answer before |
| 3200 | // opening a transaction: there is nothing to serialise. | 3200 | // opening a transaction: there is nothing to serialise. |
| @@ -3335,7 +3335,7 @@ impl Store for TursoStore { | |||
| 3335 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ | 3335 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ |
| 3336 | VALUES (?1, ?2, ?3, NULL, ?4, ?5, ?6)", | 3336 | VALUES (?1, ?2, ?3, NULL, ?4, ?5, ?6)", |
| 3337 | params![ | 3337 | params![ |
| 3338 | - Ulid::new().to_string(), | 3338 | + Ulid::generate().to_string(), |
| 3339 | task_id, | 3339 | task_id, |
| 3340 | actor_id, | 3340 | actor_id, |
| 3341 | ActivityKind::Moved.as_str(), | 3341 | ActivityKind::Moved.as_str(), |
| @@ -3469,7 +3469,7 @@ impl Store for TursoStore { | |||
| 3469 | params![task_id, stamp.clone()], | 3469 | params![task_id, stamp.clone()], |
| 3470 | ) | 3470 | ) |
| 3471 | .await?; | 3471 | .await?; |
| 3472 | - let deleted_activity_id = Ulid::new().to_string(); | 3472 | + let deleted_activity_id = Ulid::generate().to_string(); |
| 3473 | tx.execute( | 3473 | tx.execute( |
| 3474 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ | 3474 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ |
| 3475 | VALUES (?1, ?2, ?3, NULL, ?4, '', ?5)", | 3475 | VALUES (?1, ?2, ?3, NULL, ?4, '', ?5)", |
| @@ -3507,7 +3507,7 @@ impl Store for TursoStore { | |||
| 3507 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ | 3507 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ |
| 3508 | VALUES (?1, ?2, NULL, NULL, ?3, ?4, ?5)", | 3508 | VALUES (?1, ?2, NULL, NULL, ?3, ?4, ?5)", |
| 3509 | params![ | 3509 | params![ |
| 3510 | - Ulid::new().to_string(), | 3510 | + Ulid::generate().to_string(), |
| 3511 | blocked.clone(), | 3511 | blocked.clone(), |
| 3512 | ActivityKind::Unblocked.as_str(), | 3512 | ActivityKind::Unblocked.as_str(), |
| 3513 | format!("{task_key} was deleted"), | 3513 | format!("{task_key} was deleted"), |
| @@ -3526,7 +3526,7 @@ impl Store for TursoStore { | |||
| 3526 | None | 3526 | None |
| 3527 | } else { | 3527 | } else { |
| 3528 | let event = Freeing { | 3528 | let event = Freeing { |
| 3529 | - id: Ulid::new().to_string(), | 3529 | + id: Ulid::generate().to_string(), |
| 3530 | board_id, | 3530 | board_id, |
| 3531 | cause_key: task_key.clone(), | 3531 | cause_key: task_key.clone(), |
| 3532 | cause_title: title, | 3532 | cause_title: title, |
| @@ -3676,7 +3676,7 @@ impl Store for TursoStore { | |||
| 3676 | at: OffsetDateTime, | 3676 | at: OffsetDateTime, |
| 3677 | ) -> Result<String> { | 3677 | ) -> Result<String> { |
| 3678 | let conn = self.conn.lock().await; | 3678 | let conn = self.conn.lock().await; |
| 3679 | - let id = Ulid::new().to_string(); | 3679 | + let id = Ulid::generate().to_string(); |
| 3680 | conn.execute( | 3680 | conn.execute( |
| 3681 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ | 3681 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ |
| 3682 | VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)", | 3682 | VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)", |
| @@ -3706,7 +3706,7 @@ impl Store for TursoStore { | |||
| 3706 | at: OffsetDateTime, | 3706 | at: OffsetDateTime, |
| 3707 | ) -> Result<String> { | 3707 | ) -> Result<String> { |
| 3708 | let conn = self.conn.lock().await; | 3708 | let conn = self.conn.lock().await; |
| 3709 | - let id = Ulid::new().to_string(); | 3709 | + let id = Ulid::generate().to_string(); |
| 3710 | conn.execute( | 3710 | conn.execute( |
| 3711 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ | 3711 | "INSERT INTO activity (id, task_id, actor_id, subject_id, kind, detail, created_at) \ |
| 3712 | VALUES (?1, NULL, ?2, NULL, ?3, ?4, ?5)", | 3712 | VALUES (?1, NULL, ?2, NULL, ?3, ?4, ?5)", |
| @@ -3731,7 +3731,7 @@ impl Store for TursoStore { | |||
| 3731 | at: OffsetDateTime, | 3731 | at: OffsetDateTime, |
| 3732 | include_task_details: bool, | 3732 | include_task_details: bool, |
| 3733 | ) -> Result<MailRule> { | 3733 | ) -> Result<MailRule> { |
| 3734 | - let id = Ulid::new().to_string(); | 3734 | + let id = Ulid::generate().to_string(); |
| 3735 | let (kind, column) = trigger_parts(trigger); | 3735 | let (kind, column) = trigger_parts(trigger); |
| 3736 | self.conn | 3736 | self.conn |
| 3737 | .lock() | 3737 | .lock() |
| @@ -3844,7 +3844,7 @@ impl Store for TursoStore { | |||
| 3844 | at: parse_stamp(&text(&row, 5)?)?, | 3844 | at: parse_stamp(&text(&row, 5)?)?, |
| 3845 | }))); | 3845 | }))); |
| 3846 | } | 3846 | } |
| 3847 | - match self | 3847 | + if let Some(row) = self |
| 3848 | .one_row( | 3848 | .one_row( |
| 3849 | "SELECT id, board_id, cause_key, cause_title, actor_id, created_at \ | 3849 | "SELECT id, board_id, cause_key, cause_title, actor_id, created_at \ |
| 3850 | FROM freeing WHERE id = ?1", | 3850 | FROM freeing WHERE id = ?1", |
| @@ -3852,17 +3852,14 @@ impl Store for TursoStore { | |||
| 3852 | ) | 3852 | ) |
| 3853 | .await? | 3853 | .await? |
| 3854 | { | 3854 | { |
| 3855 | - Some(row) => { | 3855 | + return Ok(Some(Event::Freed(Freeing { |
| 3856 | - return Ok(Some(Event::Freed(Freeing { | 3856 | + id: text(&row, 0)?, |
| 3857 | - id: text(&row, 0)?, | 3857 | + board_id: text(&row, 1)?, |
| 3858 | - board_id: text(&row, 1)?, | 3858 | + cause_key: text(&row, 2)?, |
| 3859 | - cause_key: text(&row, 2)?, | 3859 | + cause_title: text(&row, 3)?, |
| 3860 | - cause_title: text(&row, 3)?, | 3860 | + actor_id: text(&row, 4)?, |
| 3861 | - actor_id: text(&row, 4)?, | 3861 | + at: parse_stamp(&text(&row, 5)?)?, |
| 3862 | - at: parse_stamp(&text(&row, 5)?)?, | 3862 | + }))); |
| 3863 | - }))); | ||
| 3864 | - } | ||
| 3865 | - None => {} | ||
| 3866 | } | 3863 | } |
| 3867 | match self | 3864 | match self |
| 3868 | .one_row( | 3865 | .one_row( |
| @@ -3952,7 +3949,7 @@ impl Store for TursoStore { | |||
| 3952 | at: OffsetDateTime, | 3949 | at: OffsetDateTime, |
| 3953 | until: OffsetDateTime, | 3950 | until: OffsetDateTime, |
| 3954 | ) -> Result<Option<ClaimedSend>> { | 3951 | ) -> Result<Option<ClaimedSend>> { |
| 3955 | - let id = Ulid::new().to_string(); | 3952 | + let id = Ulid::generate().to_string(); |
| 3956 | // The index is the decision. `DO NOTHING` turns the second engine run | 3953 | // The index is the decision. `DO NOTHING` turns the second engine run |
| 3957 | // into zero rows affected rather than an error to interpret, and the | 3954 | // into zero rows affected rather than an error to interpret, and the |
| 3958 | // caller that gets `None` sends nothing. | 3955 | // caller that gets `None` sends nothing. |
| @@ -3997,7 +3994,7 @@ impl Store for TursoStore { | |||
| 3997 | body: &str, | 3994 | body: &str, |
| 3998 | at: OffsetDateTime, | 3995 | at: OffsetDateTime, |
| 3999 | ) -> Result<MailSend> { | 3996 | ) -> Result<MailSend> { |
| 4000 | - let id = Ulid::new().to_string(); | 3997 | + let id = Ulid::generate().to_string(); |
| 4001 | self.conn | 3998 | self.conn |
| 4002 | .lock() | 3999 | .lock() |
| 4003 | .await | 4000 | .await |
| @@ -4027,7 +4024,7 @@ impl Store for TursoStore { | |||
| 4027 | body: &str, | 4024 | body: &str, |
| 4028 | at: OffsetDateTime, | 4025 | at: OffsetDateTime, |
| 4029 | ) -> Result<MailSend> { | 4026 | ) -> Result<MailSend> { |
| 4030 | - let id = Ulid::new().to_string(); | 4027 | + let id = Ulid::generate().to_string(); |
| 4031 | self.conn | 4028 | self.conn |
| 4032 | .lock() | 4029 | .lock() |
| 4033 | .await | 4030 | .await |
| @@ -4280,7 +4277,7 @@ impl Store for TursoStore { | |||
| 4280 | at: OffsetDateTime, | 4277 | at: OffsetDateTime, |
| 4281 | ) -> Result<()> { | 4278 | ) -> Result<()> { |
| 4282 | let conn = self.conn.lock().await; | 4279 | let conn = self.conn.lock().await; |
| 4283 | - let id = Ulid::new().to_string(); | 4280 | + let id = Ulid::generate().to_string(); |
| 4284 | conn.execute( | 4281 | conn.execute( |
| 4285 | "INSERT INTO mail_decision (id, rule_id, event_id, task_id, outcome, detail, \ | 4282 | "INSERT INTO mail_decision (id, rule_id, event_id, task_id, outcome, detail, \ |
| 4286 | created_at) \ | 4283 | created_at) \ |
| @@ -4798,7 +4795,7 @@ impl Store for TursoStore { | |||
| 4798 | } | 4795 | } |
| 4799 | 4796 | ||
| 4800 | async fn create_tag(&self, board_id: &str, name: &str, at: OffsetDateTime) -> Result<Tag> { | 4797 | async fn create_tag(&self, board_id: &str, name: &str, at: OffsetDateTime) -> Result<Tag> { |
| 4801 | - let id = Ulid::new().to_string(); | 4798 | + let id = Ulid::generate().to_string(); |
| 4802 | let now = stamp(at)?; | 4799 | let now = stamp(at)?; |
| 4803 | let mut conn = self.tx_conn().await?; | 4800 | let mut conn = self.tx_conn().await?; |
| 4804 | let tx = conn | 4801 | let tx = conn |
| @@ -5479,7 +5476,7 @@ mod probe { | |||
| 5479 | 5476 | ||
| 5480 | #[tokio::test] | 5477 | #[tokio::test] |
| 5481 | async fn durability_defaults_are_recorded() { | 5478 | async fn durability_defaults_are_recorded() { |
| 5482 | - let dir = std::env::temp_dir().join(format!("iz-probe-{}", Ulid::new())); | 5479 | + let dir = std::env::temp_dir().join(format!("iz-probe-{}", Ulid::generate())); |
| 5483 | std::fs::create_dir_all(&dir).unwrap(); | 5480 | std::fs::create_dir_all(&dir).unwrap(); |
| 5484 | let path = dir.join("probe.db"); | 5481 | let path = dir.join("probe.db"); |
| 5485 | let db = Builder::new_local(path.to_str().unwrap()) | 5482 | let db = Builder::new_local(path.to_str().unwrap()) |
| @@ -5497,7 +5494,7 @@ mod probe { | |||
| 5497 | 5494 | ||
| 5498 | #[tokio::test] | 5495 | #[tokio::test] |
| 5499 | async fn concurrent_writers_on_one_database() { | 5496 | async fn concurrent_writers_on_one_database() { |
| 5500 | - let dir = std::env::temp_dir().join(format!("iz-probe-{}", Ulid::new())); | 5497 | + let dir = std::env::temp_dir().join(format!("iz-probe-{}", Ulid::generate())); |
| 5501 | std::fs::create_dir_all(&dir).unwrap(); | 5498 | std::fs::create_dir_all(&dir).unwrap(); |
| 5502 | let path = dir.join("probe.db"); | 5499 | let path = dir.join("probe.db"); |
| 5503 | let db = Builder::new_local(path.to_str().unwrap()) | 5500 | let db = Builder::new_local(path.to_str().unwrap()) |
| @@ -5540,7 +5537,7 @@ mod probe { | |||
| 5540 | #[tokio::test(flavor = "multi_thread", worker_threads = 4)] | 5537 | #[tokio::test(flavor = "multi_thread", worker_threads = 4)] |
| 5541 | async fn two_database_handles_on_one_file() { | 5538 | async fn two_database_handles_on_one_file() { |
| 5542 | // Two handles on the same file is the shape a second process takes. | 5539 | // Two handles on the same file is the shape a second process takes. |
| 5543 | - let dir = std::env::temp_dir().join(format!("iz-probe-{}", Ulid::new())); | 5540 | + let dir = std::env::temp_dir().join(format!("iz-probe-{}", Ulid::generate())); |
| 5544 | std::fs::create_dir_all(&dir).unwrap(); | 5541 | std::fs::create_dir_all(&dir).unwrap(); |
| 5545 | let path = dir.join("probe.db"); | 5542 | let path = dir.join("probe.db"); |
| 5546 | let p = path.to_str().unwrap().to_string(); | 5543 | let p = path.to_str().unwrap().to_string(); |
| @@ -5613,7 +5610,7 @@ mod probe { | |||
| 5613 | /// is asserted against the real query rather than against a comment. | 5610 | /// is asserted against the real query rather than against a comment. |
| 5614 | #[tokio::test] | 5611 | #[tokio::test] |
| 5615 | async fn the_workspace_read_path_cannot_carry_the_password() { | 5612 | async fn the_workspace_read_path_cannot_carry_the_password() { |
| 5616 | - let dir = std::env::temp_dir().join(format!("iz-sender-{}", Ulid::new())); | 5613 | + let dir = std::env::temp_dir().join(format!("iz-sender-{}", Ulid::generate())); |
| 5617 | std::fs::create_dir_all(&dir).unwrap(); | 5614 | std::fs::create_dir_all(&dir).unwrap(); |
| 5618 | let store = TursoStore::open(dir.join("iz.db").to_str().unwrap(), &dir.join("storage")) | 5615 | let store = TursoStore::open(dir.join("iz.db").to_str().unwrap(), &dir.join("storage")) |
| 5619 | .await | 5616 | .await |
crates/iz-core/tests/store.rsmodified+50 -43
| @@ -24,7 +24,7 @@ struct Scratch { | |||
| 24 | 24 | ||
| 25 | impl Scratch { | 25 | impl Scratch { |
| 26 | async fn open() -> Self { | 26 | async fn open() -> Self { |
| 27 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 27 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 28 | std::fs::create_dir_all(&dir).unwrap(); | 28 | std::fs::create_dir_all(&dir).unwrap(); |
| 29 | let storage = dir.join("storage"); | 29 | let storage = dir.join("storage"); |
| 30 | let store = TursoStore::open(dir.join("iz.db").to_str().unwrap(), &storage) | 30 | let store = TursoStore::open(dir.join("iz.db").to_str().unwrap(), &storage) |
| @@ -102,7 +102,7 @@ async fn member_user( | |||
| 102 | 102 | ||
| 103 | #[tokio::test] | 103 | #[tokio::test] |
| 104 | async fn the_schema_is_created_once_and_survives_reopen() { | 104 | async fn the_schema_is_created_once_and_survives_reopen() { |
| 105 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 105 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 106 | std::fs::create_dir_all(&dir).unwrap(); | 106 | std::fs::create_dir_all(&dir).unwrap(); |
| 107 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 107 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 108 | 108 | ||
| @@ -971,7 +971,7 @@ async fn members_list_and_count_for_the_admin_screen() { | |||
| 971 | 971 | ||
| 972 | #[tokio::test] | 972 | #[tokio::test] |
| 973 | async fn display_preferences_default_and_persist_across_reopen() { | 973 | async fn display_preferences_default_and_persist_across_reopen() { |
| 974 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 974 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 975 | std::fs::create_dir_all(&dir).unwrap(); | 975 | std::fs::create_dir_all(&dir).unwrap(); |
| 976 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 976 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 977 | 977 | ||
| @@ -1004,7 +1004,7 @@ async fn display_preferences_default_and_persist_across_reopen() { | |||
| 1004 | #[tokio::test] | 1004 | #[tokio::test] |
| 1005 | async fn updates_to_a_missing_user_are_not_found() { | 1005 | async fn updates_to_a_missing_user_are_not_found() { |
| 1006 | let scratch = Scratch::open().await; | 1006 | let scratch = Scratch::open().await; |
| 1007 | - let missing = Ulid::new().to_string(); | 1007 | + let missing = Ulid::generate().to_string(); |
| 1008 | assert!(matches!( | 1008 | assert!(matches!( |
| 1009 | scratch.store.set_role(&missing, Role::Member).await, | 1009 | scratch.store.set_role(&missing, Role::Member).await, |
| 1010 | Err(StoreError::NotFound) | 1010 | Err(StoreError::NotFound) |
| @@ -2566,7 +2566,7 @@ async fn an_orphan_row_is_refused() { | |||
| 2566 | .len(); | 2566 | .len(); |
| 2567 | assert_eq!(existing, 1, "only the admin"); | 2567 | assert_eq!(existing, 1, "only the admin"); |
| 2568 | 2568 | ||
| 2569 | - let dir = std::env::temp_dir().join(format!("iz-fk-{}", Ulid::new())); | 2569 | + let dir = std::env::temp_dir().join(format!("iz-fk-{}", Ulid::generate())); |
| 2570 | std::fs::create_dir_all(&dir).unwrap(); | 2570 | std::fs::create_dir_all(&dir).unwrap(); |
| 2571 | let path = dir.join("iz.db").to_str().unwrap().to_owned(); | 2571 | let path = dir.join("iz.db").to_str().unwrap().to_owned(); |
| 2572 | { | 2572 | { |
| @@ -2644,7 +2644,7 @@ async fn a_rule_naming_a_column_it_cannot_act_on_is_refused_by_the_schema() { | |||
| 2644 | // past it, straight at the table. The check constraint is the guard: a | 2644 | // past it, straight at the table. The check constraint is the guard: a |
| 2645 | // column on a trigger that never reads one is a rule whose author meant | 2645 | // column on a trigger that never reads one is a rule whose author meant |
| 2646 | // something the engine will not do. | 2646 | // something the engine will not do. |
| 2647 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 2647 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 2648 | std::fs::create_dir_all(&dir).unwrap(); | 2648 | std::fs::create_dir_all(&dir).unwrap(); |
| 2649 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 2649 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 2650 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); | 2650 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); |
| @@ -2775,7 +2775,7 @@ async fn a_decision_is_written_once_per_rule_and_event() { | |||
| 2775 | 2775 | ||
| 2776 | #[tokio::test] | 2776 | #[tokio::test] |
| 2777 | async fn an_actor_only_decision_is_reworded_at_boot() { | 2777 | async fn an_actor_only_decision_is_reworded_at_boot() { |
| 2778 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 2778 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 2779 | std::fs::create_dir_all(&dir).unwrap(); | 2779 | std::fs::create_dir_all(&dir).unwrap(); |
| 2780 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 2780 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 2781 | 2781 | ||
| @@ -3179,7 +3179,7 @@ async fn shared() -> (PathBuf, Arc<TursoStore>, String, String) { | |||
| 3179 | 3179 | ||
| 3180 | /// The same, with a quiet window of `minutes` on the workspace. | 3180 | /// The same, with a quiet window of `minutes` on the workspace. |
| 3181 | async fn waiting(minutes: u32) -> (PathBuf, Arc<TursoStore>, String, String) { | 3181 | async fn waiting(minutes: u32) -> (PathBuf, Arc<TursoStore>, String, String) { |
| 3182 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 3182 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 3183 | std::fs::create_dir_all(&dir).unwrap(); | 3183 | std::fs::create_dir_all(&dir).unwrap(); |
| 3184 | let store = Arc::new( | 3184 | let store = Arc::new( |
| 3185 | TursoStore::open(dir.join("iz.db").to_str().unwrap(), &dir.join("storage")) | 3185 | TursoStore::open(dir.join("iz.db").to_str().unwrap(), &dir.join("storage")) |
| @@ -5533,7 +5533,7 @@ async fn a_write_that_failed_announces_nothing() { | |||
| 5533 | let store = &scratch.store; | 5533 | let store = &scratch.store; |
| 5534 | let mut rx = store.subscribe(); | 5534 | let mut rx = store.subscribe(); |
| 5535 | 5535 | ||
| 5536 | - let missing = Ulid::new().to_string(); | 5536 | + let missing = Ulid::generate().to_string(); |
| 5537 | assert!(matches!( | 5537 | assert!(matches!( |
| 5538 | store | 5538 | store |
| 5539 | .record_send_accepted(&missing, OffsetDateTime::now_utc()) | 5539 | .record_send_accepted(&missing, OffsetDateTime::now_utc()) |
| @@ -5589,8 +5589,7 @@ fn every_writing_method_announces_or_is_named_here() { | |||
| 5589 | let impl_block = &source[start..end]; | 5589 | let impl_block = &source[start..end]; |
| 5590 | 5590 | ||
| 5591 | let mut silent = Vec::new(); | 5591 | let mut silent = Vec::new(); |
| 5592 | - let mut methods = impl_block.split("\n async fn ").skip(1).peekable(); | 5592 | + for chunk in impl_block.split("\n async fn ").skip(1) { |
| 5593 | - while let Some(chunk) = methods.next() { | ||
| 5594 | let name = chunk | 5593 | let name = chunk |
| 5595 | .split(['(', '<', ' ']) | 5594 | .split(['(', '<', ' ']) |
| 5596 | .next() | 5595 | .next() |
| @@ -5726,7 +5725,7 @@ async fn a_sender_check_is_recorded_apart_from_a_test_and_cleared_on_edit() { | |||
| 5726 | /// deployed with, kept verbatim in `tests/fixtures/` — and fills it with the | 5725 | /// deployed with, kept verbatim in `tests/fixtures/` — and fills it with the |
| 5727 | /// kinds of row a live workspace holds, blobs included. | 5726 | /// kinds of row a live workspace holds, blobs included. |
| 5728 | async fn live_shaped_database() -> (PathBuf, String) { | 5727 | async fn live_shaped_database() -> (PathBuf, String) { |
| 5729 | - let dir = std::env::temp_dir().join(format!("iz-reconcile-{}", Ulid::new())); | 5728 | + let dir = std::env::temp_dir().join(format!("iz-reconcile-{}", Ulid::generate())); |
| 5730 | std::fs::create_dir_all(&dir).unwrap(); | 5729 | std::fs::create_dir_all(&dir).unwrap(); |
| 5731 | let path = dir.join("iz.db").to_str().unwrap().to_string(); | 5730 | let path = dir.join("iz.db").to_str().unwrap().to_string(); |
| 5732 | 5731 | ||
| @@ -7358,7 +7357,7 @@ async fn each_reminder_tells_the_meeting_in_its_own_recipients_clock() { | |||
| 7358 | 7357 | ||
| 7359 | #[tokio::test] | 7358 | #[tokio::test] |
| 7360 | async fn reminder_rows_survive_a_reopen() { | 7359 | async fn reminder_rows_survive_a_reopen() { |
| 7361 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 7360 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 7362 | std::fs::create_dir_all(&dir).unwrap(); | 7361 | std::fs::create_dir_all(&dir).unwrap(); |
| 7363 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 7362 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 7364 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); | 7363 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); |
| @@ -7369,7 +7368,6 @@ async fn reminder_rows_survive_a_reopen() { | |||
| 7369 | store.assign_task(&task, &mate).await.unwrap(); | 7368 | store.assign_task(&task, &mate).await.unwrap(); |
| 7370 | let before = reminders(&store, &task).await; | 7369 | let before = reminders(&store, &task).await; |
| 7371 | assert_eq!(before.len(), 1); | 7370 | assert_eq!(before.len(), 1); |
| 7372 | - let before = before; | ||
| 7373 | drop(store); | 7371 | drop(store); |
| 7374 | 7372 | ||
| 7375 | let reopened = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); | 7373 | let reopened = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); |
| @@ -7473,7 +7471,7 @@ async fn a_whole_second_stamp_is_written_with_nine_zero_digits() { | |||
| 7473 | /// one. | 7471 | /// one. |
| 7474 | #[tokio::test] | 7472 | #[tokio::test] |
| 7475 | async fn a_boot_canonicalizes_the_legacy_whole_second_stamps() { | 7473 | async fn a_boot_canonicalizes_the_legacy_whole_second_stamps() { |
| 7476 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 7474 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 7477 | std::fs::create_dir_all(&dir).unwrap(); | 7475 | std::fs::create_dir_all(&dir).unwrap(); |
| 7478 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 7476 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 7479 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); | 7477 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); |
| @@ -8050,7 +8048,7 @@ struct Planted { | |||
| 8050 | 8048 | ||
| 8051 | impl Planted { | 8049 | impl Planted { |
| 8052 | async fn plant(rows: &[(&str, &str, Vec<u8>)]) -> Self { | 8050 | async fn plant(rows: &[(&str, &str, Vec<u8>)]) -> Self { |
| 8053 | - let dir = std::env::temp_dir().join(format!("iz-resniff-{}", Ulid::new())); | 8051 | + let dir = std::env::temp_dir().join(format!("iz-resniff-{}", Ulid::generate())); |
| 8054 | std::fs::create_dir_all(&dir).unwrap(); | 8052 | std::fs::create_dir_all(&dir).unwrap(); |
| 8055 | let path = dir.join("iz.db").to_str().unwrap().to_string(); | 8053 | let path = dir.join("iz.db").to_str().unwrap().to_string(); |
| 8056 | drop(TursoStore::open(&path, &dir.join("storage")).await.unwrap()); | 8054 | drop(TursoStore::open(&path, &dir.join("storage")).await.unwrap()); |
| @@ -8490,7 +8488,7 @@ async fn demoting_a_member_to_viewer_takes_their_assignments_with_them() { | |||
| 8490 | /// reads agree from the first render after the deploy. | 8488 | /// reads agree from the first render after the deploy. |
| 8491 | #[tokio::test] | 8489 | #[tokio::test] |
| 8492 | async fn a_boot_leaves_no_viewer_still_assigned() { | 8490 | async fn a_boot_leaves_no_viewer_still_assigned() { |
| 8493 | - let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::new())); | 8491 | + let dir = std::env::temp_dir().join(format!("iz-test-{}", Ulid::generate())); |
| 8494 | std::fs::create_dir_all(&dir).unwrap(); | 8492 | std::fs::create_dir_all(&dir).unwrap(); |
| 8495 | let path = dir.join("iz.db").to_string_lossy().into_owned(); | 8493 | let path = dir.join("iz.db").to_string_lossy().into_owned(); |
| 8496 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); | 8494 | let store = TursoStore::open(&path, &dir.join("storage")).await.unwrap(); |
| @@ -8590,7 +8588,7 @@ async fn set_user_disabled_round_trips() { | |||
| 8590 | assert!(matches!( | 8588 | assert!(matches!( |
| 8591 | scratch | 8589 | scratch |
| 8592 | .store | 8590 | .store |
| 8593 | - .set_user_disabled(&Ulid::new().to_string(), true) | 8591 | + .set_user_disabled(&Ulid::generate().to_string(), true) |
| 8594 | .await, | 8592 | .await, |
| 8595 | Err(StoreError::NotFound) | 8593 | Err(StoreError::NotFound) |
| 8596 | )); | 8594 | )); |
| @@ -8665,7 +8663,7 @@ async fn a_sync_claims_an_unclaimed_row_without_touching_its_sign_in_fact() { | |||
| 8665 | async fn a_sync_follows_provider_drift_but_not_the_sign_in_fact() { | 8663 | async fn a_sync_follows_provider_drift_but_not_the_sign_in_fact() { |
| 8666 | let (scratch, _workspace, admin_id) = workspace_with_admin().await; | 8664 | let (scratch, _workspace, admin_id) = workspace_with_admin().await; |
| 8667 | let before = scratch.store.user(&admin_id).await.unwrap().unwrap(); | 8665 | let before = scratch.store.user(&admin_id).await.unwrap().unwrap(); |
| 8668 | - let seen = before.last_signed_in_at.clone(); | 8666 | + let seen = before.last_signed_in_at; |
| 8669 | let sync = scratch | 8667 | let sync = scratch |
| 8670 | .store | 8668 | .store |
| 8671 | .sync_member("sub-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00") | 8669 | .sync_member("sub-ada", "ada@iz.sh", "Ada Lovelace", true, 0, "UTC+03:00") |
| @@ -8865,8 +8863,16 @@ async fn app_settings_round_trip_through_one_row_per_key() { | |||
| 8865 | #[tokio::test] | 8863 | #[tokio::test] |
| 8866 | async fn a_remote_attachment_is_born_stored_without_a_local_file() { | 8864 | async fn a_remote_attachment_is_born_stored_without_a_local_file() { |
| 8867 | let (scratch, workspace, admin) = workspace_with_admin().await; | 8865 | let (scratch, workspace, admin) = workspace_with_admin().await; |
| 8868 | - let task = add_task(&scratch.store, &workspace, "Backlog", "Ship it", None, &admin).await; | 8866 | + let task = add_task( |
| 8869 | - let id = Ulid::new().to_string(); | 8867 | + &scratch.store, |
| 8868 | + &workspace, | ||
| 8869 | + "Backlog", | ||
| 8870 | + "Ship it", | ||
| 8871 | + None, | ||
| 8872 | + &admin, | ||
| 8873 | + ) | ||
| 8874 | + .await; | ||
| 8875 | + let id = Ulid::generate().to_string(); | ||
| 8870 | let stored = scratch | 8876 | let stored = scratch |
| 8871 | .store | 8877 | .store |
| 8872 | .add_remote_attachment(NewRemoteAttachment { | 8878 | .add_remote_attachment(NewRemoteAttachment { |
| @@ -8888,11 +8894,7 @@ async fn a_remote_attachment_is_born_stored_without_a_local_file() { | |||
| 8888 | assert_eq!(row.file_name, "remote.png"); | 8894 | assert_eq!(row.file_name, "remote.png"); |
| 8889 | assert_eq!(row.size_bytes, 7); | 8895 | assert_eq!(row.size_bytes, 7); |
| 8890 | assert!( | 8896 | assert!( |
| 8891 | - !scratch | 8897 | + !scratch.storage.join("attachments").join(&id).exists(), |
| 8892 | - .storage | ||
| 8893 | - .join("attachments") | ||
| 8894 | - .join(&id) | ||
| 8895 | - .exists(), | ||
| 8896 | "a stored row names no file on this machine" | 8898 | "a stored row names no file on this machine" |
| 8897 | ); | 8899 | ); |
| 8898 | assert_eq!( | 8900 | assert_eq!( |
| @@ -8964,7 +8966,15 @@ async fn setting_the_storage_backend_announces_settings() { | |||
| 8964 | #[tokio::test] | 8966 | #[tokio::test] |
| 8965 | async fn local_attachments_are_the_oldest_local_rows_up_to_the_limit() { | 8967 | async fn local_attachments_are_the_oldest_local_rows_up_to_the_limit() { |
| 8966 | let (scratch, workspace, admin) = workspace_with_admin().await; | 8968 | let (scratch, workspace, admin) = workspace_with_admin().await; |
| 8967 | - let task = add_task(&scratch.store, &workspace, "Backlog", "Ship it", None, &admin).await; | 8969 | + let task = add_task( |
| 8970 | + &scratch.store, | ||
| 8971 | + &workspace, | ||
| 8972 | + "Backlog", | ||
| 8973 | + "Ship it", | ||
| 8974 | + None, | ||
| 8975 | + &admin, | ||
| 8976 | + ) | ||
| 8977 | + .await; | ||
| 8968 | let now = OffsetDateTime::now_utc(); | 8978 | let now = OffsetDateTime::now_utc(); |
| 8969 | let mut ids = Vec::new(); | 8979 | let mut ids = Vec::new(); |
| 8970 | for (n, name) in ["a.png", "b.png", "c.png"].iter().enumerate() { | 8980 | for (n, name) in ["a.png", "b.png", "c.png"].iter().enumerate() { |
| @@ -8985,12 +8995,7 @@ async fn local_attachments_are_the_oldest_local_rows_up_to_the_limit() { | |||
| 8985 | ); | 8995 | ); |
| 8986 | } | 8996 | } |
| 8987 | // The middle one already moved; it must not appear in the drain's pick. | 8997 | // The middle one already moved; it must not appear in the drain's pick. |
| 8988 | - scratch | 8998 | + scratch.store.mark_attachment_stored(&ids[1]).await.unwrap(); |
| 8989 | - .store | ||
| 8990 | - .mark_attachment_stored(&ids[1]) | ||
| 8991 | - .await | ||
| 8992 | - .unwrap() | ||
| 8993 | - ; | ||
| 8994 | 8999 | ||
| 8995 | let picked = scratch.store.local_attachments(10).await.unwrap(); | 9000 | let picked = scratch.store.local_attachments(10).await.unwrap(); |
| 8996 | assert_eq!( | 9001 | assert_eq!( |
| @@ -9019,7 +9024,15 @@ async fn local_attachments_are_the_oldest_local_rows_up_to_the_limit() { | |||
| 9019 | #[tokio::test] | 9024 | #[tokio::test] |
| 9020 | async fn marking_stored_moves_the_row_and_unlinks_the_file() { | 9025 | async fn marking_stored_moves_the_row_and_unlinks_the_file() { |
| 9021 | let (scratch, workspace, admin) = workspace_with_admin().await; | 9026 | let (scratch, workspace, admin) = workspace_with_admin().await; |
| 9022 | - let task = add_task(&scratch.store, &workspace, "Backlog", "Ship it", None, &admin).await; | 9027 | + let task = add_task( |
| 9028 | + &scratch.store, | ||
| 9029 | + &workspace, | ||
| 9030 | + "Backlog", | ||
| 9031 | + "Ship it", | ||
| 9032 | + None, | ||
| 9033 | + &admin, | ||
| 9034 | + ) | ||
| 9035 | + .await; | ||
| 9023 | let id = scratch | 9036 | let id = scratch |
| 9024 | .store | 9037 | .store |
| 9025 | .add_attachment(NewAttachment { | 9038 | .add_attachment(NewAttachment { |
| @@ -9038,19 +9051,13 @@ async fn marking_stored_moves_the_row_and_unlinks_the_file() { | |||
| 9038 | 9051 | ||
| 9039 | assert!(scratch.store.mark_attachment_stored(&id).await.unwrap()); | 9052 | assert!(scratch.store.mark_attachment_stored(&id).await.unwrap()); |
| 9040 | assert_eq!( | 9053 | assert_eq!( |
| 9041 | - scratch | 9054 | + scratch.store.attachment(&id).await.unwrap().unwrap().remote, |
| 9042 | - .store | ||
| 9043 | - .attachment(&id) | ||
| 9044 | - .await | ||
| 9045 | - .unwrap() | ||
| 9046 | - .unwrap() | ||
| 9047 | - .remote, | ||
| 9048 | iz_core::store::AttachmentWhere::Stored | 9055 | iz_core::store::AttachmentWhere::Stored |
| 9049 | ); | 9056 | ); |
| 9050 | assert!(!file.exists(), "the local bytes left with the row's state"); | 9057 | assert!(!file.exists(), "the local bytes left with the row's state"); |
| 9051 | assert_eq!(scratch.store.local_attachment_count().await.unwrap(), 0); | 9058 | assert_eq!(scratch.store.local_attachment_count().await.unwrap(), 0); |
| 9052 | 9059 | ||
| 9053 | - let missing = Ulid::new().to_string(); | 9060 | + let missing = Ulid::generate().to_string(); |
| 9054 | assert!( | 9061 | assert!( |
| 9055 | !scratch | 9062 | !scratch |
| 9056 | .store | 9063 | .store |
| @@ -9068,7 +9075,7 @@ async fn marking_stored_moves_the_row_and_unlinks_the_file() { | |||
| 9068 | /// planted stored keeps its generic mime across the boot. | 9075 | /// planted stored keeps its generic mime across the boot. |
| 9069 | #[tokio::test] | 9076 | #[tokio::test] |
| 9070 | async fn the_boot_resniff_leaves_stored_rows_alone() { | 9077 | async fn the_boot_resniff_leaves_stored_rows_alone() { |
| 9071 | - let dir = std::env::temp_dir().join(format!("iz-resniff-{}", Ulid::new())); | 9078 | + let dir = std::env::temp_dir().join(format!("iz-resniff-{}", Ulid::generate())); |
| 9072 | std::fs::create_dir_all(&dir).unwrap(); | 9079 | std::fs::create_dir_all(&dir).unwrap(); |
| 9073 | let path = dir.join("iz.db").to_str().unwrap().to_string(); | 9080 | let path = dir.join("iz.db").to_str().unwrap().to_string(); |
| 9074 | drop(TursoStore::open(&path, &dir.join("storage")).await.unwrap()); | 9081 | drop(TursoStore::open(&path, &dir.join("storage")).await.unwrap()); |
crates/iz-web/Cargo.tomlmodified+4 -4
| @@ -7,7 +7,7 @@ repository.workspace = true | |||
| 7 | description = "iz web app: topcoat UI, routes and the server" | 7 | description = "iz web app: topcoat UI, routes and the server" |
| 8 | 8 | ||
| 9 | [dependencies] | 9 | [dependencies] |
| 10 | -topcoat = { version = "0.6.2", default-features = false, features = [ | 10 | +topcoat = { version = "0.8.0", default-features = false, features = [ |
| 11 | "router", | 11 | "router", |
| 12 | "view", | 12 | "view", |
| 13 | "runtime", | 13 | "runtime", |
| @@ -58,16 +58,16 @@ calamine = { version = "0.36.1", default-features = false } | |||
| 58 | # Opens a pptx directly: the slide order and text live in plain entries of | 58 | # Opens a pptx directly: the slide order and text live in plain entries of |
| 59 | # the same zip calamine opens for a workbook, read with the XML parser | 59 | # the same zip calamine opens for a workbook, read with the XML parser |
| 60 | # already in the tree — both crates ride the lockfile as it stands. | 60 | # already in the tree — both crates ride the lockfile as it stands. |
| 61 | -quick-xml = { version = "0.41.0", default-features = false } | 61 | +quick-xml = { version = "0.42.0", default-features = false } |
| 62 | zip.workspace = true | 62 | zip.workspace = true |
| 63 | # Hashes the compiled stylesheet against the bundle's bytes at boot, so a | 63 | # Hashes the compiled stylesheet against the bundle's bytes at boot, so a |
| 64 | # bundle from another generation refuses the boot instead of serving under | 64 | # bundle from another generation refuses the boot instead of serving under |
| 65 | # this binary (see `server.rs`'s `stylesheet_guard`). | 65 | # this binary (see `server.rs`'s `stylesheet_guard`). |
| 66 | -sha2 = "0.10" | 66 | +sha2 = "0.11" |
| 67 | 67 | ||
| 68 | [build-dependencies] | 68 | [build-dependencies] |
| 69 | grass = "0.13" | 69 | grass = "0.13" |
| 70 | -sha2 = "0.10" | 70 | +sha2 = "0.11" |
| 71 | 71 | ||
| 72 | [dev-dependencies] | 72 | [dev-dependencies] |
| 73 | http = "1.5" | 73 | http = "1.5" |
crates/iz-web/src/board.rsmodified+75 -55
| @@ -14,10 +14,10 @@ use topcoat::context::Cx; | |||
| 14 | use topcoat::router::content::Form; | 14 | use topcoat::router::content::Form; |
| 15 | use topcoat::router::request::headers; | 15 | use topcoat::router::request::headers; |
| 16 | use topcoat::router::{HeaderName, StatusCode, header, query_params, route}; | 16 | use topcoat::router::{HeaderName, StatusCode, header, query_params, route}; |
| 17 | -use topcoat::view::{class, view}; | 17 | +use topcoat::view::{View, ViewExt, class, view}; |
| 18 | 18 | ||
| 19 | use crate::i18n::{Key, Lang, t}; | 19 | use crate::i18n::{Key, Lang, t}; |
| 20 | -use crate::server::{Refusal, store, mail, require_user, require_writer}; | 20 | +use crate::server::{Refusal, mail, require_user, require_writer, store}; |
| 21 | 21 | ||
| 22 | /// The board a task belongs to, checked against this person's workspace | 22 | /// The board a task belongs to, checked against this person's workspace |
| 23 | /// before anything trusts an id the browser sent. | 23 | /// before anything trusts an id the browser sent. |
| @@ -84,7 +84,6 @@ async fn create_task_shared( | |||
| 84 | clock_hour: Option<&str>, | 84 | clock_hour: Option<&str>, |
| 85 | clock_minute: Option<&str>, | 85 | clock_minute: Option<&str>, |
| 86 | ) -> Result<Option<Refusal>> { | 86 | ) -> Result<Option<Refusal>> { |
| 87 | - | ||
| 88 | let user = match require_writer(cx).await { | 87 | let user = match require_writer(cx).await { |
| 89 | Ok(user) => user, | 88 | Ok(user) => user, |
| 90 | Err(refusal) => return Ok(Some(refusal)), | 89 | Err(refusal) => return Ok(Some(refusal)), |
| @@ -261,39 +260,41 @@ fn searched(query: Option<&str>) -> Option<String> { | |||
| 261 | fn sort_column_cards(cards: &mut [TaskCard], sort: &str) { | 260 | fn sort_column_cards(cards: &mut [TaskCard], sort: &str) { |
| 262 | match sort { | 261 | match sort { |
| 263 | "created" => cards.sort_by(|a, b| b.id.cmp(&a.id)), | 262 | "created" => cards.sort_by(|a, b| b.id.cmp(&a.id)), |
| 264 | - "title" => cards.sort_by(|a, b| a.title.to_lowercase().cmp(&b.title.to_lowercase())), | 263 | + "title" => cards.sort_by_key(|a| a.title.to_lowercase()), |
| 265 | _ => {} | 264 | _ => {} |
| 266 | } | 265 | } |
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | /// The whole column list. | 268 | /// The whole column list. |
| 270 | -async fn board_columns( | 269 | +async fn board_columns<'a>( |
| 271 | - cx: &Cx, | 270 | + cx: &'a Cx, |
| 272 | sort: String, | 271 | sort: String, |
| 273 | tag_filter: Option<String>, | 272 | tag_filter: Option<String>, |
| 274 | assigned: Option<String>, | 273 | assigned: Option<String>, |
| 275 | search: Option<String>, | 274 | search: Option<String>, |
| 276 | - default_tag_id: Option<&str>, | 275 | + default_tag_id: Option<String>, |
| 277 | -) -> Result { | 276 | +) -> Result<impl View + 'a> { |
| 278 | let user = match require_user(cx).await { | 277 | let user = match require_user(cx).await { |
| 279 | Ok(user) => user, | 278 | Ok(user) => user, |
| 280 | Err(refusal) => { | 279 | Err(refusal) => { |
| 281 | // No session to read a language off of — English, same as an | 280 | // No session to read a language off of — English, same as an |
| 282 | // auth screen with no user yet. | 281 | // auth screen with no user yet. |
| 283 | - return view! { | 282 | + return Ok(view! { |
| 284 | cx => | 283 | cx => |
| 285 | <div class="scaffold-note"><p>(refusal.message())</p></div> | 284 | <div class="scaffold-note"><p>(refusal.message())</p></div> |
| 286 | - }; | 285 | + } |
| 286 | + .boxed()); | ||
| 287 | } | 287 | } |
| 288 | }; | 288 | }; |
| 289 | let lang = Lang::from_code(&user.language); | 289 | let lang = Lang::from_code(&user.language); |
| 290 | let store = store(cx).clone(); | 290 | let store = store(cx).clone(); |
| 291 | let Some(mut view_data) = iz_core::board::load(store.as_ref(), &user.workspace_id).await? | 291 | let Some(mut view_data) = iz_core::board::load(store.as_ref(), &user.workspace_id).await? |
| 292 | else { | 292 | else { |
| 293 | - return view! { | 293 | + return Ok(view! { |
| 294 | cx => | 294 | cx => |
| 295 | <div class="scaffold-note"><p>(t(lang, Key::SomethingWentWrong))</p></div> | 295 | <div class="scaffold-note"><p>(t(lang, Key::SomethingWentWrong))</p></div> |
| 296 | - }; | 296 | + } |
| 297 | + .boxed()); | ||
| 297 | }; | 298 | }; |
| 298 | if let Some(needle) = &search { | 299 | if let Some(needle) = &search { |
| 299 | view_data.searching(needle); | 300 | view_data.searching(needle); |
| @@ -315,25 +316,39 @@ async fn board_columns( | |||
| 315 | .collect(); | 316 | .collect(); |
| 316 | let mut columns = Vec::new(); | 317 | let mut columns = Vec::new(); |
| 317 | for column in view_data.columns { | 318 | for column in view_data.columns { |
| 318 | - columns.push(render_column(cx, column, today, zone, may_write, &all_columns, default_tag_id, lang).await?); | 319 | + columns.push(topcoat::view::Child::new( |
| 320 | + render_column( | ||
| 321 | + cx, | ||
| 322 | + column, | ||
| 323 | + today, | ||
| 324 | + zone, | ||
| 325 | + may_write, | ||
| 326 | + &all_columns, | ||
| 327 | + default_tag_id.clone(), | ||
| 328 | + lang, | ||
| 329 | + ) | ||
| 330 | + .await?, | ||
| 331 | + )); | ||
| 319 | } | 332 | } |
| 320 | 333 | ||
| 321 | - view! { | 334 | + Ok(view! { |
| 322 | cx => | 335 | cx => |
| 323 | - for column in columns { (column) } | 336 | + for column in columns { (topcoat::view::Child::new(column)) } |
| 324 | } | 337 | } |
| 338 | + .boxed()) | ||
| 325 | } | 339 | } |
| 326 | 340 | ||
| 327 | -async fn render_column( | 341 | +#[allow(clippy::too_many_arguments)] |
| 328 | - cx: &Cx, | 342 | +async fn render_column<'a>( |
| 343 | + cx: &'a Cx, | ||
| 329 | column: iz_core::board::ColumnView, | 344 | column: iz_core::board::ColumnView, |
| 330 | today: Date, | 345 | today: Date, |
| 331 | zone: time::UtcOffset, | 346 | zone: time::UtcOffset, |
| 332 | may_write: bool, | 347 | may_write: bool, |
| 333 | all_columns: &[(String, String)], | 348 | all_columns: &[(String, String)], |
| 334 | - default_tag_id: Option<&str>, | 349 | + default_tag_id: Option<String>, |
| 335 | lang: Lang, | 350 | lang: Lang, |
| 336 | -) -> Result { | 351 | +) -> Result<impl View + 'a> { |
| 337 | let column_id = column.column.id; | 352 | let column_id = column.column.id; |
| 338 | let name = column.column.name; | 353 | let name = column.column.name; |
| 339 | let is_done_column = column.column.is_done; | 354 | let is_done_column = column.column.is_done; |
| @@ -351,14 +366,14 @@ async fn render_column( | |||
| 351 | &column_id, | 366 | &column_id, |
| 352 | may_write, | 367 | may_write, |
| 353 | all_columns, | 368 | all_columns, |
| 354 | - default_tag_id, | 369 | + default_tag_id.clone(), |
| 355 | lang, | 370 | lang, |
| 356 | ) | 371 | ) |
| 357 | .await?, | 372 | .await?, |
| 358 | ); | 373 | ); |
| 359 | } | 374 | } |
| 360 | 375 | ||
| 361 | - view! { | 376 | + Ok(view! { |
| 362 | cx => | 377 | cx => |
| 363 | <section class="column"> | 378 | <section class="column"> |
| 364 | <header class="column-head"> | 379 | <header class="column-head"> |
| @@ -367,17 +382,19 @@ async fn render_column( | |||
| 367 | </header> | 382 | </header> |
| 368 | <div class="column-cards" id=(column_id.clone())> | 383 | <div class="column-cards" id=(column_id.clone())> |
| 369 | if is_empty { <div class="column-empty">(t(lang, Key::NoTasks))</div> } | 384 | if is_empty { <div class="column-empty">(t(lang, Key::NoTasks))</div> } |
| 370 | - for card in cards { (card) } | 385 | + for card in cards { (topcoat::view::Child::new(card)) } |
| 371 | </div> | 386 | </div> |
| 372 | </section> | 387 | </section> |
| 373 | } | 388 | } |
| 389 | + .boxed()) | ||
| 374 | } | 390 | } |
| 375 | 391 | ||
| 376 | // Drag and the context menu are delegated document listeners in | 392 | // Drag and the context menu are delegated document listeners in |
| 377 | // `card_menu_script`, reading the card's `data-task-id`/`data-from-column` | 393 | // `card_menu_script`, reading the card's `data-task-id`/`data-from-column` |
| 378 | // — per-element handlers would die when a soft submit swaps the board in. | 394 | // — per-element handlers would die when a soft submit swaps the board in. |
| 379 | -async fn render_card( | 395 | +#[allow(clippy::too_many_arguments)] |
| 380 | - cx: &Cx, | 396 | +async fn render_card<'a>( |
| 397 | + cx: &'a Cx, | ||
| 381 | card: TaskCard, | 398 | card: TaskCard, |
| 382 | today: Date, | 399 | today: Date, |
| 383 | done_column: bool, | 400 | done_column: bool, |
| @@ -385,9 +402,9 @@ async fn render_card( | |||
| 385 | column_id: &str, | 402 | column_id: &str, |
| 386 | may_write: bool, | 403 | may_write: bool, |
| 387 | all_columns: &[(String, String)], | 404 | all_columns: &[(String, String)], |
| 388 | - default_tag_id: Option<&str>, | 405 | + default_tag_id: Option<String>, |
| 389 | lang: Lang, | 406 | lang: Lang, |
| 390 | -) -> Result { | 407 | +) -> Result<impl View + 'a> { |
| 391 | let blocks = card.blocks.join(", "); | 408 | let blocks = card.blocks.join(", "); |
| 392 | let blocked_by = card.blocked_by.join(", "); | 409 | let blocked_by = card.blocked_by.join(", "); |
| 393 | let overdue = card.is_overdue(today); | 410 | let overdue = card.is_overdue(today); |
| @@ -420,10 +437,6 @@ async fn render_card( | |||
| 420 | let comments = card.comment_count; | 437 | let comments = card.comment_count; |
| 421 | let subtasks = card.subtask_label(); | 438 | let subtasks = card.subtask_label(); |
| 422 | let subtasks_open = card.holds_on_subtasks(); | 439 | let subtasks_open = card.holds_on_subtasks(); |
| 423 | - let mut assignees = Vec::new(); | ||
| 424 | - for person in card.assignees.iter() { | ||
| 425 | - assignees.push(crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "").await?); | ||
| 426 | - } | ||
| 427 | let has_assignees = !card.assignees.is_empty(); | 440 | let has_assignees = !card.assignees.is_empty(); |
| 428 | let task_id = card.id.clone(); | 441 | let task_id = card.id.clone(); |
| 429 | let from_column = column_id.to_string(); | 442 | let from_column = column_id.to_string(); |
| @@ -434,7 +447,7 @@ async fn render_card( | |||
| 434 | .filter(|(id, _)| id != column_id) | 447 | .filter(|(id, _)| id != column_id) |
| 435 | .cloned() | 448 | .cloned() |
| 436 | .collect(); | 449 | .collect(); |
| 437 | - view! { | 450 | + Ok(view! { |
| 438 | cx => | 451 | cx => |
| 439 | <a class=(class!("card", "card-done" if done_column)) href=(href.clone()) | 452 | <a class=(class!("card", "card-done" if done_column)) href=(href.clone()) |
| 440 | draggable=(if may_write { "true" } else { "false" }) | 453 | draggable=(if may_write { "true" } else { "false" }) |
| @@ -457,7 +470,7 @@ async fn render_card( | |||
| 457 | (deadline) | 470 | (deadline) |
| 458 | </span> | 471 | </span> |
| 459 | if let Some(tag) = &card.tag { | 472 | if let Some(tag) = &card.tag { |
| 460 | - if Some(tag.id.as_str()) != default_tag_id { | 473 | + if Some(tag.id.as_str()) != default_tag_id.as_deref() { |
| 461 | <span class="card-tag">(tag.name.clone())</span> | 474 | <span class="card-tag">(tag.name.clone())</span> |
| 462 | } | 475 | } |
| 463 | } | 476 | } |
| @@ -467,7 +480,9 @@ async fn render_card( | |||
| 467 | if comments > 0 { <span class="card-comments">(format!("{comments} \u{270e}"))</span> } | 480 | if comments > 0 { <span class="card-comments">(format!("{comments} \u{270e}"))</span> } |
| 468 | <div class="spacer"></div> | 481 | <div class="spacer"></div> |
| 469 | <div class="avatars"> | 482 | <div class="avatars"> |
| 470 | - for person in assignees { (person) } | 483 | + for person in &card.assignees { |
| 484 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "").await?)) | ||
| 485 | + } | ||
| 471 | if !has_assignees { | 486 | if !has_assignees { |
| 472 | <span class="avatar avatar-none" role="img" aria-label=(t(lang, Key::NobodyAssignedAria)) data-name=(t(lang, Key::NobodyAssignedTitle))></span> | 487 | <span class="avatar avatar-none" role="img" aria-label=(t(lang, Key::NobodyAssignedAria)) data-name=(t(lang, Key::NobodyAssignedTitle))></span> |
| 473 | } | 488 | } |
| @@ -499,7 +514,7 @@ async fn render_card( | |||
| 499 | } | 514 | } |
| 500 | </div> | 515 | </div> |
| 501 | </div> | 516 | </div> |
| 502 | - } | 517 | + }.boxed()) |
| 503 | } | 518 | } |
| 504 | 519 | ||
| 505 | /// Opens a card's context menu at the cursor — clamped inside the viewport | 520 | /// Opens a card's context menu at the cursor — clamped inside the viewport |
| @@ -521,7 +536,7 @@ async fn render_card( | |||
| 521 | /// edit popovers and the modal itself stay `detail::escape_closes`'s at | 536 | /// edit popovers and the modal itself stay `detail::escape_closes`'s at |
| 522 | /// priority 90; the whole order lives in the table on `layout.rs`'s | 537 | /// priority 90; the whole order lives in the table on `layout.rs`'s |
| 523 | /// `escape_manager_script`. | 538 | /// `escape_manager_script`. |
| 524 | -async fn card_menu_script(cx: &Cx) -> Result { | 539 | +async fn card_menu_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 525 | use topcoat::view::Unescaped; | 540 | use topcoat::view::Unescaped; |
| 526 | const JS: &str = "\ | 541 | const JS: &str = "\ |
| 527 | (function () { \ | 542 | (function () { \ |
| @@ -596,7 +611,7 @@ async fn card_menu_script(cx: &Cx) -> Result { | |||
| 596 | } \ | 611 | } \ |
| 597 | }); \ | 612 | }); \ |
| 598 | })();"; | 613 | })();"; |
| 599 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 614 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 600 | } | 615 | } |
| 601 | 616 | ||
| 602 | /// Live search: the filter bar's `q` input fetches the board as the user | 617 | /// Live search: the filter bar's `q` input fetches the board as the user |
| @@ -605,7 +620,7 @@ async fn card_menu_script(cx: &Cx) -> Result { | |||
| 605 | /// orphan it, and the value is deduped against the last one fetched, so an | 620 | /// orphan it, and the value is deduped against the last one fetched, so an |
| 606 | /// unchanged box never refetches. Enter still submits through the shared | 621 | /// unchanged box never refetches. Enter still submits through the shared |
| 607 | /// soft-nav handler. | 622 | /// soft-nav handler. |
| 608 | -async fn search_script(cx: &Cx) -> Result { | 623 | +async fn search_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 609 | use topcoat::view::Unescaped; | 624 | use topcoat::view::Unescaped; |
| 610 | const JS: &str = "\ | 625 | const JS: &str = "\ |
| 611 | (function () { \ | 626 | (function () { \ |
| @@ -627,7 +642,7 @@ async fn search_script(cx: &Cx) -> Result { | |||
| 627 | timer = setTimeout(function () { timer = null; fire(); }, 200); \ | 642 | timer = setTimeout(function () { timer = null; fire(); }, 200); \ |
| 628 | }); \ | 643 | }); \ |
| 629 | })();"; | 644 | })();"; |
| 630 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 645 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 631 | } | 646 | } |
| 632 | 647 | ||
| 633 | /// Which task, if any, `/` renders the detail modal open on, and the refusal | 648 | /// Which task, if any, `/` renders the detail modal open on, and the refusal |
| @@ -664,17 +679,18 @@ fn sort_label(sort: &str, lang: Lang) -> &'static str { | |||
| 664 | /// The signed-in board: the topbar, the filter chips and the shard that owns | 679 | /// The signed-in board: the topbar, the filter chips and the shard that owns |
| 665 | /// every column and card. | 680 | /// every column and card. |
| 666 | #[allow(unused_variables)] | 681 | #[allow(unused_variables)] |
| 667 | -pub async fn board_page(cx: &Cx, user: &User) -> Result { | 682 | +pub async fn board_page<'a>(cx: &'a Cx, user: &'a User) -> Result<impl View + 'a> { |
| 668 | let view_data = { | 683 | let view_data = { |
| 669 | let store = store(cx).clone(); | 684 | let store = store(cx).clone(); |
| 670 | iz_core::board::load(store.as_ref(), &user.workspace_id).await? | 685 | iz_core::board::load(store.as_ref(), &user.workspace_id).await? |
| 671 | }; | 686 | }; |
| 672 | let lang = Lang::from_code(&user.language); | 687 | let lang = Lang::from_code(&user.language); |
| 673 | let Some(mut view_data) = view_data else { | 688 | let Some(mut view_data) = view_data else { |
| 674 | - return view! { | 689 | + return Ok(view! { |
| 675 | cx => | 690 | cx => |
| 676 | <main class="scaffold-note"><p>(t(lang, Key::SomethingWentWrong))</p></main> | 691 | <main class="scaffold-note"><p>(t(lang, Key::SomethingWentWrong))</p></main> |
| 677 | - }; | 692 | + } |
| 693 | + .boxed()); | ||
| 678 | }; | 694 | }; |
| 679 | // Column names are stored data; the viewer reads them in their own | 695 | // Column names are stored data; the viewer reads them in their own |
| 680 | // language, and every name this page derives — headers, the card move | 696 | // language, and every name this page derives — headers, the card move |
| @@ -733,19 +749,23 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { | |||
| 733 | // an open task wins and `new` is ignored. | 749 | // an open task wins and `new` is ignored. |
| 734 | let open_new = may_write && query.new.is_some() && open_task.is_none(); | 750 | let open_new = may_write && query.new.is_some() && open_task.is_none(); |
| 735 | let sort = valid_sort(query.sort.as_deref()).to_string(); | 751 | let sort = valid_sort(query.sort.as_deref()).to_string(); |
| 736 | - let default_tag_id = tags.iter().find(|tag| tag.is_default).map(|tag| tag.id.as_str()); | 752 | + let default_tag_id = tags |
| 753 | + .iter() | ||
| 754 | + .find(|tag| tag.is_default) | ||
| 755 | + .map(|tag| tag.id.clone()); | ||
| 737 | let refusal = match (query.on.as_deref(), query.refusal.as_deref()) { | 756 | let refusal = match (query.on.as_deref(), query.refusal.as_deref()) { |
| 738 | (Some("create_task") | Some("move_card"), Some(code)) => Refusal::from_code(code), | 757 | (Some("create_task") | Some("move_card"), Some(code)) => Refusal::from_code(code), |
| 739 | _ => None, | 758 | _ => None, |
| 740 | }; | 759 | }; |
| 741 | 760 | ||
| 742 | - view! { | 761 | + let me = crate::detail::Me::from(user); |
| 762 | + Ok(view! { | ||
| 743 | cx => | 763 | cx => |
| 744 | <header class="topbar"> | 764 | <header class="topbar"> |
| 745 | - (crate::layout::family_mark(cx).await?) | 765 | + (topcoat::view::Child::new(crate::layout::family_mark(cx).await?)) |
| 746 | - (crate::layout::topbar_nav(cx, crate::layout::NavPage::Board, user.role, lang).await?) | 766 | + (topcoat::view::Child::new(crate::layout::topbar_nav(cx, crate::layout::NavPage::Board, user.role, lang).await?)) |
| 747 | <div class="spacer"></div> | 767 | <div class="spacer"></div> |
| 748 | - (crate::layout::user_menu(cx, &crate::detail::Me::from(user), lang).await?) | 768 | + (topcoat::view::Child::new(crate::layout::user_menu(cx, &me, lang).await?)) |
| 749 | </header> | 769 | </header> |
| 750 | <div class="filterbar"> | 770 | <div class="filterbar"> |
| 751 | <div class="topbar-divider"></div> | 771 | <div class="topbar-divider"></div> |
| @@ -822,24 +842,24 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { | |||
| 822 | <div class="scaffold-note"><p>(t(lang, Key::NoMatches))</p></div> | 842 | <div class="scaffold-note"><p>(t(lang, Key::NoMatches))</p></div> |
| 823 | } else { | 843 | } else { |
| 824 | <div class="board-columns"> | 844 | <div class="board-columns"> |
| 825 | - (board_columns(cx, sort.clone(), tag_filter.clone(), assigned_filter.clone(), search.clone(), default_tag_id).await?) | 845 | + (topcoat::view::Child::new(board_columns(cx, sort.clone(), tag_filter.clone(), assigned_filter.clone(), search.clone(), default_tag_id).await?)) |
| 826 | </div> | 846 | </div> |
| 827 | } | 847 | } |
| 828 | </main> | 848 | </main> |
| 829 | if let Some(task_id) = &open_task { | 849 | if let Some(task_id) = &open_task { |
| 830 | - (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), open_tab).await?) | 850 | + (topcoat::view::Child::new(crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), open_tab).await?)) |
| 831 | if let Some(file_id) = &query.file { | 851 | if let Some(file_id) = &query.file { |
| 832 | - (crate::detail::file_viewer_modal(cx, task_id, file_id, open_tab, open_sheet, open_rows, open_cols).await?) | 852 | + (topcoat::view::Child::new(crate::detail::file_viewer_modal(cx, task_id, file_id, open_tab, open_sheet, open_rows, open_cols).await?)) |
| 833 | } | 853 | } |
| 834 | } | 854 | } |
| 835 | if open_new { | 855 | if open_new { |
| 836 | - (crate::detail::new_task_modal(cx, &all_columns, lang).await?) | 856 | + (topcoat::view::Child::new(crate::detail::new_task_modal(cx, &all_columns, lang).await?)) |
| 837 | } | 857 | } |
| 838 | - (crate::dropdown::dropdown_script(cx).await?) | 858 | + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) |
| 839 | - (crate::layout::escape_script(cx).await?) | 859 | + (topcoat::view::Child::new(crate::layout::escape_script(cx).await?)) |
| 840 | - (card_menu_script(cx).await?) | 860 | + (topcoat::view::Child::new(card_menu_script(cx).await?)) |
| 841 | - (search_script(cx).await?) | 861 | + (topcoat::view::Child::new(search_script(cx).await?)) |
| 842 | - } | 862 | + }.boxed()) |
| 843 | } | 863 | } |
| 844 | 864 | ||
| 845 | #[cfg(test)] | 865 | #[cfg(test)] |
crates/iz-web/src/detail.rsmodified+294 -240
| @@ -28,7 +28,7 @@ use topcoat::Result; | |||
| 28 | use topcoat::context::Cx; | 28 | use topcoat::context::Cx; |
| 29 | use topcoat::router::content::{Form, Json}; | 29 | use topcoat::router::content::{Form, Json}; |
| 30 | use topcoat::router::{HeaderName, StatusCode, header, route}; | 30 | use topcoat::router::{HeaderName, StatusCode, header, route}; |
| 31 | -use topcoat::view::{class, view}; | 31 | +use topcoat::view::{View, ViewExt, class, view}; |
| 32 | 32 | ||
| 33 | use crate::i18n::{Key, Lang, t}; | 33 | use crate::i18n::{Key, Lang, t}; |
| 34 | use crate::server::{Refusal, back_to, mail, refusal_of, require_user, require_writer, store}; | 34 | use crate::server::{Refusal, back_to, mail, refusal_of, require_user, require_writer, store}; |
| @@ -219,21 +219,6 @@ struct TaskIdForm { | |||
| 219 | task_id: String, | 219 | task_id: String, |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | -#[derive(Deserialize)] | ||
| 223 | -struct SaveTaskForm { | ||
| 224 | - task_id: String, | ||
| 225 | - #[serde(default)] | ||
| 226 | - title: Option<String>, | ||
| 227 | - #[serde(default)] | ||
| 228 | - description: Option<String>, | ||
| 229 | - #[serde(default)] | ||
| 230 | - deadline: Option<String>, | ||
| 231 | - #[serde(default)] | ||
| 232 | - clock_hour: Option<String>, | ||
| 233 | - #[serde(default)] | ||
| 234 | - clock_minute: Option<String>, | ||
| 235 | -} | ||
| 236 | - | ||
| 237 | #[derive(Deserialize)] | 222 | #[derive(Deserialize)] |
| 238 | struct PersonForm { | 223 | struct PersonForm { |
| 239 | task_id: String, | 224 | task_id: String, |
| @@ -560,15 +545,26 @@ pub(crate) fn combine_clock( | |||
| 560 | /// with its optional time. Status is not here: the column a task sits in is | 545 | /// with its optional time. Status is not here: the column a task sits in is |
| 561 | /// changed by moving it, a call `board.rs` owns. | 546 | /// changed by moving it, a call `board.rs` owns. |
| 562 | #[route(POST "/api/save_task")] | 547 | #[route(POST "/api/save_task")] |
| 563 | -async fn save_task(cx: &Cx, Form(input): Form<SaveTaskForm>) -> Redirect { | 548 | +async fn save_task(cx: &Cx, Form(pairs): Form<Vec<(String, String)>>) -> Redirect { |
| 564 | use time::OffsetDateTime; | 549 | use time::OffsetDateTime; |
| 565 | 550 | ||
| 566 | - let (user, facts) = match writer_and_task(cx, &input.task_id).await { | 551 | + // The pairs keep a blank word blank, the way the popover's Clear posts |
| 552 | + // it: absent keeps, blank clears, a value sets. (`Option` fields would | ||
| 553 | + // collapse blank and absent into one None.) | ||
| 554 | + let field = |name: &str| { | ||
| 555 | + pairs | ||
| 556 | + .iter() | ||
| 557 | + .find(|(key, _)| key == name) | ||
| 558 | + .map(|(_, value)| value.as_str()) | ||
| 559 | + }; | ||
| 560 | + let task_id = field("task_id").unwrap_or_default(); | ||
| 561 | + | ||
| 562 | + let (user, facts) = match writer_and_task(cx, task_id).await { | ||
| 567 | Ok(pair) => pair, | 563 | Ok(pair) => pair, |
| 568 | Err(refusal) => return redirect(cx, Some(refusal)), | 564 | Err(refusal) => return redirect(cx, Some(refusal)), |
| 569 | }; | 565 | }; |
| 570 | 566 | ||
| 571 | - let title = match input.title { | 567 | + let title = match field("title") { |
| 572 | Some(given) => { | 568 | Some(given) => { |
| 573 | let trimmed = given.trim().to_string(); | 569 | let trimmed = given.trim().to_string(); |
| 574 | if trimmed.is_empty() { | 570 | if trimmed.is_empty() { |
| @@ -578,17 +574,17 @@ async fn save_task(cx: &Cx, Form(input): Form<SaveTaskForm>) -> Redirect { | |||
| 578 | } | 574 | } |
| 579 | None => facts.row.title.clone(), | 575 | None => facts.row.title.clone(), |
| 580 | }; | 576 | }; |
| 581 | - let description = match &input.description { | 577 | + let description = match field("description") { |
| 582 | Some(given) => given.trim().to_string(), | 578 | Some(given) => given.trim().to_string(), |
| 583 | None => facts.description.clone(), | 579 | None => facts.description.clone(), |
| 584 | }; | 580 | }; |
| 585 | let zone = parse_zone(&user.timezone); | 581 | let zone = parse_zone(&user.timezone); |
| 586 | - let time = match combine_clock(input.clock_hour.as_deref(), input.clock_minute.as_deref()) { | 582 | + let time = match combine_clock(field("clock_hour"), field("clock_minute")) { |
| 587 | Ok(time) => time, | 583 | Ok(time) => time, |
| 588 | Err(refusal) => return redirect(cx, Some(refusal)), | 584 | Err(refusal) => return redirect(cx, Some(refusal)), |
| 589 | }; | 585 | }; |
| 590 | let (deadline, clock_at) = match moment_field( | 586 | let (deadline, clock_at) = match moment_field( |
| 591 | - input.deadline.as_deref(), | 587 | + field("deadline"), |
| 592 | (facts.row.deadline, facts.row.clock_at), | 588 | (facts.row.deadline, facts.row.clock_at), |
| 593 | time.as_deref(), | 589 | time.as_deref(), |
| 594 | zone, | 590 | zone, |
| @@ -600,7 +596,7 @@ async fn save_task(cx: &Cx, Form(input): Form<SaveTaskForm>) -> Redirect { | |||
| 600 | let store = store(cx).clone(); | 596 | let store = store(cx).clone(); |
| 601 | let activity_ids = store | 597 | let activity_ids = store |
| 602 | .save_task( | 598 | .save_task( |
| 603 | - &input.task_id, | 599 | + task_id, |
| 604 | &title, | 600 | &title, |
| 605 | &description, | 601 | &description, |
| 606 | deadline, | 602 | deadline, |
| @@ -999,7 +995,10 @@ async fn delete_file(cx: &Cx, Form(input): Form<FileIdForm>) -> Redirect { | |||
| 999 | let Some((_, url)) = crate::storage::in_of(store.as_ref()).await else { | 995 | let Some((_, url)) = crate::storage::in_of(store.as_ref()).await else { |
| 1000 | return redirect(cx, Some(Refusal::StorageUnavailable)); | 996 | return redirect(cx, Some(Refusal::StorageUnavailable)); |
| 1001 | }; | 997 | }; |
| 1002 | - if let Err(problem) = crate::storage::client(cx).delete(&url, &attachment.id).await { | 998 | + if let Err(problem) = crate::storage::client(cx) |
| 999 | + .delete(&url, &attachment.id) | ||
| 1000 | + .await | ||
| 1001 | + { | ||
| 1003 | eprintln!("storage delete: {problem:?}"); | 1002 | eprintln!("storage delete: {problem:?}"); |
| 1004 | return redirect(cx, Some(Refusal::StorageUnavailable)); | 1003 | return redirect(cx, Some(Refusal::StorageUnavailable)); |
| 1005 | } | 1004 | } |
| @@ -1049,10 +1048,10 @@ async fn delete_file(cx: &Cx, Form(input): Form<FileIdForm>) -> Redirect { | |||
| 1049 | pub(crate) mod glyph { | 1048 | pub(crate) mod glyph { |
| 1050 | use topcoat::Result; | 1049 | use topcoat::Result; |
| 1051 | use topcoat::context::Cx; | 1050 | use topcoat::context::Cx; |
| 1052 | - use topcoat::view::view; | 1051 | + use topcoat::view::{View, ViewExt, view}; |
| 1053 | 1052 | ||
| 1054 | - pub async fn chevron(cx: &Cx) -> Result { | 1053 | + pub async fn chevron<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1055 | - view! { | 1054 | + Ok(view! { |
| 1056 | cx => | 1055 | cx => |
| 1057 | <svg class="glyph" width="14" height="14" viewBox="0 0 16 16" fill="none" | 1056 | <svg class="glyph" width="14" height="14" viewBox="0 0 16 16" fill="none" |
| 1058 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" | 1057 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" |
| @@ -1060,10 +1059,11 @@ pub(crate) mod glyph { | |||
| 1060 | <path d="M4 6l4 4 4-4"></path> | 1059 | <path d="M4 6l4 4 4-4"></path> |
| 1061 | </svg> | 1060 | </svg> |
| 1062 | } | 1061 | } |
| 1062 | + .boxed()) | ||
| 1063 | } | 1063 | } |
| 1064 | 1064 | ||
| 1065 | - pub async fn calendar(cx: &Cx) -> Result { | 1065 | + pub async fn calendar<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1066 | - view! { | 1066 | + Ok(view! { |
| 1067 | cx => | 1067 | cx => |
| 1068 | <svg class="glyph" width="13" height="13" viewBox="0 0 16 16" fill="none" | 1068 | <svg class="glyph" width="13" height="13" viewBox="0 0 16 16" fill="none" |
| 1069 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"> | 1069 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"> |
| @@ -1071,20 +1071,22 @@ pub(crate) mod glyph { | |||
| 1071 | <path d="M2.5 6.5h11M5.5 2v2.5M10.5 2v2.5"></path> | 1071 | <path d="M2.5 6.5h11M5.5 2v2.5M10.5 2v2.5"></path> |
| 1072 | </svg> | 1072 | </svg> |
| 1073 | } | 1073 | } |
| 1074 | + .boxed()) | ||
| 1074 | } | 1075 | } |
| 1075 | 1076 | ||
| 1076 | - pub async fn plus(cx: &Cx) -> Result { | 1077 | + pub async fn plus<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1077 | - view! { | 1078 | + Ok(view! { |
| 1078 | cx => | 1079 | cx => |
| 1079 | <svg class="glyph" width="12" height="12" viewBox="0 0 16 16" fill="none" | 1080 | <svg class="glyph" width="12" height="12" viewBox="0 0 16 16" fill="none" |
| 1080 | stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"> | 1081 | stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"> |
| 1081 | <path d="M8 3v10M3 8h10"></path> | 1082 | <path d="M8 3v10M3 8h10"></path> |
| 1082 | </svg> | 1083 | </svg> |
| 1083 | } | 1084 | } |
| 1085 | + .boxed()) | ||
| 1084 | } | 1086 | } |
| 1085 | 1087 | ||
| 1086 | - pub async fn play(cx: &Cx) -> Result { | 1088 | + pub async fn play<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1087 | - view! { | 1089 | + Ok(view! { |
| 1088 | cx => | 1090 | cx => |
| 1089 | <svg class="glyph glyph-play" width="14" height="14" viewBox="0 0 16 16" | 1091 | <svg class="glyph glyph-play" width="14" height="14" viewBox="0 0 16 16" |
| 1090 | fill="currentColor" stroke="currentColor" stroke-width="1.5" | 1092 | fill="currentColor" stroke="currentColor" stroke-width="1.5" |
| @@ -1092,43 +1094,47 @@ pub(crate) mod glyph { | |||
| 1092 | <path d="M5.5 3.5v9l7.5-4.5z"></path> | 1094 | <path d="M5.5 3.5v9l7.5-4.5z"></path> |
| 1093 | </svg> | 1095 | </svg> |
| 1094 | } | 1096 | } |
| 1097 | + .boxed()) | ||
| 1095 | } | 1098 | } |
| 1096 | 1099 | ||
| 1097 | - pub async fn pause(cx: &Cx) -> Result { | 1100 | + pub async fn pause<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1098 | - view! { | 1101 | + Ok(view! { |
| 1099 | cx => | 1102 | cx => |
| 1100 | <svg class="glyph glyph-pause" width="14" height="14" viewBox="0 0 16 16" fill="none" | 1103 | <svg class="glyph glyph-pause" width="14" height="14" viewBox="0 0 16 16" fill="none" |
| 1101 | stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"> | 1104 | stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"> |
| 1102 | <path d="M5.5 3.5v9M10.5 3.5v9"></path> | 1105 | <path d="M5.5 3.5v9M10.5 3.5v9"></path> |
| 1103 | </svg> | 1106 | </svg> |
| 1104 | } | 1107 | } |
| 1108 | + .boxed()) | ||
| 1105 | } | 1109 | } |
| 1106 | 1110 | ||
| 1107 | - pub async fn cross(cx: &Cx) -> Result { | 1111 | + pub async fn cross<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1108 | - view! { | 1112 | + Ok(view! { |
| 1109 | cx => | 1113 | cx => |
| 1110 | <svg class="glyph" width="13" height="13" viewBox="0 0 16 16" fill="none" | 1114 | <svg class="glyph" width="13" height="13" viewBox="0 0 16 16" fill="none" |
| 1111 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"> | 1115 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"> |
| 1112 | <path d="M4 4l8 8M12 4l-8 8"></path> | 1116 | <path d="M4 4l8 8M12 4l-8 8"></path> |
| 1113 | </svg> | 1117 | </svg> |
| 1114 | } | 1118 | } |
| 1119 | + .boxed()) | ||
| 1115 | } | 1120 | } |
| 1116 | 1121 | ||
| 1117 | /// An open part. Deliberately not the padlock: a dependency row's lock | 1122 | /// An open part. Deliberately not the padlock: a dependency row's lock |
| 1118 | /// means "something is in front of this", and a subtask that is simply | 1123 | /// means "something is in front of this", and a subtask that is simply |
| 1119 | /// unfinished is not blocked by anything. | 1124 | /// unfinished is not blocked by anything. |
| 1120 | - pub async fn ring(cx: &Cx) -> Result { | 1125 | + pub async fn ring<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1121 | - view! { | 1126 | + Ok(view! { |
| 1122 | cx => | 1127 | cx => |
| 1123 | <svg class="glyph" width="12" height="12" viewBox="0 0 16 16" fill="none" | 1128 | <svg class="glyph" width="12" height="12" viewBox="0 0 16 16" fill="none" |
| 1124 | stroke="currentColor" stroke-width="1.6" aria-hidden="true"> | 1129 | stroke="currentColor" stroke-width="1.6" aria-hidden="true"> |
| 1125 | <circle cx="8" cy="8" r="5"></circle> | 1130 | <circle cx="8" cy="8" r="5"></circle> |
| 1126 | </svg> | 1131 | </svg> |
| 1127 | } | 1132 | } |
| 1133 | + .boxed()) | ||
| 1128 | } | 1134 | } |
| 1129 | 1135 | ||
| 1130 | - pub async fn tick(cx: &Cx) -> Result { | 1136 | + pub async fn tick<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1131 | - view! { | 1137 | + Ok(view! { |
| 1132 | cx => | 1138 | cx => |
| 1133 | <svg class="glyph dep-tick" width="14" height="14" viewBox="0 0 16 16" fill="none" | 1139 | <svg class="glyph dep-tick" width="14" height="14" viewBox="0 0 16 16" fill="none" |
| 1134 | stroke="currentColor" stroke-width="1.8" stroke-linecap="round" | 1140 | stroke="currentColor" stroke-width="1.8" stroke-linecap="round" |
| @@ -1136,10 +1142,11 @@ pub(crate) mod glyph { | |||
| 1136 | <path d="M3 8.5l3.5 3.5L13 5"></path> | 1142 | <path d="M3 8.5l3.5 3.5L13 5"></path> |
| 1137 | </svg> | 1143 | </svg> |
| 1138 | } | 1144 | } |
| 1145 | + .boxed()) | ||
| 1139 | } | 1146 | } |
| 1140 | 1147 | ||
| 1141 | - pub async fn lock(cx: &Cx) -> Result { | 1148 | + pub async fn lock<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1142 | - view! { | 1149 | + Ok(view! { |
| 1143 | cx => | 1150 | cx => |
| 1144 | <svg class="glyph" width="14" height="14" viewBox="0 0 16 16" fill="none" | 1151 | <svg class="glyph" width="14" height="14" viewBox="0 0 16 16" fill="none" |
| 1145 | stroke="currentColor" stroke-width="1.6" stroke-linecap="round" | 1152 | stroke="currentColor" stroke-width="1.6" stroke-linecap="round" |
| @@ -1148,17 +1155,18 @@ pub(crate) mod glyph { | |||
| 1148 | <path d="M5.5 7V5a2.5 2.5 0 015 0v2"></path> | 1155 | <path d="M5.5 7V5a2.5 2.5 0 015 0v2"></path> |
| 1149 | </svg> | 1156 | </svg> |
| 1150 | } | 1157 | } |
| 1158 | + .boxed()) | ||
| 1151 | } | 1159 | } |
| 1152 | 1160 | ||
| 1153 | - pub async fn bin(cx: &Cx) -> Result { | 1161 | + pub async fn bin<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1154 | - view! { | 1162 | + Ok(view! { |
| 1155 | cx => | 1163 | cx => |
| 1156 | <svg class="glyph" width="14" height="14" viewBox="0 0 16 16" fill="none" | 1164 | <svg class="glyph" width="14" height="14" viewBox="0 0 16 16" fill="none" |
| 1157 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" | 1165 | stroke="currentColor" stroke-width="1.5" stroke-linecap="round" |
| 1158 | stroke-linejoin="round" aria-hidden="true"> | 1166 | stroke-linejoin="round" aria-hidden="true"> |
| 1159 | <path d="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l0.7 8.5a1 1 0 001 0.9h3.6a1 1 0 001-0.9l0.7-8.5"></path> | 1167 | <path d="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l0.7 8.5a1 1 0 001 0.9h3.6a1 1 0 001-0.9l0.7-8.5"></path> |
| 1160 | </svg> | 1168 | </svg> |
| 1161 | - } | 1169 | + }.boxed()) |
| 1162 | } | 1170 | } |
| 1163 | } | 1171 | } |
| 1164 | 1172 | ||
| @@ -1177,7 +1185,7 @@ pub(crate) mod glyph { | |||
| 1177 | /// rendered. Focused native media controls swallow `Escape` before the page | 1185 | /// rendered. Focused native media controls swallow `Escape` before the page |
| 1178 | /// ever sees the key, so focus landing on the viewer's audio/video is moved | 1186 | /// ever sees the key, so focus landing on the viewer's audio/video is moved |
| 1179 | /// straight back to the panel. | 1187 | /// straight back to the panel. |
| 1180 | -pub(crate) async fn escape_closes(cx: &Cx) -> Result { | 1188 | +pub(crate) async fn escape_closes<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1181 | use topcoat::view::Unescaped; | 1189 | use topcoat::view::Unescaped; |
| 1182 | const JS: &str = "\ | 1190 | const JS: &str = "\ |
| 1183 | (function () { \ | 1191 | (function () { \ |
| @@ -1226,23 +1234,30 @@ pub(crate) async fn escape_closes(cx: &Cx) -> Result { | |||
| 1226 | }); \ | 1234 | }); \ |
| 1227 | }, true); \ | 1235 | }, true); \ |
| 1228 | })();"; | 1236 | })();"; |
| 1229 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 1237 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 1230 | } | 1238 | } |
| 1231 | 1239 | ||
| 1232 | -async fn refused(cx: &Cx, call: &str, lang: Lang) -> Result { | 1240 | +async fn refused<'a>(cx: &'a Cx, call: &'a str, lang: Lang) -> Result<impl View + 'a> { |
| 1233 | match refusal_of(cx, call) { | 1241 | match refusal_of(cx, call) { |
| 1234 | - Some(refusal) => view! { cx => <p class="modal-problem">(refusal.message_in(lang))</p> }, | 1242 | + Some(refusal) => { |
| 1235 | - None => view! { cx => }, | 1243 | + Ok(view! { cx => <p class="modal-problem">(refusal.message_in(lang))</p> }.boxed()) |
| 1244 | + } | ||
| 1245 | + None => Ok(view! { cx => }.boxed()), | ||
| 1236 | } | 1246 | } |
| 1237 | } | 1247 | } |
| 1238 | 1248 | ||
| 1239 | -async fn title_control(cx: &Cx, task: &TaskDetail, may_write: bool, lang: Lang) -> Result { | 1249 | +async fn title_control<'a>( |
| 1250 | + cx: &'a Cx, | ||
| 1251 | + task: &'a TaskDetail, | ||
| 1252 | + may_write: bool, | ||
| 1253 | + lang: Lang, | ||
| 1254 | +) -> Result<impl View + 'a> { | ||
| 1240 | if !may_write { | 1255 | if !may_write { |
| 1241 | - return view! { cx => <h2 class="detail-title">(task.title.clone())</h2> }; | 1256 | + return Ok(view! { cx => <h2 class="detail-title">(task.title.clone())</h2> }.boxed()); |
| 1242 | } | 1257 | } |
| 1243 | let toggle = format!("rename-{}", task.id); | 1258 | let toggle = format!("rename-{}", task.id); |
| 1244 | let rename_aria = t(lang, Key::RenameThisTask); | 1259 | let rename_aria = t(lang, Key::RenameThisTask); |
| 1245 | - view! { | 1260 | + Ok(view! { |
| 1246 | cx => | 1261 | cx => |
| 1247 | <div class="edit"> | 1262 | <div class="edit"> |
| 1248 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(rename_aria)> | 1263 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(rename_aria)> |
| @@ -1255,12 +1270,17 @@ async fn title_control(cx: &Cx, task: &TaskDetail, may_write: bool, lang: Lang) | |||
| 1255 | <button class="edit-save" type="submit">(t(lang, Key::Save))</button> | 1270 | <button class="edit-save" type="submit">(t(lang, Key::Save))</button> |
| 1256 | <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> | 1271 | <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> |
| 1257 | </form> | 1272 | </form> |
| 1258 | - (refused(cx, "save_task", lang).await?) | 1273 | + (topcoat::view::Child::new(refused(cx, "save_task", lang).await?)) |
| 1259 | </div> | 1274 | </div> |
| 1260 | - } | 1275 | + }.boxed()) |
| 1261 | } | 1276 | } |
| 1262 | 1277 | ||
| 1263 | -async fn description_control(cx: &Cx, task: &TaskDetail, may_write: bool, lang: Lang) -> Result { | 1278 | +async fn description_control<'a>( |
| 1279 | + cx: &'a Cx, | ||
| 1280 | + task: &'a TaskDetail, | ||
| 1281 | + may_write: bool, | ||
| 1282 | + lang: Lang, | ||
| 1283 | +) -> Result<impl View + 'a> { | ||
| 1264 | let empty = task.description.trim().is_empty(); | 1284 | let empty = task.description.trim().is_empty(); |
| 1265 | let no_description = t(lang, Key::NoDescription).to_string(); | 1285 | let no_description = t(lang, Key::NoDescription).to_string(); |
| 1266 | let prose = if empty { | 1286 | let prose = if empty { |
| @@ -1270,11 +1290,11 @@ async fn description_control(cx: &Cx, task: &TaskDetail, may_write: bool, lang: | |||
| 1270 | }; | 1290 | }; |
| 1271 | 1291 | ||
| 1272 | if !may_write { | 1292 | if !may_write { |
| 1273 | - return view! { cx => <p class=(class!("detail-prose", "detail-prose-empty" if empty))>(prose)</p> }; | 1293 | + return Ok(view! { cx => <p class=(class!("detail-prose", "detail-prose-empty" if empty))>(prose)</p> }.boxed()); |
| 1274 | } | 1294 | } |
| 1275 | let toggle = format!("describe-{}", task.id); | 1295 | let toggle = format!("describe-{}", task.id); |
| 1276 | let edit_aria = t(lang, Key::EditTheDescription); | 1296 | let edit_aria = t(lang, Key::EditTheDescription); |
| 1277 | - view! { | 1297 | + Ok(view! { |
| 1278 | cx => | 1298 | cx => |
| 1279 | <div class="edit"> | 1299 | <div class="edit"> |
| 1280 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(edit_aria)> | 1300 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(edit_aria)> |
| @@ -1289,9 +1309,9 @@ async fn description_control(cx: &Cx, task: &TaskDetail, may_write: bool, lang: | |||
| 1289 | <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> | 1309 | <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> |
| 1290 | </div> | 1310 | </div> |
| 1291 | </form> | 1311 | </form> |
| 1292 | - (refused(cx, "save_task", lang).await?) | 1312 | + (topcoat::view::Child::new(refused(cx, "save_task", lang).await?)) |
| 1293 | </div> | 1313 | </div> |
| 1294 | - } | 1314 | + }.boxed()) |
| 1295 | } | 1315 | } |
| 1296 | 1316 | ||
| 1297 | /// The moment field: the deadline's calendar popover, with one optional | 1317 | /// The moment field: the deadline's calendar popover, with one optional |
| @@ -1312,14 +1332,14 @@ async fn description_control(cx: &Cx, task: &TaskDetail, may_write: bool, lang: | |||
| 1312 | /// The box speaks the moment when there is one, the day when there is only | 1332 | /// The box speaks the moment when there is one, the day when there is only |
| 1313 | /// a day — the clock's day is always the deadline's, and the label reads in | 1333 | /// a day — the clock's day is always the deadline's, and the label reads in |
| 1314 | /// the viewer's own zone. | 1334 | /// the viewer's own zone. |
| 1315 | -async fn deadline_control( | 1335 | +async fn deadline_control<'a>( |
| 1316 | - cx: &Cx, | 1336 | + cx: &'a Cx, |
| 1317 | - task: &TaskDetail, | 1337 | + task: &'a TaskDetail, |
| 1318 | today: Date, | 1338 | today: Date, |
| 1319 | zone: UtcOffset, | 1339 | zone: UtcOffset, |
| 1320 | may_write: bool, | 1340 | may_write: bool, |
| 1321 | lang: Lang, | 1341 | lang: Lang, |
| 1322 | -) -> Result { | 1342 | +) -> Result<impl View + 'a> { |
| 1323 | let overdue = task.is_overdue(today); | 1343 | let overdue = task.is_overdue(today); |
| 1324 | let local = task.clock_at.map(|at| at.to_offset(zone)); | 1344 | let local = task.clock_at.map(|at| at.to_offset(zone)); |
| 1325 | let label = match (&local, task.deadline_parts(today)) { | 1345 | let label = match (&local, task.deadline_parts(today)) { |
| @@ -1346,32 +1366,33 @@ async fn deadline_control( | |||
| 1346 | (None, None) => t(lang, Key::NoDeadline).to_string(), | 1366 | (None, None) => t(lang, Key::NoDeadline).to_string(), |
| 1347 | }; | 1367 | }; |
| 1348 | if !may_write { | 1368 | if !may_write { |
| 1349 | - return view! { | 1369 | + return Ok(view! { |
| 1350 | cx => | 1370 | cx => |
| 1351 | <span class=(class!("field-box", "detail-overdue" if overdue))> | 1371 | <span class=(class!("field-box", "detail-overdue" if overdue))> |
| 1352 | - (glyph::calendar(cx).await?) | 1372 | + (topcoat::view::Child::new(glyph::calendar(cx).await?)) |
| 1353 | <span class="field-text">(label)</span> | 1373 | <span class="field-text">(label)</span> |
| 1354 | </span> | 1374 | </span> |
| 1355 | - }; | 1375 | + } |
| 1376 | + .boxed()); | ||
| 1356 | } | 1377 | } |
| 1357 | let toggle = format!("deadline-{}", task.id); | 1378 | let toggle = format!("deadline-{}", task.id); |
| 1358 | let input_value = task.deadline_input(); | 1379 | let input_value = task.deadline_input(); |
| 1359 | let hm = local.map(|at| (at.hour(), at.minute())); | 1380 | let hm = local.map(|at| (at.hour(), at.minute())); |
| 1360 | let change_aria = t(lang, Key::ChangeTheDeadline); | 1381 | let change_aria = t(lang, Key::ChangeTheDeadline); |
| 1361 | let no_deadline = t(lang, Key::NoDeadline); | 1382 | let no_deadline = t(lang, Key::NoDeadline); |
| 1362 | - view! { | 1383 | + Ok(view! { |
| 1363 | cx => | 1384 | cx => |
| 1364 | <div class="edit edit-pop datepick-pop"> | 1385 | <div class="edit edit-pop datepick-pop"> |
| 1365 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(change_aria)> | 1386 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(change_aria)> |
| 1366 | <label class=(class!("field-box", "edit-view", "edit-hit", "detail-overdue" if overdue)) for=(toggle.clone())> | 1387 | <label class=(class!("field-box", "edit-view", "edit-hit", "detail-overdue" if overdue)) for=(toggle.clone())> |
| 1367 | - (glyph::calendar(cx).await?) | 1388 | + (topcoat::view::Child::new(glyph::calendar(cx).await?)) |
| 1368 | <span class="field-text datepick-label" data-empty=(no_deadline)>(label)</span> | 1389 | <span class="field-text datepick-label" data-empty=(no_deadline)>(label)</span> |
| 1369 | - (glyph::chevron(cx).await?) | 1390 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1370 | </label> | 1391 | </label> |
| 1371 | <div class="edit-form pop-panel datepick-panel"> | 1392 | <div class="edit-form pop-panel datepick-panel"> |
| 1372 | <form class="pop-form" method="post" action="/api/save_task"> | 1393 | <form class="pop-form" method="post" action="/api/save_task"> |
| 1373 | <input type="hidden" name="task_id" value=(task.id.clone())> | 1394 | <input type="hidden" name="task_id" value=(task.id.clone())> |
| 1374 | - (datepicker_grid(cx, "deadline", &input_value, true, lang).await?) | 1395 | + (topcoat::view::Child::new(datepicker_grid(cx, "deadline", &input_value, true, lang).await?)) |
| 1375 | <div class="datepick-time"> | 1396 | <div class="datepick-time"> |
| 1376 | <select class="field-input" name="clock_hour" aria-label=(t(lang, Key::ClockHour)) data-search=""> | 1397 | <select class="field-input" name="clock_hour" aria-label=(t(lang, Key::ClockHour)) data-search=""> |
| 1377 | <option value="">("--")</option> | 1398 | <option value="">("--")</option> |
| @@ -1388,10 +1409,10 @@ async fn deadline_control( | |||
| 1388 | </select> | 1409 | </select> |
| 1389 | </div> | 1410 | </div> |
| 1390 | </form> | 1411 | </form> |
| 1391 | - (refused(cx, "save_task", lang).await?) | 1412 | + (topcoat::view::Child::new(refused(cx, "save_task", lang).await?)) |
| 1392 | </div> | 1413 | </div> |
| 1393 | </div> | 1414 | </div> |
| 1394 | - } | 1415 | + }.boxed()) |
| 1395 | } | 1416 | } |
| 1396 | 1417 | ||
| 1397 | /// The calendar grid's static shell inside a `.datepick-panel`: a hidden | 1418 | /// The calendar grid's static shell inside a `.datepick-panel`: a hidden |
| @@ -1399,20 +1420,20 @@ async fn deadline_control( | |||
| 1399 | /// grid — the grid cells and month title are blank until `datepicker_script` | 1420 | /// grid — the grid cells and month title are blank until `datepicker_script` |
| 1400 | /// fills them in on open (see that function's doc comment for why the fill | 1421 | /// fills them in on open (see that function's doc comment for why the fill |
| 1401 | /// happens in JS rather than here). | 1422 | /// happens in JS rather than here). |
| 1402 | -pub(crate) async fn datepicker_grid( | 1423 | +pub(crate) async fn datepicker_grid<'a>( |
| 1403 | - cx: &Cx, | 1424 | + cx: &'a Cx, |
| 1404 | - name: &str, | 1425 | + name: &'a str, |
| 1405 | - value: &str, | 1426 | + value: &'a str, |
| 1406 | autosubmit: bool, | 1427 | autosubmit: bool, |
| 1407 | lang: Lang, | 1428 | lang: Lang, |
| 1408 | -) -> Result { | 1429 | +) -> Result<impl View + 'a> { |
| 1409 | - view! { | 1430 | + Ok(view! { |
| 1410 | cx => | 1431 | cx => |
| 1411 | <input class="datepick-input" type="hidden" name=(name.to_string()) value=(value.to_string()) data-autosubmit=(autosubmit)> | 1432 | <input class="datepick-input" type="hidden" name=(name.to_string()) value=(value.to_string()) data-autosubmit=(autosubmit)> |
| 1412 | <div class="datepick-head"> | 1433 | <div class="datepick-head"> |
| 1413 | - <button class="datepick-nav datepick-prev" type="button" aria-label=(t(lang, Key::PreviousMonth))>(glyph::chevron(cx).await?)</button> | 1434 | + <button class="datepick-nav datepick-prev" type="button" aria-label=(t(lang, Key::PreviousMonth))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</button> |
| 1414 | <span class="datepick-title"></span> | 1435 | <span class="datepick-title"></span> |
| 1415 | - <button class="datepick-nav datepick-next" type="button" aria-label=(t(lang, Key::NextMonth))>(glyph::chevron(cx).await?)</button> | 1436 | + <button class="datepick-nav datepick-next" type="button" aria-label=(t(lang, Key::NextMonth))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</button> |
| 1416 | </div> | 1437 | </div> |
| 1417 | <div class="datepick-weekdays"></div> | 1438 | <div class="datepick-weekdays"></div> |
| 1418 | <div class="datepick-grid"></div> | 1439 | <div class="datepick-grid"></div> |
| @@ -1420,7 +1441,7 @@ pub(crate) async fn datepicker_grid( | |||
| 1420 | <button class="datepick-action datepick-clear" type="button">(t(lang, Key::Clear))</button> | 1441 | <button class="datepick-action datepick-clear" type="button">(t(lang, Key::Clear))</button> |
| 1421 | <button class="datepick-action datepick-today" type="button">(t(lang, Key::Today))</button> | 1442 | <button class="datepick-action datepick-today" type="button">(t(lang, Key::Today))</button> |
| 1422 | </div> | 1443 | </div> |
| 1423 | - } | 1444 | + }.boxed()) |
| 1424 | } | 1445 | } |
| 1425 | 1446 | ||
| 1426 | /// The house calendar's month grid, wholly in JS: this is a plain document | 1447 | /// The house calendar's month grid, wholly in JS: this is a plain document |
| @@ -1447,7 +1468,7 @@ pub(crate) async fn datepicker_grid( | |||
| 1447 | /// the grid of one standing open. The pass runs on every wire — a repair, | 1468 | /// the grid of one standing open. The pass runs on every wire — a repair, |
| 1448 | /// not an install; closed popovers with no unsaved pick are left to the | 1469 | /// not an install; closed popovers with no unsaved pick are left to the |
| 1449 | /// server's own voice. | 1470 | /// server's own voice. |
| 1450 | -pub(crate) async fn datepicker_script(cx: &Cx, lang: Lang) -> Result { | 1471 | +pub(crate) async fn datepicker_script<'a>(cx: &'a Cx, lang: Lang) -> Result<impl View + 'a> { |
| 1451 | use crate::i18n::datepicker_js_literals; | 1472 | use crate::i18n::datepicker_js_literals; |
| 1452 | use topcoat::view::Unescaped; | 1473 | use topcoat::view::Unescaped; |
| 1453 | let (months, weekdays) = datepicker_js_literals(lang); | 1474 | let (months, weekdays) = datepicker_js_literals(lang); |
| @@ -1557,46 +1578,51 @@ pub(crate) async fn datepicker_script(cx: &Cx, lang: Lang) -> Result { | |||
| 1557 | }}, true);\ | 1578 | }}, true);\ |
| 1558 | }})();" | 1579 | }})();" |
| 1559 | ); | 1580 | ); |
| 1560 | - view! { cx => <script>(Unescaped::new_unchecked(js))</script> } | 1581 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(js))</script> }.boxed()) |
| 1561 | } | 1582 | } |
| 1562 | 1583 | ||
| 1563 | -async fn assignee_chip( | 1584 | +async fn assignee_chip<'a>( |
| 1564 | - cx: &Cx, | 1585 | + cx: &'a Cx, |
| 1565 | - task_id: &str, | 1586 | + task_id: &'a str, |
| 1566 | - person: &Person, | 1587 | + person: &'a Person, |
| 1567 | may_write: bool, | 1588 | may_write: bool, |
| 1568 | lang: Lang, | 1589 | lang: Lang, |
| 1569 | -) -> Result { | 1590 | +) -> Result<impl View + 'a> { |
| 1570 | let remove_title = crate::i18n::take_off_this_task(lang, &person.display_name); | 1591 | let remove_title = crate::i18n::take_off_this_task(lang, &person.display_name); |
| 1571 | - view! { | 1592 | + Ok(view! { |
| 1572 | cx => | 1593 | cx => |
| 1573 | <span class="assignee-chip"> | 1594 | <span class="assignee-chip"> |
| 1574 | <a class="person-link" href=(format!("/people/{}", person.id))> | 1595 | <a class="person-link" href=(format!("/people/{}", person.id))> |
| 1575 | - (crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "avatar-sm").await?) | 1596 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "avatar-sm").await?)) |
| 1576 | <span class="assignee-name">(person.display_name.clone())</span> | 1597 | <span class="assignee-name">(person.display_name.clone())</span> |
| 1577 | </a> | 1598 | </a> |
| 1578 | if may_write { | 1599 | if may_write { |
| 1579 | <form class="assignee-drop" method="post" action="/api/unassign"> | 1600 | <form class="assignee-drop" method="post" action="/api/unassign"> |
| 1580 | <input type="hidden" name="task_id" value=(task_id.to_string())> | 1601 | <input type="hidden" name="task_id" value=(task_id.to_string())> |
| 1581 | <input type="hidden" name="user_id" value=(person.id.clone())> | 1602 | <input type="hidden" name="user_id" value=(person.id.clone())> |
| 1582 | - <button class="assignee-remove" type="submit" title=(remove_title)>(glyph::cross(cx).await?)</button> | 1603 | + <button class="assignee-remove" type="submit" title=(remove_title)>(topcoat::view::Child::new(glyph::cross(cx).await?))</button> |
| 1583 | </form> | 1604 | </form> |
| 1584 | } | 1605 | } |
| 1585 | </span> | 1606 | </span> |
| 1586 | - } | 1607 | + }.boxed()) |
| 1587 | } | 1608 | } |
| 1588 | 1609 | ||
| 1589 | -async fn assignee_picker(cx: &Cx, task_id: &str, people: &[Person], lang: Lang) -> Result { | 1610 | +async fn assignee_picker<'a>( |
| 1611 | + cx: &'a Cx, | ||
| 1612 | + task_id: &'a str, | ||
| 1613 | + people: &'a [Person], | ||
| 1614 | + lang: Lang, | ||
| 1615 | +) -> Result<impl View + 'a> { | ||
| 1590 | if people.is_empty() { | 1616 | if people.is_empty() { |
| 1591 | - return view! { cx => }; | 1617 | + return Ok(view! { cx => }.boxed()); |
| 1592 | } | 1618 | } |
| 1593 | let toggle = format!("assign-{task_id}"); | 1619 | let toggle = format!("assign-{task_id}"); |
| 1594 | let put_aria = t(lang, Key::PutSomeoneOnThisTask); | 1620 | let put_aria = t(lang, Key::PutSomeoneOnThisTask); |
| 1595 | - view! { | 1621 | + Ok(view! { |
| 1596 | cx => | 1622 | cx => |
| 1597 | <div class="edit edit-pop assignee-pop"> | 1623 | <div class="edit edit-pop assignee-pop"> |
| 1598 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(put_aria)> | 1624 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(put_aria)> |
| 1599 | - <label class="assignee-add edit-view edit-hit" for=(toggle.clone())>(glyph::plus(cx).await?)</label> | 1625 | + <label class="assignee-add edit-view edit-hit" for=(toggle.clone())>(topcoat::view::Child::new(glyph::plus(cx).await?))</label> |
| 1600 | <div class="edit-form pop-panel"> | 1626 | <div class="edit-form pop-panel"> |
| 1601 | <div class="pop-list pop-list-scroll"> | 1627 | <div class="pop-list pop-list-scroll"> |
| 1602 | for person in people { | 1628 | for person in people { |
| @@ -1604,30 +1630,35 @@ async fn assignee_picker(cx: &Cx, task_id: &str, people: &[Person], lang: Lang) | |||
| 1604 | <input type="hidden" name="task_id" value=(task_id.to_string())> | 1630 | <input type="hidden" name="task_id" value=(task_id.to_string())> |
| 1605 | <input type="hidden" name="user_id" value=(person.id.clone())> | 1631 | <input type="hidden" name="user_id" value=(person.id.clone())> |
| 1606 | <button class="pop-row" type="submit"> | 1632 | <button class="pop-row" type="submit"> |
| 1607 | - (crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "avatar-sm").await?) | 1633 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "avatar-sm").await?)) |
| 1608 | <span class="pop-row-name">(person.display_name.clone())</span> | 1634 | <span class="pop-row-name">(person.display_name.clone())</span> |
| 1609 | </button> | 1635 | </button> |
| 1610 | </form> | 1636 | </form> |
| 1611 | } | 1637 | } |
| 1612 | </div> | 1638 | </div> |
| 1613 | - (refused(cx, "assign", lang).await?) | 1639 | + (topcoat::view::Child::new(refused(cx, "assign", lang).await?)) |
| 1614 | </div> | 1640 | </div> |
| 1615 | </div> | 1641 | </div> |
| 1616 | - } | 1642 | + }.boxed()) |
| 1617 | } | 1643 | } |
| 1618 | 1644 | ||
| 1619 | -async fn link_picker(cx: &Cx, task_id: &str, linkable: &[LinkTarget], lang: Lang) -> Result { | 1645 | +async fn link_picker<'a>( |
| 1646 | + cx: &'a Cx, | ||
| 1647 | + task_id: &'a str, | ||
| 1648 | + linkable: &'a [LinkTarget], | ||
| 1649 | + lang: Lang, | ||
| 1650 | +) -> Result<impl View + 'a> { | ||
| 1620 | if linkable.is_empty() { | 1651 | if linkable.is_empty() { |
| 1621 | - return view! { cx => }; | 1652 | + return Ok(view! { cx => }.boxed()); |
| 1622 | } | 1653 | } |
| 1623 | let toggle = format!("link-{task_id}"); | 1654 | let toggle = format!("link-{task_id}"); |
| 1624 | let link_aria = t(lang, Key::LinkAnotherTask); | 1655 | let link_aria = t(lang, Key::LinkAnotherTask); |
| 1625 | - view! { | 1656 | + Ok(view! { |
| 1626 | cx => | 1657 | cx => |
| 1627 | <div class="edit edit-pop link-pop"> | 1658 | <div class="edit edit-pop link-pop"> |
| 1628 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(link_aria)> | 1659 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(link_aria)> |
| 1629 | <label class="dep-chip edit-view edit-hit" for=(toggle.clone())> | 1660 | <label class="dep-chip edit-view edit-hit" for=(toggle.clone())> |
| 1630 | - (glyph::plus(cx).await?) | 1661 | + (topcoat::view::Child::new(glyph::plus(cx).await?)) |
| 1631 | <span class="dep-chip-text">(t(lang, Key::LinkATask))</span> | 1662 | <span class="dep-chip-text">(t(lang, Key::LinkATask))</span> |
| 1632 | </label> | 1663 | </label> |
| 1633 | <div class="edit-form pop-panel pop-panel-wide"> | 1664 | <div class="edit-form pop-panel pop-panel-wide"> |
| @@ -1658,22 +1689,22 @@ async fn link_picker(cx: &Cx, task_id: &str, linkable: &[LinkTarget], lang: Lang | |||
| 1658 | <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> | 1689 | <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> |
| 1659 | </div> | 1690 | </div> |
| 1660 | </form> | 1691 | </form> |
| 1661 | - (refused(cx, "link_tasks", lang).await?) | 1692 | + (topcoat::view::Child::new(refused(cx, "link_tasks", lang).await?)) |
| 1662 | </div> | 1693 | </div> |
| 1663 | </div> | 1694 | </div> |
| 1664 | - } | 1695 | + }.boxed()) |
| 1665 | } | 1696 | } |
| 1666 | 1697 | ||
| 1667 | /// One part on its parent's page: its key, its title, who holds it, and the | 1698 | /// One part on its parent's page: its key, its title, who holds it, and the |
| 1668 | /// button that lets it out. The status is the column's name, read off the | 1699 | /// button that lets it out. The status is the column's name, read off the |
| 1669 | /// board's columns the page already has. | 1700 | /// board's columns the page already has. |
| 1670 | -async fn subtask_row( | 1701 | +async fn subtask_row<'a>( |
| 1671 | - cx: &Cx, | 1702 | + cx: &'a Cx, |
| 1672 | - part: &iz_core::detail::SubtaskLine, | 1703 | + part: &'a iz_core::detail::SubtaskLine, |
| 1673 | - columns: &[iz_core::Column], | 1704 | + columns: &'a [iz_core::Column], |
| 1674 | may_write: bool, | 1705 | may_write: bool, |
| 1675 | lang: Lang, | 1706 | lang: Lang, |
| 1676 | -) -> Result { | 1707 | +) -> Result<impl View + 'a> { |
| 1677 | let done = part.is_done(); | 1708 | let done = part.is_done(); |
| 1678 | let status = columns | 1709 | let status = columns |
| 1679 | .iter() | 1710 | .iter() |
| @@ -1695,14 +1726,14 @@ async fn subtask_row( | |||
| 1695 | .await?, | 1726 | .await?, |
| 1696 | ); | 1727 | ); |
| 1697 | } | 1728 | } |
| 1698 | - view! { | 1729 | + Ok(view! { |
| 1699 | cx => | 1730 | cx => |
| 1700 | <div class=(class!("subtask-row", "subtask-row-done" if done))> | 1731 | <div class=(class!("subtask-row", "subtask-row-done" if done))> |
| 1701 | // One link, not two: the key and the title are the same target, | 1732 | // One link, not two: the key and the title are the same target, |
| 1702 | // so the whole of the row's text is the way in. | 1733 | // so the whole of the row's text is the way in. |
| 1703 | <a class="subtask-open" href=(href)> | 1734 | <a class="subtask-open" href=(href)> |
| 1704 | <span class="subtask-mark"> | 1735 | <span class="subtask-mark"> |
| 1705 | - if done { (glyph::tick(cx).await?) } else { (glyph::ring(cx).await?) } | 1736 | + if done { (topcoat::view::Child::new(glyph::tick(cx).await?)) } else { (topcoat::view::Child::new(glyph::ring(cx).await?)) } |
| 1706 | </span> | 1737 | </span> |
| 1707 | <span class="subtask-key">(part.task_key.clone())</span> | 1738 | <span class="subtask-key">(part.task_key.clone())</span> |
| 1708 | <span class="subtask-title">(part.title.clone())</span> | 1739 | <span class="subtask-title">(part.title.clone())</span> |
| @@ -1710,33 +1741,38 @@ async fn subtask_row( | |||
| 1710 | <div class="spacer"></div> | 1741 | <div class="spacer"></div> |
| 1711 | <span class="subtask-status">(status)</span> | 1742 | <span class="subtask-status">(status)</span> |
| 1712 | <div class="avatars"> | 1743 | <div class="avatars"> |
| 1713 | - for face in faces { (face) } | 1744 | + for face in faces { (topcoat::view::Child::new(face)) } |
| 1714 | </div> | 1745 | </div> |
| 1715 | if may_write { | 1746 | if may_write { |
| 1716 | <form class="dep-unlink-form" method="post" action="/api/set_parent"> | 1747 | <form class="dep-unlink-form" method="post" action="/api/set_parent"> |
| 1717 | <input type="hidden" name="task_id" value=(part.id.clone())> | 1748 | <input type="hidden" name="task_id" value=(part.id.clone())> |
| 1718 | <input type="hidden" name="parent_id" value=""> | 1749 | <input type="hidden" name="parent_id" value=""> |
| 1719 | - <button class="dep-unlink" type="submit" title=(release_title)>(glyph::cross(cx).await?)</button> | 1750 | + <button class="dep-unlink" type="submit" title=(release_title)>(topcoat::view::Child::new(glyph::cross(cx).await?))</button> |
| 1720 | </form> | 1751 | </form> |
| 1721 | } | 1752 | } |
| 1722 | </div> | 1753 | </div> |
| 1723 | - } | 1754 | + }.boxed()) |
| 1724 | } | 1755 | } |
| 1725 | 1756 | ||
| 1726 | /// Takes an existing task in as a part. The same shape as `link_picker`, and | 1757 | /// Takes an existing task in as a part. The same shape as `link_picker`, and |
| 1727 | /// absent for the same reason: with nothing to offer it shows nothing. | 1758 | /// absent for the same reason: with nothing to offer it shows nothing. |
| 1728 | -async fn adopt_picker(cx: &Cx, task_id: &str, adoptable: &[LinkTarget], lang: Lang) -> Result { | 1759 | +async fn adopt_picker<'a>( |
| 1760 | + cx: &'a Cx, | ||
| 1761 | + task_id: &'a str, | ||
| 1762 | + adoptable: &'a [LinkTarget], | ||
| 1763 | + lang: Lang, | ||
| 1764 | +) -> Result<impl View + 'a> { | ||
| 1729 | if adoptable.is_empty() { | 1765 | if adoptable.is_empty() { |
| 1730 | - return view! { cx => }; | 1766 | + return Ok(view! { cx => }.boxed()); |
| 1731 | } | 1767 | } |
| 1732 | let toggle = format!("adopt-{task_id}"); | 1768 | let toggle = format!("adopt-{task_id}"); |
| 1733 | let aria = t(lang, Key::MakeAPart); | 1769 | let aria = t(lang, Key::MakeAPart); |
| 1734 | - view! { | 1770 | + Ok(view! { |
| 1735 | cx => | 1771 | cx => |
| 1736 | <div class="edit edit-pop link-pop"> | 1772 | <div class="edit edit-pop link-pop"> |
| 1737 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(aria)> | 1773 | <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(aria)> |
| 1738 | <label class="dep-chip edit-view edit-hit" for=(toggle.clone())> | 1774 | <label class="dep-chip edit-view edit-hit" for=(toggle.clone())> |
| 1739 | - (glyph::plus(cx).await?) | 1775 | + (topcoat::view::Child::new(glyph::plus(cx).await?)) |
| 1740 | <span class="dep-chip-text">(t(lang, Key::MakeAPart))</span> | 1776 | <span class="dep-chip-text">(t(lang, Key::MakeAPart))</span> |
| 1741 | </label> | 1777 | </label> |
| 1742 | <div class="edit-form pop-panel pop-panel-wide"> | 1778 | <div class="edit-form pop-panel pop-panel-wide"> |
| @@ -1758,17 +1794,17 @@ async fn adopt_picker(cx: &Cx, task_id: &str, adoptable: &[LinkTarget], lang: La | |||
| 1758 | </form> | 1794 | </form> |
| 1759 | </div> | 1795 | </div> |
| 1760 | </div> | 1796 | </div> |
| 1761 | - } | 1797 | + }.boxed()) |
| 1762 | } | 1798 | } |
| 1763 | 1799 | ||
| 1764 | -async fn dep_row( | 1800 | +async fn dep_row<'a>( |
| 1765 | - cx: &Cx, | 1801 | + cx: &'a Cx, |
| 1766 | - task_id: &str, | 1802 | + task_id: &'a str, |
| 1767 | - edge: &DependencyEdge, | 1803 | + edge: &'a DependencyEdge, |
| 1768 | direction: Direction, | 1804 | direction: Direction, |
| 1769 | may_write: bool, | 1805 | may_write: bool, |
| 1770 | lang: Lang, | 1806 | lang: Lang, |
| 1771 | -) -> Result { | 1807 | +) -> Result<impl View + 'a> { |
| 1772 | let cleared = edge.is_cleared(); | 1808 | let cleared = edge.is_cleared(); |
| 1773 | let note = match direction { | 1809 | let note = match direction { |
| 1774 | Direction::BlockedBy => edge.blocked_by_label(), | 1810 | Direction::BlockedBy => edge.blocked_by_label(), |
| @@ -1785,7 +1821,7 @@ async fn dep_row( | |||
| 1785 | }; | 1821 | }; |
| 1786 | let remove_title = t(lang, Key::RemoveThisLink); | 1822 | let remove_title = t(lang, Key::RemoveThisLink); |
| 1787 | let href = format!("/?task={}", edge.task_id); | 1823 | let href = format!("/?task={}", edge.task_id); |
| 1788 | - view! { | 1824 | + Ok(view! { |
| 1789 | cx => | 1825 | cx => |
| 1790 | <div class=(class!("dep-row", "dep-row-waiting" if waiting))> | 1826 | <div class=(class!("dep-row", "dep-row-waiting" if waiting))> |
| 1791 | // One link, not two, the subtask row's own shape: tag, key, | 1827 | // One link, not two, the subtask row's own shape: tag, key, |
| @@ -1793,7 +1829,7 @@ async fn dep_row( | |||
| 1793 | // between the row's edges and the X is the way in. | 1829 | // between the row's edges and the X is the way in. |
| 1794 | <a class="dep-link" href=(href)> | 1830 | <a class="dep-link" href=(href)> |
| 1795 | <span class="dep-tag">(tag)</span> | 1831 | <span class="dep-tag">(tag)</span> |
| 1796 | - if cleared { (glyph::tick(cx).await?) } else { (glyph::lock(cx).await?) } | 1832 | + if cleared { (topcoat::view::Child::new(glyph::tick(cx).await?)) } else { (topcoat::view::Child::new(glyph::lock(cx).await?)) } |
| 1797 | <span class="dep-key">(edge.task_key.clone())</span> | 1833 | <span class="dep-key">(edge.task_key.clone())</span> |
| 1798 | <span class="dep-title">(edge.title.clone())</span> | 1834 | <span class="dep-title">(edge.title.clone())</span> |
| 1799 | <div class="spacer"></div> | 1835 | <div class="spacer"></div> |
| @@ -1804,11 +1840,11 @@ async fn dep_row( | |||
| 1804 | <input type="hidden" name="task_id" value=(task_id.to_string())> | 1840 | <input type="hidden" name="task_id" value=(task_id.to_string())> |
| 1805 | <input type="hidden" name="other_id" value=(edge.task_id.clone())> | 1841 | <input type="hidden" name="other_id" value=(edge.task_id.clone())> |
| 1806 | <input type="hidden" name="direction" value=(wire)> | 1842 | <input type="hidden" name="direction" value=(wire)> |
| 1807 | - <button class="dep-unlink" type="submit" title=(remove_title)>(glyph::cross(cx).await?)</button> | 1843 | + <button class="dep-unlink" type="submit" title=(remove_title)>(topcoat::view::Child::new(glyph::cross(cx).await?))</button> |
| 1808 | </form> | 1844 | </form> |
| 1809 | } | 1845 | } |
| 1810 | </div> | 1846 | </div> |
| 1811 | - } | 1847 | + }.boxed()) |
| 1812 | } | 1848 | } |
| 1813 | 1849 | ||
| 1814 | /// The version stamp a `/files/{id}` URL carries: the row's `uploaded_at`. | 1850 | /// The version stamp a `/files/{id}` URL carries: the row's `uploaded_at`. |
| @@ -1819,14 +1855,14 @@ fn attachment_stamp(attachment: &iz_core::store::Attachment) -> String { | |||
| 1819 | (attachment.uploaded_at.unix_timestamp_nanos() / 1_000).to_string() | 1855 | (attachment.uploaded_at.unix_timestamp_nanos() / 1_000).to_string() |
| 1820 | } | 1856 | } |
| 1821 | 1857 | ||
| 1822 | -async fn file_chip( | 1858 | +async fn file_chip<'a>( |
| 1823 | - cx: &Cx, | 1859 | + cx: &'a Cx, |
| 1824 | - task_id: &str, | 1860 | + task_id: &'a str, |
| 1825 | - file: &iz_core::detail::FileLine, | 1861 | + file: &'a iz_core::detail::FileLine, |
| 1826 | - me: &Me, | 1862 | + me: &'a Me, |
| 1827 | may_write: bool, | 1863 | may_write: bool, |
| 1828 | lang: Lang, | 1864 | lang: Lang, |
| 1829 | -) -> Result { | 1865 | +) -> Result<impl View + 'a> { |
| 1830 | let _ = may_write; | 1866 | let _ = may_write; |
| 1831 | let may_drop = me.id == file.uploaded_by || me.role.can_administer(); | 1867 | let may_drop = me.id == file.uploaded_by || me.role.can_administer(); |
| 1832 | let on_comment = file.comment_id.is_some(); | 1868 | let on_comment = file.comment_id.is_some(); |
| @@ -1846,7 +1882,7 @@ async fn file_chip( | |||
| 1846 | _ => format!("/files/{}", file.id), | 1882 | _ => format!("/files/{}", file.id), |
| 1847 | } | 1883 | } |
| 1848 | }; | 1884 | }; |
| 1849 | - view! { | 1885 | + Ok(view! { |
| 1850 | cx => | 1886 | cx => |
| 1851 | <span class="file-chip"> | 1887 | <span class="file-chip"> |
| 1852 | <a class="file-chip-name" href=(href)>(file.name.clone())</a> | 1888 | <a class="file-chip-name" href=(href)>(file.name.clone())</a> |
| @@ -1857,19 +1893,23 @@ async fn file_chip( | |||
| 1857 | if may_drop { | 1893 | if may_drop { |
| 1858 | <form class="file-chip-drop-form" method="post" action="/api/delete_file"> | 1894 | <form class="file-chip-drop-form" method="post" action="/api/delete_file"> |
| 1859 | <input type="hidden" name="file_id" value=(file.id.clone())> | 1895 | <input type="hidden" name="file_id" value=(file.id.clone())> |
| 1860 | - <button class="file-chip-drop" type="submit" title=(remove_title)>(glyph::cross(cx).await?)</button> | 1896 | + <button class="file-chip-drop" type="submit" title=(remove_title)>(topcoat::view::Child::new(glyph::cross(cx).await?))</button> |
| 1861 | </form> | 1897 | </form> |
| 1862 | } | 1898 | } |
| 1863 | </span> | 1899 | </span> |
| 1864 | - } | 1900 | + }.boxed()) |
| 1865 | } | 1901 | } |
| 1866 | 1902 | ||
| 1867 | -async fn comment_row(cx: &Cx, comment: &Comment, zone: UtcOffset) -> Result { | 1903 | +async fn comment_row<'a>( |
| 1868 | - view! { | 1904 | + cx: &'a Cx, |
| 1905 | + comment: &'a Comment, | ||
| 1906 | + zone: UtcOffset, | ||
| 1907 | +) -> Result<impl View + 'a> { | ||
| 1908 | + Ok(view! { | ||
| 1869 | cx => | 1909 | cx => |
| 1870 | <div class="comment"> | 1910 | <div class="comment"> |
| 1871 | <a class="person-link" href=(format!("/people/{}", comment.author.id))> | 1911 | <a class="person-link" href=(format!("/people/{}", comment.author.id))> |
| 1872 | - (crate::layout::avatar(cx, &comment.author.id, &comment.author.display_name, comment.author.photo_version, "avatar-lg").await?) | 1912 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &comment.author.id, &comment.author.display_name, comment.author.photo_version, "avatar-lg").await?)) |
| 1873 | </a> | 1913 | </a> |
| 1874 | <div class="comment-said"> | 1914 | <div class="comment-said"> |
| 1875 | <div class="comment-head"> | 1915 | <div class="comment-head"> |
| @@ -1879,7 +1919,7 @@ async fn comment_row(cx: &Cx, comment: &Comment, zone: UtcOffset) -> Result { | |||
| 1879 | <div class="comment-body">(comment.body.clone())</div> | 1919 | <div class="comment-body">(comment.body.clone())</div> |
| 1880 | </div> | 1920 | </div> |
| 1881 | </div> | 1921 | </div> |
| 1882 | - } | 1922 | + }.boxed()) |
| 1883 | } | 1923 | } |
| 1884 | 1924 | ||
| 1885 | /// The task modal's markup: title, description, assignees, deadline, | 1925 | /// The task modal's markup: title, description, assignees, deadline, |
| @@ -1934,7 +1974,12 @@ fn tab_class(current: Tab, target: Tab) -> &'static str { | |||
| 1934 | 1974 | ||
| 1935 | /// artboard draws them. Wiring `?task=<id>` on the board page is a later | 1975 | /// artboard draws them. Wiring `?task=<id>` on the board page is a later |
| 1936 | /// integration slice — this only renders the fragment. | 1976 | /// integration slice — this only renders the fragment. |
| 1937 | -pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) -> Result { | 1977 | +pub async fn task_modal<'a>( |
| 1978 | + cx: &'a Cx, | ||
| 1979 | + task_id: &'a str, | ||
| 1980 | + confirm_delete: bool, | ||
| 1981 | + tab: Tab, | ||
| 1982 | +) -> Result<impl View + 'a> { | ||
| 1938 | let snapshot = match load_snapshot(cx, task_id).await? { | 1983 | let snapshot = match load_snapshot(cx, task_id).await? { |
| 1939 | Ok(snapshot) => snapshot, | 1984 | Ok(snapshot) => snapshot, |
| 1940 | Err(refusal) => { | 1985 | Err(refusal) => { |
| @@ -1946,13 +1991,13 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1946 | .await | 1991 | .await |
| 1947 | .map(|user| Lang::from_code(&user.language)) | 1992 | .map(|user| Lang::from_code(&user.language)) |
| 1948 | .unwrap_or(Lang::En); | 1993 | .unwrap_or(Lang::En); |
| 1949 | - return view! { | 1994 | + return Ok(view! { |
| 1950 | cx => | 1995 | cx => |
| 1951 | <div class="modal-scrim"> | 1996 | <div class="modal-scrim"> |
| 1952 | <div class="modal modal-task"><p class="modal-note">(refusal.message_in(lang))</p></div> | 1997 | <div class="modal modal-task"><p class="modal-note">(refusal.message_in(lang))</p></div> |
| 1953 | </div> | 1998 | </div> |
| 1954 | - (escape_closes(cx).await?) | 1999 | + (topcoat::view::Child::new(escape_closes(cx).await?)) |
| 1955 | - }; | 2000 | + }.boxed()); |
| 1956 | } | 2001 | } |
| 1957 | }; | 2002 | }; |
| 1958 | let DetailSnapshot { | 2003 | let DetailSnapshot { |
| @@ -1997,7 +2042,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1997 | None | 2042 | None |
| 1998 | }; | 2043 | }; |
| 1999 | 2044 | ||
| 2000 | - view! { | 2045 | + Ok(view! { |
| 2001 | cx => | 2046 | cx => |
| 2002 | <div class="modal-scrim"> | 2047 | <div class="modal-scrim"> |
| 2003 | <div class="modal modal-task" tabindex="-1"> | 2048 | <div class="modal modal-task" tabindex="-1"> |
| @@ -2019,7 +2064,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2019 | } | 2064 | } |
| 2020 | <span class="detail-key">(detail.task_key.clone())</span> | 2065 | <span class="detail-key">(detail.task_key.clone())</span> |
| 2021 | </div> | 2066 | </div> |
| 2022 | - (title_control(cx, &detail, may_write, lang).await?) | 2067 | + (topcoat::view::Child::new(title_control(cx, &detail, may_write, lang).await?)) |
| 2023 | </div> | 2068 | </div> |
| 2024 | <span class="detail-state"> | 2069 | <span class="detail-state"> |
| 2025 | if may_write { | 2070 | if may_write { |
| @@ -2032,7 +2077,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2032 | <option value=(column.id.clone()) selected=(column.id == detail.column.id)>(column.name.clone())</option> | 2077 | <option value=(column.id.clone()) selected=(column.id == detail.column.id)>(column.name.clone())</option> |
| 2033 | } | 2078 | } |
| 2034 | </select> | 2079 | </select> |
| 2035 | - (glyph::chevron(cx).await?) | 2080 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 2036 | </form> | 2081 | </form> |
| 2037 | } else { | 2082 | } else { |
| 2038 | <span class="field-box"> | 2083 | <span class="field-box"> |
| @@ -2043,7 +2088,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2043 | </span> | 2088 | </span> |
| 2044 | <div class="spacer"></div> | 2089 | <div class="spacer"></div> |
| 2045 | <span class="detail-esc">(t(lang, Key::Esc))</span> | 2090 | <span class="detail-esc">(t(lang, Key::Esc))</span> |
| 2046 | - <a class="detail-close" href="/" aria-label=(t(lang, Key::CloseThisTask))>(glyph::cross(cx).await?)</a> | 2091 | + <a class="detail-close" href="/" aria-label=(t(lang, Key::CloseThisTask))>(topcoat::view::Child::new(glyph::cross(cx).await?))</a> |
| 2047 | <a class="quiet detail-board" href="/">(format!("<- {}", t(lang, Key::NavBoard)))</a> | 2092 | <a class="quiet detail-board" href="/">(format!("<- {}", t(lang, Key::NavBoard)))</a> |
| 2048 | </header> | 2093 | </header> |
| 2049 | 2094 | ||
| @@ -2087,7 +2132,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2087 | <option value=(column.id.clone()) selected=(column.id == detail.column.id)>(column.name.clone())</option> | 2132 | <option value=(column.id.clone()) selected=(column.id == detail.column.id)>(column.name.clone())</option> |
| 2088 | } | 2133 | } |
| 2089 | </select> | 2134 | </select> |
| 2090 | - (glyph::chevron(cx).await?) | 2135 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 2091 | </form> | 2136 | </form> |
| 2092 | } else { | 2137 | } else { |
| 2093 | <span class="field-box"> | 2138 | <span class="field-box"> |
| @@ -2106,7 +2151,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2106 | <option value=(tag.id.clone()) selected=(Some(tag.id.as_str()) == detail.tag.as_ref().map(|t| t.id.as_str()))>(tag.name.clone())</option> | 2151 | <option value=(tag.id.clone()) selected=(Some(tag.id.as_str()) == detail.tag.as_ref().map(|t| t.id.as_str()))>(tag.name.clone())</option> |
| 2107 | } | 2152 | } |
| 2108 | </select> | 2153 | </select> |
| 2109 | - (glyph::chevron(cx).await?) | 2154 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 2110 | </form> | 2155 | </form> |
| 2111 | } else { | 2156 | } else { |
| 2112 | <span class="field-box"> | 2157 | <span class="field-box"> |
| @@ -2118,38 +2163,38 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2118 | </div> | 2163 | </div> |
| 2119 | <div class="detail-field"> | 2164 | <div class="detail-field"> |
| 2120 | <span class="detail-label">(t(lang, Key::Deadline))</span> | 2165 | <span class="detail-label">(t(lang, Key::Deadline))</span> |
| 2121 | - (deadline_control(cx, &detail, today, zone, may_write, lang).await?) | 2166 | + (topcoat::view::Child::new(deadline_control(cx, &detail, today, zone, may_write, lang).await?)) |
| 2122 | </div> | 2167 | </div> |
| 2123 | <div class="detail-field detail-field-people"> | 2168 | <div class="detail-field detail-field-people"> |
| 2124 | <span class="detail-label">(format!("{} — {}", t(lang, Key::Assignees), detail.assignees.len()))</span> | 2169 | <span class="detail-label">(format!("{} — {}", t(lang, Key::Assignees), detail.assignees.len()))</span> |
| 2125 | <div class="detail-assignees"> | 2170 | <div class="detail-assignees"> |
| 2126 | for person in &detail.assignees { | 2171 | for person in &detail.assignees { |
| 2127 | - (assignee_chip(cx, &detail.id, person, may_write, lang).await?) | 2172 | + (topcoat::view::Child::new(assignee_chip(cx, &detail.id, person, may_write, lang).await?)) |
| 2128 | } | 2173 | } |
| 2129 | <div class="spacer"></div> | 2174 | <div class="spacer"></div> |
| 2130 | if may_write { | 2175 | if may_write { |
| 2131 | - (assignee_picker(cx, &detail.id, &unassigned, lang).await?) | 2176 | + (topcoat::view::Child::new(assignee_picker(cx, &detail.id, &unassigned, lang).await?)) |
| 2132 | } | 2177 | } |
| 2133 | </div> | 2178 | </div> |
| 2134 | </div> | 2179 | </div> |
| 2135 | </div> | 2180 | </div> |
| 2136 | - (refused(cx, "move_card", lang).await?) | 2181 | + (topcoat::view::Child::new(refused(cx, "move_card", lang).await?)) |
| 2137 | 2182 | ||
| 2138 | <section class="detail-block"> | 2183 | <section class="detail-block"> |
| 2139 | <div class="detail-block-head"> | 2184 | <div class="detail-block-head"> |
| 2140 | <span class="detail-label">(t(lang, Key::Dependencies))</span> | 2185 | <span class="detail-label">(t(lang, Key::Dependencies))</span> |
| 2141 | <div class="spacer"></div> | 2186 | <div class="spacer"></div> |
| 2142 | if may_write { | 2187 | if may_write { |
| 2143 | - (link_picker(cx, &detail.id, &linkable, lang).await?) | 2188 | + (topcoat::view::Child::new(link_picker(cx, &detail.id, &linkable, lang).await?)) |
| 2144 | } | 2189 | } |
| 2145 | </div> | 2190 | </div> |
| 2146 | if has_deps { | 2191 | if has_deps { |
| 2147 | <div class="dep-list"> | 2192 | <div class="dep-list"> |
| 2148 | for edge in &detail.blocked_by { | 2193 | for edge in &detail.blocked_by { |
| 2149 | - (dep_row(cx, &detail.id, edge, Direction::BlockedBy, may_write, lang).await?) | 2194 | + (topcoat::view::Child::new(dep_row(cx, &detail.id, edge, Direction::BlockedBy, may_write, lang).await?)) |
| 2150 | } | 2195 | } |
| 2151 | for edge in &detail.blocks { | 2196 | for edge in &detail.blocks { |
| 2152 | - (dep_row(cx, &detail.id, edge, Direction::Blocks, may_write, lang).await?) | 2197 | + (topcoat::view::Child::new(dep_row(cx, &detail.id, edge, Direction::Blocks, may_write, lang).await?)) |
| 2153 | } | 2198 | } |
| 2154 | </div> | 2199 | </div> |
| 2155 | } else { | 2200 | } else { |
| @@ -2170,7 +2215,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2170 | 2215 | ||
| 2171 | <section class="detail-block"> | 2216 | <section class="detail-block"> |
| 2172 | <span class="detail-label">(t(lang, Key::Description))</span> | 2217 | <span class="detail-label">(t(lang, Key::Description))</span> |
| 2173 | - (description_control(cx, &detail, may_write, lang).await?) | 2218 | + (topcoat::view::Child::new(description_control(cx, &detail, may_write, lang).await?)) |
| 2174 | </section> | 2219 | </section> |
| 2175 | } | 2220 | } |
| 2176 | 2221 | ||
| @@ -2183,7 +2228,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2183 | } | 2228 | } |
| 2184 | <div class="spacer"></div> | 2229 | <div class="spacer"></div> |
| 2185 | if may_write { | 2230 | if may_write { |
| 2186 | - (adopt_picker(cx, &detail.id, &adoptable, lang).await?) | 2231 | + (topcoat::view::Child::new(adopt_picker(cx, &detail.id, &adoptable, lang).await?)) |
| 2187 | } | 2232 | } |
| 2188 | </div> | 2233 | </div> |
| 2189 | if may_write { | 2234 | if may_write { |
| @@ -2194,14 +2239,14 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2194 | <button class="edit-save" type="submit">(t(lang, Key::AddSubtask))</button> | 2239 | <button class="edit-save" type="submit">(t(lang, Key::AddSubtask))</button> |
| 2195 | </form> | 2240 | </form> |
| 2196 | } | 2241 | } |
| 2197 | - (refused(cx, "create_subtask", lang).await?) | 2242 | + (topcoat::view::Child::new(refused(cx, "create_subtask", lang).await?)) |
| 2198 | - (refused(cx, "set_parent", lang).await?) | 2243 | + (topcoat::view::Child::new(refused(cx, "set_parent", lang).await?)) |
| 2199 | if detail.subtasks.is_empty() { | 2244 | if detail.subtasks.is_empty() { |
| 2200 | <p class="detail-prose detail-prose-empty">(t(lang, Key::NoSubtasks))</p> | 2245 | <p class="detail-prose detail-prose-empty">(t(lang, Key::NoSubtasks))</p> |
| 2201 | } else { | 2246 | } else { |
| 2202 | <div class="subtask-list"> | 2247 | <div class="subtask-list"> |
| 2203 | for part in &detail.subtasks { | 2248 | for part in &detail.subtasks { |
| 2204 | - (subtask_row(cx, part, &detail.columns, may_write, lang).await?) | 2249 | + (topcoat::view::Child::new(subtask_row(cx, part, &detail.columns, may_write, lang).await?)) |
| 2205 | } | 2250 | } |
| 2206 | </div> | 2251 | </div> |
| 2207 | } | 2252 | } |
| @@ -2218,18 +2263,18 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2218 | <form class="file-upload" method="post" action="/files" enctype="multipart/form-data" data-cancel-label=(t(lang, Key::Cancel)) data-empty-label=(t(lang, Key::File))> | 2263 | <form class="file-upload" method="post" action="/files" enctype="multipart/form-data" data-cancel-label=(t(lang, Key::Cancel)) data-empty-label=(t(lang, Key::File))> |
| 2219 | <input type="hidden" name="task_id" value=(detail.id.clone())> | 2264 | <input type="hidden" name="task_id" value=(detail.id.clone())> |
| 2220 | <label class="field-box file-upload-box"> | 2265 | <label class="field-box file-upload-box"> |
| 2221 | - (glyph::plus(cx).await?) | 2266 | + (topcoat::view::Child::new(glyph::plus(cx).await?)) |
| 2222 | <span class="field-text file-upload-name">(t(lang, Key::File))</span> | 2267 | <span class="field-text file-upload-name">(t(lang, Key::File))</span> |
| 2223 | <input class="file-upload-input" type="file" name="file" accept=(accept) multiple="" required=""> | 2268 | <input class="file-upload-input" type="file" name="file" accept=(accept) multiple="" required=""> |
| 2224 | </label> | 2269 | </label> |
| 2225 | </form> | 2270 | </form> |
| 2226 | - (refused(cx, "upload_file", lang).await?) | 2271 | + (topcoat::view::Child::new(refused(cx, "upload_file", lang).await?)) |
| 2227 | } | 2272 | } |
| 2228 | - (refused(cx, "delete_file", lang).await?) | 2273 | + (topcoat::view::Child::new(refused(cx, "delete_file", lang).await?)) |
| 2229 | if !detail.files.is_empty() { | 2274 | if !detail.files.is_empty() { |
| 2230 | <div class="file-list"> | 2275 | <div class="file-list"> |
| 2231 | for file in &detail.files { | 2276 | for file in &detail.files { |
| 2232 | - (file_chip(cx, &detail.id, file, &me, may_write, lang).await?) | 2277 | + (topcoat::view::Child::new(file_chip(cx, &detail.id, file, &me, may_write, lang).await?)) |
| 2233 | } | 2278 | } |
| 2234 | </div> | 2279 | </div> |
| 2235 | } | 2280 | } |
| @@ -2244,7 +2289,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2244 | </div> | 2289 | </div> |
| 2245 | <div class="comment-list"> | 2290 | <div class="comment-list"> |
| 2246 | for entry in &detail.comments { | 2291 | for entry in &detail.comments { |
| 2247 | - (comment_row(cx, entry, zone).await?) | 2292 | + (topcoat::view::Child::new(comment_row(cx, entry, zone).await?)) |
| 2248 | } | 2293 | } |
| 2249 | </div> | 2294 | </div> |
| 2250 | </section> | 2295 | </section> |
| @@ -2313,7 +2358,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2313 | </div> | 2358 | </div> |
| 2314 | 2359 | ||
| 2315 | if tab == Tab::Task { | 2360 | if tab == Tab::Task { |
| 2316 | - (refused(cx, "delete_task", lang).await?) | 2361 | + (topcoat::view::Child::new(refused(cx, "delete_task", lang).await?)) |
| 2317 | 2362 | ||
| 2318 | <footer class="detail-foot"> | 2363 | <footer class="detail-foot"> |
| 2319 | if may_delete { | 2364 | if may_delete { |
| @@ -2321,7 +2366,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2321 | Some(cost) => { | 2366 | Some(cost) => { |
| 2322 | let freed = cost.frees.join(", "); | 2367 | let freed = cost.frees.join(", "); |
| 2323 | <details class="confirm-details" open=(confirm_delete)> | 2368 | <details class="confirm-details" open=(confirm_delete)> |
| 2324 | - <summary class="detail-delete">(glyph::bin(cx).await?)<span>(t(lang, Key::DeleteTask))</span></summary> | 2369 | + <summary class="detail-delete">(topcoat::view::Child::new(glyph::bin(cx).await?))<span>(t(lang, Key::DeleteTask))</span></summary> |
| 2325 | <div class="confirm"> | 2370 | <div class="confirm"> |
| 2326 | <div class="confirm-title">(format!("{} — {}?", cost.task_key, cost.title))</div> | 2371 | <div class="confirm-title">(format!("{} — {}?", cost.task_key, cost.title))</div> |
| 2327 | <ul class="confirm-list"> | 2372 | <ul class="confirm-list"> |
| @@ -2362,13 +2407,13 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2362 | <button class="comment-post" type="submit">(t(lang, Key::Comment))</button> | 2407 | <button class="comment-post" type="submit">(t(lang, Key::Comment))</button> |
| 2363 | </div> | 2408 | </div> |
| 2364 | </form> | 2409 | </form> |
| 2365 | - (refused(cx, "post_comment", lang).await?) | 2410 | + (topcoat::view::Child::new(refused(cx, "post_comment", lang).await?)) |
| 2366 | } | 2411 | } |
| 2367 | </div> | 2412 | </div> |
| 2368 | </div> | 2413 | </div> |
| 2369 | - (datepicker_script(cx, lang).await?) | 2414 | + (topcoat::view::Child::new(datepicker_script(cx, lang).await?)) |
| 2370 | - (escape_closes(cx).await?) | 2415 | + (topcoat::view::Child::new(escape_closes(cx).await?)) |
| 2371 | - } | 2416 | + }.boxed()) |
| 2372 | } | 2417 | } |
| 2373 | 2418 | ||
| 2374 | /// The house audio player: play toggle, clock, seek bar over a hidden | 2419 | /// The house audio player: play toggle, clock, seek bar over a hidden |
| @@ -2377,7 +2422,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 2377 | /// Wiring is per-player and idempotent (`data-wired`), re-run on | 2422 | /// Wiring is per-player and idempotent (`data-wired`), re-run on |
| 2378 | /// `iz:wire` so a player arriving in a soft page swap — where inline | 2423 | /// `iz:wire` so a player arriving in a soft page swap — where inline |
| 2379 | /// scripts never execute — still gets its controls. | 2424 | /// scripts never execute — still gets its controls. |
| 2380 | -async fn audio_player_script(cx: &Cx) -> Result { | 2425 | +async fn audio_player_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 2381 | use topcoat::view::Unescaped; | 2426 | use topcoat::view::Unescaped; |
| 2382 | const JS: &str = "\ | 2427 | const JS: &str = "\ |
| 2383 | (function () { \ | 2428 | (function () { \ |
| @@ -2422,7 +2467,7 @@ async fn audio_player_script(cx: &Cx) -> Result { | |||
| 2422 | wireAll(); \ | 2467 | wireAll(); \ |
| 2423 | document.addEventListener('iz:wire', wireAll); \ | 2468 | document.addEventListener('iz:wire', wireAll); \ |
| 2424 | })();"; | 2469 | })();"; |
| 2425 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 2470 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 2426 | } | 2471 | } |
| 2427 | 2472 | ||
| 2428 | /// The in-app file viewer: `<img>`/`<video>`/`<audio>`/`<object>` per | 2473 | /// The in-app file viewer: `<img>`/`<video>`/`<audio>`/`<object>` per |
| @@ -2433,31 +2478,31 @@ async fn audio_player_script(cx: &Cx) -> Result { | |||
| 2433 | /// mime type with no viewer element: a filename's own link only ever points | 2478 | /// mime type with no viewer element: a filename's own link only ever points |
| 2434 | /// here when [`crate::files::viewer_kind`] already said yes, but a hand-edited | 2479 | /// here when [`crate::files::viewer_kind`] already said yes, but a hand-edited |
| 2435 | /// query string gets the same silent no as a stale or foreign id. | 2480 | /// query string gets the same silent no as a stale or foreign id. |
| 2436 | -pub async fn file_viewer_modal( | 2481 | +pub async fn file_viewer_modal<'a>( |
| 2437 | - cx: &Cx, | 2482 | + cx: &'a Cx, |
| 2438 | - task_id: &str, | 2483 | + task_id: &'a str, |
| 2439 | - file_id: &str, | 2484 | + file_id: &'a str, |
| 2440 | tab: Tab, | 2485 | tab: Tab, |
| 2441 | sheet_index: usize, | 2486 | sheet_index: usize, |
| 2442 | row_page: usize, | 2487 | row_page: usize, |
| 2443 | column_page: usize, | 2488 | column_page: usize, |
| 2444 | -) -> Result { | 2489 | +) -> Result<impl View + 'a> { |
| 2445 | let user = match require_user(cx).await { | 2490 | let user = match require_user(cx).await { |
| 2446 | Ok(user) => user, | 2491 | Ok(user) => user, |
| 2447 | - Err(_) => return view! { cx => }, | 2492 | + Err(_) => return Ok(view! { cx => }.boxed()), |
| 2448 | }; | 2493 | }; |
| 2449 | let store = store(cx).clone(); | 2494 | let store = store(cx).clone(); |
| 2450 | if task_of(store.as_ref(), &user, task_id).await.is_err() { | 2495 | if task_of(store.as_ref(), &user, task_id).await.is_err() { |
| 2451 | - return view! { cx => }; | 2496 | + return Ok(view! { cx => }.boxed()); |
| 2452 | } | 2497 | } |
| 2453 | let Ok(Some(attachment)) = store.attachment(file_id).await else { | 2498 | let Ok(Some(attachment)) = store.attachment(file_id).await else { |
| 2454 | - return view! { cx => }; | 2499 | + return Ok(view! { cx => }.boxed()); |
| 2455 | }; | 2500 | }; |
| 2456 | if attachment.task_id != task_id { | 2501 | if attachment.task_id != task_id { |
| 2457 | - return view! { cx => }; | 2502 | + return Ok(view! { cx => }.boxed()); |
| 2458 | } | 2503 | } |
| 2459 | let Some(kind) = crate::files::viewer_kind(&attachment.mime_type) else { | 2504 | let Some(kind) = crate::files::viewer_kind(&attachment.mime_type) else { |
| 2460 | - return view! { cx => }; | 2505 | + return Ok(view! { cx => }.boxed()); |
| 2461 | }; | 2506 | }; |
| 2462 | let lang = Lang::from_code(&user.language); | 2507 | let lang = Lang::from_code(&user.language); |
| 2463 | // Closing a file returns to the panel exactly as it stood, tab and all: | 2508 | // Closing a file returns to the panel exactly as it stood, tab and all: |
| @@ -2503,7 +2548,7 @@ pub async fn file_viewer_modal( | |||
| 2503 | } else { | 2548 | } else { |
| 2504 | None | 2549 | None |
| 2505 | }; | 2550 | }; |
| 2506 | - view! { | 2551 | + Ok(view! { |
| 2507 | cx => | 2552 | cx => |
| 2508 | <div class="modal-scrim viewer-scrim"> | 2553 | <div class="modal-scrim viewer-scrim"> |
| 2509 | <a class="viewer-close" href=(close_href.clone()) aria-label=(t(lang, Key::CloseTheFile))></a> | 2554 | <a class="viewer-close" href=(close_href.clone()) aria-label=(t(lang, Key::CloseTheFile))></a> |
| @@ -2515,7 +2560,7 @@ pub async fn file_viewer_modal( | |||
| 2515 | } | 2560 | } |
| 2516 | <a class="quiet" href=(download_href)>(t(lang, Key::Download))</a> | 2561 | <a class="quiet" href=(download_href)>(t(lang, Key::Download))</a> |
| 2517 | <span class="detail-esc">(t(lang, Key::Esc))</span> | 2562 | <span class="detail-esc">(t(lang, Key::Esc))</span> |
| 2518 | - <a class="detail-close" href=(close_href) aria-label=(t(lang, Key::CloseTheFile))>(glyph::cross(cx).await?)</a> | 2563 | + <a class="detail-close" href=(close_href) aria-label=(t(lang, Key::CloseTheFile))>(topcoat::view::Child::new(glyph::cross(cx).await?))</a> |
| 2519 | </header> | 2564 | </header> |
| 2520 | <div class="viewer-body"> | 2565 | <div class="viewer-body"> |
| 2521 | match kind { | 2566 | match kind { |
| @@ -2524,28 +2569,28 @@ pub async fn file_viewer_modal( | |||
| 2524 | crate::files::ViewerKind::Audio => <div class="audio-player"> | 2569 | crate::files::ViewerKind::Audio => <div class="audio-player"> |
| 2525 | <button type="button" class="audio-play" aria-label=(t(lang, Key::Play)) | 2570 | <button type="button" class="audio-play" aria-label=(t(lang, Key::Play)) |
| 2526 | data-play=(t(lang, Key::Play)) data-pause=(t(lang, Key::Pause))> | 2571 | data-play=(t(lang, Key::Play)) data-pause=(t(lang, Key::Pause))> |
| 2527 | - (glyph::play(cx).await?) | 2572 | + (topcoat::view::Child::new(glyph::play(cx).await?)) |
| 2528 | - (glyph::pause(cx).await?) | 2573 | + (topcoat::view::Child::new(glyph::pause(cx).await?)) |
| 2529 | </button> | 2574 | </button> |
| 2530 | <span class="audio-time audio-now">"0:00"</span> | 2575 | <span class="audio-time audio-now">"0:00"</span> |
| 2531 | <input class="audio-seek" type="range" min="0" max="1000" value="0" aria-label=(name.clone())> | 2576 | <input class="audio-seek" type="range" min="0" max="1000" value="0" aria-label=(name.clone())> |
| 2532 | <span class="audio-time audio-dur">"0:00"</span> | 2577 | <span class="audio-time audio-dur">"0:00"</span> |
| 2533 | <audio class="audio-el" src=(src) preload="metadata"></audio> | 2578 | <audio class="audio-el" src=(src) preload="metadata"></audio> |
| 2534 | - (audio_player_script(cx).await?) | 2579 | + (topcoat::view::Child::new(audio_player_script(cx).await?)) |
| 2535 | </div>, | 2580 | </div>, |
| 2536 | crate::files::ViewerKind::Pdf => <object class="viewer-media viewer-pdf" data=(src) type="application/pdf"></object>, | 2581 | crate::files::ViewerKind::Pdf => <object class="viewer-media viewer-pdf" data=(src) type="application/pdf"></object>, |
| 2537 | - crate::files::ViewerKind::Sheet => (sheet_view(cx, sheet, task_id, file_id, tab, lang).await?), | 2582 | + crate::files::ViewerKind::Sheet => (topcoat::view::Child::new(sheet_view(cx, sheet, task_id, file_id, tab, lang).await?)), |
| 2538 | crate::files::ViewerKind::Slides => { | 2583 | crate::files::ViewerKind::Slides => { |
| 2539 | - (slides_view(cx, deck, task_id, file_id, tab, lang).await?) | 2584 | + (topcoat::view::Child::new(slides_view(cx, deck, task_id, file_id, tab, lang).await?)) |
| 2540 | } | 2585 | } |
| 2541 | } | 2586 | } |
| 2542 | </div> | 2587 | </div> |
| 2543 | </div> | 2588 | </div> |
| 2544 | if kind == crate::files::ViewerKind::Pdf { | 2589 | if kind == crate::files::ViewerKind::Pdf { |
| 2545 | - (pdf_present_script(cx).await?) | 2590 | + (topcoat::view::Child::new(pdf_present_script(cx).await?)) |
| 2546 | } | 2591 | } |
| 2547 | </div> | 2592 | </div> |
| 2548 | - } | 2593 | + }.boxed()) |
| 2549 | } | 2594 | } |
| 2550 | 2595 | ||
| 2551 | /// The PDF reader's presentation mode: the browser's own plugin fills the | 2596 | /// The PDF reader's presentation mode: the browser's own plugin fills the |
| @@ -2556,7 +2601,7 @@ pub async fn file_viewer_modal( | |||
| 2556 | /// click lands is the one that presents. `Escape` in fullscreen is the | 2601 | /// click lands is the one that presents. `Escape` in fullscreen is the |
| 2557 | /// browser's own exit gesture and never reaches the page; the guard in | 2602 | /// browser's own exit gesture and never reaches the page; the guard in |
| 2558 | /// [`escape_closes`] covers the ones that do. | 2603 | /// [`escape_closes`] covers the ones that do. |
| 2559 | -async fn pdf_present_script(cx: &Cx) -> Result { | 2604 | +async fn pdf_present_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 2560 | use topcoat::view::Unescaped; | 2605 | use topcoat::view::Unescaped; |
| 2561 | const JS: &str = "\ | 2606 | const JS: &str = "\ |
| 2562 | (function () { \ | 2607 | (function () { \ |
| @@ -2570,25 +2615,27 @@ async fn pdf_present_script(cx: &Cx) -> Result { | |||
| 2570 | if (document.fullscreenElement) { document.exitFullscreen(); } else { panel.requestFullscreen(); } \ | 2615 | if (document.fullscreenElement) { document.exitFullscreen(); } else { panel.requestFullscreen(); } \ |
| 2571 | }); \ | 2616 | }); \ |
| 2572 | })();"; | 2617 | })();"; |
| 2573 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 2618 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 2574 | } | 2619 | } |
| 2575 | 2620 | ||
| 2576 | /// One window of one sheet as a table: the tab strip when the book has more | 2621 | /// One window of one sheet as a table: the tab strip when the book has more |
| 2577 | /// than one sheet, the grid with its column letters and row numbers, and the | 2622 | /// than one sheet, the grid with its column letters and row numbers, and the |
| 2578 | /// two pagers that move the window. A workbook no reader here understands | 2623 | /// two pagers that move the window. A workbook no reader here understands |
| 2579 | /// says so in one line — the header's download link is still the whole file. | 2624 | /// says so in one line — the header's download link is still the whole file. |
| 2580 | -async fn sheet_view( | 2625 | +async fn sheet_view<'a>( |
| 2581 | - cx: &Cx, | 2626 | + cx: &'a Cx, |
| 2582 | sheet: Option<crate::sheet::Sheet>, | 2627 | sheet: Option<crate::sheet::Sheet>, |
| 2583 | - task_id: &str, | 2628 | + task_id: &'a str, |
| 2584 | - file_id: &str, | 2629 | + file_id: &'a str, |
| 2585 | tab: Tab, | 2630 | tab: Tab, |
| 2586 | lang: Lang, | 2631 | lang: Lang, |
| 2587 | -) -> Result { | 2632 | +) -> Result<impl View + 'a> { |
| 2588 | use crate::sheet::{COLUMNS_PER_PAGE, ROWS_PER_PAGE, column_name}; | 2633 | use crate::sheet::{COLUMNS_PER_PAGE, ROWS_PER_PAGE, column_name}; |
| 2589 | 2634 | ||
| 2590 | let Some(sheet) = sheet else { | 2635 | let Some(sheet) = sheet else { |
| 2591 | - return view! { cx => <p class="sheet-note">(t(lang, Key::ThisFileWillNotOpen))</p> }; | 2636 | + return Ok( |
| 2637 | + view! { cx => <p class="sheet-note">(t(lang, Key::ThisFileWillNotOpen))</p> }.boxed(), | ||
| 2638 | + ); | ||
| 2592 | }; | 2639 | }; |
| 2593 | let width = sheet.rows.iter().map(Vec::len).max().unwrap_or(0); | 2640 | let width = sheet.rows.iter().map(Vec::len).max().unwrap_or(0); |
| 2594 | let columns: Vec<String> = (0..width) | 2641 | let columns: Vec<String> = (0..width) |
| @@ -2645,7 +2692,7 @@ async fn sheet_view( | |||
| 2645 | Some(total) => format!("{first_letter}–{last_letter} / {total}"), | 2692 | Some(total) => format!("{first_letter}–{last_letter} / {total}"), |
| 2646 | None => format!("{first_letter}–{last_letter}"), | 2693 | None => format!("{first_letter}–{last_letter}"), |
| 2647 | }; | 2694 | }; |
| 2648 | - view! { | 2695 | + Ok(view! { |
| 2649 | cx => | 2696 | cx => |
| 2650 | <div class="viewer-sheet"> | 2697 | <div class="viewer-sheet"> |
| 2651 | if tabs.len() > 1 { | 2698 | if tabs.len() > 1 { |
| @@ -2681,32 +2728,32 @@ async fn sheet_view( | |||
| 2681 | <div class="sheet-pager"> | 2728 | <div class="sheet-pager"> |
| 2682 | <span class="sheet-range">(row_range)</span> | 2729 | <span class="sheet-range">(row_range)</span> |
| 2683 | if let Some(href) = rows_back { | 2730 | if let Some(href) = rows_back { |
| 2684 | - <a class="sheet-step sheet-step-up" href=(href) aria-label=(t(lang, Key::Previous))>(glyph::chevron(cx).await?)</a> | 2731 | + <a class="sheet-step sheet-step-up" href=(href) aria-label=(t(lang, Key::Previous))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</a> |
| 2685 | } else { | 2732 | } else { |
| 2686 | - <span class="sheet-step sheet-step-up sheet-step-off">(glyph::chevron(cx).await?)</span> | 2733 | + <span class="sheet-step sheet-step-up sheet-step-off">(topcoat::view::Child::new(glyph::chevron(cx).await?))</span> |
| 2687 | } | 2734 | } |
| 2688 | if let Some(href) = rows_on { | 2735 | if let Some(href) = rows_on { |
| 2689 | - <a class="sheet-step" href=(href) aria-label=(t(lang, Key::Next))>(glyph::chevron(cx).await?)</a> | 2736 | + <a class="sheet-step" href=(href) aria-label=(t(lang, Key::Next))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</a> |
| 2690 | } else { | 2737 | } else { |
| 2691 | - <span class="sheet-step sheet-step-off">(glyph::chevron(cx).await?)</span> | 2738 | + <span class="sheet-step sheet-step-off">(topcoat::view::Child::new(glyph::chevron(cx).await?))</span> |
| 2692 | } | 2739 | } |
| 2693 | </div> | 2740 | </div> |
| 2694 | <div class="sheet-pager"> | 2741 | <div class="sheet-pager"> |
| 2695 | <span class="sheet-range">(column_range)</span> | 2742 | <span class="sheet-range">(column_range)</span> |
| 2696 | if let Some(href) = columns_back { | 2743 | if let Some(href) = columns_back { |
| 2697 | - <a class="sheet-step sheet-step-left" href=(href) aria-label=(t(lang, Key::Previous))>(glyph::chevron(cx).await?)</a> | 2744 | + <a class="sheet-step sheet-step-left" href=(href) aria-label=(t(lang, Key::Previous))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</a> |
| 2698 | } else { | 2745 | } else { |
| 2699 | - <span class="sheet-step sheet-step-left sheet-step-off">(glyph::chevron(cx).await?)</span> | 2746 | + <span class="sheet-step sheet-step-left sheet-step-off">(topcoat::view::Child::new(glyph::chevron(cx).await?))</span> |
| 2700 | } | 2747 | } |
| 2701 | if let Some(href) = columns_on { | 2748 | if let Some(href) = columns_on { |
| 2702 | - <a class="sheet-step sheet-step-right" href=(href) aria-label=(t(lang, Key::Next))>(glyph::chevron(cx).await?)</a> | 2749 | + <a class="sheet-step sheet-step-right" href=(href) aria-label=(t(lang, Key::Next))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</a> |
| 2703 | } else { | 2750 | } else { |
| 2704 | - <span class="sheet-step sheet-step-right sheet-step-off">(glyph::chevron(cx).await?)</span> | 2751 | + <span class="sheet-step sheet-step-right sheet-step-off">(topcoat::view::Child::new(glyph::chevron(cx).await?))</span> |
| 2705 | } | 2752 | } |
| 2706 | </div> | 2753 | </div> |
| 2707 | </div> | 2754 | </div> |
| 2708 | </div> | 2755 | </div> |
| 2709 | - } | 2756 | + }.boxed()) |
| 2710 | } | 2757 | } |
| 2711 | 2758 | ||
| 2712 | /// One slide of a deck as an outline: the strip of slide numbers when the | 2759 | /// One slide of a deck as an outline: the strip of slide numbers when the |
| @@ -2714,16 +2761,18 @@ async fn sheet_view( | |||
| 2714 | /// paragraph as the heading, the rest as lines — and the pager that moves | 2761 | /// paragraph as the heading, the rest as lines — and the pager that moves |
| 2715 | /// between slides. A deck no reader here understands says so in one line; | 2762 | /// between slides. A deck no reader here understands says so in one line; |
| 2716 | /// the header's download link is still the whole file. | 2763 | /// the header's download link is still the whole file. |
| 2717 | -async fn slides_view( | 2764 | +async fn slides_view<'a>( |
| 2718 | - cx: &Cx, | 2765 | + cx: &'a Cx, |
| 2719 | deck: Option<crate::slides::Deck>, | 2766 | deck: Option<crate::slides::Deck>, |
| 2720 | - task_id: &str, | 2767 | + task_id: &'a str, |
| 2721 | - file_id: &str, | 2768 | + file_id: &'a str, |
| 2722 | tab: Tab, | 2769 | tab: Tab, |
| 2723 | lang: Lang, | 2770 | lang: Lang, |
| 2724 | -) -> Result { | 2771 | +) -> Result<impl View + 'a> { |
| 2725 | let Some(deck) = deck else { | 2772 | let Some(deck) = deck else { |
| 2726 | - return view! { cx => <p class="sheet-note">(t(lang, Key::ThisFileWillNotOpen))</p> }; | 2773 | + return Ok( |
| 2774 | + view! { cx => <p class="sheet-note">(t(lang, Key::ThisFileWillNotOpen))</p> }.boxed(), | ||
| 2775 | + ); | ||
| 2727 | }; | 2776 | }; |
| 2728 | // Every link out of here is the same page with one number moved: the | 2777 | // Every link out of here is the same page with one number moved: the |
| 2729 | // slide index rides the query param a sheet's tabs use, so the two | 2778 | // slide index rides the query param a sheet's tabs use, so the two |
| @@ -2734,7 +2783,7 @@ async fn slides_view( | |||
| 2734 | tab.slug() | 2783 | tab.slug() |
| 2735 | ) | 2784 | ) |
| 2736 | }; | 2785 | }; |
| 2737 | - let slide = &deck.slides[deck.index]; | 2786 | + let slide = deck.slides[deck.index].clone(); |
| 2738 | let steps: Vec<(String, String, &'static str)> = (0..deck.slides.len()) | 2787 | let steps: Vec<(String, String, &'static str)> = (0..deck.slides.len()) |
| 2739 | .map(|index| { | 2788 | .map(|index| { |
| 2740 | ( | 2789 | ( |
| @@ -2750,7 +2799,7 @@ async fn slides_view( | |||
| 2750 | .collect(); | 2799 | .collect(); |
| 2751 | let back = (deck.index > 0).then(|| at(deck.index - 1)); | 2800 | let back = (deck.index > 0).then(|| at(deck.index - 1)); |
| 2752 | let on = (deck.index + 1 < deck.slides.len()).then(|| at(deck.index + 1)); | 2801 | let on = (deck.index + 1 < deck.slides.len()).then(|| at(deck.index + 1)); |
| 2753 | - view! { | 2802 | + Ok(view! { |
| 2754 | cx => | 2803 | cx => |
| 2755 | <div class="viewer-slides"> | 2804 | <div class="viewer-slides"> |
| 2756 | if steps.len() > 1 { | 2805 | if steps.len() > 1 { |
| @@ -2775,33 +2824,38 @@ async fn slides_view( | |||
| 2775 | (format!("{} / {}", deck.index + 1, deck.slides.len())) | 2824 | (format!("{} / {}", deck.index + 1, deck.slides.len())) |
| 2776 | </span> | 2825 | </span> |
| 2777 | if let Some(href) = back { | 2826 | if let Some(href) = back { |
| 2778 | - <a class="slides-step slides-step-left" href=(href) aria-label=(t(lang, Key::Previous))>(glyph::chevron(cx).await?)</a> | 2827 | + <a class="slides-step slides-step-left" href=(href) aria-label=(t(lang, Key::Previous))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</a> |
| 2779 | } else { | 2828 | } else { |
| 2780 | - <span class="slides-step slides-step-left slides-step-off">(glyph::chevron(cx).await?)</span> | 2829 | + <span class="slides-step slides-step-left slides-step-off">(topcoat::view::Child::new(glyph::chevron(cx).await?))</span> |
| 2781 | } | 2830 | } |
| 2782 | if let Some(href) = on { | 2831 | if let Some(href) = on { |
| 2783 | - <a class="slides-step slides-step-right" href=(href) aria-label=(t(lang, Key::Next))>(glyph::chevron(cx).await?)</a> | 2832 | + <a class="slides-step slides-step-right" href=(href) aria-label=(t(lang, Key::Next))>(topcoat::view::Child::new(glyph::chevron(cx).await?))</a> |
| 2784 | } else { | 2833 | } else { |
| 2785 | - <span class="slides-step slides-step-right slides-step-off">(glyph::chevron(cx).await?)</span> | 2834 | + <span class="slides-step slides-step-right slides-step-off">(topcoat::view::Child::new(glyph::chevron(cx).await?))</span> |
| 2786 | } | 2835 | } |
| 2787 | </div> | 2836 | </div> |
| 2788 | </div> | 2837 | </div> |
| 2789 | </div> | 2838 | </div> |
| 2790 | - } | 2839 | + }.boxed()) |
| 2791 | } | 2840 | } |
| 2792 | 2841 | ||
| 2793 | /// The "New task" popup: a house modal wearing the same scrim/panel chrome | 2842 | /// The "New task" popup: a house modal wearing the same scrim/panel chrome |
| 2794 | /// as [`task_modal`], with a form posting straight to `/api/create_task`. | 2843 | /// as [`task_modal`], with a form posting straight to `/api/create_task`. |
| 2795 | /// Wired off the board top bar's "New task" button as `/?new=1`. | 2844 | /// Wired off the board top bar's "New task" button as `/?new=1`. |
| 2796 | -pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result { | 2845 | +pub async fn new_task_modal<'a>( |
| 2797 | - view! { | 2846 | + cx: &'a Cx, |
| 2847 | + columns: &[(String, String)], | ||
| 2848 | + lang: Lang, | ||
| 2849 | +) -> Result<impl View + 'a> { | ||
| 2850 | + let columns = columns.to_vec(); | ||
| 2851 | + Ok(view! { | ||
| 2798 | cx => | 2852 | cx => |
| 2799 | <div class="modal-scrim"> | 2853 | <div class="modal-scrim"> |
| 2800 | <div class="modal modal-new-task" tabindex="-1"> | 2854 | <div class="modal modal-new-task" tabindex="-1"> |
| 2801 | <header class="detail-head"> | 2855 | <header class="detail-head"> |
| 2802 | <span class="detail-headline">(t(lang, Key::NewTask))</span> | 2856 | <span class="detail-headline">(t(lang, Key::NewTask))</span> |
| 2803 | <span class="detail-esc">(t(lang, Key::Esc))</span> | 2857 | <span class="detail-esc">(t(lang, Key::Esc))</span> |
| 2804 | - <a class="detail-close" href="/" aria-label=(t(lang, Key::CloseThisTask))>(glyph::cross(cx).await?)</a> | 2858 | + <a class="detail-close" href="/" aria-label=(t(lang, Key::CloseThisTask))>(topcoat::view::Child::new(glyph::cross(cx).await?))</a> |
| 2805 | </header> | 2859 | </header> |
| 2806 | <form class="new-task-form" method="post" action="/api/create_task"> | 2860 | <form class="new-task-form" method="post" action="/api/create_task"> |
| 2807 | <label class="field"> | 2861 | <label class="field"> |
| @@ -2813,11 +2867,11 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) - | |||
| 2813 | <span class="field-label">(t(lang, Key::Status))</span> | 2867 | <span class="field-label">(t(lang, Key::Status))</span> |
| 2814 | <span class="field-box"> | 2868 | <span class="field-box"> |
| 2815 | <select class="status-select" name="column_id"> | 2869 | <select class="status-select" name="column_id"> |
| 2816 | - for column in columns { | 2870 | + for column in &columns { |
| 2817 | <option value=(column.0.clone())>(column.1.clone())</option> | 2871 | <option value=(column.0.clone())>(column.1.clone())</option> |
| 2818 | } | 2872 | } |
| 2819 | </select> | 2873 | </select> |
| 2820 | - (glyph::chevron(cx).await?) | 2874 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 2821 | </span> | 2875 | </span> |
| 2822 | </label> | 2876 | </label> |
| 2823 | <div class="field"> | 2877 | <div class="field"> |
| @@ -2825,11 +2879,11 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) - | |||
| 2825 | <div class="edit edit-pop datepick-pop"> | 2879 | <div class="edit edit-pop datepick-pop"> |
| 2826 | <input class="edit-toggle" type="checkbox" id="new-task-deadline"> | 2880 | <input class="edit-toggle" type="checkbox" id="new-task-deadline"> |
| 2827 | <label class="field-box edit-view edit-hit" for="new-task-deadline"> | 2881 | <label class="field-box edit-view edit-hit" for="new-task-deadline"> |
| 2828 | - (glyph::calendar(cx).await?) | 2882 | + (topcoat::view::Child::new(glyph::calendar(cx).await?)) |
| 2829 | <span class="field-text datepick-label" data-empty=(t(lang, Key::NoDeadline))>(t(lang, Key::NoDeadline))</span> | 2883 | <span class="field-text datepick-label" data-empty=(t(lang, Key::NoDeadline))>(t(lang, Key::NoDeadline))</span> |
| 2830 | </label> | 2884 | </label> |
| 2831 | <div class="edit-form pop-panel datepick-panel"> | 2885 | <div class="edit-form pop-panel datepick-panel"> |
| 2832 | - (datepicker_grid(cx, "deadline", "", false, lang).await?) | 2886 | + (topcoat::view::Child::new(datepicker_grid(cx, "deadline", "", false, lang).await?)) |
| 2833 | <div class="datepick-time"> | 2887 | <div class="datepick-time"> |
| 2834 | <select class="field-input" name="clock_hour" aria-label=(t(lang, Key::ClockHour)) data-search=""> | 2888 | <select class="field-input" name="clock_hour" aria-label=(t(lang, Key::ClockHour)) data-search=""> |
| 2835 | <option value="">("--")</option> | 2889 | <option value="">("--")</option> |
| @@ -2853,7 +2907,7 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) - | |||
| 2853 | <span class="field-label">(t(lang, Key::Description))</span> | 2907 | <span class="field-label">(t(lang, Key::Description))</span> |
| 2854 | <textarea class="detail-textarea" name="description" rows="4"></textarea> | 2908 | <textarea class="detail-textarea" name="description" rows="4"></textarea> |
| 2855 | </label> | 2909 | </label> |
| 2856 | - (refused(cx, "create_task", lang).await?) | 2910 | + (topcoat::view::Child::new(refused(cx, "create_task", lang).await?)) |
| 2857 | <div class="new-task-foot"> | 2911 | <div class="new-task-foot"> |
| 2858 | <div class="spacer"></div> | 2912 | <div class="spacer"></div> |
| 2859 | <a class="quiet" href="/">(t(lang, Key::Cancel))</a> | 2913 | <a class="quiet" href="/">(t(lang, Key::Cancel))</a> |
| @@ -2862,7 +2916,7 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) - | |||
| 2862 | </form> | 2916 | </form> |
| 2863 | </div> | 2917 | </div> |
| 2864 | </div> | 2918 | </div> |
| 2865 | - (datepicker_script(cx, lang).await?) | 2919 | + (topcoat::view::Child::new(datepicker_script(cx, lang).await?)) |
| 2866 | - (escape_closes(cx).await?) | 2920 | + (topcoat::view::Child::new(escape_closes(cx).await?)) |
| 2867 | - } | 2921 | + }.boxed()) |
| 2868 | } | 2922 | } |
crates/iz-web/src/dropdown.rsmodified+3 -3
| @@ -40,7 +40,7 @@ | |||
| 40 | 40 | ||
| 41 | use topcoat::Result; | 41 | use topcoat::Result; |
| 42 | use topcoat::context::Cx; | 42 | use topcoat::context::Cx; |
| 43 | -use topcoat::view::{Unescaped, view}; | 43 | +use topcoat::view::{ViewExt, View, Unescaped, view}; |
| 44 | 44 | ||
| 45 | /// Emitted once per page that renders a `<select>`; the enhancement is | 45 | /// Emitted once per page that renders a `<select>`; the enhancement is |
| 46 | /// per-element and idempotent (`data-dd-done`), re-run on `iz:wire` so | 46 | /// per-element and idempotent (`data-dd-done`), re-run on `iz:wire` so |
| @@ -66,7 +66,7 @@ use topcoat::view::{Unescaped, view}; | |||
| 66 | /// `place` caps the open panel's width at `innerWidth − 8`, shaving off the | 66 | /// `place` caps the open panel's width at `innerWidth − 8`, shaving off the |
| 67 | /// padding and borders a `max-width` does not cover, or its right edge would | 67 | /// padding and borders a `max-width` does not cover, or its right edge would |
| 68 | /// clip on a 320px phone no matter where the left clamp puts it. | 68 | /// clip on a 320px phone no matter where the left clamp puts it. |
| 69 | -pub async fn dropdown_script(cx: &Cx) -> Result { | 69 | +pub async fn dropdown_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 70 | const JS: &str = "\ | 70 | const JS: &str = "\ |
| 71 | (function () {\ | 71 | (function () {\ |
| 72 | if (window.__izDd) { return; }\ | 72 | if (window.__izDd) { return; }\ |
| @@ -299,5 +299,5 @@ pub async fn dropdown_script(cx: &Cx) -> Result { | |||
| 299 | enhanceAll();\ | 299 | enhanceAll();\ |
| 300 | document.addEventListener('iz:wire', enhanceAll);\ | 300 | document.addEventListener('iz:wire', enhanceAll);\ |
| 301 | })();"; | 301 | })();"; |
| 302 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 302 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 303 | } | 303 | } |
crates/iz-web/src/files.rsmodified+14 -10
| @@ -16,10 +16,10 @@ use topcoat::router::{ | |||
| 16 | 16 | ||
| 17 | use iz_core::store::sniff::sniff; | 17 | use iz_core::store::sniff::sniff; |
| 18 | use iz_core::store::{ | 18 | use iz_core::store::{ |
| 19 | - NewAttachment, NewRemoteAttachment, AttachmentWhere, StorageBackend, Store, User, | 19 | + AttachmentWhere, NewAttachment, NewRemoteAttachment, StorageBackend, Store, User, |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | -use crate::server::{Refusal, store, require_user}; | 22 | +use crate::server::{Refusal, require_user, store}; |
| 23 | use ulid::Ulid; | 23 | use ulid::Ulid; |
| 24 | 24 | ||
| 25 | path_param!(id); | 25 | path_param!(id); |
| @@ -52,7 +52,10 @@ fn redirect_to(location: &str) -> (StatusCode, HeaderMap, Vec<u8>) { | |||
| 52 | fn back_to(task_id: &str, refusal: Option<Refusal>) -> (StatusCode, HeaderMap, Vec<u8>) { | 52 | fn back_to(task_id: &str, refusal: Option<Refusal>) -> (StatusCode, HeaderMap, Vec<u8>) { |
| 53 | let location = match refusal { | 53 | let location = match refusal { |
| 54 | Some(refusal) => { | 54 | Some(refusal) => { |
| 55 | - format!("/?task={task_id}&tab=files&refusal={}&on=upload_file", refusal.code()) | 55 | + format!( |
| 56 | + "/?task={task_id}&tab=files&refusal={}&on=upload_file", | ||
| 57 | + refusal.code() | ||
| 58 | + ) | ||
| 56 | } | 59 | } |
| 57 | None => format!("/?task={task_id}&tab=files"), | 60 | None => format!("/?task={task_id}&tab=files"), |
| 58 | }; | 61 | }; |
| @@ -209,7 +212,8 @@ pub(crate) fn viewer_kind(mime_type: &str) -> Option<ViewerKind> { | |||
| 209 | Some(ViewerKind::Pdf) | 212 | Some(ViewerKind::Pdf) |
| 210 | } else if is_spreadsheet(mime_type) { | 213 | } else if is_spreadsheet(mime_type) { |
| 211 | Some(ViewerKind::Sheet) | 214 | Some(ViewerKind::Sheet) |
| 212 | - } else if mime_type == "application/vnd.openxmlformats-officedocument.presentationml.presentation" | 215 | + } else if mime_type |
| 216 | + == "application/vnd.openxmlformats-officedocument.presentationml.presentation" | ||
| 213 | { | 217 | { |
| 214 | Some(ViewerKind::Slides) | 218 | Some(ViewerKind::Slides) |
| 215 | } else { | 219 | } else { |
| @@ -458,6 +462,7 @@ async fn upload( | |||
| 458 | /// after the push landed (the task gone mid-request, say) the push is | 462 | /// after the push landed (the task gone mid-request, say) the push is |
| 459 | /// taken back best-effort; a leaked remote file is the accepted residual | 463 | /// taken back best-effort; a leaked remote file is the accepted residual |
| 460 | /// if that take-back also fails. | 464 | /// if that take-back also fails. |
| 465 | +#[allow(clippy::too_many_arguments)] | ||
| 461 | async fn push_to_in( | 466 | async fn push_to_in( |
| 462 | cx: &Cx, | 467 | cx: &Cx, |
| 463 | store: &dyn Store, | 468 | store: &dyn Store, |
| @@ -471,7 +476,7 @@ async fn push_to_in( | |||
| 471 | let Some((_, url)) = crate::storage::in_of(store).await else { | 476 | let Some((_, url)) = crate::storage::in_of(store).await else { |
| 472 | return Err(Refusal::StorageNotListed); | 477 | return Err(Refusal::StorageNotListed); |
| 473 | }; | 478 | }; |
| 474 | - let external_id = Ulid::new().to_string(); | 479 | + let external_id = Ulid::generate().to_string(); |
| 475 | let size = bytes.len() as u64; | 480 | let size = bytes.len() as u64; |
| 476 | let client = crate::storage::client(cx); | 481 | let client = crate::storage::client(cx); |
| 477 | if let Err(problem) = client | 482 | if let Err(problem) = client |
| @@ -726,10 +731,7 @@ mod tests { | |||
| 726 | // carries no UTF-16 `Workbook` stream, so it sniffs as the unnamed | 731 | // carries no UTF-16 `Workbook` stream, so it sniffs as the unnamed |
| 727 | // container — which has no viewer element and never renders inline: | 732 | // container — which has no viewer element and never renders inline: |
| 728 | // a filename's own link is the download. | 733 | // a filename's own link is the download. |
| 729 | - let ppt = [ | 734 | + let ppt = [0xD0u8, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1, 0, 0, 0, 0]; |
| 730 | - 0xD0u8, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1, | ||
| 731 | - 0, 0, 0, 0, | ||
| 732 | - ]; | ||
| 733 | assert_eq!(sniff(&ppt), "application/x-ole-storage"); | 735 | assert_eq!(sniff(&ppt), "application/x-ole-storage"); |
| 734 | assert_eq!(viewer_kind("application/x-ole-storage"), None); | 736 | assert_eq!(viewer_kind("application/x-ole-storage"), None); |
| 735 | assert!(!renders_inline("application/x-ole-storage")); | 737 | assert!(!renders_inline("application/x-ole-storage")); |
| @@ -738,7 +740,9 @@ mod tests { | |||
| 738 | #[test] | 740 | #[test] |
| 739 | fn a_presentation_opens_the_slides_viewer() { | 741 | fn a_presentation_opens_the_slides_viewer() { |
| 740 | assert_eq!( | 742 | assert_eq!( |
| 741 | - viewer_kind("application/vnd.openxmlformats-officedocument.presentationml.presentation"), | 743 | + viewer_kind( |
| 744 | + "application/vnd.openxmlformats-officedocument.presentationml.presentation" | ||
| 745 | + ), | ||
| 742 | Some(ViewerKind::Slides) | 746 | Some(ViewerKind::Slides) |
| 743 | ); | 747 | ); |
| 744 | } | 748 | } |
crates/iz-web/src/layout.rsmodified+74 -68
| @@ -10,7 +10,7 @@ use topcoat::{ | |||
| 10 | error::{NotFoundError, not_found}, | 10 | error::{NotFoundError, not_found}, |
| 11 | layout, page, | 11 | layout, page, |
| 12 | }, | 12 | }, |
| 13 | - view::{Unescaped, view}, | 13 | + view::{BoxView, Unescaped, View, ViewExt, error_boundary, view}, |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | use crate::i18n::{Key, Lang, t}; | 16 | use crate::i18n::{Key, Lang, t}; |
| @@ -39,8 +39,8 @@ const FAVICON: &str = "data:image/svg+xml,\ | |||
| 39 | /// stutter no amount of space or framing repairs. The mark carries the chrome, | 39 | /// stutter no amount of space or framing repairs. The mark carries the chrome, |
| 40 | /// where the name is already known and the room is 44px; the word carries the | 40 | /// where the name is already known and the room is 44px; the word carries the |
| 41 | /// front door, where a stranger arrives and nothing else has said it yet. | 41 | /// front door, where a stranger arrives and nothing else has said it yet. |
| 42 | -pub(crate) async fn mark(cx: &Cx) -> Result { | 42 | +pub(crate) async fn mark<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 43 | - view! { | 43 | + Ok(view! { |
| 44 | cx => | 44 | cx => |
| 45 | <a class="wordmark" href="/" aria-label="iz"> | 45 | <a class="wordmark" href="/" aria-label="iz"> |
| 46 | <svg class="wordmark-mark" width="24" height="24" viewBox="0 0 24 24" | 46 | <svg class="wordmark-mark" width="24" height="24" viewBox="0 0 24 24" |
| @@ -54,17 +54,19 @@ pub(crate) async fn mark(cx: &Cx) -> Result { | |||
| 54 | </svg> | 54 | </svg> |
| 55 | </a> | 55 | </a> |
| 56 | } | 56 | } |
| 57 | + .boxed()) | ||
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | /// The wordmark, the monogram's other half: the name alone, in the one face | 60 | /// The wordmark, the monogram's other half: the name alone, in the one face |
| 60 | /// both skins agree on. The sign-in and setup pages wear it — see `mark`. | 61 | /// both skins agree on. The sign-in and setup pages wear it — see `mark`. |
| 61 | -pub(crate) async fn wordmark(cx: &Cx) -> Result { | 62 | +pub(crate) async fn wordmark<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 62 | - view! { | 63 | + Ok(view! { |
| 63 | cx => | 64 | cx => |
| 64 | <a class="wordmark wordmark-lone" href="/"> | 65 | <a class="wordmark wordmark-lone" href="/"> |
| 65 | <span class="wordmark-text">"iz"</span> | 66 | <span class="wordmark-text">"iz"</span> |
| 66 | </a> | 67 | </a> |
| 67 | } | 68 | } |
| 69 | + .boxed()) | ||
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | /// A person as a circle (or, on the Instrument skin, a square): the initials, | 72 | /// A person as a circle (or, on the Instrument skin, a square): the initials, |
| @@ -76,13 +78,13 @@ pub(crate) async fn wordmark(cx: &Cx) -> Result { | |||
| 76 | /// renders and hides itself on error (see `avatar_script`), leaving the | 78 | /// renders and hides itself on error (see `avatar_script`), leaving the |
| 77 | /// initials beneath as the fallback. Shared by the board, the modal and | 79 | /// initials beneath as the fallback. Shared by the board, the modal and |
| 78 | /// every topbar user menu. | 80 | /// every topbar user menu. |
| 79 | -pub(crate) async fn avatar( | 81 | +pub(crate) async fn avatar<'a>( |
| 80 | - cx: &Cx, | 82 | + cx: &'a Cx, |
| 81 | - id: &str, | 83 | + id: &'a str, |
| 82 | - display_name: &str, | 84 | + display_name: &'a str, |
| 83 | photo_version: u64, | 85 | photo_version: u64, |
| 84 | - extra: &str, | 86 | + extra: &'a str, |
| 85 | -) -> Result { | 87 | +) -> Result<impl View + 'a> { |
| 86 | let tone = id | 88 | let tone = id |
| 87 | .bytes() | 89 | .bytes() |
| 88 | .fold(0u32, |acc, b| acc.wrapping_mul(31).wrapping_add(b as u32)) | 90 | .fold(0u32, |acc, b| acc.wrapping_mul(31).wrapping_add(b as u32)) |
| @@ -90,13 +92,13 @@ pub(crate) async fn avatar( | |||
| 90 | let class = format!("avatar avatar-tone-{tone} {extra}"); | 92 | let class = format!("avatar avatar-tone-{tone} {extra}"); |
| 91 | let initials = initials_of(display_name); | 93 | let initials = initials_of(display_name); |
| 92 | let src = format!("/avatar/{id}?v={photo_version}"); | 94 | let src = format!("/avatar/{id}?v={photo_version}"); |
| 93 | - view! { | 95 | + Ok(view! { |
| 94 | cx => | 96 | cx => |
| 95 | <span class="avatar-stack"> | 97 | <span class="avatar-stack"> |
| 96 | <span class=(class.clone()) data-name=(display_name.to_string())>(initials)</span> | 98 | <span class=(class.clone()) data-name=(display_name.to_string())>(initials)</span> |
| 97 | <img class=(format!("{class} avatar-photo")) src=(src) alt="" data-name=(display_name.to_string())> | 99 | <img class=(format!("{class} avatar-photo")) src=(src) alt="" data-name=(display_name.to_string())> |
| 98 | </span> | 100 | </span> |
| 99 | - } | 101 | + }.boxed()) |
| 100 | } | 102 | } |
| 101 | 103 | ||
| 102 | /// The first letters of the first two words, uppercased — "Ada Lovelace" | 104 | /// The first letters of the first two words, uppercased — "Ada Lovelace" |
| @@ -121,8 +123,8 @@ fn initials_of(name: &str) -> String { | |||
| 121 | /// before it ran; hiding is registered through `__izOwn` so the live morph | 123 | /// before it ran; hiding is registered through `__izOwn` so the live morph |
| 122 | /// — which owns no names, only what the client declares — does not strip it | 124 | /// — which owns no names, only what the client declares — does not strip it |
| 123 | /// back off on the next refresh. | 125 | /// back off on the next refresh. |
| 124 | -pub(crate) async fn avatar_script(cx: &Cx) -> Result { | 126 | +pub(crate) async fn avatar_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 125 | - use topcoat::view::Unescaped; | 127 | + use topcoat::view::{Unescaped, ViewExt}; |
| 126 | const JS: &str = "\ | 128 | const JS: &str = "\ |
| 127 | (function () { \ | 129 | (function () { \ |
| 128 | if (window.__izAvatar) { return; } \ | 130 | if (window.__izAvatar) { return; } \ |
| @@ -139,7 +141,7 @@ pub(crate) async fn avatar_script(cx: &Cx) -> Result { | |||
| 139 | if (img.complete && img.naturalWidth === 0) { hide(img); } \ | 141 | if (img.complete && img.naturalWidth === 0) { hide(img); } \ |
| 140 | }); \ | 142 | }); \ |
| 141 | })();"; | 143 | })();"; |
| 142 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 144 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 143 | } | 145 | } |
| 144 | 146 | ||
| 145 | /// The topbar's signed-in identity: the display name, opening on hover or | 147 | /// The topbar's signed-in identity: the display name, opening on hover or |
| @@ -147,17 +149,21 @@ pub(crate) async fn avatar_script(cx: &Cx) -> Result { | |||
| 147 | /// signed-in page's topbar — which is why `avatar_script` rides along here: | 149 | /// signed-in page's topbar — which is why `avatar_script` rides along here: |
| 148 | /// every page with avatars has this menu, and the script's guard makes the | 150 | /// every page with avatars has this menu, and the script's guard makes the |
| 149 | /// one emission enough no matter how many avatars the page carries. | 151 | /// one emission enough no matter how many avatars the page carries. |
| 150 | -pub async fn user_menu(cx: &Cx, me: &crate::detail::Me, lang: Lang) -> Result { | 152 | +pub async fn user_menu<'a>( |
| 153 | + cx: &'a Cx, | ||
| 154 | + me: &'a crate::detail::Me, | ||
| 155 | + lang: Lang, | ||
| 156 | +) -> Result<impl View + 'a> { | ||
| 151 | let role_key = match me.role { | 157 | let role_key = match me.role { |
| 152 | iz_core::Role::Admin => Key::RoleAdminOption, | 158 | iz_core::Role::Admin => Key::RoleAdminOption, |
| 153 | iz_core::Role::Member => Key::RoleMemberOption, | 159 | iz_core::Role::Member => Key::RoleMemberOption, |
| 154 | iz_core::Role::Viewer => Key::RoleViewerOption, | 160 | iz_core::Role::Viewer => Key::RoleViewerOption, |
| 155 | }; | 161 | }; |
| 156 | - view! { | 162 | + Ok(view! { |
| 157 | cx => | 163 | cx => |
| 158 | <div class="user-menu"> | 164 | <div class="user-menu"> |
| 159 | <button type="button" class="user-menu-trigger"> | 165 | <button type="button" class="user-menu-trigger"> |
| 160 | - (avatar(cx, &me.id, &me.display_name, me.photo_version, "").await?) | 166 | + (topcoat::view::Child::new(avatar(cx, &me.id, &me.display_name, me.photo_version, "").await?)) |
| 161 | <span class="user-menu-trigger-name">(me.display_name.clone())</span> | 167 | <span class="user-menu-trigger-name">(me.display_name.clone())</span> |
| 162 | </button> | 168 | </button> |
| 163 | <div class="user-menu-panel"> | 169 | <div class="user-menu-panel"> |
| @@ -168,8 +174,8 @@ pub async fn user_menu(cx: &Cx, me: &crate::detail::Me, lang: Lang) -> Result { | |||
| 168 | <a class="user-menu-item" href="/settings">(t(lang, Key::NavSettings))</a> | 174 | <a class="user-menu-item" href="/settings">(t(lang, Key::NavSettings))</a> |
| 169 | </div> | 175 | </div> |
| 170 | </div> | 176 | </div> |
| 171 | - (avatar_script(cx).await?) | 177 | + (topcoat::view::Child::new(avatar_script(cx).await?)) |
| 172 | - } | 178 | + }.boxed()) |
| 173 | } | 179 | } |
| 174 | 180 | ||
| 175 | /// The signed-in pages, as the topbar nav links between them. | 181 | /// The signed-in pages, as the topbar nav links between them. |
| @@ -216,8 +222,13 @@ impl NavPage { | |||
| 216 | /// current one marked, the admin-only ones (rules, logs, tags) shown only to | 222 | /// current one marked, the admin-only ones (rules, logs, tags) shown only to |
| 217 | /// roles that can administer. Plain `<a>`s — the soft-nav forwarder swaps them | 223 | /// roles that can administer. Plain `<a>`s — the soft-nav forwarder swaps them |
| 218 | /// like any same-origin link, so `data-hard` stays off. | 224 | /// like any same-origin link, so `data-hard` stays off. |
| 219 | -pub async fn topbar_nav(cx: &Cx, active: NavPage, role: iz_core::Role, lang: Lang) -> Result { | 225 | +pub async fn topbar_nav<'a>( |
| 220 | - view! { | 226 | + cx: &'a Cx, |
| 227 | + active: NavPage, | ||
| 228 | + role: iz_core::Role, | ||
| 229 | + lang: Lang, | ||
| 230 | +) -> Result<impl View + 'a> { | ||
| 231 | + Ok(view! { | ||
| 221 | cx => | 232 | cx => |
| 222 | <nav class="topbar-nav-links"> | 233 | <nav class="topbar-nav-links"> |
| 223 | for page in NavPage::ALL { | 234 | for page in NavPage::ALL { |
| @@ -231,7 +242,7 @@ pub async fn topbar_nav(cx: &Cx, active: NavPage, role: iz_core::Role, lang: Lan | |||
| 231 | } | 242 | } |
| 232 | } | 243 | } |
| 233 | </nav> | 244 | </nav> |
| 234 | - } | 245 | + }.boxed()) |
| 235 | } | 246 | } |
| 236 | 247 | ||
| 237 | /// The family list as the switcher shows it, read from the app's own | 248 | /// The family list as the switcher shows it, read from the app's own |
| @@ -259,7 +270,7 @@ pub(crate) async fn family_of(cx: &Cx) -> Vec<iz_client::FamilyService> { | |||
| 259 | /// deployment standing alone, renders the bare mark: nothing to reveal. | 270 | /// deployment standing alone, renders the bare mark: nothing to reveal. |
| 260 | /// The links leave this origin, so they carry `data-hard`, like the issuer | 271 | /// The links leave this origin, so they carry `data-hard`, like the issuer |
| 261 | /// link in the user menu. | 272 | /// link in the user menu. |
| 262 | -pub(crate) async fn family_mark(cx: &Cx) -> Result { | 273 | +pub(crate) async fn family_mark<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 263 | const SELF: &str = "iz"; | 274 | const SELF: &str = "iz"; |
| 264 | let siblings: Vec<_> = family_of(cx) | 275 | let siblings: Vec<_> = family_of(cx) |
| 265 | .await | 276 | .await |
| @@ -267,12 +278,12 @@ pub(crate) async fn family_mark(cx: &Cx) -> Result { | |||
| 267 | .filter(|service| service.key != SELF) | 278 | .filter(|service| service.key != SELF) |
| 268 | .collect(); | 279 | .collect(); |
| 269 | if siblings.is_empty() { | 280 | if siblings.is_empty() { |
| 270 | - return mark(cx).await; | 281 | + return mark(cx).await.map(|v| v.boxed()); |
| 271 | } | 282 | } |
| 272 | - view! { | 283 | + Ok(view! { |
| 273 | cx => | 284 | cx => |
| 274 | <div class="wordmark-family"> | 285 | <div class="wordmark-family"> |
| 275 | - (mark(cx).await?) | 286 | + (topcoat::view::Child::new(mark(cx).await?)) |
| 276 | <nav class="service-switcher"> | 287 | <nav class="service-switcher"> |
| 277 | for (at, service) in siblings.iter().enumerate() { | 288 | for (at, service) in siblings.iter().enumerate() { |
| 278 | if at > 0 { | 289 | if at > 0 { |
| @@ -284,7 +295,7 @@ pub(crate) async fn family_mark(cx: &Cx) -> Result { | |||
| 284 | } | 295 | } |
| 285 | </nav> | 296 | </nav> |
| 286 | </div> | 297 | </div> |
| 287 | - } | 298 | + }.boxed()) |
| 288 | } | 299 | } |
| 289 | 300 | ||
| 290 | /// The page-swap machinery that keeps every mutation on the same document. | 301 | /// The page-swap machinery that keeps every mutation on the same document. |
| @@ -353,7 +364,7 @@ pub(crate) async fn family_mark(cx: &Cx) -> Result { | |||
| 353 | /// to top; in-place swaps (form posts, back) keep the scroll position. | 364 | /// to top; in-place swaps (form posts, back) keep the scroll position. |
| 354 | /// `wire()` also pins every `.comment-list` to its bottom, on initial | 365 | /// `wire()` also pins every `.comment-list` to its bottom, on initial |
| 355 | /// load (DOMContentLoaded) included. | 366 | /// load (DOMContentLoaded) included. |
| 356 | -pub async fn soft_nav_script(cx: &Cx) -> Result { | 367 | +pub async fn soft_nav_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 357 | const JS: &str = "\ | 368 | const JS: &str = "\ |
| 358 | (function () { \ | 369 | (function () { \ |
| 359 | if (window.__izSoft) { return; } \ | 370 | if (window.__izSoft) { return; } \ |
| @@ -754,7 +765,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result { | |||
| 754 | }); \ | 765 | }); \ |
| 755 | if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', wire); } else { wire(); } \ | 766 | if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', wire); } else { wire(); } \ |
| 756 | })();"; | 767 | })();"; |
| 757 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 768 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 758 | } | 769 | } |
| 759 | 770 | ||
| 760 | /// The one document-level capture `keydown` listener for `Escape`, emitted | 771 | /// The one document-level capture `keydown` listener for `Escape`, emitted |
| @@ -867,7 +878,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result { | |||
| 867 | /// disagree with it — the tick re-fetches, and the server stays the only thing | 878 | /// disagree with it — the tick re-fetches, and the server stays the only thing |
| 868 | /// that decides what a moment reads as. It runs only on pages carrying a | 879 | /// that decides what a moment reads as. It runs only on pages carrying a |
| 869 | /// `data-tick` element, so a page with no clock-driven text is silent. | 880 | /// `data-tick` element, so a page with no clock-driven text is silent. |
| 870 | -pub async fn live_script(cx: &Cx) -> Result { | 881 | +pub async fn live_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 871 | const JS: &str = "\ | 882 | const JS: &str = "\ |
| 872 | (function () { \ | 883 | (function () { \ |
| 873 | if (window.__izLive) { return; } \ | 884 | if (window.__izLive) { return; } \ |
| @@ -904,11 +915,11 @@ pub async fn live_script(cx: &Cx) -> Result { | |||
| 904 | }, 60000); \ | 915 | }, 60000); \ |
| 905 | })(); \ | 916 | })(); \ |
| 906 | "; | 917 | "; |
| 907 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 918 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 908 | } | 919 | } |
| 909 | 920 | ||
| 910 | -pub async fn escape_manager_script(cx: &Cx) -> Result { | 921 | +pub async fn escape_manager_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 911 | - use topcoat::view::Unescaped; | 922 | + use topcoat::view::{Unescaped, ViewExt}; |
| 912 | const JS: &str = "\ | 923 | const JS: &str = "\ |
| 913 | (function () { \ | 924 | (function () { \ |
| 914 | if (window.__izEsc) { return; } \ | 925 | if (window.__izEsc) { return; } \ |
| @@ -930,7 +941,7 @@ pub async fn escape_manager_script(cx: &Cx) -> Result { | |||
| 930 | } \ | 941 | } \ |
| 931 | }, true); \ | 942 | }, true); \ |
| 932 | })();"; | 943 | })();"; |
| 933 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 944 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 934 | } | 945 | } |
| 935 | /// Registers the topbar/rules `Escape` resolvers on `window.__izEsc` | 946 | /// Registers the topbar/rules `Escape` resolvers on `window.__izEsc` |
| 936 | /// (priority 40 — the table is on `escape_manager_script`): the topbar | 947 | /// (priority 40 — the table is on `escape_manager_script`): the topbar |
| @@ -939,7 +950,7 @@ pub async fn escape_manager_script(cx: &Cx) -> Result { | |||
| 939 | /// a `.rule-new` composer left open on the rules page, then a rules edit | 950 | /// a `.rule-new` composer left open on the rules page, then a rules edit |
| 940 | /// row (navigating back to `/rules`). Never touches | 951 | /// row (navigating back to `/rules`). Never touches |
| 941 | /// `details.confirm-details`; that flow stays `detail.rs`'s. | 952 | /// `details.confirm-details`; that flow stays `detail.rs`'s. |
| 942 | -pub async fn escape_script(cx: &Cx) -> Result { | 953 | +pub async fn escape_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 943 | const JS: &str = "\ | 954 | const JS: &str = "\ |
| 944 | (function () { \ | 955 | (function () { \ |
| 945 | if (window.__izEscTop) { return; } \ | 956 | if (window.__izEscTop) { return; } \ |
| @@ -965,14 +976,14 @@ pub async fn escape_script(cx: &Cx) -> Result { | |||
| 965 | if (menu) { menu.classList.remove('user-menu-esc'); } \ | 976 | if (menu) { menu.classList.remove('user-menu-esc'); } \ |
| 966 | }, true); \ | 977 | }, true); \ |
| 967 | })();"; | 978 | })();"; |
| 968 | - view! { cx => <script>(Unescaped::new_unchecked(JS))</script> } | 979 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }.boxed()) |
| 969 | } | 980 | } |
| 970 | 981 | ||
| 971 | /// Every path that matches no page raises a `NotFoundError`, so it renders | 982 | /// Every path that matches no page raises a `NotFoundError`, so it renders |
| 972 | /// through `root_layout`'s catch below rather than the router's bare default. | 983 | /// through `root_layout`'s catch below rather than the router's bare default. |
| 973 | /// `/` itself is served by `landing` above and never reaches this route. | 984 | /// `/` itself is served by `landing` above and never reaches this route. |
| 974 | #[page("/{*path}")] | 985 | #[page("/{*path}")] |
| 975 | -async fn missing() -> Result { | 986 | +async fn missing() -> Result<BoxView<'static>> { |
| 976 | Err(not_found().into()) | 987 | Err(not_found().into()) |
| 977 | } | 988 | } |
| 978 | 989 | ||
| @@ -980,7 +991,7 @@ async fn missing() -> Result { | |||
| 980 | const STYLE: Asset = asset!("assets/main.css"); | 991 | const STYLE: Asset = asset!("assets/main.css"); |
| 981 | 992 | ||
| 982 | #[layout("/")] | 993 | #[layout("/")] |
| 983 | -async fn root_layout(cx: &Cx, slot: Result) -> Result { | 994 | +async fn root_layout(cx: &Cx, slot: topcoat::view::Child<'_>) -> Result<impl View> { |
| 984 | // Pages with no session (auth screens) render light and English; both are | 995 | // Pages with no session (auth screens) render light and English; both are |
| 985 | // only set when the request's own user has one to read. | 996 | // only set when the request's own user has one to read. |
| 986 | let asking = match current_user(cx).await { | 997 | let asking = match current_user(cx).await { |
| @@ -991,27 +1002,11 @@ async fn root_layout(cx: &Cx, slot: Result) -> Result { | |||
| 991 | let ui = asking.map_or("instrument", |user| user.ui.as_str()); | 1002 | let ui = asking.map_or("instrument", |user| user.ui.as_str()); |
| 992 | let lang = asking.map_or(Lang::En, |user| Lang::from_code(&user.language)); | 1003 | let lang = asking.map_or(Lang::En, |user| Lang::from_code(&user.language)); |
| 993 | 1004 | ||
| 994 | - let content = match slot { | 1005 | + let nothing = t(lang, Key::NothingAtThisAddress).to_string(); |
| 995 | - Err(error) if error.downcast_ref::<NotFoundError>().is_some() => view! { | 1006 | + Ok(view! { |
| 996 | - cx => | 1007 | + cx => |
| 997 | - (StatusCode::NOT_FOUND) | ||
| 998 | - <main class="scaffold-note"> | ||
| 999 | - <p>(t(lang, Key::NothingAtThisAddress))</p> | ||
| 1000 | - </main> | ||
| 1001 | - }, | ||
| 1002 | - content => content, | ||
| 1003 | - }?; | ||
| 1004 | - | ||
| 1005 | - // The build stamp rides the html element on every render — page load, | ||
| 1006 | - // soft navigation and live refresh all answer through this layout, and | ||
| 1007 | - // the swap path reads it off the fetched document before it touches the | ||
| 1008 | - // page. A tab left open across a deploy keeps the old stylesheet link | ||
| 1009 | - // (the morph swaps body children, never the head), so a mismatch is | ||
| 1010 | - // the client's cue to hard-reload rather than wear the old css. | ||
| 1011 | - let build = STYLE.id().as_u64().to_string(); | ||
| 1012 | - view! { | ||
| 1013 | <!DOCTYPE html> | 1008 | <!DOCTYPE html> |
| 1014 | - <html lang=(lang.code()) data-theme=(dark.then_some("dark")) data-ui=(ui) data-build=(build)> | 1009 | + <html lang=(lang.code()) data-theme=(dark.then_some("dark")) data-ui=(ui) data-build=(STYLE.id().as_u64().to_string())> |
| 1015 | <head> | 1010 | <head> |
| 1016 | <meta charset="utf-8"> | 1011 | <meta charset="utf-8"> |
| 1017 | <meta name="viewport" content="width=device-width, initial-scale=1"> | 1012 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| @@ -1028,14 +1023,25 @@ async fn root_layout(cx: &Cx, slot: Result) -> Result { | |||
| 1028 | topcoat::dev::script() | 1023 | topcoat::dev::script() |
| 1029 | </head> | 1024 | </head> |
| 1030 | <body> | 1025 | <body> |
| 1031 | - (escape_manager_script(cx).await?) | 1026 | + (topcoat::view::Child::new(escape_manager_script(cx).await?)) |
| 1032 | - (soft_nav_script(cx).await?) | 1027 | + (topcoat::view::Child::new(soft_nav_script(cx).await?)) |
| 1033 | - // Only for a signed-in page: `/api/live` answers 401 to | 1028 | + if asking.is_some() { (topcoat::view::Child::new(live_script(cx).await?)) } |
| 1034 | - // everybody else, and an auth screen that opened a stream | 1029 | + error_boundary( |
| 1035 | - // would just reconnect against that refusal forever. | 1030 | + fallback: |error| { |
| 1036 | - if asking.is_some() { (live_script(cx).await?) } | 1031 | + if error.downcast_ref::<NotFoundError>().is_none() { |
| 1037 | - (content) | 1032 | + return Err(error); |
| 1033 | + } | ||
| 1034 | + Ok(view! { | ||
| 1035 | + cx => | ||
| 1036 | + (StatusCode::NOT_FOUND) | ||
| 1037 | + <main class="scaffold-note"> | ||
| 1038 | + <p>(nothing)</p> | ||
| 1039 | + </main> | ||
| 1040 | + }) | ||
| 1041 | + }, | ||
| 1042 | + (slot) | ||
| 1043 | + ) | ||
| 1038 | </body> | 1044 | </body> |
| 1039 | </html> | 1045 | </html> |
| 1040 | - } | 1046 | + }.boxed()) |
| 1041 | } | 1047 | } |
crates/iz-web/src/logs.rsmodified+60 -54
| @@ -16,11 +16,11 @@ use topcoat::Result; | |||
| 16 | use topcoat::context::Cx; | 16 | use topcoat::context::Cx; |
| 17 | use topcoat::router::content::{Form, Json}; | 17 | use topcoat::router::content::{Form, Json}; |
| 18 | use topcoat::router::{HeaderName, StatusCode, header, page, route}; | 18 | use topcoat::router::{HeaderName, StatusCode, header, page, route}; |
| 19 | -use topcoat::view::view; | 19 | +use topcoat::view::{View, ViewExt, view}; |
| 20 | 20 | ||
| 21 | use crate::detail::{Me, datepicker_grid, glyph}; | 21 | use crate::detail::{Me, datepicker_grid, glyph}; |
| 22 | use crate::i18n::{Key, Lang, t}; | 22 | use crate::i18n::{Key, Lang, t}; |
| 23 | -use crate::server::{Refusal, store, back_to, require_admin}; | 23 | +use crate::server::{Refusal, back_to, require_admin, store}; |
| 24 | 24 | ||
| 25 | /// A query value survives the round trip to a `Location` header only if it | 25 | /// A query value survives the round trip to a `Location` header only if it |
| 26 | /// cannot be mistaken for another pair or break the header outright — a | 26 | /// cannot be mistaken for another pair or break the header outright — a |
| @@ -44,12 +44,13 @@ fn decode_q(raw: &str) -> String { | |||
| 44 | let mut out = Vec::with_capacity(bytes.len()); | 44 | let mut out = Vec::with_capacity(bytes.len()); |
| 45 | let mut i = 0; | 45 | let mut i = 0; |
| 46 | while i < bytes.len() { | 46 | while i < bytes.len() { |
| 47 | - if bytes[i] == b'%' && i + 2 < bytes.len() { | 47 | + if bytes[i] == b'%' |
| 48 | - if let Ok(value) = u8::from_str_radix(&raw[i + 1..i + 3], 16) { | 48 | + && i + 2 < bytes.len() |
| 49 | - out.push(value); | 49 | + && let Ok(value) = u8::from_str_radix(&raw[i + 1..i + 3], 16) |
| 50 | - i += 3; | 50 | + { |
| 51 | - continue; | 51 | + out.push(value); |
| 52 | - } | 52 | + i += 3; |
| 53 | + continue; | ||
| 53 | } | 54 | } |
| 54 | out.push(bytes[i]); | 55 | out.push(bytes[i]); |
| 55 | i += 1; | 56 | i += 1; |
| @@ -469,10 +470,10 @@ fn far_future() -> OffsetDateTime { | |||
| 469 | /// so garbage input narrows nothing rather than 500ing. | 470 | /// so garbage input narrows nothing rather than 500ing. |
| 470 | fn parse_day_range(query: &str, zone: time::UtcOffset) -> Option<(OffsetDateTime, OffsetDateTime)> { | 471 | fn parse_day_range(query: &str, zone: time::UtcOffset) -> Option<(OffsetDateTime, OffsetDateTime)> { |
| 471 | let (from_raw, to_raw) = match (query_value(query, "from"), query_value(query, "to")) { | 472 | let (from_raw, to_raw) = match (query_value(query, "from"), query_value(query, "to")) { |
| 472 | - (None, None) => match query_value(query, "on").filter(|v| !v.is_empty()) { | 473 | + (None, None) => { |
| 473 | - Some(on) => (Some(on), Some(on)), | 474 | + let on = query_value(query, "on").filter(|v| !v.is_empty())?; |
| 474 | - None => return None, | 475 | + (Some(on), Some(on)) |
| 475 | - }, | 476 | + } |
| 476 | (from, to) => (from.filter(|v| !v.is_empty()), to.filter(|v| !v.is_empty())), | 477 | (from, to) => (from.filter(|v| !v.is_empty()), to.filter(|v| !v.is_empty())), |
| 477 | }; | 478 | }; |
| 478 | if from_raw.is_none() && to_raw.is_none() { | 479 | if from_raw.is_none() && to_raw.is_none() { |
| @@ -483,10 +484,10 @@ fn parse_day_range(query: &str, zone: time::UtcOffset) -> Option<(OffsetDateTime | |||
| 483 | // one shifted 24h later. | 484 | // one shifted 24h later. |
| 484 | let mut from_start = from_raw.and_then(|raw| parse_day_start(raw, zone)); | 485 | let mut from_start = from_raw.and_then(|raw| parse_day_start(raw, zone)); |
| 485 | let mut to_start = to_raw.and_then(|raw| parse_day_start(raw, zone)); | 486 | let mut to_start = to_raw.and_then(|raw| parse_day_start(raw, zone)); |
| 486 | - if let (Some(f), Some(t)) = (from_start, to_start) { | 487 | + if let (Some(f), Some(t)) = (from_start, to_start) |
| 487 | - if f > t { | 488 | + && f > t |
| 488 | - std::mem::swap(&mut from_start, &mut to_start); | 489 | + { |
| 489 | - } | 490 | + std::mem::swap(&mut from_start, &mut to_start); |
| 490 | } | 491 | } |
| 491 | let start = from_start.unwrap_or_else(far_past); | 492 | let start = from_start.unwrap_or_else(far_past); |
| 492 | let end = match to_start { | 493 | let end = match to_start { |
| @@ -890,7 +891,7 @@ fn rail_class(current: Section, target: Section) -> &'static str { | |||
| 890 | } | 891 | } |
| 891 | 892 | ||
| 892 | #[page("/logs")] | 893 | #[page("/logs")] |
| 893 | -async fn logs_page(cx: &Cx) -> Result { | 894 | +async fn logs_page(cx: &Cx) -> Result<impl View> { |
| 894 | let lang = Lang::En; | 895 | let lang = Lang::En; |
| 895 | let query = topcoat::router::request::uri(cx) | 896 | let query = topcoat::router::request::uri(cx) |
| 896 | .query() | 897 | .query() |
| @@ -913,22 +914,26 @@ async fn logs_page(cx: &Cx) -> Result { | |||
| 913 | let filter = parse_activity_filter(&query, zone); | 914 | let filter = parse_activity_filter(&query, zone); |
| 914 | let limit = resolve_limit(cx, section); | 915 | let limit = resolve_limit(cx, section); |
| 915 | match snapshot(cx, section, page, dir, &filter, limit).await { | 916 | match snapshot(cx, section, page, dir, &filter, limit).await { |
| 916 | - Ok(Ok((snapshot, links))) => logs_screen(cx, snapshot, section, links, &query, limit).await, | 917 | + Ok(Ok((snapshot, links))) => Ok(logs_screen(cx, snapshot, section, links, &query, limit) |
| 918 | + .await? | ||
| 919 | + .boxed()), | ||
| 917 | // No `Me` here to read a language off of when the refusal itself is | 920 | // No `Me` here to read a language off of when the refusal itself is |
| 918 | // "no session" — English, same as the other admin pages' own gate. | 921 | // "no session" — English, same as the other admin pages' own gate. |
| 919 | - Ok(Err(refusal)) => view! { | 922 | + Ok(Err(refusal)) => Ok(view! { |
| 920 | cx => | 923 | cx => |
| 921 | <main class="scaffold-note"> | 924 | <main class="scaffold-note"> |
| 922 | <p>(refusal.message())</p> | 925 | <p>(refusal.message())</p> |
| 923 | <p><a href="/">(t(lang, Key::BackToBoard))</a></p> | 926 | <p><a href="/">(t(lang, Key::BackToBoard))</a></p> |
| 924 | </main> | 927 | </main> |
| 925 | - }, | 928 | + } |
| 926 | - Err(_) => view! { | 929 | + .boxed()), |
| 930 | + Err(_) => Ok(view! { | ||
| 927 | cx => | 931 | cx => |
| 928 | <main class="scaffold-note"> | 932 | <main class="scaffold-note"> |
| 929 | <p>(t(lang, Key::SomethingWentWrong))</p> | 933 | <p>(t(lang, Key::SomethingWentWrong))</p> |
| 930 | </main> | 934 | </main> |
| 931 | - }, | 935 | + } |
| 936 | + .boxed()), | ||
| 932 | } | 937 | } |
| 933 | } | 938 | } |
| 934 | 939 | ||
| @@ -941,14 +946,15 @@ fn section_slug(section: Section) -> &'static str { | |||
| 941 | } | 946 | } |
| 942 | } | 947 | } |
| 943 | 948 | ||
| 944 | -async fn logs_screen( | 949 | +async fn logs_screen<'a>( |
| 945 | - cx: &Cx, | 950 | + cx: &'a Cx, |
| 946 | snapshot: LogsSnapshot, | 951 | snapshot: LogsSnapshot, |
| 947 | section: Section, | 952 | section: Section, |
| 948 | links: PageLinks, | 953 | links: PageLinks, |
| 949 | query: &str, | 954 | query: &str, |
| 950 | limit: u32, | 955 | limit: u32, |
| 951 | -) -> Result { | 956 | +) -> Result<impl View + 'a> { |
| 957 | + let query = query.to_string(); | ||
| 952 | let lang = Lang::from_code(&snapshot.me.language); | 958 | let lang = Lang::from_code(&snapshot.me.language); |
| 953 | let me = snapshot.me; | 959 | let me = snapshot.me; |
| 954 | let queue = snapshot.queue; | 960 | let queue = snapshot.queue; |
| @@ -959,7 +965,7 @@ async fn logs_screen( | |||
| 959 | let activity_empty = activity.is_empty(); | 965 | let activity_empty = activity.is_empty(); |
| 960 | let slug = section_slug(section); | 966 | let slug = section_slug(section); |
| 961 | let extra = if section == Section::Activity { | 967 | let extra = if section == Section::Activity { |
| 962 | - activity_query_suffix(query) | 968 | + activity_query_suffix(&query) |
| 963 | } else { | 969 | } else { |
| 964 | String::new() | 970 | String::new() |
| 965 | }; | 971 | }; |
| @@ -976,18 +982,18 @@ async fn logs_screen( | |||
| 976 | .map(|(x, y, n)| format!("{x}\u{2013}{y} / {n}")); | 982 | .map(|(x, y, n)| format!("{x}\u{2013}{y} / {n}")); |
| 977 | 983 | ||
| 978 | let (filter_actor, filter_kind, filter_task, filter_dir) = ( | 984 | let (filter_actor, filter_kind, filter_task, filter_dir) = ( |
| 979 | - query_value(query, "actor").unwrap_or("").to_string(), | 985 | + query_value(&query, "actor").unwrap_or("").to_string(), |
| 980 | - query_value(query, "kind").unwrap_or("").to_string(), | 986 | + query_value(&query, "kind").unwrap_or("").to_string(), |
| 981 | - query_value(query, "task").unwrap_or("").to_string(), | 987 | + query_value(&query, "task").unwrap_or("").to_string(), |
| 982 | - query_value(query, "dir").unwrap_or("").to_string(), | 988 | + query_value(&query, "dir").unwrap_or("").to_string(), |
| 983 | ); | 989 | ); |
| 984 | // `on=` is a shorthand for `from=to=on`; the boxes themselves only ever | 990 | // `on=` is a shorthand for `from=to=on`; the boxes themselves only ever |
| 985 | // read/write `from`/`to`, so a link that arrived with only `on=` shows | 991 | // read/write `from`/`to`, so a link that arrived with only `on=` shows |
| 986 | // it in both. | 992 | // it in both. |
| 987 | let (filter_from, filter_to) = { | 993 | let (filter_from, filter_to) = { |
| 988 | - let on = query_value(query, "on").unwrap_or(""); | 994 | + let on = query_value(&query, "on").unwrap_or(""); |
| 989 | - let from = query_value(query, "from").unwrap_or(on).to_string(); | 995 | + let from = query_value(&query, "from").unwrap_or(on).to_string(); |
| 990 | - let to = query_value(query, "to").unwrap_or(on).to_string(); | 996 | + let to = query_value(&query, "to").unwrap_or(on).to_string(); |
| 991 | (from, to) | 997 | (from, to) |
| 992 | }; | 998 | }; |
| 993 | let members: Vec<(String, String)> = if section == Section::Activity { | 999 | let members: Vec<(String, String)> = if section == Section::Activity { |
| @@ -1010,13 +1016,13 @@ async fn logs_screen( | |||
| 1010 | Vec::new() | 1016 | Vec::new() |
| 1011 | }; | 1017 | }; |
| 1012 | 1018 | ||
| 1013 | - view! { | 1019 | + Ok(view! { |
| 1014 | cx => | 1020 | cx => |
| 1015 | <header class="topbar"> | 1021 | <header class="topbar"> |
| 1016 | - (crate::layout::family_mark(cx).await?) | 1022 | + (topcoat::view::Child::new(crate::layout::family_mark(cx).await?)) |
| 1017 | - (crate::layout::topbar_nav(cx, crate::layout::NavPage::Logs, me.role, lang).await?) | 1023 | + (topcoat::view::Child::new(crate::layout::topbar_nav(cx, crate::layout::NavPage::Logs, me.role, lang).await?)) |
| 1018 | <div class="spacer"></div> | 1024 | <div class="spacer"></div> |
| 1019 | - (crate::layout::user_menu(cx, &me, lang).await?) | 1025 | + (topcoat::view::Child::new(crate::layout::user_menu(cx, &me, lang).await?)) |
| 1020 | </header> | 1026 | </header> |
| 1021 | 1027 | ||
| 1022 | <div class="settings-shell"> | 1028 | <div class="settings-shell"> |
| @@ -1163,7 +1169,7 @@ async fn logs_screen( | |||
| 1163 | <option value=(member.0.clone()) selected=(filter_actor == member.0)>(member.1.clone())</option> | 1169 | <option value=(member.0.clone()) selected=(filter_actor == member.0)>(member.1.clone())</option> |
| 1164 | } | 1170 | } |
| 1165 | </select> | 1171 | </select> |
| 1166 | - (glyph::chevron(cx).await?) | 1172 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1167 | </div> | 1173 | </div> |
| 1168 | <div class="field-box field-box-sort"> | 1174 | <div class="field-box field-box-sort"> |
| 1169 | <select class="status-select" name="kind" data-autosubmit="" data-search=""> | 1175 | <select class="status-select" name="kind" data-autosubmit="" data-search=""> |
| @@ -1172,7 +1178,7 @@ async fn logs_screen( | |||
| 1172 | <option value=(kind) selected=(filter_kind == *kind)>(crate::i18n::activity_kind_word(lang, kind))</option> | 1178 | <option value=(kind) selected=(filter_kind == *kind)>(crate::i18n::activity_kind_word(lang, kind))</option> |
| 1173 | } | 1179 | } |
| 1174 | </select> | 1180 | </select> |
| 1175 | - (glyph::chevron(cx).await?) | 1181 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1176 | </div> | 1182 | </div> |
| 1177 | <div class="field-box field-box-sort"> | 1183 | <div class="field-box field-box-sort"> |
| 1178 | <select class="status-select" name="task" data-autosubmit="" data-search=""> | 1184 | <select class="status-select" name="task" data-autosubmit="" data-search=""> |
| @@ -1181,29 +1187,29 @@ async fn logs_screen( | |||
| 1181 | <option value=(task.0.clone()) selected=(filter_task == task.0)>(format!("{} {}", task.0, task.1))</option> | 1187 | <option value=(task.0.clone()) selected=(filter_task == task.0)>(format!("{} {}", task.0, task.1))</option> |
| 1182 | } | 1188 | } |
| 1183 | </select> | 1189 | </select> |
| 1184 | - (glyph::chevron(cx).await?) | 1190 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1185 | </div> | 1191 | </div> |
| 1186 | <div class="edit edit-pop datepick-pop"> | 1192 | <div class="edit edit-pop datepick-pop"> |
| 1187 | <input class="edit-toggle" type="checkbox" id="log-from-toggle" aria-label=(t(lang, Key::From))> | 1193 | <input class="edit-toggle" type="checkbox" id="log-from-toggle" aria-label=(t(lang, Key::From))> |
| 1188 | <label class="field-box edit-view edit-hit" for="log-from-toggle"> | 1194 | <label class="field-box edit-view edit-hit" for="log-from-toggle"> |
| 1189 | - (glyph::calendar(cx).await?) | 1195 | + (topcoat::view::Child::new(glyph::calendar(cx).await?)) |
| 1190 | <span class="field-text datepick-label" data-empty=(t(lang, Key::From))>(if filter_from.is_empty() { t(lang, Key::From).to_string() } else { filter_from.clone() })</span> | 1196 | <span class="field-text datepick-label" data-empty=(t(lang, Key::From))>(if filter_from.is_empty() { t(lang, Key::From).to_string() } else { filter_from.clone() })</span> |
| 1191 | - (glyph::chevron(cx).await?) | 1197 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1192 | </label> | 1198 | </label> |
| 1193 | <div class="edit-form pop-panel datepick-panel"> | 1199 | <div class="edit-form pop-panel datepick-panel"> |
| 1194 | - (datepicker_grid(cx, "from", &filter_from, true, lang).await?) | 1200 | + (topcoat::view::Child::new(datepicker_grid(cx, "from", &filter_from, true, lang).await?)) |
| 1195 | </div> | 1201 | </div> |
| 1196 | </div> | 1202 | </div> |
| 1197 | <span class="log-range-dash">("\u{2013}")</span> | 1203 | <span class="log-range-dash">("\u{2013}")</span> |
| 1198 | <div class="edit edit-pop datepick-pop"> | 1204 | <div class="edit edit-pop datepick-pop"> |
| 1199 | <input class="edit-toggle" type="checkbox" id="log-to-toggle" aria-label=(t(lang, Key::To))> | 1205 | <input class="edit-toggle" type="checkbox" id="log-to-toggle" aria-label=(t(lang, Key::To))> |
| 1200 | <label class="field-box edit-view edit-hit" for="log-to-toggle"> | 1206 | <label class="field-box edit-view edit-hit" for="log-to-toggle"> |
| 1201 | - (glyph::calendar(cx).await?) | 1207 | + (topcoat::view::Child::new(glyph::calendar(cx).await?)) |
| 1202 | <span class="field-text datepick-label" data-empty=(t(lang, Key::To))>(if filter_to.is_empty() { t(lang, Key::To).to_string() } else { filter_to.clone() })</span> | 1208 | <span class="field-text datepick-label" data-empty=(t(lang, Key::To))>(if filter_to.is_empty() { t(lang, Key::To).to_string() } else { filter_to.clone() })</span> |
| 1203 | - (glyph::chevron(cx).await?) | 1209 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1204 | </label> | 1210 | </label> |
| 1205 | <div class="edit-form pop-panel datepick-panel"> | 1211 | <div class="edit-form pop-panel datepick-panel"> |
| 1206 | - (datepicker_grid(cx, "to", &filter_to, true, lang).await?) | 1212 | + (topcoat::view::Child::new(datepicker_grid(cx, "to", &filter_to, true, lang).await?)) |
| 1207 | </div> | 1213 | </div> |
| 1208 | </div> | 1214 | </div> |
| 1209 | <div class="field-box field-box-sort"> | 1215 | <div class="field-box field-box-sort"> |
| @@ -1211,7 +1217,7 @@ async fn logs_screen( | |||
| 1211 | <option value="" selected=(filter_dir != "oldest")>(t(lang, Key::Newest))</option> | 1217 | <option value="" selected=(filter_dir != "oldest")>(t(lang, Key::Newest))</option> |
| 1212 | <option value="oldest" selected=(filter_dir == "oldest")>(t(lang, Key::Oldest))</option> | 1218 | <option value="oldest" selected=(filter_dir == "oldest")>(t(lang, Key::Oldest))</option> |
| 1213 | </select> | 1219 | </select> |
| 1214 | - (glyph::chevron(cx).await?) | 1220 | + (topcoat::view::Child::new(glyph::chevron(cx).await?)) |
| 1215 | </div> | 1221 | </div> |
| 1216 | </form> | 1222 | </form> |
| 1217 | <div class="log-list" data-rows=(limit) data-section="activity"> | 1223 | <div class="log-list" data-rows=(limit) data-section="activity"> |
| @@ -1256,11 +1262,11 @@ async fn logs_screen( | |||
| 1256 | } | 1262 | } |
| 1257 | </main> | 1263 | </main> |
| 1258 | </div> | 1264 | </div> |
| 1259 | - (crate::dropdown::dropdown_script(cx).await?) | 1265 | + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) |
| 1260 | - (crate::layout::escape_script(cx).await?) | 1266 | + (topcoat::view::Child::new(crate::layout::escape_script(cx).await?)) |
| 1261 | - (crate::detail::datepicker_script(cx, lang).await?) | 1267 | + (topcoat::view::Child::new(crate::detail::datepicker_script(cx, lang).await?)) |
| 1262 | - (log_fit_script(cx).await?) | 1268 | + (topcoat::view::Child::new(log_fit_script(cx).await?)) |
| 1263 | - } | 1269 | + }.boxed()) |
| 1264 | } | 1270 | } |
| 1265 | 1271 | ||
| 1266 | /// Fits the active tab's page size to the browser's own viewport: measured | 1272 | /// Fits the active tab's page size to the browser's own viewport: measured |
| @@ -1281,7 +1287,7 @@ async fn logs_screen( | |||
| 1281 | /// its height changes, a window resize re-measures for the new viewport. | 1287 | /// its height changes, a window resize re-measures for the new viewport. |
| 1282 | /// A container too short to measure (no rows yet, or a stage not yet laid | 1288 | /// A container too short to measure (no rows yet, or a stage not yet laid |
| 1283 | /// out) is left alone rather than guessed at. | 1289 | /// out) is left alone rather than guessed at. |
| 1284 | -async fn log_fit_script(cx: &Cx) -> Result { | 1290 | +async fn log_fit_script<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 1285 | use topcoat::view::Unescaped; | 1291 | use topcoat::view::Unescaped; |
| 1286 | let js = "(function() {\ | 1292 | let js = "(function() {\ |
| 1287 | var waits = 0;\ | 1293 | var waits = 0;\ |
| @@ -1320,5 +1326,5 @@ async fn log_fit_script(cx: &Cx) -> Result { | |||
| 1320 | window.addEventListener('resize', schedule);\ | 1326 | window.addEventListener('resize', schedule);\ |
| 1321 | schedule();\ | 1327 | schedule();\ |
| 1322 | })();"; | 1328 | })();"; |
| 1323 | - view! { cx => <script>(Unescaped::new_unchecked(js))</script> } | 1329 | + Ok(view! { cx => <script>(Unescaped::new_unchecked(js))</script> }.boxed()) |
| 1324 | } | 1330 | } |
crates/iz-web/src/main.rsmodified+13 -7
| @@ -4,6 +4,7 @@ use topcoat::Result; | |||
| 4 | use topcoat::asset::{AssetBundle, RouterBuilderAssetExt}; | 4 | use topcoat::asset::{AssetBundle, RouterBuilderAssetExt}; |
| 5 | use topcoat::cookie::RouterBuilderCookieExt; | 5 | use topcoat::cookie::RouterBuilderCookieExt; |
| 6 | use topcoat::router::{BodyLimit, Router, RouterBuilderDiscoverExt, route}; | 6 | use topcoat::router::{BodyLimit, Router, RouterBuilderDiscoverExt, route}; |
| 7 | +use topcoat::runtime::RouterBuilderRuntimeExt; | ||
| 7 | 8 | ||
| 8 | #[route(GET "/healthz")] | 9 | #[route(GET "/healthz")] |
| 9 | async fn healthz() -> Result<&'static str> { | 10 | async fn healthz() -> Result<&'static str> { |
| @@ -150,7 +151,10 @@ async fn main() { | |||
| 150 | // is what the Settings Storage card renders. The beat below keeps | 151 | // is what the Settings Storage card renders. The beat below keeps |
| 151 | // both current. | 152 | // both current. |
| 152 | let storage_client = iz_web::storage::StorageClient::new( | 153 | let storage_client = iz_web::storage::StorageClient::new( |
| 153 | - config.storage_in.as_ref().map(|storage| storage.token.clone()), | 154 | + config |
| 155 | + .storage_in | ||
| 156 | + .as_ref() | ||
| 157 | + .map(|storage| storage.token.clone()), | ||
| 154 | ); | 158 | ); |
| 155 | let storage_health = iz_web::storage::StorageHealth::new(); | 159 | let storage_health = iz_web::storage::StorageHealth::new(); |
| 156 | // The engine is always built, because a sender can appear at any moment: | 160 | // The engine is always built, because a sender can appear at any moment: |
| @@ -182,7 +186,11 @@ async fn main() { | |||
| 182 | config.base_url.clone(), | 186 | config.base_url.clone(), |
| 183 | health.clone(), | 187 | health.clone(), |
| 184 | )); | 188 | )); |
| 185 | - tokio::spawn(directory_stream(store.clone(), directory.clone(), health.clone())); | 189 | + tokio::spawn(directory_stream( |
| 190 | + store.clone(), | ||
| 191 | + directory.clone(), | ||
| 192 | + health.clone(), | ||
| 193 | + )); | ||
| 186 | // The storage mirror's watchdog: follows the family to wherever in | 194 | // The storage mirror's watchdog: follows the family to wherever in |
| 187 | // lives now, keeps the card's facts current, and — while the | 195 | // lives now, keeps the card's facts current, and — while the |
| 188 | // workspace's attachments live on in — drains the rows still on this | 196 | // workspace's attachments live on in — drains the rows still on this |
| @@ -200,6 +208,7 @@ async fn main() { | |||
| 200 | let router = iz_client::mount( | 208 | let router = iz_client::mount( |
| 201 | Router::builder() | 209 | Router::builder() |
| 202 | .discover() | 210 | .discover() |
| 211 | + .runtime() | ||
| 203 | .layer( | 212 | .layer( |
| 204 | BodyLimit::max(iz_web::settings::WIDEST_ATTACHMENT_MB as usize * 1024 * 1024) | 213 | BodyLimit::max(iz_web::settings::WIDEST_ATTACHMENT_MB as usize * 1024 * 1024) |
| 205 | .at("/files"), | 214 | .at("/files"), |
| @@ -264,9 +273,7 @@ fn ensure_storage_tree(storage: &std::path::Path) { | |||
| 264 | } | 273 | } |
| 265 | }; | 274 | }; |
| 266 | make(storage); | 275 | make(storage); |
| 267 | - for name in ["attachments"] { | 276 | + make(&storage.join("attachments")); |
| 268 | - make(&storage.join(name)); | ||
| 269 | - } | ||
| 270 | } | 277 | } |
| 271 | 278 | ||
| 272 | /// Resolves when the process is asked to stop: Ctrl+C, or `SIGTERM` from a | 279 | /// Resolves when the process is asked to stop: Ctrl+C, or `SIGTERM` from a |
| @@ -425,8 +432,7 @@ async fn directory_sync( | |||
| 425 | match client.family().await { | 432 | match client.family().await { |
| 426 | Some(family) => match serde_json::to_string(&family) { | 433 | Some(family) => match serde_json::to_string(&family) { |
| 427 | Ok(json) => { | 434 | Ok(json) => { |
| 428 | - if let Err(problem) = | 435 | + if let Err(problem) = store.set_setting(iz_web::server::FAMILY_KEY, &json).await |
| 429 | - store.set_setting(iz_web::server::FAMILY_KEY, &json).await | ||
| 430 | { | 436 | { |
| 431 | eprintln!("family sync: {problem}"); | 437 | eprintln!("family sync: {problem}"); |
| 432 | } | 438 | } |
crates/iz-web/src/pages.rsmodified+12 -15
| @@ -12,7 +12,7 @@ | |||
| 12 | use topcoat::Result; | 12 | use topcoat::Result; |
| 13 | use topcoat::context::Cx; | 13 | use topcoat::context::Cx; |
| 14 | use topcoat::router::page; | 14 | use topcoat::router::page; |
| 15 | -use topcoat::view::view; | 15 | +use topcoat::view::{View, ViewExt, view}; |
| 16 | 16 | ||
| 17 | use crate::i18n::{Key, Lang, t}; | 17 | use crate::i18n::{Key, Lang, t}; |
| 18 | use crate::layout::wordmark; | 18 | use crate::layout::wordmark; |
| @@ -21,38 +21,35 @@ use crate::server::current_user; | |||
| 21 | /// The front door: the board for a signed-in browser, the sign-in card for | 21 | /// The front door: the board for a signed-in browser, the sign-in card for |
| 22 | /// everybody else. | 22 | /// everybody else. |
| 23 | #[page("/")] | 23 | #[page("/")] |
| 24 | -async fn landing(cx: &Cx) -> Result { | 24 | +async fn landing(cx: &Cx) -> Result<impl View> { |
| 25 | match current_user(cx).await { | 25 | match current_user(cx).await { |
| 26 | - Ok(Some(user)) => crate::board::board_page(cx, &user).await, | 26 | + Ok(Some(user)) => Ok(crate::board::board_page(cx, user).await?.boxed()), |
| 27 | - Ok(None) => sign_in_card(cx).await, | 27 | + Ok(None) => Ok(sign_in_card(cx).await?.boxed()), |
| 28 | - Err(_) => view! { | 28 | + Err(_) => Ok(view! { |
| 29 | cx => | 29 | cx => |
| 30 | <main class="scaffold-note"> | 30 | <main class="scaffold-note"> |
| 31 | <p>(t(Lang::En, Key::SomethingWentWrong))</p> | 31 | <p>(t(Lang::En, Key::SomethingWentWrong))</p> |
| 32 | </main> | 32 | </main> |
| 33 | - }, | 33 | + } |
| 34 | + .boxed()), | ||
| 34 | } | 35 | } |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | /// The sign-in card for a browser with nobody in it: the wordmark and one | 38 | /// The sign-in card for a browser with nobody in it: the wordmark and one |
| 38 | /// link, which starts the OIDC round-trip at `/auth/login`. A round-trip | 39 | /// link, which starts the OIDC round-trip at `/auth/login`. A round-trip |
| 39 | /// that just failed names nothing but the fact. | 40 | /// that just failed names nothing but the fact. |
| 40 | -async fn sign_in_card(cx: &Cx) -> Result { | 41 | +async fn sign_in_card<'a>(cx: &'a Cx) -> Result<impl View + 'a> { |
| 41 | let language = Lang::En; | 42 | let language = Lang::En; |
| 42 | let failed = topcoat::router::request::uri(cx) | 43 | let failed = topcoat::router::request::uri(cx) |
| 43 | .query() | 44 | .query() |
| 44 | - .is_some_and(|query| { | 45 | + .is_some_and(|query| query.split('&').any(|pair| pair.starts_with("auth_error="))); |
| 45 | - query | 46 | + Ok(view! { |
| 46 | - .split('&') | ||
| 47 | - .any(|pair| pair.starts_with("auth_error=")) | ||
| 48 | - }); | ||
| 49 | - view! { | ||
| 50 | cx => | 47 | cx => |
| 51 | <main class="auth-stage"> | 48 | <main class="auth-stage"> |
| 52 | <div class="auth-column"> | 49 | <div class="auth-column"> |
| 53 | <div class="auth-card"> | 50 | <div class="auth-card"> |
| 54 | <div class="auth-head"> | 51 | <div class="auth-head"> |
| 55 | - <div class="auth-title">(wordmark(cx).await?)</div> | 52 | + <div class="auth-title">(topcoat::view::Child::new(wordmark(cx).await?))</div> |
| 56 | <div class="auth-sub">(t(language, Key::WelcomeBlurb))</div> | 53 | <div class="auth-sub">(t(language, Key::WelcomeBlurb))</div> |
| 57 | </div> | 54 | </div> |
| 58 | <a class="auth-submit" href="/auth/login"> | 55 | <a class="auth-submit" href="/auth/login"> |
| @@ -64,5 +61,5 @@ async fn sign_in_card(cx: &Cx) -> Result { | |||
| 64 | </div> | 61 | </div> |
| 65 | </div> | 62 | </div> |
| 66 | </main> | 63 | </main> |
| 67 | - } | 64 | + }.boxed()) |
| 68 | } | 65 | } |
crates/iz-web/src/people.rsmodified+11 -10
| @@ -9,7 +9,7 @@ use topcoat::Result; | |||
| 9 | use topcoat::context::Cx; | 9 | use topcoat::context::Cx; |
| 10 | use topcoat::router::error::not_found; | 10 | use topcoat::router::error::not_found; |
| 11 | use topcoat::router::{page, path_param}; | 11 | use topcoat::router::{page, path_param}; |
| 12 | -use topcoat::view::view; | 12 | +use topcoat::view::{View, ViewExt, view}; |
| 13 | 13 | ||
| 14 | use iz_core::detail::ActivityKind; | 14 | use iz_core::detail::ActivityKind; |
| 15 | use iz_core::store::{ActivityFilter, Dir, FeedPage}; | 15 | use iz_core::store::{ActivityFilter, Dir, FeedPage}; |
| @@ -56,7 +56,7 @@ fn kind_word(lang: Lang, kind: &ActivityKind) -> String { | |||
| 56 | 56 | ||
| 57 | /// A person's page. `/people/{user_id}`. | 57 | /// A person's page. `/people/{user_id}`. |
| 58 | #[page("/people/{user_id}")] | 58 | #[page("/people/{user_id}")] |
| 59 | -async fn people_page(cx: &Cx) -> Result { | 59 | +async fn people_page(cx: &Cx) -> Result<impl View> { |
| 60 | let user = match require_user(cx).await { | 60 | let user = match require_user(cx).await { |
| 61 | Ok(user) => user, | 61 | Ok(user) => user, |
| 62 | Err(_) => return Err(not_found().into()), | 62 | Err(_) => return Err(not_found().into()), |
| @@ -105,19 +105,20 @@ async fn people_page(cx: &Cx) -> Result { | |||
| 105 | ) | 105 | ) |
| 106 | .await?; | 106 | .await?; |
| 107 | 107 | ||
| 108 | - view! { | 108 | + let me = crate::detail::Me::from(&user); |
| 109 | + Ok(view! { | ||
| 109 | cx => | 110 | cx => |
| 110 | <header class="topbar"> | 111 | <header class="topbar"> |
| 111 | - (crate::layout::family_mark(cx).await?) | 112 | + (topcoat::view::Child::new(crate::layout::family_mark(cx).await?)) |
| 112 | - (crate::layout::topbar_nav(cx, crate::layout::NavPage::Settings, user.role, lang).await?) | 113 | + (topcoat::view::Child::new(crate::layout::topbar_nav(cx, crate::layout::NavPage::Settings, user.role, lang).await?)) |
| 113 | <div class="spacer"></div> | 114 | <div class="spacer"></div> |
| 114 | - (crate::layout::user_menu(cx, &crate::detail::Me::from(&user), lang).await?) | 115 | + (topcoat::view::Child::new(crate::layout::user_menu(cx, &me, lang).await?)) |
| 115 | </header> | 116 | </header> |
| 116 | 117 | ||
| 117 | <main class="people-shell"> | 118 | <main class="people-shell"> |
| 118 | <section class="panel person-card"> | 119 | <section class="panel person-card"> |
| 119 | <div class="person-head"> | 120 | <div class="person-head"> |
| 120 | - (crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "avatar-xl").await?) | 121 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &person.id, &person.display_name, person.photo_version, "avatar-xl").await?)) |
| 121 | <div class="person-heading"> | 122 | <div class="person-heading"> |
| 122 | <h2 class="person-name">(person.display_name.clone())</h2> | 123 | <h2 class="person-name">(person.display_name.clone())</h2> |
| 123 | <div class="person-marks"> | 124 | <div class="person-marks"> |
| @@ -196,7 +197,7 @@ async fn people_page(cx: &Cx) -> Result { | |||
| 196 | </section> | 197 | </section> |
| 197 | </main> | 198 | </main> |
| 198 | 199 | ||
| 199 | - (crate::layout::escape_script(cx).await?) | 200 | + (topcoat::view::Child::new(crate::layout::escape_script(cx).await?)) |
| 200 | - (crate::detail::escape_closes(cx).await?) | 201 | + (topcoat::view::Child::new(crate::detail::escape_closes(cx).await?)) |
| 201 | - } | 202 | + }.boxed()) |
| 202 | } | 203 | } |
crates/iz-web/src/rules.rsmodified+46 -42
| @@ -21,13 +21,13 @@ use topcoat::Result; | |||
| 21 | use topcoat::context::Cx; | 21 | use topcoat::context::Cx; |
| 22 | use topcoat::router::content::{Form, Json}; | 22 | use topcoat::router::content::{Form, Json}; |
| 23 | use topcoat::router::{HeaderName, StatusCode, header, page, query_params, route}; | 23 | use topcoat::router::{HeaderName, StatusCode, header, page, query_params, route}; |
| 24 | -use topcoat::view::view; | 24 | +use topcoat::view::{View, ViewExt, view}; |
| 25 | 25 | ||
| 26 | use iz_core::board::Column; | 26 | use iz_core::board::Column; |
| 27 | use iz_core::store::{Audience, Store, Trigger, User, Workspace}; | 27 | use iz_core::store::{Audience, Store, Trigger, User, Workspace}; |
| 28 | 28 | ||
| 29 | use crate::i18n::{Key, Lang, t}; | 29 | use crate::i18n::{Key, Lang, t}; |
| 30 | -use crate::server::{Refusal, store, back_to, refusal_of, require_admin}; | 30 | +use crate::server::{Refusal, back_to, refusal_of, require_admin, store}; |
| 31 | 31 | ||
| 32 | /// One rule as the screen reads it: a sentence, a switch and a stamp. | 32 | /// One rule as the screen reads it: a sentence, a switch and a stamp. |
| 33 | /// | 33 | /// |
| @@ -640,13 +640,13 @@ struct RulesQuery { | |||
| 640 | /// server-side, from whichever trigger the form starts on (the existing | 640 | /// server-side, from whichever trigger the form starts on (the existing |
| 641 | /// rule's, or "status" for a fresh one), since there is no script to flip it | 641 | /// rule's, or "status" for a fresh one), since there is no script to flip it |
| 642 | /// as the admin changes the select. | 642 | /// as the admin changes the select. |
| 643 | -async fn rule_form( | 643 | +async fn rule_form<'a>( |
| 644 | - cx: &Cx, | 644 | + cx: &'a Cx, |
| 645 | - columns: &[ColumnChoice], | 645 | + columns: &'a [ColumnChoice], |
| 646 | - existing: Option<&RuleLine>, | 646 | + existing: Option<&'a RuleLine>, |
| 647 | - refusal: Option<&Refusal>, | 647 | + refusal: Option<&'a Refusal>, |
| 648 | lang: Lang, | 648 | lang: Lang, |
| 649 | -) -> Result { | 649 | +) -> Result<impl View + 'a> { |
| 650 | let is_edit = existing.is_some(); | 650 | let is_edit = existing.is_some(); |
| 651 | let action = if is_edit { | 651 | let action = if is_edit { |
| 652 | "/api/update_rule" | 652 | "/api/update_rule" |
| @@ -668,7 +668,7 @@ async fn rule_form( | |||
| 668 | .unwrap_or("assignees"); | 668 | .unwrap_or("assignees"); |
| 669 | let include_task_details = existing.is_some_and(|rule| rule.include_task_details); | 669 | let include_task_details = existing.is_some_and(|rule| rule.include_task_details); |
| 670 | 670 | ||
| 671 | - view! { | 671 | + Ok(view! { |
| 672 | cx => | 672 | cx => |
| 673 | <form method="post" action=(action) class="rule-new-body"> | 673 | <form method="post" action=(action) class="rule-new-body"> |
| 674 | if let Some(rule) = existing { | 674 | if let Some(rule) = existing { |
| @@ -741,44 +741,45 @@ async fn rule_form( | |||
| 741 | <button class="primary" type="submit">(if is_edit { t(lang, Key::SaveRule) } else { t(lang, Key::AddRule) })</button> | 741 | <button class="primary" type="submit">(if is_edit { t(lang, Key::SaveRule) } else { t(lang, Key::AddRule) })</button> |
| 742 | </div> | 742 | </div> |
| 743 | </form> | 743 | </form> |
| 744 | - } | 744 | + }.boxed()) |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | /// The "New rule" control and the form inside it. A `<details>` rather than | 747 | /// The "New rule" control and the form inside it. A `<details>` rather than |
| 748 | /// anything script-driven, so a browser with no script can still open it and | 748 | /// anything script-driven, so a browser with no script can still open it and |
| 749 | /// post the form. | 749 | /// post the form. |
| 750 | -async fn composer( | 750 | +async fn composer<'a>( |
| 751 | - cx: &Cx, | 751 | + cx: &'a Cx, |
| 752 | - columns: &[ColumnChoice], | 752 | + columns: &'a [ColumnChoice], |
| 753 | - refusal: Option<&Refusal>, | 753 | + refusal: Option<&'a Refusal>, |
| 754 | lang: Lang, | 754 | lang: Lang, |
| 755 | -) -> Result { | 755 | +) -> Result<impl View + 'a> { |
| 756 | - view! { | 756 | + Ok(view! { |
| 757 | cx => | 757 | cx => |
| 758 | <details class="rule-new"> | 758 | <details class="rule-new"> |
| 759 | <summary class="rule-new-open">(t(lang, Key::NewRule))</summary> | 759 | <summary class="rule-new-open">(t(lang, Key::NewRule))</summary> |
| 760 | - (rule_form(cx, columns, None, refusal, lang).await?) | 760 | + (topcoat::view::Child::new(rule_form(cx, columns, None, refusal, lang).await?)) |
| 761 | </details> | 761 | </details> |
| 762 | } | 762 | } |
| 763 | + .boxed()) | ||
| 763 | } | 764 | } |
| 764 | 765 | ||
| 765 | /// One rule's row: the form in place of it when `editing`, its display | 766 | /// One rule's row: the form in place of it when `editing`, its display |
| 766 | /// otherwise. | 767 | /// otherwise. |
| 767 | -async fn rule_row( | 768 | +async fn rule_row<'a>( |
| 768 | - cx: &Cx, | 769 | + cx: &'a Cx, |
| 769 | - rule: &RuleLine, | 770 | + rule: &'a RuleLine, |
| 770 | - columns: &[ColumnChoice], | 771 | + columns: &'a [ColumnChoice], |
| 771 | editing: bool, | 772 | editing: bool, |
| 772 | - refusal: Option<&Refusal>, | 773 | + refusal: Option<&'a Refusal>, |
| 773 | lang: Lang, | 774 | lang: Lang, |
| 774 | -) -> Result { | 775 | +) -> Result<impl View + 'a> { |
| 775 | if editing { | 776 | if editing { |
| 776 | - return view! { | 777 | + return Ok(view! { |
| 777 | cx => | 778 | cx => |
| 778 | <div class="rule-row"> | 779 | <div class="rule-row"> |
| 779 | - (rule_form(cx, columns, Some(rule), refusal, lang).await?) | 780 | + (topcoat::view::Child::new(rule_form(cx, columns, Some(rule), refusal, lang).await?)) |
| 780 | </div> | 781 | </div> |
| 781 | - }; | 782 | + }.boxed()); |
| 782 | } | 783 | } |
| 783 | 784 | ||
| 784 | let row_class = if rule.enabled { | 785 | let row_class = if rule.enabled { |
| @@ -807,7 +808,7 @@ async fn rule_row( | |||
| 807 | }) | 808 | }) |
| 808 | .unwrap_or_else(|| t(lang, Key::NeverFired).to_string()); | 809 | .unwrap_or_else(|| t(lang, Key::NeverFired).to_string()); |
| 809 | 810 | ||
| 810 | - view! { | 811 | + Ok(view! { |
| 811 | cx => | 812 | cx => |
| 812 | <div class=(row_class)> | 813 | <div class=(row_class)> |
| 813 | <form method="post" action="/api/set_rule_enabled" class="rule-switch-form"> | 814 | <form method="post" action="/api/set_rule_enabled" class="rule-switch-form"> |
| @@ -841,20 +842,21 @@ async fn rule_row( | |||
| 841 | <button class="quiet quiet-danger" type="submit" title=(t(lang, Key::DeleteThisRule))>(t(lang, Key::Delete))</button> | 842 | <button class="quiet quiet-danger" type="submit" title=(t(lang, Key::DeleteThisRule))>(t(lang, Key::Delete))</button> |
| 842 | </form> | 843 | </form> |
| 843 | </div> | 844 | </div> |
| 844 | - } | 845 | + }.boxed()) |
| 845 | } | 846 | } |
| 846 | 847 | ||
| 847 | #[page("/rules")] | 848 | #[page("/rules")] |
| 848 | -async fn rules_page(cx: &Cx) -> Result { | 849 | +async fn rules_page(cx: &Cx) -> Result<impl View> { |
| 849 | let user = match require_admin(cx).await { | 850 | let user = match require_admin(cx).await { |
| 850 | Ok(user) => user, | 851 | Ok(user) => user, |
| 851 | Err(refusal) => { | 852 | Err(refusal) => { |
| 852 | - return view! { | 853 | + return Ok(view! { |
| 853 | <main class="scaffold-note"> | 854 | <main class="scaffold-note"> |
| 854 | <p>(refusal.message())</p> | 855 | <p>(refusal.message())</p> |
| 855 | <p><a href="/">(t(Lang::En, Key::BackToBoard))</a></p> | 856 | <p><a href="/">(t(Lang::En, Key::BackToBoard))</a></p> |
| 856 | </main> | 857 | </main> |
| 857 | - }; | 858 | + } |
| 859 | + .boxed()); | ||
| 858 | } | 860 | } |
| 859 | }; | 861 | }; |
| 860 | let lang = Lang::from_code(&user.language); | 862 | let lang = Lang::from_code(&user.language); |
| @@ -862,24 +864,26 @@ async fn rules_page(cx: &Cx) -> Result { | |||
| 862 | let snapshot = match snapshot_of(&store, &user).await { | 864 | let snapshot = match snapshot_of(&store, &user).await { |
| 863 | Ok(snapshot) => snapshot, | 865 | Ok(snapshot) => snapshot, |
| 864 | Err(refusal) => { | 866 | Err(refusal) => { |
| 865 | - return view! { | 867 | + return Ok(view! { |
| 866 | <main class="scaffold-note"> | 868 | <main class="scaffold-note"> |
| 867 | <p>(refusal.message_in(lang))</p> | 869 | <p>(refusal.message_in(lang))</p> |
| 868 | <p><a href="/">(t(lang, Key::BackToBoard))</a></p> | 870 | <p><a href="/">(t(lang, Key::BackToBoard))</a></p> |
| 869 | </main> | 871 | </main> |
| 870 | - }; | 872 | + } |
| 873 | + .boxed()); | ||
| 871 | } | 874 | } |
| 872 | }; | 875 | }; |
| 873 | let edit_id = query_params::<RulesQuery>(cx)?.edit.clone(); | 876 | let edit_id = query_params::<RulesQuery>(cx)?.edit.clone(); |
| 874 | let create_refusal = refusal_of(cx, "create_rule"); | 877 | let create_refusal = refusal_of(cx, "create_rule"); |
| 875 | let update_refusal = refusal_of(cx, "update_rule"); | 878 | let update_refusal = refusal_of(cx, "update_rule"); |
| 876 | 879 | ||
| 877 | - view! { | 880 | + let me = crate::detail::Me::from(&user); |
| 881 | + Ok(view! { | ||
| 878 | <header class="topbar"> | 882 | <header class="topbar"> |
| 879 | - (crate::layout::family_mark(cx).await?) | 883 | + (topcoat::view::Child::new(crate::layout::family_mark(cx).await?)) |
| 880 | - (crate::layout::topbar_nav(cx, crate::layout::NavPage::Rules, user.role, lang).await?) | 884 | + (topcoat::view::Child::new(crate::layout::topbar_nav(cx, crate::layout::NavPage::Rules, user.role, lang).await?)) |
| 881 | <div class="spacer"></div> | 885 | <div class="spacer"></div> |
| 882 | - (crate::layout::user_menu(cx, &crate::detail::Me::from(&user), lang).await?) | 886 | + (topcoat::view::Child::new(crate::layout::user_menu(cx, &me, lang).await?)) |
| 883 | </header> | 887 | </header> |
| 884 | 888 | ||
| 885 | <div class="settings-shell"> | 889 | <div class="settings-shell"> |
| @@ -897,19 +901,19 @@ async fn rules_page(cx: &Cx) -> Result { | |||
| 897 | </p> | 901 | </p> |
| 898 | } | 902 | } |
| 899 | 903 | ||
| 900 | - (composer(cx, &snapshot.columns, create_refusal.as_ref(), lang).await?) | 904 | + (topcoat::view::Child::new(composer(cx, &snapshot.columns, create_refusal.as_ref(), lang).await?)) |
| 901 | 905 | ||
| 902 | <div class="rule-list"> | 906 | <div class="rule-list"> |
| 903 | for rule in &snapshot.rules { | 907 | for rule in &snapshot.rules { |
| 904 | - (rule_row(cx, rule, &snapshot.columns, edit_id.as_deref() == Some(rule.id.as_str()), update_refusal.as_ref(), lang).await?) | 908 | + (topcoat::view::Child::new(rule_row(cx, rule, &snapshot.columns, edit_id.as_deref() == Some(rule.id.as_str()), update_refusal.as_ref(), lang).await?)) |
| 905 | } | 909 | } |
| 906 | if snapshot.rules.is_empty() { | 910 | if snapshot.rules.is_empty() { |
| 907 | <p class="rules-quiet">(t(lang, Key::NoRulesYet))</p> | 911 | <p class="rules-quiet">(t(lang, Key::NoRulesYet))</p> |
| 908 | } | 912 | } |
| 909 | </div> | 913 | </div> |
| 910 | </main> | 914 | </main> |
| 911 | - (crate::dropdown::dropdown_script(cx).await?) | 915 | + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) |
| 912 | - (crate::layout::escape_script(cx).await?) | 916 | + (topcoat::view::Child::new(crate::layout::escape_script(cx).await?)) |
| 913 | </div> | 917 | </div> |
| 914 | - } | 918 | + }.boxed()) |
| 915 | } | 919 | } |
crates/iz-web/src/server.rsmodified+5 -1
| @@ -245,7 +245,11 @@ pub fn stylesheet_guard(bundle: &AssetBundle) -> Result<String, String> { | |||
| 245 | stylesheet.name() | 245 | stylesheet.name() |
| 246 | ) | 246 | ) |
| 247 | })?; | 247 | })?; |
| 248 | - let actual = format!("sha256:{:x}", sha2::Sha256::digest(&bytes)); | 248 | + let digest = sha2::Sha256::digest(&bytes); |
| 249 | + let actual = format!( | ||
| 250 | + "sha256:{}", | ||
| 251 | + digest.as_slice().iter().map(|b| format!("{b:02x}")).collect::<String>() | ||
| 252 | + ); | ||
| 249 | if actual != expected { | 253 | if actual != expected { |
| 250 | return Err(format!( | 254 | return Err(format!( |
| 251 | "the asset bundle at {} is from another build: stylesheet {} is {actual} but this binary was compiled against {expected}; run `topcoat asset bundle` and redeploy", | 255 | "the asset bundle at {} is from another build: stylesheet {} is {actual} but this binary was compiled against {expected}; run `topcoat asset bundle` and redeploy", |
crates/iz-web/src/settings.rsmodified+35 -29
| @@ -18,7 +18,7 @@ use topcoat::Result; | |||
| 18 | use topcoat::context::Cx; | 18 | use topcoat::context::Cx; |
| 19 | use topcoat::router::content::Form; | 19 | use topcoat::router::content::Form; |
| 20 | use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, page, route}; | 20 | use topcoat::router::{HeaderMap, HeaderValue, StatusCode, header, page, route}; |
| 21 | -use topcoat::view::view; | 21 | +use topcoat::view::{View, ViewExt, view}; |
| 22 | 22 | ||
| 23 | use iz_core::detail::ActivityKind; | 23 | use iz_core::detail::ActivityKind; |
| 24 | use iz_core::store::{NewSender, SenderCheck, SenderTest, StorageBackend, Store, StoreError, User}; | 24 | use iz_core::store::{NewSender, SenderCheck, SenderTest, StorageBackend, Store, StoreError, User}; |
| @@ -955,8 +955,10 @@ async fn send_message( | |||
| 955 | /// and whether the live identity feed is open at this moment. Read from | 955 | /// and whether the live identity feed is open at this moment. Read from |
| 956 | /// the config and the mirror's health only — the client secret is not | 956 | /// the config and the mirror's health only — the client secret is not |
| 957 | /// read here, so no render path can carry it. | 957 | /// read here, so no render path can carry it. |
| 958 | -async fn connection_card(cx: &Cx, lang: Lang) -> Result { | 958 | +async fn connection_card<'a>(cx: &'a Cx, lang: Lang) -> Result<impl View + 'a> { |
| 959 | - let oidc = &config(cx).oidc; | 959 | + let config = config(cx); |
| 960 | + let issuer = config.oidc.issuer.clone(); | ||
| 961 | + let client_id = config.oidc.client_id.clone(); | ||
| 960 | let snap = crate::directory::health(cx).snapshot(); | 962 | let snap = crate::directory::health(cx).snapshot(); |
| 961 | let (state_word, state_class) = if snap.connected { | 963 | let (state_word, state_class) = if snap.connected { |
| 962 | (t(lang, Key::ConnectionConnected), "connection-on") | 964 | (t(lang, Key::ConnectionConnected), "connection-on") |
| @@ -976,13 +978,13 @@ async fn connection_card(cx: &Cx, lang: Lang) -> Result { | |||
| 976 | } else { | 978 | } else { |
| 977 | format!("{pass_age} ago") | 979 | format!("{pass_age} ago") |
| 978 | }; | 980 | }; |
| 979 | - view! { | 981 | + Ok(view! { |
| 980 | cx => | 982 | cx => |
| 981 | <dl class="connection-facts"> | 983 | <dl class="connection-facts"> |
| 982 | <dt>(t(lang, Key::ConnectionIssuer))</dt> | 984 | <dt>(t(lang, Key::ConnectionIssuer))</dt> |
| 983 | - <dd class="connection-fact">(oidc.issuer.clone())</dd> | 985 | + <dd class="connection-fact">(issuer)</dd> |
| 984 | <dt>(t(lang, Key::ConnectionClientId))</dt> | 986 | <dt>(t(lang, Key::ConnectionClientId))</dt> |
| 985 | - <dd class="connection-fact">(oidc.client_id.clone())</dd> | 987 | + <dd class="connection-fact">(client_id)</dd> |
| 986 | <dt>(t(lang, Key::ConnectionStream))</dt> | 988 | <dt>(t(lang, Key::ConnectionStream))</dt> |
| 987 | <dd class="connection-fact"> | 989 | <dd class="connection-fact"> |
| 988 | <span class=(format!("connection-dot {state_class}"))></span> | 990 | <span class=(format!("connection-dot {state_class}"))></span> |
| @@ -994,6 +996,7 @@ async fn connection_card(cx: &Cx, lang: Lang) -> Result { | |||
| 994 | <dd class="connection-fact">(pass_line)</dd> | 996 | <dd class="connection-fact">(pass_line)</dd> |
| 995 | </dl> | 997 | </dl> |
| 996 | } | 998 | } |
| 999 | + .boxed()) | ||
| 997 | } | 1000 | } |
| 998 | 1001 | ||
| 999 | /// The share of a migration already moved, for the bar's width. An empty | 1002 | /// The share of a migration already moved, for the bar's width. An empty |
| @@ -1011,13 +1014,13 @@ fn migration_percent(moved: u64, total: u64) -> u8 { | |||
| 1011 | /// stands, and — while rows still move — how far the drain has come. | 1014 | /// stands, and — while rows still move — how far the drain has come. |
| 1012 | /// Read from the mirror and the beat's health only; the key | 1015 | /// Read from the mirror and the beat's health only; the key |
| 1013 | /// `[storage.in]` holds is not read here, so no render path can carry it. | 1016 | /// `[storage.in]` holds is not read here, so no render path can carry it. |
| 1014 | -async fn storage_card( | 1017 | +async fn storage_card<'a>( |
| 1015 | - cx: &Cx, | 1018 | + cx: &'a Cx, |
| 1016 | lang: Lang, | 1019 | lang: Lang, |
| 1017 | listed: Option<(String, String)>, | 1020 | listed: Option<(String, String)>, |
| 1018 | snap: &crate::storage::StorageSnapshot, | 1021 | snap: &crate::storage::StorageSnapshot, |
| 1019 | backend: StorageBackend, | 1022 | backend: StorageBackend, |
| 1020 | -) -> Result { | 1023 | +) -> Result<impl View + 'a> { |
| 1021 | let service_line = match &listed { | 1024 | let service_line = match &listed { |
| 1022 | Some((name, url)) => format!("{name} · {url}"), | 1025 | Some((name, url)) => format!("{name} · {url}"), |
| 1023 | None => t(lang, Key::StorageAbsent).to_string(), | 1026 | None => t(lang, Key::StorageAbsent).to_string(), |
| @@ -1043,7 +1046,8 @@ async fn storage_card( | |||
| 1043 | ), | 1046 | ), |
| 1044 | None => t(lang, Key::ConnectionNever).to_string(), | 1047 | None => t(lang, Key::ConnectionNever).to_string(), |
| 1045 | }; | 1048 | }; |
| 1046 | - view! { | 1049 | + let migrating = snap.migrating; |
| 1050 | + Ok(view! { | ||
| 1047 | cx => | 1051 | cx => |
| 1048 | <dl class="connection-facts"> | 1052 | <dl class="connection-facts"> |
| 1049 | <dt>(t(lang, Key::StorageService))</dt> | 1053 | <dt>(t(lang, Key::StorageService))</dt> |
| @@ -1055,7 +1059,7 @@ async fn storage_card( | |||
| 1055 | </dd> | 1059 | </dd> |
| 1056 | <dt>(t(lang, Key::StorageLimit))</dt> | 1060 | <dt>(t(lang, Key::StorageLimit))</dt> |
| 1057 | <dd class="connection-fact">(limit_line)</dd> | 1061 | <dd class="connection-fact">(limit_line)</dd> |
| 1058 | - if backend == StorageBackend::In && let Some((moved, total)) = snap.migrating { | 1062 | + if backend == StorageBackend::In && let Some((moved, total)) = migrating { |
| 1059 | <dt>(t(lang, Key::StorageMigration))</dt> | 1063 | <dt>(t(lang, Key::StorageMigration))</dt> |
| 1060 | <dd class="connection-fact"> | 1064 | <dd class="connection-fact"> |
| 1061 | (format!("{moved} of {total}")) | 1065 | (format!("{moved} of {total}")) |
| @@ -1067,7 +1071,7 @@ async fn storage_card( | |||
| 1067 | <dt>(t(lang, Key::StorageLastProblem))</dt> | 1071 | <dt>(t(lang, Key::StorageLastProblem))</dt> |
| 1068 | <dd class="connection-fact">(problem_line)</dd> | 1072 | <dd class="connection-fact">(problem_line)</dd> |
| 1069 | </dl> | 1073 | </dl> |
| 1070 | - } | 1074 | + }.boxed()) |
| 1071 | } | 1075 | } |
| 1072 | 1076 | ||
| 1073 | /// One row of the member list, as an admin may see it. Identity is im's to | 1077 | /// One row of the member list, as an admin may see it. Identity is im's to |
| @@ -1256,7 +1260,7 @@ fn is_origin(value: &str) -> bool { | |||
| 1256 | 1260 | ||
| 1257 | /// The refusal that landed on this call's redirect, if any, and this call's | 1261 | /// The refusal that landed on this call's redirect, if any, and this call's |
| 1258 | /// own `saved=<call>` flag. | 1262 | /// own `saved=<call>` flag. |
| 1259 | -fn call_state<'q>(query: &'q str, call: &str) -> (Option<Refusal>, bool) { | 1263 | +fn call_state(query: &str, call: &str) -> (Option<Refusal>, bool) { |
| 1260 | let mut refusal_code = None; | 1264 | let mut refusal_code = None; |
| 1261 | let mut on = None; | 1265 | let mut on = None; |
| 1262 | let mut saved = false; | 1266 | let mut saved = false; |
| @@ -1322,17 +1326,18 @@ fn rail_class(current: Section, target: Section) -> &'static str { | |||
| 1322 | /// The settings screen. | 1326 | /// The settings screen. |
| 1323 | #[page("/settings")] | 1327 | #[page("/settings")] |
| 1324 | #[allow(unused_variables)] | 1328 | #[allow(unused_variables)] |
| 1325 | -async fn settings_page(cx: &Cx) -> Result { | 1329 | +async fn settings_page(cx: &Cx) -> Result<impl View> { |
| 1326 | let user = match require_user(cx).await { | 1330 | let user = match require_user(cx).await { |
| 1327 | Ok(user) => user, | 1331 | Ok(user) => user, |
| 1328 | Err(refusal) => { | 1332 | Err(refusal) => { |
| 1329 | - return view! { | 1333 | + return Ok(view! { |
| 1330 | cx => | 1334 | cx => |
| 1331 | <main class="scaffold-note"> | 1335 | <main class="scaffold-note"> |
| 1332 | <p>(refusal.message())</p> | 1336 | <p>(refusal.message())</p> |
| 1333 | <p><a href="/">(t(Lang::En, Key::BackToBoard))</a></p> | 1337 | <p><a href="/">(t(Lang::En, Key::BackToBoard))</a></p> |
| 1334 | </main> | 1338 | </main> |
| 1335 | - }; | 1339 | + } |
| 1340 | + .boxed()); | ||
| 1336 | } | 1341 | } |
| 1337 | }; | 1342 | }; |
| 1338 | let lang = Lang::from_code(&user.language); | 1343 | let lang = Lang::from_code(&user.language); |
| @@ -1407,13 +1412,14 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1407 | None | 1412 | None |
| 1408 | }; | 1413 | }; |
| 1409 | 1414 | ||
| 1410 | - view! { | 1415 | + let me = crate::detail::Me::from(&user); |
| 1416 | + Ok(view! { | ||
| 1411 | cx => | 1417 | cx => |
| 1412 | <header class="topbar"> | 1418 | <header class="topbar"> |
| 1413 | - (crate::layout::family_mark(cx).await?) | 1419 | + (topcoat::view::Child::new(crate::layout::family_mark(cx).await?)) |
| 1414 | - (crate::layout::topbar_nav(cx, crate::layout::NavPage::Settings, user.role, lang).await?) | 1420 | + (topcoat::view::Child::new(crate::layout::topbar_nav(cx, crate::layout::NavPage::Settings, user.role, lang).await?)) |
| 1415 | <div class="spacer"></div> | 1421 | <div class="spacer"></div> |
| 1416 | - (crate::layout::user_menu(cx, &crate::detail::Me::from(&user), lang).await?) | 1422 | + (topcoat::view::Child::new(crate::layout::user_menu(cx, &me, lang).await?)) |
| 1417 | </header> | 1423 | </header> |
| 1418 | 1424 | ||
| 1419 | <div class="settings-shell"> | 1425 | <div class="settings-shell"> |
| @@ -1434,7 +1440,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1434 | </div> | 1440 | </div> |
| 1435 | <div class="panel-body"> | 1441 | <div class="panel-body"> |
| 1436 | <div class="identity-row"> | 1442 | <div class="identity-row"> |
| 1437 | - (crate::layout::avatar(cx, &user.id, &user.display_name, user.photo_version, "avatar-lg").await?) | 1443 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &user.id, &user.display_name, user.photo_version, "avatar-lg").await?)) |
| 1438 | <div class="identity-who"> | 1444 | <div class="identity-who"> |
| 1439 | <div class="identity-name">(user.display_name.clone())</div> | 1445 | <div class="identity-name">(user.display_name.clone())</div> |
| 1440 | <div class="identity-address">(user.email.clone())</div> | 1446 | <div class="identity-address">(user.email.clone())</div> |
| @@ -1486,7 +1492,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1486 | <h2 class="panel-title">(t(lang, Key::Connection))</h2> | 1492 | <h2 class="panel-title">(t(lang, Key::Connection))</h2> |
| 1487 | </div> | 1493 | </div> |
| 1488 | <div class="panel-body"> | 1494 | <div class="panel-body"> |
| 1489 | - (connection_card(cx, lang).await?) | 1495 | + (topcoat::view::Child::new(connection_card(cx, lang).await?)) |
| 1490 | </div> | 1496 | </div> |
| 1491 | </section> | 1497 | </section> |
| 1492 | } | 1498 | } |
| @@ -1737,7 +1743,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1737 | </div> | 1743 | </div> |
| 1738 | </form> | 1744 | </form> |
| 1739 | <div class="panel-body"> | 1745 | <div class="panel-body"> |
| 1740 | - (storage_card(cx, lang, listed, &snap, backend).await?) | 1746 | + (topcoat::view::Child::new(storage_card(cx, lang, listed, &snap, backend).await?)) |
| 1741 | </div> | 1747 | </div> |
| 1742 | </section> | 1748 | </section> |
| 1743 | } | 1749 | } |
| @@ -1810,7 +1816,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1810 | <tr class="member-row"> | 1816 | <tr class="member-row"> |
| 1811 | <td class="member-col-name member-name"> | 1817 | <td class="member-col-name member-name"> |
| 1812 | <span class="member-name-row"> | 1818 | <span class="member-name-row"> |
| 1813 | - (crate::layout::avatar(cx, &member.id, &member.display_name, member.photo_version, "avatar-sm").await?) | 1819 | + (topcoat::view::Child::new(crate::layout::avatar(cx, &member.id, &member.display_name, member.photo_version, "avatar-sm").await?)) |
| 1814 | <a href=(format!("/people/{}", member.id))>(member.display_name.clone())</a> | 1820 | <a href=(format!("/people/{}", member.id))>(member.display_name.clone())</a> |
| 1815 | if member.is_you { | 1821 | if member.is_you { |
| 1816 | <span class="member-you">(t(lang, Key::You))</span> | 1822 | <span class="member-you">(t(lang, Key::You))</span> |
| @@ -1839,7 +1845,7 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1839 | <option value="member" selected=(member.role == iz_core::Role::Member)>(t(lang, Key::RoleMemberOption))</option> | 1845 | <option value="member" selected=(member.role == iz_core::Role::Member)>(t(lang, Key::RoleMemberOption))</option> |
| 1840 | <option value="viewer" selected=(member.role == iz_core::Role::Viewer)>(t(lang, Key::RoleViewerOption))</option> | 1846 | <option value="viewer" selected=(member.role == iz_core::Role::Viewer)>(t(lang, Key::RoleViewerOption))</option> |
| 1841 | </select> | 1847 | </select> |
| 1842 | - (crate::detail::glyph::chevron(cx).await?) | 1848 | + (topcoat::view::Child::new(crate::detail::glyph::chevron(cx).await?)) |
| 1843 | </form> | 1849 | </form> |
| 1844 | } | 1850 | } |
| 1845 | </td> | 1851 | </td> |
| @@ -1939,8 +1945,8 @@ async fn settings_page(cx: &Cx) -> Result { | |||
| 1939 | } | 1945 | } |
| 1940 | </main> | 1946 | </main> |
| 1941 | </div> | 1947 | </div> |
| 1942 | - (crate::dropdown::dropdown_script(cx).await?) | 1948 | + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) |
| 1943 | - (crate::layout::escape_script(cx).await?) | 1949 | + (topcoat::view::Child::new(crate::layout::escape_script(cx).await?)) |
| 1944 | - (crate::detail::escape_closes(cx).await?) | 1950 | + (topcoat::view::Child::new(crate::detail::escape_closes(cx).await?)) |
| 1945 | - } | 1951 | + }.boxed()) |
| 1946 | } | 1952 | } |
crates/iz-web/src/slides.rsmodified+35 -44
| @@ -26,6 +26,7 @@ use zip::ZipArchive; | |||
| 26 | 26 | ||
| 27 | /// One slide: the paragraphs of text it carries, in the order they sit on | 27 | /// One slide: the paragraphs of text it carries, in the order they sit on |
| 28 | /// the slide. | 28 | /// the slide. |
| 29 | +#[derive(Clone)] | ||
| 29 | pub(crate) struct Slide { | 30 | pub(crate) struct Slide { |
| 30 | pub paragraphs: Vec<Paragraph>, | 31 | pub paragraphs: Vec<Paragraph>, |
| 31 | } | 32 | } |
| @@ -33,6 +34,7 @@ pub(crate) struct Slide { | |||
| 33 | /// One paragraph of a slide. `title` marks a paragraph from a title | 34 | /// One paragraph of a slide. `title` marks a paragraph from a title |
| 34 | /// placeholder (`type="title"` or `ctrTitle`), which the view sets off as | 35 | /// placeholder (`type="title"` or `ctrTitle`), which the view sets off as |
| 35 | /// the slide's heading. | 36 | /// the slide's heading. |
| 37 | +#[derive(Clone)] | ||
| 36 | pub(crate) struct Paragraph { | 38 | pub(crate) struct Paragraph { |
| 37 | pub title: bool, | 39 | pub title: bool, |
| 38 | pub text: String, | 40 | pub text: String, |
| @@ -78,7 +80,7 @@ fn slide_order(archive: &mut ZipArchive<Cursor<Vec<u8>>>) -> Option<Vec<String>> | |||
| 78 | let mut reader = Reader::from_str(&presentation); | 80 | let mut reader = Reader::from_str(&presentation); |
| 79 | loop { | 81 | loop { |
| 80 | match &reader.read_event() { | 82 | match &reader.read_event() { |
| 81 | - Ok(Event::Start(e)) | Ok(Event::Empty(e)) if is(e, b"p:sldId") => { | 83 | + Ok(Event::Start(e)) | Ok(Event::Empty(e)) if is(e, "p:sldId") => { |
| 82 | if let Some(id) = attribute(e, "r:id") { | 84 | if let Some(id) = attribute(e, "r:id") { |
| 83 | ids.push(id); | 85 | ids.push(id); |
| 84 | } | 86 | } |
| @@ -96,7 +98,7 @@ fn slide_order(archive: &mut ZipArchive<Cursor<Vec<u8>>>) -> Option<Vec<String>> | |||
| 96 | let mut reader = Reader::from_str(&rels); | 98 | let mut reader = Reader::from_str(&rels); |
| 97 | loop { | 99 | loop { |
| 98 | match &reader.read_event() { | 100 | match &reader.read_event() { |
| 99 | - Ok(Event::Start(e)) | Ok(Event::Empty(e)) if is(e, b"Relationship") => { | 101 | + Ok(Event::Start(e)) | Ok(Event::Empty(e)) if is(e, "Relationship") => { |
| 100 | if let (Some(id), Some(target)) = (attribute(e, "Id"), attribute(e, "Target")) { | 102 | if let (Some(id), Some(target)) = (attribute(e, "Id"), attribute(e, "Target")) { |
| 101 | let target = target.trim_start_matches('/'); | 103 | let target = target.trim_start_matches('/'); |
| 102 | let part = if let Some(part) = target.strip_prefix("ppt/") { | 104 | let part = if let Some(part) = target.strip_prefix("ppt/") { |
| @@ -154,27 +156,25 @@ fn slide(archive: &mut ZipArchive<Cursor<Vec<u8>>>, part: &str) -> Option<Slide> | |||
| 154 | loop { | 156 | loop { |
| 155 | match &reader.read_event() { | 157 | match &reader.read_event() { |
| 156 | Ok(Event::Start(e)) => match e.name().as_ref() { | 158 | Ok(Event::Start(e)) => match e.name().as_ref() { |
| 157 | - b"p:sp" => title_shape = false, | 159 | + "p:sp" => title_shape = false, |
| 158 | - b"p:ph" => title_shape |= title_placeholder(e), | 160 | + "p:ph" => title_shape |= title_placeholder(e), |
| 159 | - b"a:p" => current = Some((title_shape, String::new())), | 161 | + "a:p" => current = Some((title_shape, String::new())), |
| 160 | - b"a:t" => in_run = true, | 162 | + "a:t" => in_run = true, |
| 161 | - b"a:fld" => in_field = true, | 163 | + "a:fld" => in_field = true, |
| 162 | _ => {} | 164 | _ => {} |
| 163 | }, | 165 | }, |
| 164 | - // A self-closing placeholder has no body of its own, but its | 166 | + Ok(Event::Empty(e)) if is(e, "p:ph") => title_shape |= title_placeholder(e), |
| 165 | - // type still titles the shape's paragraphs. | ||
| 166 | - Ok(Event::Empty(e)) if is(e, b"p:ph") => title_shape |= title_placeholder(e), | ||
| 167 | Ok(Event::End(e)) => match e.name().as_ref() { | 167 | Ok(Event::End(e)) => match e.name().as_ref() { |
| 168 | - b"a:p" => { | 168 | + "a:p" => { |
| 169 | - if let Some((title, text)) = current.take() { | 169 | + if let Some((title, text)) = current.take() |
| 170 | - if !text.is_empty() { | 170 | + && !text.is_empty() |
| 171 | - paragraphs.push(Paragraph { title, text }); | 171 | + { |
| 172 | - } | 172 | + paragraphs.push(Paragraph { title, text }); |
| 173 | } | 173 | } |
| 174 | } | 174 | } |
| 175 | - b"a:t" => in_run = false, | 175 | + "a:t" => in_run = false, |
| 176 | - b"a:fld" => in_field = false, | 176 | + "a:fld" => in_field = false, |
| 177 | - b"p:sp" => title_shape = false, | 177 | + "p:sp" => title_shape = false, |
| 178 | _ => {} | 178 | _ => {} |
| 179 | }, | 179 | }, |
| 180 | // The reader splits a character reference out of the text, so | 180 | // The reader splits a character reference out of the text, so |
| @@ -185,31 +185,28 @@ fn slide(archive: &mut ZipArchive<Cursor<Vec<u8>>>, part: &str) -> Option<Slide> | |||
| 185 | if in_run && !in_field { | 185 | if in_run && !in_field { |
| 186 | let ch = match r.resolve_char_ref() { | 186 | let ch = match r.resolve_char_ref() { |
| 187 | Ok(Some(ch)) => Some(ch), | 187 | Ok(Some(ch)) => Some(ch), |
| 188 | - Ok(None) => match std::str::from_utf8(&r) { | 188 | + Ok(None) => match r.as_ref() { |
| 189 | - Ok("amp") => Some('&'), | 189 | + "amp" => Some('&'), |
| 190 | - Ok("lt") => Some('<'), | 190 | + "lt" => Some('<'), |
| 191 | - Ok("gt") => Some('>'), | 191 | + "gt" => Some('>'), |
| 192 | - Ok("quot") => Some('"'), | 192 | + "quot" => Some('"'), |
| 193 | - Ok("apos") => Some('\''), | 193 | + "apos" => Some('\''), |
| 194 | - // A reference the XML grammar does not define | ||
| 195 | - // is a malformed document; such a deck does not | ||
| 196 | - // open. | ||
| 197 | _ => return None, | 194 | _ => return None, |
| 198 | }, | 195 | }, |
| 199 | Err(_) => return None, | 196 | Err(_) => return None, |
| 200 | }; | 197 | }; |
| 201 | - if let Some((_, text_so_far)) = current.as_mut() { | 198 | + if let Some((_, text_so_far)) = current.as_mut() |
| 202 | - if let Some(ch) = ch { | 199 | + && let Some(ch) = ch |
| 203 | - text_so_far.push(ch); | 200 | + { |
| 204 | - } | 201 | + text_so_far.push(ch); |
| 205 | } | 202 | } |
| 206 | } | 203 | } |
| 207 | } | 204 | } |
| 208 | Ok(Event::Text(t)) => { | 205 | Ok(Event::Text(t)) => { |
| 209 | if in_run && !in_field { | 206 | if in_run && !in_field { |
| 210 | - let text = t.decode().ok()?; | 207 | + let text: &str = t; |
| 211 | if let Some((_, text_so_far)) = current.as_mut() { | 208 | if let Some((_, text_so_far)) = current.as_mut() { |
| 212 | - text_so_far.push_str(&text); | 209 | + text_so_far.push_str(text); |
| 213 | } | 210 | } |
| 214 | } | 211 | } |
| 215 | } | 212 | } |
| @@ -225,24 +222,18 @@ fn slide(archive: &mut ZipArchive<Cursor<Vec<u8>>>, part: &str) -> Option<Slide> | |||
| 225 | /// default body placeholder, and only `title` and `ctrTitle` are titles. | 222 | /// default body placeholder, and only `title` and `ctrTitle` are titles. |
| 226 | fn title_placeholder(ph: &BytesStart) -> bool { | 223 | fn title_placeholder(ph: &BytesStart) -> bool { |
| 227 | matches!(ph.try_get_attribute("type"), Ok(Some(attr)) | 224 | matches!(ph.try_get_attribute("type"), Ok(Some(attr)) |
| 228 | - if std::str::from_utf8(&attr.value).is_ok_and(|decoded| { | 225 | + if matches!(unescape(attr.value.as_ref()).as_deref(), Ok("title" | "ctrTitle"))) |
| 229 | - matches!(unescape(decoded).as_deref(), Ok("title" | "ctrTitle")) | ||
| 230 | - })) | ||
| 231 | } | 226 | } |
| 232 | 227 | ||
| 233 | -/// Whether this element's name is `name`, prefix included. The prefixes are | 228 | +fn is(element: &BytesStart, name: &str) -> bool { |
| 234 | -/// the format's own (`p:` for presentation parts, `a:` for drawing), fixed | ||
| 235 | -/// by the schema rather than chosen by the writer. | ||
| 236 | -fn is(element: &BytesStart, name: &[u8]) -> bool { | ||
| 237 | element.name().as_ref() == name | 229 | element.name().as_ref() == name |
| 238 | } | 230 | } |
| 239 | 231 | ||
| 240 | -/// An element attribute's value, unescaped. `None` when absent — an `r:id` | ||
| 241 | -/// nobody wrote is a slide with no place in the order, not a broken deck. | ||
| 242 | fn attribute(element: &BytesStart, name: &str) -> Option<String> { | 232 | fn attribute(element: &BytesStart, name: &str) -> Option<String> { |
| 243 | let attr = element.try_get_attribute(name).ok().flatten()?; | 233 | let attr = element.try_get_attribute(name).ok().flatten()?; |
| 244 | - let decoded = std::str::from_utf8(&attr.value).ok()?; | 234 | + unescape(attr.value.as_ref()) |
| 245 | - unescape(decoded).ok().map(|value| value.into_owned()) | 235 | + .ok() |
| 236 | + .map(|value| value.into_owned()) | ||
| 246 | } | 237 | } |
| 247 | 238 | ||
| 248 | #[cfg(test)] | 239 | #[cfg(test)] |
crates/iz-web/src/tags.rsmodified+37 -23
| @@ -23,12 +23,12 @@ use topcoat::Result; | |||
| 23 | use topcoat::context::Cx; | 23 | use topcoat::context::Cx; |
| 24 | use topcoat::router::content::{Form, Json}; | 24 | use topcoat::router::content::{Form, Json}; |
| 25 | use topcoat::router::{HeaderName, StatusCode, header, page, query_params, route}; | 25 | use topcoat::router::{HeaderName, StatusCode, header, page, query_params, route}; |
| 26 | -use topcoat::view::view; | 26 | +use topcoat::view::{View, ViewExt, view}; |
| 27 | 27 | ||
| 28 | use iz_core::store::{Store, Tag, User}; | 28 | use iz_core::store::{Store, Tag, User}; |
| 29 | 29 | ||
| 30 | use crate::i18n::{Key, Lang, t}; | 30 | use crate::i18n::{Key, Lang, t}; |
| 31 | -use crate::server::{Refusal, store, back_to, refusal_of, require_admin}; | 31 | +use crate::server::{Refusal, back_to, refusal_of, require_admin, store}; |
| 32 | 32 | ||
| 33 | /// One tag as the screen reads it: a name, an order and whether it is the | 33 | /// One tag as the screen reads it: a name, an order and whether it is the |
| 34 | /// default every task wears when nothing else is chosen. | 34 | /// default every task wears when nothing else is chosen. |
| @@ -261,8 +261,12 @@ struct TagsQuery { | |||
| 261 | /// The "New tag" control and the form inside it. A `<details>` rather than | 261 | /// The "New tag" control and the form inside it. A `<details>` rather than |
| 262 | /// anything script-driven, so a browser with no script can still open it and | 262 | /// anything script-driven, so a browser with no script can still open it and |
| 263 | /// post the form. | 263 | /// post the form. |
| 264 | -async fn composer(cx: &Cx, refusal: Option<&Refusal>, lang: Lang) -> Result { | 264 | +async fn composer<'a>( |
| 265 | - view! { | 265 | + cx: &'a Cx, |
| 266 | + refusal: Option<&'a Refusal>, | ||
| 267 | + lang: Lang, | ||
| 268 | +) -> Result<impl View + 'a> { | ||
| 269 | + Ok(view! { | ||
| 266 | cx => | 270 | cx => |
| 267 | <details class="tag-new"> | 271 | <details class="tag-new"> |
| 268 | <summary class="tag-new-open">(t(lang, Key::NewTag))</summary> | 272 | <summary class="tag-new-open">(t(lang, Key::NewTag))</summary> |
| @@ -280,6 +284,7 @@ async fn composer(cx: &Cx, refusal: Option<&Refusal>, lang: Lang) -> Result { | |||
| 280 | </form> | 284 | </form> |
| 281 | </details> | 285 | </details> |
| 282 | } | 286 | } |
| 287 | + .boxed()) | ||
| 283 | } | 288 | } |
| 284 | 289 | ||
| 285 | /// One tag's row: the rename form in place of it when `editing`, its display | 290 | /// One tag's row: the rename form in place of it when `editing`, its display |
| @@ -287,9 +292,15 @@ async fn composer(cx: &Cx, refusal: Option<&Refusal>, lang: Lang) -> Result { | |||
| 287 | /// with cards on it — the store would refuse both, and a control that cannot | 292 | /// with cards on it — the store would refuse both, and a control that cannot |
| 288 | /// act is not drawn. The card count sits on the row, so a missing delete is | 293 | /// act is not drawn. The card count sits on the row, so a missing delete is |
| 289 | /// a number the admin can already see rather than a control that vanished. | 294 | /// a number the admin can already see rather than a control that vanished. |
| 290 | -async fn tag_row(cx: &Cx, tag: &TagLine, editing: bool, refusal: Option<&Refusal>, lang: Lang) -> Result { | 295 | +async fn tag_row<'a>( |
| 296 | + cx: &'a Cx, | ||
| 297 | + tag: &'a TagLine, | ||
| 298 | + editing: bool, | ||
| 299 | + refusal: Option<&'a Refusal>, | ||
| 300 | + lang: Lang, | ||
| 301 | +) -> Result<impl View + 'a> { | ||
| 291 | if editing { | 302 | if editing { |
| 292 | - return view! { | 303 | + return Ok(view! { |
| 293 | cx => | 304 | cx => |
| 294 | <div class="tag-row"> | 305 | <div class="tag-row"> |
| 295 | <form class="tag-form" method="post" action="/api/rename_tag"> | 306 | <form class="tag-form" method="post" action="/api/rename_tag"> |
| @@ -307,10 +318,10 @@ async fn tag_row(cx: &Cx, tag: &TagLine, editing: bool, refusal: Option<&Refusal | |||
| 307 | </div> | 318 | </div> |
| 308 | </form> | 319 | </form> |
| 309 | </div> | 320 | </div> |
| 310 | - }; | 321 | + }.boxed()); |
| 311 | } | 322 | } |
| 312 | 323 | ||
| 313 | - view! { | 324 | + Ok(view! { |
| 314 | cx => | 325 | cx => |
| 315 | <div class="tag-row"> | 326 | <div class="tag-row"> |
| 316 | <span class="tag-name">(tag.name.clone())</span> | 327 | <span class="tag-name">(tag.name.clone())</span> |
| @@ -336,20 +347,21 @@ async fn tag_row(cx: &Cx, tag: &TagLine, editing: bool, refusal: Option<&Refusal | |||
| 336 | </form> | 347 | </form> |
| 337 | } | 348 | } |
| 338 | </div> | 349 | </div> |
| 339 | - } | 350 | + }.boxed()) |
| 340 | } | 351 | } |
| 341 | 352 | ||
| 342 | #[page("/tags")] | 353 | #[page("/tags")] |
| 343 | -async fn tags_page(cx: &Cx) -> Result { | 354 | +async fn tags_page(cx: &Cx) -> Result<impl View> { |
| 344 | let user = match require_admin(cx).await { | 355 | let user = match require_admin(cx).await { |
| 345 | Ok(user) => user, | 356 | Ok(user) => user, |
| 346 | Err(refusal) => { | 357 | Err(refusal) => { |
| 347 | - return view! { | 358 | + return Ok(view! { |
| 348 | <main class="scaffold-note"> | 359 | <main class="scaffold-note"> |
| 349 | <p>(refusal.message())</p> | 360 | <p>(refusal.message())</p> |
| 350 | <p><a href="/">(t(Lang::En, Key::BackToBoard))</a></p> | 361 | <p><a href="/">(t(Lang::En, Key::BackToBoard))</a></p> |
| 351 | </main> | 362 | </main> |
| 352 | - }; | 363 | + } |
| 364 | + .boxed()); | ||
| 353 | } | 365 | } |
| 354 | }; | 366 | }; |
| 355 | let lang = Lang::from_code(&user.language); | 367 | let lang = Lang::from_code(&user.language); |
| @@ -357,24 +369,26 @@ async fn tags_page(cx: &Cx) -> Result { | |||
| 357 | let tags = match tags_of(&store, &user).await { | 369 | let tags = match tags_of(&store, &user).await { |
| 358 | Ok(tags) => tags, | 370 | Ok(tags) => tags, |
| 359 | Err(refusal) => { | 371 | Err(refusal) => { |
| 360 | - return view! { | 372 | + return Ok(view! { |
| 361 | <main class="scaffold-note"> | 373 | <main class="scaffold-note"> |
| 362 | <p>(refusal.message_in(lang))</p> | 374 | <p>(refusal.message_in(lang))</p> |
| 363 | <p><a href="/">(t(lang, Key::BackToBoard))</a></p> | 375 | <p><a href="/">(t(lang, Key::BackToBoard))</a></p> |
| 364 | </main> | 376 | </main> |
| 365 | - }; | 377 | + } |
| 378 | + .boxed()); | ||
| 366 | } | 379 | } |
| 367 | }; | 380 | }; |
| 368 | let edit_id = query_params::<TagsQuery>(cx)?.edit.clone(); | 381 | let edit_id = query_params::<TagsQuery>(cx)?.edit.clone(); |
| 369 | let create_refusal = refusal_of(cx, "create_tag"); | 382 | let create_refusal = refusal_of(cx, "create_tag"); |
| 370 | let rename_refusal = refusal_of(cx, "rename_tag"); | 383 | let rename_refusal = refusal_of(cx, "rename_tag"); |
| 371 | 384 | ||
| 372 | - view! { | 385 | + let me = crate::detail::Me::from(&user); |
| 386 | + Ok(view! { | ||
| 373 | <header class="topbar"> | 387 | <header class="topbar"> |
| 374 | - (crate::layout::family_mark(cx).await?) | 388 | + (topcoat::view::Child::new(crate::layout::family_mark(cx).await?)) |
| 375 | - (crate::layout::topbar_nav(cx, crate::layout::NavPage::Tags, user.role, lang).await?) | 389 | + (topcoat::view::Child::new(crate::layout::topbar_nav(cx, crate::layout::NavPage::Tags, user.role, lang).await?)) |
| 376 | <div class="spacer"></div> | 390 | <div class="spacer"></div> |
| 377 | - (crate::layout::user_menu(cx, &crate::detail::Me::from(&user), lang).await?) | 391 | + (topcoat::view::Child::new(crate::layout::user_menu(cx, &me, lang).await?)) |
| 378 | </header> | 392 | </header> |
| 379 | 393 | ||
| 380 | <div class="settings-shell"> | 394 | <div class="settings-shell"> |
| @@ -384,16 +398,16 @@ async fn tags_page(cx: &Cx) -> Result { | |||
| 384 | <span class="chip chip-admin">(t(lang, Key::AdminOnly))</span> | 398 | <span class="chip chip-admin">(t(lang, Key::AdminOnly))</span> |
| 385 | </div> | 399 | </div> |
| 386 | 400 | ||
| 387 | - (composer(cx, create_refusal.as_ref(), lang).await?) | 401 | + (topcoat::view::Child::new(composer(cx, create_refusal.as_ref(), lang).await?)) |
| 388 | 402 | ||
| 389 | <div class="tag-list"> | 403 | <div class="tag-list"> |
| 390 | for tag in &tags { | 404 | for tag in &tags { |
| 391 | - (tag_row(cx, tag, edit_id.as_deref() == Some(tag.id.as_str()), rename_refusal.as_ref(), lang).await?) | 405 | + (topcoat::view::Child::new(tag_row(cx, tag, edit_id.as_deref() == Some(tag.id.as_str()), rename_refusal.as_ref(), lang).await?)) |
| 392 | } | 406 | } |
| 393 | </div> | 407 | </div> |
| 394 | </main> | 408 | </main> |
| 395 | - (crate::dropdown::dropdown_script(cx).await?) | 409 | + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) |
| 396 | - (crate::layout::escape_script(cx).await?) | 410 | + (topcoat::view::Child::new(crate::layout::escape_script(cx).await?)) |
| 397 | </div> | 411 | </div> |
| 398 | - } | 412 | + }.boxed()) |
| 399 | } | 413 | } |
crates/iz-web/tests/http.rsmodified+24 -15
| @@ -32,6 +32,7 @@ use iz_web::server::Mail; | |||
| 32 | use topcoat::asset::{AssetBundle, RouterBuilderAssetExt}; | 32 | use topcoat::asset::{AssetBundle, RouterBuilderAssetExt}; |
| 33 | use topcoat::cookie::RouterBuilderCookieExt; | 33 | use topcoat::cookie::RouterBuilderCookieExt; |
| 34 | use topcoat::router::{Body, BodyLimit, Router, RouterBuilderDiscoverExt, to_bytes}; | 34 | use topcoat::router::{Body, BodyLimit, Router, RouterBuilderDiscoverExt, to_bytes}; |
| 35 | +use topcoat::runtime::RouterBuilderRuntimeExt; | ||
| 35 | use ulid::Ulid; | 36 | use ulid::Ulid; |
| 36 | 37 | ||
| 37 | /// The session cookie iz-client seals: the tests mint it directly instead of | 38 | /// The session cookie iz-client seals: the tests mint it directly instead of |
| @@ -58,13 +59,16 @@ fn asset_dir() -> PathBuf { | |||
| 58 | const TEST_LIVE_WINDOW: iz_web::live::LiveWindow = | 59 | const TEST_LIVE_WINDOW: iz_web::live::LiveWindow = |
| 59 | iz_web::live::LiveWindow(std::time::Duration::from_secs(10)); | 60 | iz_web::live::LiveWindow(std::time::Duration::from_secs(10)); |
| 60 | 61 | ||
| 62 | +/// Photos the fake im can serve, keyed by person id. | ||
| 63 | +type Photos = Arc<Mutex<HashMap<String, (Vec<u8>, String)>>>; | ||
| 64 | + | ||
| 61 | /// A fake im: answers `POST /introspect` from its token map, `{"active": | 65 | /// A fake im: answers `POST /introspect` from its token map, `{"active": |
| 62 | /// false}` for anything it does not know. Bare TCP + hand-rolled HTTP/1.1 — | 66 | /// false}` for anything it does not know. Bare TCP + hand-rolled HTTP/1.1 — |
| 63 | /// just enough for the client's form post. | 67 | /// just enough for the client's form post. |
| 64 | struct FakeIm { | 68 | struct FakeIm { |
| 65 | addr: std::net::SocketAddr, | 69 | addr: std::net::SocketAddr, |
| 66 | tokens: Arc<Mutex<HashMap<String, serde_json::Value>>>, | 70 | tokens: Arc<Mutex<HashMap<String, serde_json::Value>>>, |
| 67 | - photos: Arc<Mutex<HashMap<String, (Vec<u8>, String)>>>, | 71 | + photos: Photos, |
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | impl FakeIm { | 74 | impl FakeIm { |
| @@ -73,8 +77,7 @@ impl FakeIm { | |||
| 73 | let addr = listener.local_addr().unwrap(); | 77 | let addr = listener.local_addr().unwrap(); |
| 74 | let tokens: Arc<Mutex<HashMap<String, serde_json::Value>>> = | 78 | let tokens: Arc<Mutex<HashMap<String, serde_json::Value>>> = |
| 75 | Arc::new(Mutex::new(HashMap::new())); | 79 | Arc::new(Mutex::new(HashMap::new())); |
| 76 | - let photos: Arc<Mutex<HashMap<String, (Vec<u8>, String)>>> = | 80 | + let photos: Photos = Arc::new(Mutex::new(HashMap::new())); |
| 77 | - Arc::new(Mutex::new(HashMap::new())); | ||
| 78 | let map = tokens.clone(); | 81 | let map = tokens.clone(); |
| 79 | let pmap = photos.clone(); | 82 | let pmap = photos.clone(); |
| 80 | tokio::spawn(async move { | 83 | tokio::spawn(async move { |
| @@ -176,7 +179,7 @@ const PHOTO_BASIC: &str = "Basic aXotdGVzdDpzM2NyM3Q="; | |||
| 176 | /// or nothing, a missing photo exactly like a missing person. `None` for | 179 | /// or nothing, a missing photo exactly like a missing person. `None` for |
| 177 | /// anything else, which stays the introspection JSON. | 180 | /// anything else, which stays the introspection JSON. |
| 178 | fn photo_answer( | 181 | fn photo_answer( |
| 179 | - photos: &Arc<Mutex<HashMap<String, (Vec<u8>, String)>>>, | 182 | + photos: &Photos, |
| 180 | head: &str, | 183 | head: &str, |
| 181 | request_line: &str, | 184 | request_line: &str, |
| 182 | ) -> Option<(&'static str, String, Vec<u8>)> { | 185 | ) -> Option<(&'static str, String, Vec<u8>)> { |
| @@ -305,7 +308,7 @@ impl App { | |||
| 305 | base_url: &str, | 308 | base_url: &str, |
| 306 | storage_in: Option<String>, | 309 | storage_in: Option<String>, |
| 307 | ) -> Self { | 310 | ) -> Self { |
| 308 | - let dir = std::env::temp_dir().join(format!("iz-http-{}", Ulid::new())); | 311 | + let dir = std::env::temp_dir().join(format!("iz-http-{}", Ulid::generate())); |
| 309 | std::fs::create_dir_all(&dir).unwrap(); | 312 | std::fs::create_dir_all(&dir).unwrap(); |
| 310 | let db = dir.join("iz.db"); | 313 | let db = dir.join("iz.db"); |
| 311 | let storage = dir.join("storage"); | 314 | let storage = dir.join("storage"); |
| @@ -357,6 +360,7 @@ impl App { | |||
| 357 | let router = iz_client::mount( | 360 | let router = iz_client::mount( |
| 358 | Router::builder() | 361 | Router::builder() |
| 359 | .discover() | 362 | .discover() |
| 363 | + .runtime() | ||
| 360 | .layer( | 364 | .layer( |
| 361 | BodyLimit::max(iz_web::settings::WIDEST_ATTACHMENT_MB as usize * 1024 * 1024) | 365 | BodyLimit::max(iz_web::settings::WIDEST_ATTACHMENT_MB as usize * 1024 * 1024) |
| 362 | .at("/files"), | 366 | .at("/files"), |
| @@ -404,7 +408,7 @@ impl App { | |||
| 404 | /// settings, so a transition actually reaches the ledger instead of the | 408 | /// settings, so a transition actually reaches the ledger instead of the |
| 405 | /// silent no-op `open`'s router hands every crossing. | 409 | /// silent no-op `open`'s router hands every crossing. |
| 406 | async fn open_with_mail() -> Self { | 410 | async fn open_with_mail() -> Self { |
| 407 | - let dir = std::env::temp_dir().join(format!("iz-http-{}", Ulid::new())); | 411 | + let dir = std::env::temp_dir().join(format!("iz-http-{}", Ulid::generate())); |
| 408 | std::fs::create_dir_all(&dir).unwrap(); | 412 | std::fs::create_dir_all(&dir).unwrap(); |
| 409 | let db = dir.join("iz.db"); | 413 | let db = dir.join("iz.db"); |
| 410 | let storage = dir.join("storage"); | 414 | let storage = dir.join("storage"); |
| @@ -453,6 +457,7 @@ impl App { | |||
| 453 | let router = iz_client::mount( | 457 | let router = iz_client::mount( |
| 454 | Router::builder() | 458 | Router::builder() |
| 455 | .discover() | 459 | .discover() |
| 460 | + .runtime() | ||
| 456 | .layer( | 461 | .layer( |
| 457 | BodyLimit::max(iz_web::settings::WIDEST_ATTACHMENT_MB as usize * 1024 * 1024) | 462 | BodyLimit::max(iz_web::settings::WIDEST_ATTACHMENT_MB as usize * 1024 * 1024) |
| 458 | .at("/files"), | 463 | .at("/files"), |
| @@ -496,7 +501,7 @@ impl App { | |||
| 496 | /// dance. The local row is provisioned on the next request, the way a | 501 | /// dance. The local row is provisioned on the next request, the way a |
| 497 | /// real first login provisions it. | 502 | /// real first login provisions it. |
| 498 | fn mint(&self, sub: &str, email: &str, name: &str, im_admin: bool) -> String { | 503 | fn mint(&self, sub: &str, email: &str, name: &str, im_admin: bool) -> String { |
| 499 | - let token = format!("tok-{}", Ulid::new()); | 504 | + let token = format!("tok-{}", Ulid::generate()); |
| 500 | let exp = time::OffsetDateTime::now_utc() + time::Duration::hours(1); | 505 | let exp = time::OffsetDateTime::now_utc() + time::Duration::hours(1); |
| 501 | self.fake.tokens.lock().insert( | 506 | self.fake.tokens.lock().insert( |
| 502 | token.clone(), | 507 | token.clone(), |
| @@ -824,7 +829,6 @@ impl Answer { | |||
| 824 | } | 829 | } |
| 825 | 830 | ||
| 826 | /// Form encoding, enough for the addresses these tests send. | 831 | /// Form encoding, enough for the addresses these tests send. |
| 827 | - | ||
| 828 | fn encode(raw: &str) -> String { | 832 | fn encode(raw: &str) -> String { |
| 829 | let mut out = String::with_capacity(raw.len()); | 833 | let mut out = String::with_capacity(raw.len()); |
| 830 | for byte in raw.bytes() { | 834 | for byte in raw.bytes() { |
| @@ -2658,7 +2662,12 @@ async fn a_sender_field_that_cannot_work_is_refused_by_name() { | |||
| 2658 | let app = App::open().await; | 2662 | let app = App::open().await; |
| 2659 | let admin_cookie = admin(&app).await; | 2663 | let admin_cookie = admin(&app).await; |
| 2660 | 2664 | ||
| 2661 | - let bad: &[(&str, &[(&str, &str)], &str)] = &[ | 2665 | + type BadCase = ( |
| 2666 | + &'static str, | ||
| 2667 | + &'static [(&'static str, &'static str)], | ||
| 2668 | + &'static str, | ||
| 2669 | + ); | ||
| 2670 | + let bad: &[BadCase] = &[ | ||
| 2662 | ("host", &[("host", " ")], "Give the SMTP host."), | 2671 | ("host", &[("host", " ")], "Give the SMTP host."), |
| 2663 | ( | 2672 | ( |
| 2664 | "host", | 2673 | "host", |
| @@ -3155,7 +3164,7 @@ async fn a_rule_may_not_be_hung_off_a_column_that_is_not_on_this_board() { | |||
| 3155 | Some(&admin_cookie), | 3164 | Some(&admin_cookie), |
| 3156 | &[ | 3165 | &[ |
| 3157 | ("trigger", "status"), | 3166 | ("trigger", "status"), |
| 3158 | - ("column_id", &Ulid::new().to_string()), | 3167 | + ("column_id", &Ulid::generate().to_string()), |
| 3159 | ("subject", "Task completed"), | 3168 | ("subject", "Task completed"), |
| 3160 | ("audience", "assignees"), | 3169 | ("audience", "assignees"), |
| 3161 | ], | 3170 | ], |
| @@ -3223,7 +3232,7 @@ async fn switching_a_rule_off_leaves_it_listed_and_switched_off() { | |||
| 3223 | async fn a_rule_id_this_workspace_does_not_own_is_refused() { | 3232 | async fn a_rule_id_this_workspace_does_not_own_is_refused() { |
| 3224 | let app = App::open().await; | 3233 | let app = App::open().await; |
| 3225 | let admin_cookie = admin(&app).await; | 3234 | let admin_cookie = admin(&app).await; |
| 3226 | - let stranger = Ulid::new().to_string(); | 3235 | + let stranger = Ulid::generate().to_string(); |
| 3227 | 3236 | ||
| 3228 | for path in ["/api/set_rule_enabled", "/api/delete_rule"] { | 3237 | for path in ["/api/set_rule_enabled", "/api/delete_rule"] { |
| 3229 | let answer = app | 3238 | let answer = app |
| @@ -5119,7 +5128,7 @@ async fn add_member_cannot_make_an_admin() { | |||
| 5119 | #[tokio::test] | 5128 | #[tokio::test] |
| 5120 | async fn losing_the_im_admin_flag_drops_the_role_to_member() { | 5129 | async fn losing_the_im_admin_flag_drops_the_role_to_member() { |
| 5121 | let app = App::open().await; | 5130 | let app = App::open().await; |
| 5122 | - let token = format!("tok-{}", Ulid::new()); | 5131 | + let token = format!("tok-{}", Ulid::generate()); |
| 5123 | let exp = time::OffsetDateTime::now_utc() + time::Duration::hours(1); | 5132 | let exp = time::OffsetDateTime::now_utc() + time::Duration::hours(1); |
| 5124 | app.fake.tokens.lock().insert( | 5133 | app.fake.tokens.lock().insert( |
| 5125 | token.clone(), | 5134 | token.clone(), |
| @@ -5329,7 +5338,7 @@ async fn the_avatar_is_not_found_without_a_linked_row() { | |||
| 5329 | assert_eq!(photo.status, StatusCode::NOT_FOUND); | 5338 | assert_eq!(photo.status, StatusCode::NOT_FOUND); |
| 5330 | 5339 | ||
| 5331 | let stranger = app | 5340 | let stranger = app |
| 5332 | - .get(&format!("/avatar/{}", Ulid::new()), Some(&member)) | 5341 | + .get(&format!("/avatar/{}", Ulid::generate()), Some(&member)) |
| 5333 | .await; | 5342 | .await; |
| 5334 | assert_eq!(stranger.status, StatusCode::NOT_FOUND); | 5343 | assert_eq!(stranger.status, StatusCode::NOT_FOUND); |
| 5335 | } | 5344 | } |
| @@ -5379,7 +5388,7 @@ async fn the_connection_card_names_its_provider_without_its_secret() { | |||
| 5379 | "no Connection card: {html}" | 5388 | "no Connection card: {html}" |
| 5380 | ); | 5389 | ); |
| 5381 | assert!( | 5390 | assert!( |
| 5382 | - html.contains("iz-test:s3cr3t") == false, | 5391 | + !html.contains("iz-test:s3cr3t"), |
| 5383 | "the client secret leaked onto the page: {html}" | 5392 | "the client secret leaked onto the page: {html}" |
| 5384 | ); | 5393 | ); |
| 5385 | assert!( | 5394 | assert!( |
| @@ -9705,7 +9714,7 @@ fn the_stylesheet_guard_refuses_a_foreign_bundle() { | |||
| 9705 | let bundle = AssetBundle::load_dir(asset_dir()).expect("no bundle: run `topcoat asset bundle`"); | 9714 | let bundle = AssetBundle::load_dir(asset_dir()).expect("no bundle: run `topcoat asset bundle`"); |
| 9706 | assert!(iz_web::server::stylesheet_guard(&bundle).is_ok()); | 9715 | assert!(iz_web::server::stylesheet_guard(&bundle).is_ok()); |
| 9707 | 9716 | ||
| 9708 | - let foreign = std::env::temp_dir().join(format!("iz-foreign-{}", Ulid::new())); | 9717 | + let foreign = std::env::temp_dir().join(format!("iz-foreign-{}", Ulid::generate())); |
| 9709 | std::fs::create_dir_all(&foreign).unwrap(); | 9718 | std::fs::create_dir_all(&foreign).unwrap(); |
| 9710 | for entry in std::fs::read_dir(asset_dir()).unwrap().flatten() { | 9719 | for entry in std::fs::read_dir(asset_dir()).unwrap().flatten() { |
| 9711 | std::fs::copy(entry.path(), foreign.join(entry.file_name())).unwrap(); | 9720 | std::fs::copy(entry.path(), foreign.join(entry.file_name())).unwrap(); |