Added motivation support

main
Joey Hines 2024-03-03 12:43:58 -07:00
parent 6919b2b6f0
commit 774f63625d
No known key found for this signature in database
GPG Key ID: 995E531F7A569DDB
8 changed files with 804 additions and 88 deletions

570
Cargo.lock generated
View File

@ -136,10 +136,10 @@ dependencies = [
"axum-core",
"bytes",
"futures-util",
"http",
"http-body",
"http 1.0.0",
"http-body 1.0.0",
"http-body-util",
"hyper",
"hyper 1.1.0",
"hyper-util",
"itoa",
"matchit",
@ -170,8 +170,8 @@ dependencies = [
"async-trait",
"bytes",
"futures-util",
"http",
"http-body",
"http 1.0.0",
"http-body 1.0.0",
"http-body-util",
"mime",
"pin-project-lite",
@ -215,6 +215,35 @@ version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
[[package]]
name = "bindgen"
version = "0.69.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
dependencies = [
"bitflags 2.4.2",
"cexpr",
"clang-sys",
"itertools",
"lazy_static",
"lazycell",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 2.0.48",
"which",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@ -266,6 +295,15 @@ dependencies = [
"libc",
]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -309,6 +347,17 @@ dependencies = [
"phf_codegen",
]
[[package]]
name = "clang-sys"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clap"
version = "2.34.0"
@ -379,6 +428,16 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "core-foundation"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
@ -453,6 +512,12 @@ dependencies = [
"const-random",
]
[[package]]
name = "either"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
[[package]]
name = "encoding_rs"
version = "0.8.33"
@ -491,12 +556,43 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "fastrand"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@ -591,6 +687,31 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "h2"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 0.2.11",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "h2"
version = "0.4.1"
@ -602,7 +723,7 @@ dependencies = [
"futures-core",
"futures-sink",
"futures-util",
"http",
"http 1.0.0",
"indexmap",
"slab",
"tokio",
@ -658,6 +779,26 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "http"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]]
name = "http"
version = "1.0.0"
@ -669,6 +810,17 @@ dependencies = [
"itoa",
]
[[package]]
name = "http-body"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"http 0.2.11",
"pin-project-lite",
]
[[package]]
name = "http-body"
version = "1.0.0"
@ -676,7 +828,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
dependencies = [
"bytes",
"http",
"http 1.0.0",
]
[[package]]
@ -687,8 +839,8 @@ checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840"
dependencies = [
"bytes",
"futures-util",
"http",
"http-body",
"http 1.0.0",
"http-body 1.0.0",
"pin-project-lite",
]
@ -710,6 +862,30 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hyper"
version = "0.14.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.24",
"http 0.2.11",
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"socket2",
"tokio",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "hyper"
version = "1.1.0"
@ -719,9 +895,9 @@ dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2",
"http",
"http-body",
"h2 0.4.1",
"http 1.0.0",
"http-body 1.0.0",
"httparse",
"httpdate",
"itoa",
@ -729,6 +905,19 @@ dependencies = [
"tokio",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"hyper 0.14.28",
"native-tls",
"tokio",
"tokio-native-tls",
]
[[package]]
name = "hyper-util"
version = "0.1.2"
@ -738,9 +927,9 @@ dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http",
"http-body",
"hyper",
"http 1.0.0",
"http-body 1.0.0",
"hyper 1.1.0",
"pin-project-lite",
"socket2",
"tokio",
@ -799,6 +988,21 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "ipnet"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]]
name = "itertools"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.10"
@ -852,18 +1056,40 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "libloading"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161"
dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "lock_api"
version = "0.4.11"
@ -880,6 +1106,17 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "magick_rust"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bcea563f2aca74310eff7a545e1added08b1f4dce7679385034683fd482e9cc"
dependencies = [
"bindgen",
"libc",
"pkg-config",
]
[[package]]
name = "matchit"
version = "0.7.3"
@ -933,7 +1170,7 @@ dependencies = [
"bytes",
"encoding_rs",
"futures-util",
"http",
"http 1.0.0",
"httparse",
"log",
"memchr",
@ -942,6 +1179,24 @@ dependencies = [
"version_check",
]
[[package]]
name = "native-tls"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
dependencies = [
"lazy_static",
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]]
name = "nom"
version = "7.1.3"
@ -996,6 +1251,50 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "openssl"
version = "0.10.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
dependencies = [
"bitflags 2.4.2",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "ordered-multimap"
version = "0.6.0"
@ -1143,12 +1442,12 @@ dependencies = [
[[package]]
name = "pic_ox"
version = "0.1.1"
version = "0.2.0"
dependencies = [
"async-trait",
"axum",
"axum-macros",
"base64",
"base64 0.22.0",
"bitflags 2.4.2",
"chrono",
"chrono-tz",
@ -1158,8 +1457,10 @@ dependencies = [
"j_db",
"json",
"log",
"magick_rust",
"multer",
"rand",
"reqwest",
"serde",
"serde_json",
"sha2",
@ -1201,12 +1502,28 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "prettyplease"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5"
dependencies = [
"proc-macro2",
"syn 2.0.48",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@ -1317,13 +1634,53 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "reqwest"
version = "0.11.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251"
dependencies = [
"base64 0.21.7",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"h2 0.3.24",
"http 0.2.11",
"http-body 0.4.6",
"hyper 0.14.28",
"hyper-tls",
"ipnet",
"js-sys",
"log",
"mime",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
"tokio-native-tls",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"winreg",
]
[[package]]
name = "ron"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
dependencies = [
"base64",
"base64 0.21.7",
"bitflags 2.4.2",
"serde",
"serde_derive",
@ -1345,6 +1702,34 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
"bitflags 2.4.2",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "rustls-pemfile"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
dependencies = [
"base64 0.21.7",
]
[[package]]
name = "rustversion"
version = "1.0.14"
@ -1357,12 +1742,44 @@ version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "schannel"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "security-framework"
version = "2.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "serde"
version = "1.0.195"
@ -1445,6 +1862,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "siphasher"
version = "0.3.11"
@ -1556,6 +1979,39 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "system-configuration"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "tempfile"
version = "3.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
dependencies = [
"cfg-if",
"fastrand",
"rustix",
"windows-sys 0.52.0",
]
[[package]]
name = "textwrap"
version = "0.11.0"
@ -1647,6 +2103,16 @@ dependencies = [
"syn 2.0.48",
]
[[package]]
name = "tokio-native-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
dependencies = [
"native-tls",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.7.10"
@ -1769,6 +2235,12 @@ dependencies = [
"tracing-log",
]
[[package]]
name = "try-lock"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "typenum"
version = "1.17.0"
@ -1823,6 +2295,7 @@ dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
"serde",
]
[[package]]
@ -1837,6 +2310,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -1849,6 +2328,15 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "want"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
dependencies = [
"try-lock",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@ -1880,6 +2368,18 @@ dependencies = [
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461"
dependencies = [
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.90"
@ -1909,6 +2409,28 @@ version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
[[package]]
name = "web-sys"
version = "0.3.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "which"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"home",
"once_cell",
"rustix",
]
[[package]]
name = "winapi"
version = "0.3.9"
@ -2081,6 +2603,16 @@ dependencies = [
"memchr",
]
[[package]]
name = "winreg"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]]
name = "yaml-rust"
version = "0.4.5"

View File

@ -1,6 +1,6 @@
[package]
name = "pic_ox"
version = "0.1.1"
version = "0.2.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -15,7 +15,6 @@ chrono = { version = "0.4.31", features = ["serde"] }
chrono-tz = "0.8.5"
async-trait = "0.1.77"
hex = "0.4.3"
url = "2.5.0"
structopt = "0.3.26"
log = { version = "0.4.20", features = [] }
env_logger = "0.11.0"
@ -25,7 +24,13 @@ rand = "0.8.5"
sha2 = "0.10.8"
bitflags = "2.4.2"
json = "0.12.4"
base64 = "0.21.7"
base64 = "0.22.0"
magick_rust = "0.20.0"
reqwest = "0.11.24"
[dependencies.url]
version = "2.5.0"
features = ["serde"]
[dependencies.axum]
version = "0.7.4"

View File

@ -1,7 +1,9 @@
use crate::api::models::{
AddImage, AlbumQuery, CreateAlbum, ImageQuery, ImageSort, PicContext, PicOxError, Response,
AddImage, AlbumQuery, CreateAlbum, ImageQuery, ImageSort, MotivationGenerator, PicContext,
PicOxError, Response,
};
use crate::config::PicOxConfig;
use crate::img_manipulation;
use crate::model::album::Album;
use crate::model::api_key::ApiKey;
use crate::model::image::{Image, ImageData};
@ -9,6 +11,7 @@ use crate::state::Context;
use crate::storage_manager::StorageManager;
use axum::body::Bytes;
use axum::extract::{DefaultBodyLimit, Multipart, Path, Query, Request, State};
use axum::http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
use axum::http::HeaderMap;
use axum::middleware::Next;
use axum::response::IntoResponse;
@ -16,9 +19,9 @@ use axum::routing::{get, post};
use axum::{middleware, Json, Router};
use j_db::database::Database;
use j_db::model::JdbModel;
use log::info;
use rand::prelude::SliceRandom;
use rand::thread_rng;
use log::{debug, info};
use magick_rust::magick_wand_genesis;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::RwLock;
@ -63,66 +66,7 @@ async fn query_images(
State(context): State<PicContext>,
Json(image_query): Json<ImageQuery>,
) -> Result<Response<Vec<Image>>, PicOxError> {
let album_id = if let Some(album) = &image_query.album {
Some(
Album::find_album_by_query(
&context.db,
AlbumQuery {
album_name: Some(album.to_string()),
},
)
.first()
.ok_or(PicOxError::AlbumNotFound)?
.id()
.unwrap(),
)
} else {
None
};
let mut images: Vec<Image> = context
.db
.filter(|_, img: &Image| {
if let Some(album_id) = album_id {
if img.album != album_id {
return false;
}
}
if !image_query.tags.is_empty() {
let mut found = false;
for tag in &image_query.tags {
if img.tags.contains(tag) {
found = true;
break;
}
}
if !found {
return false;
}
}
true
})?
.collect();
match image_query.order {
ImageSort::Random => {
images.shuffle(&mut thread_rng());
}
ImageSort::DateAscending => {
images.sort_by(|img_a, img_b| img_a.create_date.cmp(&img_b.create_date))
}
ImageSort::DateDescending => {
images.sort_by(|img_a, img_b| img_b.create_date.cmp(&img_a.create_date))
}
ImageSort::None => {}
}
if images.len() > image_query.limit {
images.drain(image_query.limit..);
}
let images = Image::query_image(&context.db, &image_query)?;
Ok(Response(images))
}
@ -210,6 +154,49 @@ async fn query_album(
Ok(Response(resp))
}
async fn generate_motivation(
Path(file_name): Path<PathBuf>,
motivation: Query<MotivationGenerator>,
State(context): State<PicContext>,
) -> impl IntoResponse {
let query = ImageQuery {
album: Some(motivation.album.clone()),
tags: vec![],
order: ImageSort::Random,
limit: 1,
image_type: vec!["jpg".to_string(), "jpeg".to_string(), "png".to_string()],
};
let image = Image::query_image(&context.db, &query)
.unwrap()
.first()
.cloned()
.unwrap();
let mut store_manager = context.store_manager.write().await;
let motivation_image_blob = store_manager.get_image(&image).await.unwrap();
let img = img_manipulation::generate_motivation_image(&motivation, motivation_image_blob);
let mut resp = img.into_response();
let headers = resp.headers_mut();
headers.insert(
CONTENT_DISPOSITION,
format!("inline; filename={}", file_name.to_str().unwrap())
.parse()
.unwrap(),
);
headers.insert(
CONTENT_TYPE,
format!("image/{}", file_name.extension().unwrap().to_str().unwrap())
.parse()
.unwrap(),
);
resp
}
async fn check_token_header(
State(context): State<PicContext>,
mut request: Request,
@ -217,6 +204,8 @@ async fn check_token_header(
) -> Result<impl IntoResponse, PicOxError> {
let headers = request.headers();
debug!("Checking token for path: {}", request.uri());
if let Some(token) = headers.get("token") {
if let Some(api_key) = ApiKey::find_api_key_by_token(&context.db, token.to_str().unwrap())?
{
@ -236,6 +225,8 @@ async fn check_token_header(
}
pub async fn run_picox(db: Database, config: PicOxConfig) {
magick_wand_genesis(); // initiate ImageMagick library
let store_manager = StorageManager::new(config.storage_config.clone());
let context = Context {
@ -258,6 +249,7 @@ pub async fn run_picox(db: Database, config: PicOxConfig) {
.route("/api/album/", get(query_album))
.route("/api/image/", get(query_images))
.route("/api/image/:id", get(get_image))
.route("/api/meme/motivation/:file_name", get(generate_motivation))
.with_state(context);
let listener = tokio::net::TcpListener::bind(&config.host).await.unwrap();

View File

@ -44,6 +44,17 @@ pub struct ImageQuery {
pub order: ImageSort,
#[serde(default)]
pub limit: usize,
#[serde(default)]
pub image_type: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MotivationGenerator {
pub album: String,
pub action: String,
pub goal: String,
pub border_color: String,
pub tagline: Option<String>,
}
#[derive(FromRequest)]
@ -68,6 +79,7 @@ pub enum PicOxError {
ImageNotFound,
TokenInvalid,
NoUserInHeader,
EditingError(magick_rust::MagickError),
}
impl From<StoreError> for PicOxError {
@ -82,6 +94,12 @@ impl From<j_db::error::JDbError> for PicOxError {
}
}
impl From<magick_rust::MagickError> for PicOxError {
fn from(value: magick_rust::MagickError) -> Self {
Self::EditingError(value)
}
}
#[derive(Serialize)]
pub struct ErrorResponse {
pub message: String,
@ -114,6 +132,10 @@ impl IntoResponse for PicOxError {
StatusCode::INTERNAL_SERVER_ERROR,
"User not found in header".to_string(),
),
PicOxError::EditingError(err) => (
StatusCode::INTERNAL_SERVER_ERROR,
format!("Error editing image: {}", err),
),
};
(status, Response(ErrorResponse { message })).into_response()

View File

@ -0,0 +1,71 @@
use crate::api::models::{MotivationGenerator, PicOxError};
use log::info;
use magick_rust::{DrawingWand, MagickWand, PixelWand};
pub fn generate_motivation_image(
motivation: &MotivationGenerator,
motivation_image_blob: Vec<u8>,
) -> Result<Vec<u8>, PicOxError> {
let start_time = std::time::Instant::now();
let top_text = format!("{} {}", motivation.action, motivation.goal);
let mut wand = MagickWand::new();
let mut border_wand = PixelWand::new();
wand.read_image_blob(motivation_image_blob)?;
border_wand.set_color(&motivation.border_color)?;
let width = wand.get_image_width();
let border = width / 100;
wand.border_image(
&border_wand,
border,
border,
magick_rust::bindings::CompositeOperator_OverCompositeOp.into(),
)?;
border_wand.set_color("black")?;
let width = wand.get_image_width();
let border = width * 20 / 100;
wand.border_image(
&border_wand,
border,
border,
magick_rust::bindings::CompositeOperator_OverCompositeOp.into(),
)?;
let mut text_wand = DrawingWand::new();
let mut text_color_wand = PixelWand::new();
text_color_wand.set_color("white")?;
text_wand.set_fill_color(&text_color_wand);
text_wand.set_text_alignment(magick_rust::bindings::AlignType_CenterAlign);
text_wand.set_font("DejaVu-Serif")?;
if let Some(bottom_text) = &motivation.tagline {
let text_pos_x = wand.get_image_width() as f64 / 2.0;
let top_text_pos_y =
wand.get_image_height() as f64 - (wand.get_image_height() as f64 * 0.06);
let top_text_size = 0.08 * (wand.get_image_width() as f64);
text_wand.set_font_size(top_text_size);
wand.annotate_image(&text_wand, text_pos_x, top_text_pos_y, 0.0, &top_text)?;
let bot_text_pos_y =
wand.get_image_height() as f64 - (wand.get_image_height() as f64 * 0.03);
let bot_text_size = 0.03 * (wand.get_image_width() as f64);
text_wand.set_font_size(bot_text_size);
wand.annotate_image(&text_wand, text_pos_x, bot_text_pos_y, 0.0, bottom_text)?;
} else {
let font_size = 0.07 * (wand.get_image_width() as f64);
let text_pos_x = wand.get_image_width() as f64 / 2.0;
let text_pos_y = wand.get_image_height() as f64 - ((border / 2) as f64) + font_size * 0.33;
text_wand.set_font_size(font_size);
wand.annotate_image(&text_wand, text_pos_x, text_pos_y, 0.0, &top_text)?;
}
let img = wand.write_image_blob("jpeg")?;
let dur = std::time::Instant::now() - start_time;
info!("Generated motivation in {} seconds", dur.as_secs_f64());
Ok(img)
}

View File

@ -1,5 +1,6 @@
mod api;
mod config;
mod img_manipulation;
mod model;
mod state;
mod storage_manager;

View File

@ -1,4 +1,10 @@
use crate::api::models::{AlbumQuery, ImageQuery, ImageSort, PicOxError};
use crate::model::album::Album;
use chrono::{DateTime, Utc};
use j_db::database::Database;
use j_db::model::JdbModel;
use rand::prelude::SliceRandom;
use rand::thread_rng;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use url::Url;
@ -14,7 +20,7 @@ pub struct Image {
pub filename: String,
pub tags: Vec<String>,
pub create_date: DateTime<Utc>,
pub link: String,
pub link: Url,
pub created_by: u64,
pub storage_location: StorageLocation,
pub album: u64,
@ -35,13 +41,87 @@ impl Image {
filename: filename.to_string(),
tags,
create_date: Utc::now(),
link: link.to_string(),
link,
created_by,
storage_location,
album,
id: None,
}
}
pub fn query_image(db: &Database, image_query: &ImageQuery) -> Result<Vec<Self>, PicOxError> {
let album_id = if let Some(album) = &image_query.album {
Some(
Album::find_album_by_query(
db,
AlbumQuery {
album_name: Some(album.to_string()),
},
)
.first()
.ok_or(PicOxError::AlbumNotFound)?
.id()
.unwrap(),
)
} else {
None
};
let mut images: Vec<Image> = db
.filter(|_, img: &Image| {
if let Some(album_id) = album_id {
if img.album != album_id {
return false;
}
}
if !image_query.image_type.is_empty() {
let path = img.link.to_file_path().unwrap();
let ext = path.extension().unwrap().to_str().unwrap();
if !image_query.image_type.contains(&ext.to_string())
{
return false;
}
}
if !image_query.tags.is_empty() {
let mut found = false;
for tag in &image_query.tags {
if img.tags.contains(tag) {
found = true;
break;
}
}
if !found {
return false;
}
}
true
})?
.collect();
match image_query.order {
ImageSort::Random => {
images.shuffle(&mut thread_rng());
}
ImageSort::DateAscending => {
images.sort_by(|img_a, img_b| img_a.create_date.cmp(&img_b.create_date))
}
ImageSort::DateDescending => {
images.sort_by(|img_a, img_b| img_b.create_date.cmp(&img_a.create_date))
}
ImageSort::None => {}
}
if images.len() > image_query.limit {
images.drain(image_query.limit..);
}
Ok(images)
}
}
impl j_db::model::JdbModel for Image {

View File

@ -159,4 +159,17 @@ impl StorageManager {
Ok(db.insert::<Image>(img).unwrap())
}
pub async fn get_image(&mut self, image: &Image) -> Result<Vec<u8>, StoreError> {
match &image.storage_location {
StorageLocation::FileStore { path } => Ok(tokio::fs::read(path).await?),
StorageLocation::Link => Ok(reqwest::get(image.link.clone())
.await
.unwrap()
.bytes()
.await
.unwrap()
.to_vec()),
}
}
}