Merge pull request 'First working version' (#11) from routes into main

Reviewed-on: ajmartinez/caty-blog#11
pull/13/head
Anthony J. Martinez 2 years ago
commit f746259236

1
.gitignore vendored

@ -1 +1,2 @@
/target
/working

584
Cargo.lock generated

@ -18,6 +18,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "argon2"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ee15f9f5e0f846cab0aa13d5dd1edbc49331dcae95a2e43b84ccc0b406dcda4"
dependencies = [
"blake2",
"password-hash",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -36,10 +46,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "base64"
version = "0.13.0"
name = "base64ct"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
checksum = "d0d27fb6b6f1e43147af148af49d49329413ba781aa0d5e10979831c210173b5"
[[package]]
name = "bitflags"
@ -47,6 +57,17 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blake2"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4"
dependencies = [
"crypto-mac",
"digest 0.9.0",
"opaque-debug 0.3.0",
]
[[package]]
name = "block-buffer"
version = "0.7.3"
@ -59,15 +80,6 @@ dependencies = [
"generic-array 0.12.4",
]
[[package]]
name = "block-buffer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "block-padding"
version = "0.1.5"
@ -86,16 +98,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "buf_redux"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f"
dependencies = [
"memchr",
"safemem",
]
[[package]]
name = "byte-tools"
version = "0.3.1"
@ -118,12 +120,21 @@ checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
name = "caty_blog"
version = "0.1.0"
dependencies = [
"argon2",
"clap",
"data-encoding",
"glob",
"hyper",
"log",
"pulldown-cmark",
"rand",
"routerify",
"serde",
"simplelog",
"tempfile",
"tera",
"tokio",
"warp",
"toml",
]
[[package]]
@ -170,12 +181,6 @@ dependencies = [
"vec_map",
]
[[package]]
name = "cpuid-bool"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
[[package]]
name = "crossbeam-utils"
version = "0.8.3"
@ -187,6 +192,22 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "crypto-mac"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
dependencies = [
"generic-array 0.14.4",
"subtle",
]
[[package]]
name = "data-encoding"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
[[package]]
name = "deunicode"
version = "0.4.3"
@ -223,30 +244,6 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "form_urlencoded"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
dependencies = [
"matches",
"percent-encoding",
]
[[package]]
name = "futures"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.13"
@ -254,7 +251,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
@ -263,12 +259,6 @@ version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94"
[[package]]
name = "futures-io"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
[[package]]
name = "futures-sink"
version = "0.3.13"
@ -288,11 +278,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1"
dependencies = [
"futures-core",
"futures-sink",
"futures-task",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]]
@ -314,17 +302,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
name = "getrandom"
version = "0.2.2"
@ -333,7 +310,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
dependencies = [
"cfg-if",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasi",
]
[[package]]
@ -368,9 +345,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d832b01df74254fe364568d6ddc294443f61cbec82816b60904303af87efae78"
checksum = "fc018e188373e2777d0ef2467ebff62a08e66c3f5857b23c8fbec3018210dc00"
dependencies = [
"bytes",
"fnv",
@ -391,31 +368,6 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]]
name = "headers"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0b7591fb62902706ae8e7aaff416b1b0fa2c0fd0878b46dc13baa3712d8a855"
dependencies = [
"base64",
"bitflags",
"bytes",
"headers-core",
"http",
"mime",
"sha-1 0.9.4",
"time",
]
[[package]]
name = "headers-core"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
dependencies = [
"http",
]
[[package]]
name = "hermit-abi"
version = "0.1.18"
@ -467,9 +419,9 @@ checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e"
[[package]]
name = "hyper"
version = "0.14.4"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7"
checksum = "8bf09f61b52cfcf4c00de50df88ae423d6c02354e385a86341133b5338630ad1"
dependencies = [
"bytes",
"futures-channel",
@ -489,17 +441,6 @@ dependencies = [
"want",
]
[[package]]
name = "idna"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "ignore"
version = "0.4.17"
@ -528,15 +469,6 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "input_buffer"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413"
dependencies = [
"bytes",
]
[[package]]
name = "instant"
version = "0.1.9"
@ -560,15 +492,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.90"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae"
checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714"
[[package]]
name = "lock_api"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312"
checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
dependencies = [
"scopeguard",
]
@ -588,39 +520,17 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "matches"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]]
name = "memchr"
version = "2.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
[[package]]
name = "mime"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mime_guess"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "mio"
version = "0.7.10"
version = "0.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2182a122f3b7f3f5329cb1972cee089ba2459a0a80a56935e6e674f096f8d839"
checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956"
dependencies = [
"libc",
"log",
@ -631,32 +541,13 @@ dependencies = [
[[package]]
name = "miow"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"socket2",
"winapi",
]
[[package]]
name = "multipart"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d050aeedc89243f5347c3e237e3e13dc76fbe4ae3742a57b94dc14f69acf76d4"
dependencies = [
"buf_redux",
"httparse",
"log",
"mime",
"mime_guess",
"quick-error",
"rand 0.7.3",
"safemem",
"tempfile",
"twoway",
]
[[package]]
name = "ntapi"
version = "0.3.6"
@ -747,6 +638,16 @@ dependencies = [
"regex",
]
[[package]]
name = "password-hash"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85d8faea6c018131952a192ee55bd9394c51fc6f63294b668d97636e6f842d40"
dependencies = [
"base64ct",
"rand_core",
]
[[package]]
name = "percent-encoding"
version = "2.1.0"
@ -793,23 +694,23 @@ checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
dependencies = [
"maplit",
"pest",
"sha-1 0.8.2",
"sha-1",
]
[[package]]
name = "pin-project"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63"
checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
checksum = "a490329918e856ed1b083f244e3bfe2d8c4f336407e4ea9e1a9f479ff09049e5"
dependencies = [
"proc-macro2",
"quote",
@ -836,9 +737,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "proc-macro2"
version = "1.0.24"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
dependencies = [
"unicode-xid",
]
@ -854,12 +755,6 @@ dependencies = [
"unicase",
]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]]
name = "quote"
version = "1.0.9"
@ -869,19 +764,6 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom 0.1.16",
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
]
[[package]]
name = "rand"
version = "0.8.3"
@ -889,19 +771,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
dependencies = [
"libc",
"rand_chacha 0.3.0",
"rand_core 0.6.2",
"rand_hc 0.3.0",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core 0.5.1",
"rand_chacha",
"rand_core",
"rand_hc",
]
[[package]]
@ -911,16 +783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
dependencies = [
"ppv-lite86",
"rand_core 0.6.2",
]
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom 0.1.16",
"rand_core",
]
[[package]]
@ -929,16 +792,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
dependencies = [
"getrandom 0.2.2",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.5.1",
"getrandom",
]
[[package]]
@ -947,7 +801,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
dependencies = [
"rand_core 0.6.2",
"rand_core",
]
[[package]]
@ -986,16 +840,23 @@ dependencies = [
]
[[package]]
name = "ryu"
version = "1.0.5"
name = "routerify"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
checksum = "c18f54182904acfbd8082adb04985c59eb037027105631e3a68a5a51de31294d"
dependencies = [
"http",
"hyper",
"lazy_static",
"percent-encoding",
"regex",
]
[[package]]
name = "safemem"
version = "0.3.3"
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "same-file"
@ -1006,12 +867,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "scopeguard"
version = "1.1.0"
@ -1020,28 +875,30 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.124"
version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_json"
version = "1.0.64"
name = "serde_derive"
version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
dependencies = [
"itoa",
"ryu",
"serde",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.0"
name = "serde_json"
version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde",
@ -1053,32 +910,30 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
dependencies = [
"block-buffer 0.7.3",
"block-buffer",
"digest 0.8.1",
"fake-simd",
"opaque-debug 0.2.3",
]
[[package]]
name = "sha-1"
version = "0.9.4"
name = "signal-hook-registry"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f"
checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
"cpuid-bool",
"digest 0.9.0",
"opaque-debug 0.3.0",
"libc",
]
[[package]]
name = "signal-hook-registry"
version = "1.3.0"
name = "simplelog"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6"
checksum = "59d0fe306a0ced1c88a58042dc22fc2ddd000982c26d75f6aa09a394547c41e0"
dependencies = [
"libc",
"chrono",
"log",
"termcolor",
]
[[package]]
@ -1104,11 +959,10 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "socket2"
version = "0.3.19"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2"
dependencies = [
"cfg-if",
"libc",
"winapi",
]
@ -1119,11 +973,17 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "subtle"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
[[package]]
name = "syn"
version = "1.0.64"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f"
checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87"
dependencies = [
"proc-macro2",
"quote",
@ -1138,7 +998,7 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
"cfg-if",
"libc",
"rand 0.8.3",
"rand",
"redox_syscall",
"remove_dir_all",
"winapi",
@ -1158,7 +1018,7 @@ dependencies = [
"percent-encoding",
"pest",
"pest_derive",
"rand 0.8.3",
"rand",
"regex",
"serde",
"serde_json",
@ -1166,6 +1026,15 @@ dependencies = [
"unic-segment",
]
[[package]]
name = "termcolor"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.11.0"
@ -1194,21 +1063,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "tinyvec"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.4.0"
@ -1240,30 +1094,6 @@ dependencies = [
"syn",
]
[[package]]
name = "tokio-stream"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e177a5d8c3bf36de9ebe6d58537d8879e964332f93fb3339e43f618c81361af0"
dependencies = [
"futures-core",
"pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-tungstenite"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1a5f475f1b9d077ea1017ecbc60890fda8e54942d680ca0b1d2b47cfa2d861b"
dependencies = [
"futures-util",
"log",
"pin-project",
"tokio",
"tungstenite",
]
[[package]]
name = "tokio-util"
version = "0.6.5"
@ -1278,6 +1108,15 @@ dependencies = [
"tokio",
]
[[package]]
name = "toml"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde",
]
[[package]]
name = "tower-service"
version = "0.3.1"
@ -1291,7 +1130,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
dependencies = [
"cfg-if",
"log",
"pin-project-lite",
"tracing-core",
]
@ -1305,50 +1143,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]]
name = "try-lock"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "tungstenite"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24"
dependencies = [
"base64",
"byteorder",
"bytes",
"http",
"httparse",
"input_buffer",
"log",
"rand 0.8.3",
"sha-1 0.9.4",
"url",
"utf-8",
]
[[package]]
name = "twoway"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1"
dependencies = [
"memchr",
]
[[package]]
name = "typenum"
version = "1.13.0"
@ -1420,24 +1220,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "unicode-bidi"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
dependencies = [
"matches",
]
[[package]]
name = "unicode-normalization"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-width"
version = "0.1.8"
@ -1450,24 +1232,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "url"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b"
dependencies = [
"form_urlencoded",
"idna",
"matches",
"percent-encoding",
]
[[package]]
name = "utf-8"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -1482,9 +1246,9 @@ checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]]
name = "walkdir"
version = "2.3.1"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi",
@ -1501,42 +1265,6 @@ dependencies = [
"try-lock",
]
[[package]]
name = "warp"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dafd0aac2818a94a34df0df1100a7356c493d8ede4393875fd0b5c51bb6bc80"
dependencies = [
"bytes",
"futures",
"headers",
"http",
"hyper",
"log",
"mime",
"mime_guess",
"multipart",
"percent-encoding",
"pin-project",
"scoped-tls",
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-stream",
"tokio-tungstenite",
"tokio-util",
"tower-service",
"tracing",
"tracing-futures",
]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"

@ -7,12 +7,23 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
argon2 = "0.1"
clap = "2.33.3"
data-encoding = "2.3.2"
glob = "0.3.0"
tera = "1.7.0"
hyper = "0.14"
log = "0.4.14"
pulldown-cmark = { version = "0.8", default-features = false, features = ["simd"] }
rand = "0.8"
routerify = "2.0.0"
serde = { version = "1", features = ["derive"] }
simplelog = "0.10.0"
tera = "1.7.0"
tokio = { version = "1", features = ["full"] }
warp = "0.3"
toml = "0.5"
[dev-dependencies]
tempfile = "3"
[profile.release]
panic = "abort"

@ -0,0 +1,63 @@
/// TODO Document
pub fn generate_secret(len: usize) -> Result<String, Box<dyn std::error::Error>> {
use rand::{thread_rng, Rng,
distributions::Alphanumeric};
if len < 32 {
Err(From::from("Random passwords shorter than 32ch are useless"))
} else {
let pass: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(len)
.map(char::from)
.collect();
Ok(pass)
}
}
/// TODO Document
pub fn generate_argon2_phc(secret: &str) -> Result<String, Box<dyn std::error::Error>> {
use rand::rngs::OsRng;
use argon2::{Argon2, password_hash::{SaltString, PasswordHasher}};
let secret = secret.as_bytes();
let salt = SaltString::generate(&mut OsRng);
let argon2 = Argon2::default();
let argon2_phc: Result<String, Box<dyn std::error::Error>>;
if let Ok(phc) = argon2.hash_password_simple(secret, salt.as_ref()) {
argon2_phc = Ok(phc.to_string());
} else {
argon2_phc = Err(From::from("Failed to hash password"));
}
argon2_phc
}
pub use data_encoding::BASE32_NOPAD;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn check_secret_len() {
const SECLEN: usize = 32;
let secret = generate_secret(SECLEN).unwrap();
assert_eq!(SECLEN, secret.len())
}
#[test]
fn check_short_secret() {
const SECLEN: usize = 12;
let secret = generate_secret(SECLEN);
assert!(secret.is_err())
}
#[test]
fn check_argon2_hasher() {
const SECLEN: usize = 32;
let secret = generate_secret(SECLEN).unwrap();
let phc = generate_argon2_phc(&secret);
assert!(phc.is_ok())
}
}

@ -1,25 +1,25 @@
use caty_blog::*;
use warp::Filter;
use std::net::SocketAddr;
use std::sync::Arc;
use caty_blog::*;
use hyper::Server;
use routerify::RouterService;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// TODO: Load configuration file defining paths to stuff
// Load into memory as a Struct in an Arc(Mutex(something))
// This should also include the admin username/hash(password)
write_main(&render_main())?;
let static_files = warp::path("static")
.and(warp::fs::dir("webroot/static"));
let index = warp::get()
.and(warp::path::end())
.and(warp::fs::file("webroot/index.html"));
let routes = static_files.or(index);
warp::serve(routes).run(([127,0,0,1], 3030)).await;
let config = config::load()?;
let app = Arc::new(config);
// TODO: Configure logging
let router = routes::router(app.clone());
let service = RouterService::new(router).unwrap();
let addr: SocketAddr = "0.0.0.0:9090".parse().unwrap();
let server = Server::bind(&addr).serve(service);
if let Err(err) = server.await {
eprintln!("Server error: {}", err)
}
Ok(())
}

@ -0,0 +1,52 @@
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use glob::glob;
#[cfg(target_family = "unix")]
pub fn str_to_ro_file<P: AsRef<Path>>(content: &str, dest: P) -> Result<(), Box<dyn std::error::Error>> {
use std::os::unix::fs::OpenOptionsExt;
let mut options = OpenOptions::new();
options.create(true);
options.write(true);
options.mode(0o600);
let mut ro_file = options.open(dest)?;
ro_file.write_all(content.as_bytes())?;
if !content.ends_with("\n") {
ro_file.write(b"\n")?;
}
Ok(())
}
#[cfg(target_family = "windows")]
pub fn str_to_ro_file<P: AsRef<Path>>(content: &str, dest: P) -> Result<(), Box<dyn std::error::Error>> {
let mut ro_file = File::create(dest)?;
ro_file.write_all(content.as_bytes())?;
let metadata = secret_file.metadata()?;
let mut perms = metadata.permissions();
if !content.ends_with("\n") {
ro_file.write(b"\n")?;
}
perms.set_readonly(true);
Ok(())
}
pub fn path_matches(pat: &str) -> Result<Vec<PathBuf>, Box<dyn std::error::Error>> {
let mut path_vec: Vec<PathBuf> = Vec::new();
let entries = glob(pat)?;
for entry in entries.filter_map(Result::ok) {
path_vec.push(entry);
}
path_vec.reverse();
Ok(path_vec)
}
pub fn slugify(topic: &str) -> String {
let topic = topic
.to_ascii_lowercase()
.replace(char::is_whitespace, "-");
topic
}

@ -0,0 +1,271 @@
use std::fs::create_dir_all;
use std::{io::BufRead, usize};
use std::path::Path;
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use serde::{Serialize, Deserialize};
use toml;
use super::auth;
use super::common;
fn args() -> App<'static, 'static> {
App::new("Caty's Blog")
.version("1.0")
.author("Anthony Martinez")
.setting(AppSettings::ArgRequiredElseHelp)
.subcommand(SubCommand::with_name("run")
.about("Run the blog server")
.arg(Arg::with_name("config")
.help("Provides the path to the server configuration file.")
.required(true)
.takes_value(true)
.index(1)))
.subcommand(SubCommand::with_name("new")
.about("Generates a base directory structure and configuration file for a new blog")
)
}
/// TODO Document this public function
/// And Include an Example of its Use
pub fn load() -> Result<AppConfig, Box<dyn std::error::Error>> {
let matches = args().get_matches();
let config: Result<AppConfig, Box<dyn std::error::Error>>;
if matches.is_present("run") {
config = runner_config(matches);
} else if matches.is_present("new") {
let reader = std::io::stdin();
let mut reader = reader.lock();
let current_path = std::env::current_dir()?;
config = AppConfig::generate(current_path, &mut reader);
} else {
let msg = format!("Unable to load configuration");
config = Err(From::from(msg));
}
config
}
fn runner_config(m: ArgMatches) -> Result<AppConfig, Box<dyn std::error::Error>> {
if let Some(run) = m.subcommand_matches("run") {
let value = run.value_of("config").unwrap();
let config = AppConfig::new(value)?;
Ok(config)
} else {
let msg = format!("Failed to read arguments for 'run' subcommand");
Err(From::from(msg))
}
}
fn get_input<R: BufRead>(prompt: &str, reader: &mut R) -> Result<String, Box<dyn std::error::Error>> {
let mut buf = String::new();
println!("{}", prompt);
reader.read_line(&mut buf)?;
let buf = String::from(buf
.trim_start_matches(char::is_whitespace)
.trim_end_matches(char::is_whitespace));
Ok(buf)
}
fn csv_to_vec(csv: &str) -> Vec<String> {
let val_vec: Vec<String> = csv.split(",")
.map(|s| s
.trim_start_matches(char::is_whitespace)
.trim_end_matches(char::is_whitespace)
.to_string())
.collect();
val_vec
}
/// TODO Document
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct Blog {
pub name: String,
pub author: String,
pub topics: Vec<String>,
}
impl Blog {
pub fn new_from_input<R: BufRead>(reader: &mut R) -> Result<Blog, Box<dyn std::error::Error>> {
let name = get_input("Please enter a name for the blog: ", reader)?;
let author = get_input("Please enter the blog author's name: ", reader)?;
let topics = get_input("Please enter comma-separated blog topics: ", reader)?;
let topics = csv_to_vec(&topics);
let blog = Blog { name, author, topics };
Ok(blog)
}
}
/// TODO Document
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct Credentials {
pub user: String,
pub password: String,
pub token: String,
}
impl Credentials {
pub fn new_from_input<P: AsRef<Path>, R: BufRead>(dir: P, reader: &mut R) -> Result<Credentials, Box<dyn std::error::Error>> {
let user = get_input("Please enter an username for the blog admin: ", reader)?;
const PASSWORD_LEN: usize = 32;
let password = auth::generate_secret(PASSWORD_LEN)?;
let password_file = dir.as_ref().join("admin.pass");
common::str_to_ro_file(&password, password_file)?;
let password = auth::generate_argon2_phc(&password)?;
const TOKEN_LEN: usize = 34;
let token = auth::generate_secret(TOKEN_LEN)?;
let token = token.as_bytes();
let token = auth::BASE32_NOPAD.encode(token);
let token_file = dir.as_ref().join("admin.totp");
common::str_to_ro_file(&token, token_file)?;
let creds = Credentials { user, password, token };
Ok(creds)
}
}
/// TODO Document
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct DocPaths {
pub templates: String,
pub webroot: String,
}
impl DocPaths {
pub fn new<P: AsRef<Path>>(dir: P) -> Result<DocPaths, Box<dyn std::error::Error>> {
let dir = dir.as_ref().display();
let templates = format!("{}/blog/templates", dir);
let webroot = format!("{}/blog/webroot", dir);
let docpaths = DocPaths { templates, webroot };
Ok(docpaths)
}
}
/// TODO Document
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct LogConfig {
level: String
}
/// TODO Document
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct AppConfig {
pub blog: Blog,
pub creds: Credentials,
pub logging: LogConfig,
pub docpaths: DocPaths,
}
impl AppConfig {
pub fn new<T>(config: T) -> Result<AppConfig, Box<dyn std::error::Error>>
where T: AsRef<Path> {
let config = std::fs::read_to_string(config)?;
let app_config: AppConfig = toml::from_str(&config)?;
Ok(app_config)
}
pub fn generate<P: AsRef<Path>, R: BufRead>(dir: P, reader: &mut R) -> Result<AppConfig, Box<dyn std::error::Error>> {
let docpaths = DocPaths::new(&dir)?;
let blog = Blog::new_from_input(reader)?;
let creds = Credentials::new_from_input(&dir, reader)?;
let level = format!("INFO");
let logging = LogConfig { level };
let config = AppConfig {
blog,
creds,
logging,
docpaths,
};
config.create_paths()?;
config.write(&dir)?;
Ok(config)
}
fn create_paths(&self) -> Result<(), Box<dyn std::error::Error>> {
create_dir_all(&self.docpaths.templates)?;
create_dir_all(format!("{}/static/ext", &self.docpaths.webroot))?;
create_dir_all(format!("{}/main/ext", &self.docpaths.webroot))?;
create_dir_all(format!("{}/main/posts", &self.docpaths.webroot))?;
for topic in &self.blog.topics {
let topic = common::slugify(&topic);
create_dir_all(format!("{}/{}/ext", &self.docpaths.webroot, &topic))?;
create_dir_all(format!("{}/{}/posts", &self.docpaths.webroot, &topic))?;
}
Ok(())
}
fn write<P: AsRef<Path>>(&self, dir: P) -> Result<(), Box<dyn std::error::Error>> {
let config = toml::to_string_pretty(&self)?;
let conf_path = &dir.as_ref().join("config.toml");
common::str_to_ro_file(&config, &conf_path)?;
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use tempfile;
#[test]
fn build_run_config() {
let arg_vec = vec!["caty-blog", "run", "./test_files/test-config.toml"];
let matches = args().get_matches_from(arg_vec);
let config = runner_config(matches);
assert!(config.is_ok());
}
#[test]
fn build_config_from_input() {
let dir = tempfile::tempdir().unwrap();
// Setup all target fields
let mut src: &[u8] = b"Blog Name\nAuthor Name\nOne, Two, Three, And More\nadmin\n";
let config = AppConfig::generate(&dir, &mut src);
assert!(config.is_ok());
let tmp_dir = &dir.path();
let config_path = &tmp_dir.join("config.toml");
let admin = &tmp_dir.join("admin.pass");
let token = &tmp_dir.join("admin.totp");
let blog = &tmp_dir.join("blog");
let templates = &tmp_dir.join("blog/templates");
let webroot = &tmp_dir.join("blog/webroot");
let static_ext = &tmp_dir.join("blog/webroot/static/ext");
let main_ext = &tmp_dir.join("blog/webroot/main/ext");
let main_posts = &tmp_dir.join("blog/webroot/main/posts");
let one_ext = &tmp_dir.join("blog/webroot/one/ext");
let one_posts = &tmp_dir.join("blog/webroot/one/posts");
let two_ext = &tmp_dir.join("blog/webroot/two/ext");
let two_posts = &tmp_dir.join("blog/webroot/two/posts");
let three_ext = &tmp_dir.join("blog/webroot/three/ext");
let three_posts = &tmp_dir.join("blog/webroot/three/posts");
let and_more_ext = &tmp_dir.join("blog/webroot/and-more/ext");
let and_more_posts = &tmp_dir.join("blog/webroot/and-more/posts");
let core = vec![config_path, admin, token, blog, templates,
webroot, static_ext, main_ext, main_posts,
one_ext, one_posts, two_ext, two_posts,
three_ext, three_posts, and_more_ext, and_more_posts];
for p in core {
assert!(Path::new(p).exists())
}
}
#[test]
fn handle_csv_topics() {
let reference_topics: Vec<String> = vec![format!("One"), format!("Two"), format!("Three"), format!("And More")];
let topics = format!("One, Two, Three, And More");
assert_eq!(reference_topics, csv_to_vec(&topics))
}
}

@ -1,86 +1,5 @@
use std::fs::File;
use std::path::PathBuf;
use std::io::prelude::*;
use clap::{App, Arg};
use glob::glob;
use pulldown_cmark::{Parser, html};
use tera::{Tera, Context};
// Todo expand parsing to include a path for loading config
pub fn parse_args() -> String {
let mut pat_string = String::new();
let matches = App::new("Make Blog Posts")
.version("1.0")
.author("Anthony Martinez")
.about("I made it of course it rocks")
.arg(Arg::with_name("glob_pattern")
.short("p")
.long("--pattern")
.help("Provides the input file glob pattern")
.takes_value(true)
.required(true))
.get_matches();
if let Some(pattern) = matches.value_of("glob_pattern") {
pat_string = String::from(pattern);
}
pat_string
}
pub fn path_matches(pat: &str) -> Vec<PathBuf> {
let mut path_vec: Vec<PathBuf> = Vec::new();
for path in glob(pat).unwrap().filter_map(Result::ok) {
path_vec.push(path)
}
path_vec
}
pub fn read_to_html(paths: Vec<PathBuf>) -> Vec<String> {
let mut contents: Vec<String> = Vec::new();
for path in paths {
let buffer = std::fs::read_to_string(path).unwrap();
let parser = Parser::new(&buffer);
let mut html_output = String::new();
html::push_html(&mut html_output, parser);
contents.push(html_output);
}
contents
}
pub fn load_templates(dir: &str) -> Tera {
match Tera::new(dir) {
Ok(t) => t,
Err(e) => panic!("Failed with {}", e)
}
}
pub fn render_main() -> String {
let pattern = parse_args();
let path_vec = path_matches(&pattern);
let mut data = read_to_html(path_vec);