Compare commits
2 Commits
75bfae02c4
...
56d7fae43c
Author | SHA1 | Date |
---|---|---|
Savanni D'Gerinel | 56d7fae43c | |
Savanni D'Gerinel | a02e335492 |
|
@ -96,7 +96,7 @@ checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
|
|||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide 0.7.1",
|
||||
"object",
|
||||
|
@ -113,6 +113,12 @@ dependencies = [
|
|||
"safemem 0.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.3"
|
||||
|
@ -164,6 +170,15 @@ dependencies = [
|
|||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.1.5"
|
||||
|
@ -196,6 +211,12 @@ dependencies = [
|
|||
"safemem 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build_html"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3108fe6fe7ac796fb7625bdde8fa2b67b5a7731496251ca57c7b8cadd78a16a1"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.13.0"
|
||||
|
@ -270,12 +291,6 @@ dependencies = [
|
|||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -411,13 +426,22 @@ version = "0.8.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -426,7 +450,7 @@ version = "0.5.8"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
|
@ -436,7 +460,7 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
@ -448,7 +472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||
dependencies = [
|
||||
"autocfg 1.1.0",
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
|
@ -460,7 +484,7 @@ version = "0.8.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -469,6 +493,16 @@ version = "0.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cyberpunk-splash"
|
||||
version = "0.1.0"
|
||||
|
@ -525,6 +559,16 @@ dependencies = [
|
|||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer 0.10.4",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dimensioned"
|
||||
version = "0.7.0"
|
||||
|
@ -575,7 +619,7 @@ version = "0.8.33"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -656,22 +700,26 @@ dependencies = [
|
|||
name = "file-service"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"build_html",
|
||||
"chrono",
|
||||
"hex-string",
|
||||
"http",
|
||||
"image 0.23.14",
|
||||
"iron",
|
||||
"logger",
|
||||
"mime 0.3.17",
|
||||
"mime_guess 2.0.4",
|
||||
"mustache",
|
||||
"orizentic 1.0.0",
|
||||
"orizentic",
|
||||
"params",
|
||||
"router",
|
||||
"serde 1.0.188",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"uuid 0.4.0",
|
||||
"warp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -961,6 +1009,16 @@ dependencies = [
|
|||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check 0.9.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "geo-types"
|
||||
version = "0.1.0"
|
||||
|
@ -971,7 +1029,7 @@ version = "0.2.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
|
@ -1376,6 +1434,30 @@ version = "0.14.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
|
||||
|
||||
[[package]]
|
||||
name = "headers"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
|
||||
dependencies = [
|
||||
"base64 0.21.3",
|
||||
"bytes",
|
||||
"headers-core",
|
||||
"http",
|
||||
"httpdate",
|
||||
"mime 0.3.17",
|
||||
"sha1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "headers-core"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
|
||||
dependencies = [
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
|
@ -1664,15 +1746,6 @@ dependencies = [
|
|||
"url 1.7.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
|
@ -2004,6 +2077,24 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58"
|
||||
|
||||
[[package]]
|
||||
name = "multer"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-util",
|
||||
"http",
|
||||
"httparse",
|
||||
"log 0.4.20",
|
||||
"memchr 2.6.1",
|
||||
"mime 0.3.17",
|
||||
"spin",
|
||||
"version_check 0.9.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multipart"
|
||||
version = "0.13.6"
|
||||
|
@ -2213,7 +2304,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c"
|
||||
dependencies = [
|
||||
"bitflags 2.4.0",
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"once_cell",
|
||||
|
@ -2250,31 +2341,13 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "orizentic"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48f4af9d9002d3b129cdad6ebdb5b745b2b7d5e8c1c85c8addd7b447695af6a3"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"itertools 0.7.11",
|
||||
"jsonwebtoken",
|
||||
"serde 1.0.188",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"uuid 0.6.5",
|
||||
"version_check 0.1.5",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "orizentic"
|
||||
version = "1.0.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"itertools 0.10.5",
|
||||
"itertools",
|
||||
"jsonwebtoken",
|
||||
"serde 1.0.188",
|
||||
"serde_derive",
|
||||
|
@ -2368,7 +2441,7 @@ version = "0.9.8"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
|
@ -3006,6 +3079,15 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2"
|
||||
dependencies = [
|
||||
"base64 0.21.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusty-fork"
|
||||
version = "0.3.0"
|
||||
|
@ -3045,6 +3127,12 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
|
||||
|
||||
[[package]]
|
||||
name = "scoped_threadpool"
|
||||
version = "0.1.9"
|
||||
|
@ -3169,14 +3257,25 @@ dependencies = [
|
|||
"typeshare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.10.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"digest",
|
||||
"block-buffer 0.7.3",
|
||||
"digest 0.8.1",
|
||||
"fake-simd",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
@ -3315,7 +3414,7 @@ version = "3.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"redox_syscall",
|
||||
"rustix",
|
||||
|
@ -3448,6 +3547,29 @@ dependencies = [
|
|||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log 0.4.20",
|
||||
"tokio",
|
||||
"tungstenite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.8"
|
||||
|
@ -3508,7 +3630,8 @@ version = "0.1.37"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"log 0.4.20",
|
||||
"pin-project-lite",
|
||||
"tracing-core",
|
||||
]
|
||||
|
@ -3534,6 +3657,25 @@ version = "0.2.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
||||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"http",
|
||||
"httparse",
|
||||
"log 0.4.20",
|
||||
"rand 0.8.5",
|
||||
"sha1",
|
||||
"thiserror",
|
||||
"url 2.4.1",
|
||||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "twoway"
|
||||
version = "0.1.8"
|
||||
|
@ -3713,6 +3855,12 @@ dependencies = [
|
|||
"url 1.7.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.4.0"
|
||||
|
@ -3723,16 +3871,6 @@ dependencies = [
|
|||
"serde 0.9.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"rand 0.4.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.8.2"
|
||||
|
@ -3800,6 +3938,37 @@ dependencies = [
|
|||
"try-lock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "warp"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"http",
|
||||
"hyper 0.14.27",
|
||||
"log 0.4.20",
|
||||
"mime 0.3.17",
|
||||
"mime_guess 2.0.4",
|
||||
"multer",
|
||||
"percent-encoding 2.3.0",
|
||||
"pin-project",
|
||||
"rustls-pemfile",
|
||||
"scoped-tls",
|
||||
"serde 1.0.188",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-tungstenite",
|
||||
"tokio-util",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
|
@ -3818,7 +3987,7 @@ version = "0.2.87"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
|
@ -3843,7 +4012,7 @@ version = "0.4.37"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
|
@ -4006,7 +4175,7 @@ version = "0.50.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"cfg-if",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
build_html = { version = "2" }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
hex-string = "0.1.0"
|
||||
http = { version = "0.2" }
|
||||
image = "0.23.5"
|
||||
iron = "0.6.1"
|
||||
logger = "*"
|
||||
|
@ -22,4 +24,6 @@ serde_json = "*"
|
|||
serde = { version = "1.0", features = ["derive"] }
|
||||
sha2 = "0.8.2"
|
||||
thiserror = "1.0.20"
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
uuid = { version = "0.4", features = [ "serde", "v4" ] }
|
||||
warp = { version = "0.3" }
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"id":"rawr.png","size":23777,"created":"2020-06-04T16:04:10.085680927Z","file_type":"image/png","hash":"b6cd35e113b95d62f53d9cbd27ccefef47d3e324aef01a2db6c0c6d3a43c89ee"}
|
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
|
@ -0,0 +1,135 @@
|
|||
use build_html::{self, Html, HtmlContainer};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Form {
|
||||
method: String,
|
||||
encoding: Option<String>,
|
||||
elements: String,
|
||||
}
|
||||
|
||||
impl Form {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
method: "get".to_owned(),
|
||||
encoding: None,
|
||||
elements: "".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_method(mut self, method: &str) -> Self {
|
||||
self.method = method.to_owned();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_encoding(mut self, encoding: &str) -> Self {
|
||||
self.encoding = Some(encoding.to_owned());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Html for Form {
|
||||
fn to_html_string(&self) -> String {
|
||||
let encoding = match self.encoding {
|
||||
Some(ref encoding) => format!("encoding={encoding}", encoding = encoding),
|
||||
None => format!(""),
|
||||
};
|
||||
format!(
|
||||
"<form method={method} {encoding}>\n{elements}\n</form>\n",
|
||||
method = self.method,
|
||||
encoding = encoding,
|
||||
elements = self.elements.to_html_string()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl HtmlContainer for Form {
|
||||
fn add_html<H: Html>(&mut self, html: H) {
|
||||
self.elements.push_str(&html.to_html_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Input {
|
||||
ty: String,
|
||||
name: String,
|
||||
id: String,
|
||||
value: Option<String>,
|
||||
}
|
||||
|
||||
impl Html for Input {
|
||||
fn to_html_string(&self) -> String {
|
||||
format!(
|
||||
"<input type=\"{ty}\" name=\"{name}\" id=\"{id}\">{value}</input>\n",
|
||||
ty = self.ty,
|
||||
name = self.name,
|
||||
id = self.id,
|
||||
value = self.value.clone().unwrap_or("".to_owned()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Input {
|
||||
pub fn new(ty: &str, name: &str, id: &str) -> Self {
|
||||
Self {
|
||||
ty: ty.to_owned(),
|
||||
name: name.to_owned(),
|
||||
id: id.to_owned(),
|
||||
value: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_value(mut self, val: &str) -> Self {
|
||||
self.value = Some(val.to_owned());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Label {
|
||||
target: String,
|
||||
text: String,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
pub fn new(target: &str, text: &str) -> Self {
|
||||
Self {
|
||||
target: target.to_owned(),
|
||||
text: text.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Html for Label {
|
||||
fn to_html_string(&self) -> String {
|
||||
format!(
|
||||
"<label for=\"{target}\">{text}</label>",
|
||||
target = self.target,
|
||||
text = self.text
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Button {
|
||||
name: String,
|
||||
text: String,
|
||||
}
|
||||
|
||||
impl Button {
|
||||
pub fn new(name: &str, text: &str) -> Self {
|
||||
Self {
|
||||
name: name.to_owned(),
|
||||
text: text.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Html for Button {
|
||||
fn to_html_string(&self) -> String {
|
||||
format!(
|
||||
"<button name={name}>{text}</button>",
|
||||
name = self.name,
|
||||
text = self.text
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("not implemented")]
|
||||
NotImplemented,
|
||||
|
||||
#[error("file not found: `{0}`")]
|
||||
FileNotFound(PathBuf),
|
||||
|
||||
#[error("file is not an image: `{0}`")]
|
||||
NotAnImage(PathBuf),
|
||||
|
||||
#[error("path is not a file: `{0}`")]
|
||||
NotAFile(PathBuf),
|
||||
|
||||
#[error("Image loading error")]
|
||||
ImageError(#[from] image::ImageError),
|
||||
|
||||
#[error("IO error")]
|
||||
IOError(#[from] std::io::Error),
|
||||
|
||||
#[error("JSON error")]
|
||||
JSONError(#[from] serde_json::error::Error),
|
||||
|
||||
#[error("UTF8 Error")]
|
||||
UTF8Error(#[from] std::str::Utf8Error),
|
||||
}
|
||||
|
||||
pub type Result<A> = std::result::Result<A, Error>;
|
|
@ -1,9 +1,38 @@
|
|||
use super::error::{Error, Result};
|
||||
use super::fileinfo::FileInfo;
|
||||
use super::thumbnail::Thumbnail;
|
||||
use std::fs::{copy, read_dir, remove_file};
|
||||
use std::path::{Path, PathBuf};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum FileError {
|
||||
#[error("not implemented")]
|
||||
NotImplemented,
|
||||
|
||||
#[error("file not found: `{0}`")]
|
||||
FileNotFound(PathBuf),
|
||||
|
||||
#[error("file is not an image: `{0}`")]
|
||||
NotAnImage(PathBuf),
|
||||
|
||||
#[error("path is not a file: `{0}`")]
|
||||
NotAFile(PathBuf),
|
||||
|
||||
#[error("Image loading error")]
|
||||
ImageError(#[from] image::ImageError),
|
||||
|
||||
#[error("IO error")]
|
||||
IOError(#[from] std::io::Error),
|
||||
|
||||
#[error("JSON error")]
|
||||
JSONError(#[from] serde_json::error::Error),
|
||||
|
||||
#[error("UTF8 Error")]
|
||||
UTF8Error(#[from] std::str::Utf8Error),
|
||||
}
|
||||
|
||||
/// One file in the database, complete with the path of the file and information about the
|
||||
/// thumbnail of the file.
|
||||
#[derive(Debug)]
|
||||
pub struct File {
|
||||
info: FileInfo,
|
||||
|
@ -17,7 +46,7 @@ impl File {
|
|||
root: &Path,
|
||||
temp_path: &PathBuf,
|
||||
filename: &Option<PathBuf>,
|
||||
) -> Result<File> {
|
||||
) -> Result<Self, FileError> {
|
||||
let mut dest_path = PathBuf::from(root);
|
||||
dest_path.push(id);
|
||||
match filename {
|
||||
|
@ -33,27 +62,27 @@ impl File {
|
|||
copy(temp_path, dest_path.clone())?;
|
||||
let info = FileInfo::from_path(&dest_path)?;
|
||||
let tn = Thumbnail::from_path(&dest_path)?;
|
||||
Ok(File {
|
||||
Ok(Self {
|
||||
info,
|
||||
tn,
|
||||
root: PathBuf::from(root),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn open(id: &str, root: &Path) -> Result<File> {
|
||||
pub fn open(id: &str, root: &Path) -> Result<Self, FileError> {
|
||||
let mut file_path = PathBuf::from(root);
|
||||
file_path.push(id.clone());
|
||||
|
||||
if !file_path.exists() {
|
||||
return Err(Error::FileNotFound(file_path));
|
||||
return Err(FileError::FileNotFound(file_path));
|
||||
}
|
||||
if !file_path.is_file() {
|
||||
return Err(Error::NotAFile(file_path));
|
||||
return Err(FileError::NotAFile(file_path));
|
||||
}
|
||||
|
||||
let info = match FileInfo::open(id, root) {
|
||||
Ok(i) => Ok(i),
|
||||
Err(Error::FileNotFound(_)) => {
|
||||
Err(FileError::FileNotFound(_)) => {
|
||||
let info = FileInfo::from_path(&file_path)?;
|
||||
info.save(&root)?;
|
||||
Ok(info)
|
||||
|
@ -63,14 +92,14 @@ impl File {
|
|||
|
||||
let tn = Thumbnail::open(id, root)?;
|
||||
|
||||
Ok(File {
|
||||
Ok(Self {
|
||||
info,
|
||||
tn,
|
||||
root: PathBuf::from(root),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn list(root: &Path) -> Vec<Result<File>> {
|
||||
pub fn list(root: &Path) -> Vec<Result<Self, FileError>> {
|
||||
let dir_iter = read_dir(&root).unwrap();
|
||||
dir_iter
|
||||
.filter(|entry| {
|
||||
|
@ -81,7 +110,7 @@ impl File {
|
|||
.map(|entry| {
|
||||
let entry_ = entry.unwrap();
|
||||
let id = entry_.file_name().into_string().unwrap();
|
||||
File::open(&id, root)
|
||||
Self::open(&id, root)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
@ -94,13 +123,13 @@ impl File {
|
|||
self.tn.clone()
|
||||
}
|
||||
|
||||
pub fn stream(&self) -> Result<std::fs::File> {
|
||||
pub fn stream(&self) -> Result<std::fs::File, FileError> {
|
||||
let mut path = self.root.clone();
|
||||
path.push(self.info.id.clone());
|
||||
std::fs::File::open(path).map_err(Error::from)
|
||||
std::fs::File::open(path).map_err(FileError::from)
|
||||
}
|
||||
|
||||
pub fn delete(&self) -> Result<()> {
|
||||
pub fn delete(&self) -> Result<(), FileError> {
|
||||
let mut path = self.root.clone();
|
||||
path.push(self.info.id.clone());
|
||||
remove_file(path)?;
|
||||
|
|
|
@ -7,8 +7,7 @@ use std::fs::remove_file;
|
|||
use std::io::{Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use super::error::{Error, Result};
|
||||
use super::utils::append_extension;
|
||||
use crate::{append_extension, FileError};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct FileInfo {
|
||||
|
@ -23,45 +22,45 @@ pub struct FileInfo {
|
|||
}
|
||||
|
||||
impl FileInfo {
|
||||
pub fn save(&self, root: &Path) -> Result<()> {
|
||||
pub fn save(&self, root: &Path) -> Result<(), FileError> {
|
||||
let ser = serde_json::to_string(self).unwrap();
|
||||
std::fs::File::create(FileInfo::metadata_path(&self.id, root))
|
||||
.and_then(|mut stream| stream.write(ser.as_bytes()).map(|_| (())))
|
||||
.map_err(Error::from)
|
||||
.map_err(FileError::from)
|
||||
}
|
||||
|
||||
pub fn open(id: &str, root: &Path) -> Result<FileInfo> {
|
||||
pub fn open(id: &str, root: &Path) -> Result<FileInfo, FileError> {
|
||||
let mut buf = Vec::new();
|
||||
|
||||
let md_path = FileInfo::metadata_path(id, root);
|
||||
std::fs::File::open(md_path.clone())
|
||||
.and_then(|mut stream| stream.read_to_end(&mut buf))
|
||||
.map_err(move |err| match err.kind() {
|
||||
std::io::ErrorKind::NotFound => Error::FileNotFound(md_path),
|
||||
_ => Error::IOError(err),
|
||||
std::io::ErrorKind::NotFound => FileError::FileNotFound(md_path),
|
||||
_ => FileError::IOError(err),
|
||||
})?;
|
||||
|
||||
let str_repr = std::str::from_utf8(&buf)?;
|
||||
|
||||
serde_json::from_str(&str_repr).map_err(Error::from)
|
||||
serde_json::from_str(&str_repr).map_err(FileError::from)
|
||||
}
|
||||
|
||||
pub fn from_path(path: &Path) -> Result<FileInfo> {
|
||||
pub fn from_path(path: &Path) -> Result<FileInfo, FileError> {
|
||||
match (path.is_file(), path.is_dir()) {
|
||||
(false, false) => Err(Error::FileNotFound(PathBuf::from(path))),
|
||||
(false, true) => Err(Error::NotAFile(PathBuf::from(path))),
|
||||
(false, false) => Err(FileError::FileNotFound(PathBuf::from(path))),
|
||||
(false, true) => Err(FileError::NotAFile(PathBuf::from(path))),
|
||||
(true, _) => Ok(()),
|
||||
}?;
|
||||
|
||||
let metadata = path.metadata().map_err(Error::IOError)?;
|
||||
let metadata = path.metadata().map_err(FileError::IOError)?;
|
||||
let id = path
|
||||
.file_name()
|
||||
.map(|s| String::from(s.to_string_lossy()))
|
||||
.ok_or(Error::NotAFile(PathBuf::from(path)))?;
|
||||
.ok_or(FileError::NotAFile(PathBuf::from(path)))?;
|
||||
let created = metadata
|
||||
.created()
|
||||
.map(|m| DateTime::from(m))
|
||||
.map_err(|err| Error::IOError(err))?;
|
||||
.map_err(|err| FileError::IOError(err))?;
|
||||
let file_type = String::from(
|
||||
mime_guess::from_path(path)
|
||||
.first_or_octet_stream()
|
||||
|
@ -71,18 +70,18 @@ impl FileInfo {
|
|||
Ok(FileInfo {
|
||||
id,
|
||||
size: metadata.len(),
|
||||
created: created,
|
||||
created,
|
||||
file_type,
|
||||
hash: hash.as_string(),
|
||||
root: PathBuf::from(path.parent().unwrap()),
|
||||
})
|
||||
}
|
||||
|
||||
fn hash_file(path: &Path) -> Result<HexString> {
|
||||
fn hash_file(path: &Path) -> Result<HexString, FileError> {
|
||||
let mut buf = Vec::new();
|
||||
let mut file = std::fs::File::open(path).map_err(Error::from)?;
|
||||
let mut file = std::fs::File::open(path).map_err(FileError::from)?;
|
||||
|
||||
file.read_to_end(&mut buf).map_err(Error::from)?;
|
||||
file.read_to_end(&mut buf).map_err(FileError::from)?;
|
||||
let mut vec = Vec::new();
|
||||
vec.extend_from_slice(Sha256::digest(&buf).as_slice());
|
||||
Ok(HexString::from_bytes(&vec))
|
||||
|
@ -95,9 +94,9 @@ impl FileInfo {
|
|||
append_extension(&path, "json")
|
||||
}
|
||||
|
||||
pub fn delete(&self) -> Result<()> {
|
||||
pub fn delete(&self) -> Result<(), FileError> {
|
||||
let path = FileInfo::metadata_path(&self.id, &self.root);
|
||||
remove_file(path).map_err(Error::from)
|
||||
remove_file(path).map_err(FileError::from)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
use uuid::Uuid;
|
||||
|
||||
mod error;
|
||||
mod file;
|
||||
mod fileinfo;
|
||||
mod thumbnail;
|
||||
mod utils;
|
||||
pub mod utils;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
pub use file::File;
|
||||
pub use file::{File, FileError};
|
||||
pub use fileinfo::FileInfo;
|
||||
pub use thumbnail::Thumbnail;
|
||||
|
||||
|
@ -23,32 +21,36 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn list_files(&self) -> Vec<Result<File>> {
|
||||
pub fn list_files(&self) -> Vec<Result<File, FileError>> {
|
||||
File::list(&self.files_root)
|
||||
}
|
||||
|
||||
pub fn add_file(&mut self, temp_path: &PathBuf, filename: &Option<PathBuf>) -> Result<File> {
|
||||
pub fn add_file(
|
||||
&mut self,
|
||||
temp_path: &PathBuf,
|
||||
filename: &Option<PathBuf>,
|
||||
) -> Result<File, FileError> {
|
||||
let id = Uuid::new_v4().hyphenated().to_string();
|
||||
File::new(&id, &self.files_root, temp_path, filename)
|
||||
}
|
||||
|
||||
pub fn delete_file(&mut self, id: String) -> Result<()> {
|
||||
pub fn delete_file(&mut self, id: String) -> Result<(), FileError> {
|
||||
let f = File::open(&id, &self.files_root)?;
|
||||
f.delete()
|
||||
}
|
||||
|
||||
pub fn get_metadata(&self, id: String) -> Result<FileInfo> {
|
||||
pub fn get_metadata(&self, id: String) -> Result<FileInfo, FileError> {
|
||||
FileInfo::open(&id, &self.files_root)
|
||||
}
|
||||
|
||||
pub fn get_file(&self, id: String) -> Result<(FileInfo, std::fs::File)> {
|
||||
pub fn get_file(&self, id: String) -> Result<(FileInfo, std::fs::File), FileError> {
|
||||
let f = File::open(&id, &self.files_root)?;
|
||||
let info = f.info();
|
||||
let stream = f.stream()?;
|
||||
Ok((info, stream))
|
||||
}
|
||||
|
||||
pub fn get_thumbnail(&self, id: &str) -> Result<(FileInfo, std::fs::File)> {
|
||||
pub fn get_thumbnail(&self, id: &str) -> Result<(FileInfo, std::fs::File), FileError> {
|
||||
let f = File::open(id, &self.files_root)?;
|
||||
let stream = f.thumbnail().stream()?;
|
||||
Ok((f.info(), stream))
|
||||
|
|
|
@ -2,7 +2,7 @@ use image::imageops::FilterType;
|
|||
use std::fs::remove_file;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use super::error::{Error, Result};
|
||||
use crate::FileError;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Thumbnail {
|
||||
|
@ -11,7 +11,7 @@ pub struct Thumbnail {
|
|||
}
|
||||
|
||||
impl Thumbnail {
|
||||
pub fn open(id: &str, root: &Path) -> Result<Thumbnail> {
|
||||
pub fn open(id: &str, root: &Path) -> Result<Thumbnail, FileError> {
|
||||
let mut source_path = PathBuf::from(root);
|
||||
source_path.push(id);
|
||||
|
||||
|
@ -30,15 +30,15 @@ impl Thumbnail {
|
|||
Ok(self_)
|
||||
}
|
||||
|
||||
pub fn from_path(path: &Path) -> Result<Thumbnail> {
|
||||
pub fn from_path(path: &Path) -> Result<Thumbnail, FileError> {
|
||||
let id = path
|
||||
.file_name()
|
||||
.map(|s| String::from(s.to_string_lossy()))
|
||||
.ok_or(Error::NotAnImage(PathBuf::from(path)))?;
|
||||
.ok_or(FileError::NotAnImage(PathBuf::from(path)))?;
|
||||
|
||||
let root = path
|
||||
.parent()
|
||||
.ok_or(Error::FileNotFound(PathBuf::from(path)))?;
|
||||
.ok_or(FileError::FileNotFound(PathBuf::from(path)))?;
|
||||
|
||||
Thumbnail::open(&id, root)
|
||||
}
|
||||
|
@ -50,20 +50,20 @@ impl Thumbnail {
|
|||
path
|
||||
}
|
||||
|
||||
pub fn stream(&self) -> Result<std::fs::File> {
|
||||
pub fn stream(&self) -> Result<std::fs::File, FileError> {
|
||||
let thumbnail_path = Thumbnail::thumbnail_path(&self.id, &self.root);
|
||||
std::fs::File::open(thumbnail_path.clone()).map_err(|err| {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
Error::FileNotFound(thumbnail_path)
|
||||
FileError::FileNotFound(thumbnail_path)
|
||||
} else {
|
||||
Error::from(err)
|
||||
FileError::from(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete(&self) -> Result<()> {
|
||||
pub fn delete(&self) -> Result<(), FileError> {
|
||||
let path = Thumbnail::thumbnail_path(&self.id, &self.root);
|
||||
remove_file(path).map_err(Error::from)
|
||||
remove_file(path).map_err(FileError::from)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
/*
|
||||
use iron::headers;
|
||||
use iron::middleware::Handler;
|
||||
use iron::modifiers::{Header, Redirect};
|
||||
use iron::prelude::*;
|
||||
use iron::response::BodyReader;
|
||||
use iron::status;
|
||||
use mustache::{compile_path, Template};
|
||||
use orizentic::{Permissions, ResourceName, Secret};
|
||||
use params::{Params, Value};
|
||||
use router::Router;
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, RwLock};
|
||||
*/
|
||||
use http::status::StatusCode;
|
||||
// use mustache::{compile_path, Template};
|
||||
// use orizentic::{Permissions, ResourceName, Secret};
|
||||
use build_html::Html;
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
path::Path,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
use warp::Filter;
|
||||
|
||||
mod cookies;
|
||||
mod html;
|
||||
mod lib;
|
||||
mod middleware;
|
||||
mod pages;
|
||||
|
||||
use lib::{App, FileInfo};
|
||||
use middleware::{Authentication, RestForm};
|
||||
use lib::{utils::append_extension, App, File, FileError, FileInfo};
|
||||
|
||||
/*
|
||||
fn is_admin(resource: &ResourceName, permissions: &Permissions) -> bool {
|
||||
let Permissions(perms) = permissions;
|
||||
ResourceName(String::from(
|
||||
|
@ -280,18 +283,17 @@ fn script(_: &mut Request) -> IronResult<Response> {
|
|||
js,
|
||||
)))
|
||||
}
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
pub async fn main() {
|
||||
/*
|
||||
let auth_db_path = std::env::var("ORIZENTIC_DB").unwrap();
|
||||
let secret = Secret(Vec::from(
|
||||
std::env::var("ORIZENTIC_SECRET").unwrap().as_bytes(),
|
||||
));
|
||||
let auth_middleware = Authentication::new(secret, auth_db_path);
|
||||
|
||||
let app = Arc::new(RwLock::new(App::new(Path::new(
|
||||
&std::env::var("FILE_SHARE_DIR").unwrap(),
|
||||
))));
|
||||
|
||||
let mut router = Router::new();
|
||||
router.get(
|
||||
"/",
|
||||
|
@ -338,4 +340,39 @@ fn main() {
|
|||
chain.link_before(RestForm {});
|
||||
|
||||
Iron::new(chain).http("0.0.0.0:3000").unwrap();
|
||||
*/
|
||||
|
||||
/*
|
||||
let root = warp::path!().and(warp::get()).map({
|
||||
|| {
|
||||
warp::http::Response::builder()
|
||||
.header("content-type", "text/html")
|
||||
.status(StatusCode::NOT_MODIFIED)
|
||||
.body(())
|
||||
}
|
||||
});
|
||||
let server = warp::serve(root);
|
||||
server
|
||||
.run(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8002))
|
||||
.await;
|
||||
*/
|
||||
|
||||
let app = Arc::new(RwLock::new(App::new(Path::new(
|
||||
&std::env::var("FILE_SHARE_DIR").unwrap(),
|
||||
))));
|
||||
|
||||
let root = warp::path!().map({
|
||||
let app = app.clone();
|
||||
move || {
|
||||
warp::http::Response::builder()
|
||||
.header("content-type", "text/html")
|
||||
.status(StatusCode::OK)
|
||||
.body(pages::index(app.read().unwrap().list_files()).to_html_string())
|
||||
}
|
||||
});
|
||||
|
||||
let server = warp::serve(root);
|
||||
server
|
||||
.run(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8002))
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ impl Authentication {
|
|||
&self,
|
||||
token_str: String,
|
||||
) -> Result<orizentic::VerifiedToken, orizentic::Error> {
|
||||
self.auth.decode_and_validate_text(&token_str)
|
||||
self.auth.decode_and_validate_text(token_str)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
use crate::{html::*, File, FileError};
|
||||
use build_html::{self, Container, ContainerType, HtmlContainer};
|
||||
|
||||
pub fn index(files: Vec<Result<File, FileError>>) -> build_html::HtmlPage {
|
||||
let mut page = build_html::HtmlPage::new()
|
||||
.with_title("Admin list of files")
|
||||
.with_header(1, "Admin list of files")
|
||||
.with_html(
|
||||
Form::new()
|
||||
.with_method("post")
|
||||
.with_encoding("multipart/form-data")
|
||||
.with_container(
|
||||
Container::new(ContainerType::Div)
|
||||
.with_html(Input::new("file", "file", "file-selector-input"))
|
||||
.with_html(Label::new("for-selector-input", "Select a file")),
|
||||
)
|
||||
.with_html(Button::new("upload", "Upload file")),
|
||||
);
|
||||
|
||||
for file in files {
|
||||
let mut container =
|
||||
Container::new(ContainerType::Div).with_attributes(vec![("class", "file")]);
|
||||
match file {
|
||||
Ok(file) => {
|
||||
let tn = Container::new(ContainerType::Div)
|
||||
.with_attributes(vec![("class", "thumbnail")])
|
||||
.with_link(
|
||||
format!("/file/{}", file.info().id),
|
||||
"<p> paragraph within the link </p>".to_owned(),
|
||||
);
|
||||
container.add_html(tn);
|
||||
}
|
||||
Err(err) => {
|
||||
container.add_paragraph(format!("{:?}", err));
|
||||
}
|
||||
}
|
||||
page.add_container(container);
|
||||
}
|
||||
page
|
||||
}
|
Loading…
Reference in New Issue