You've already forked AstralRinth
forked from didirus/AstralRinth
Curseforge Indexer
This commit is contained in:
1
.idea/dictionaries/geometrically.xml
generated
1
.idea/dictionaries/geometrically.xml
generated
@@ -1,6 +1,7 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="geometrically">
|
||||
<words>
|
||||
<w>curseforge</w>
|
||||
<w>serde</w>
|
||||
<w>tantivy</w>
|
||||
</words>
|
||||
|
||||
247
Cargo.lock
generated
247
Cargo.lock
generated
@@ -30,8 +30,11 @@ dependencies = [
|
||||
"futures",
|
||||
"http",
|
||||
"log",
|
||||
"rustls",
|
||||
"tokio-rustls",
|
||||
"trust-dns-proto",
|
||||
"trust-dns-resolver",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -65,8 +68,9 @@ dependencies = [
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-threadpool",
|
||||
"actix-tls",
|
||||
"actix-utils",
|
||||
"base64",
|
||||
"base64 0.11.0",
|
||||
"bitflags",
|
||||
"brotli2",
|
||||
"bytes",
|
||||
@@ -212,6 +216,10 @@ dependencies = [
|
||||
"either",
|
||||
"futures",
|
||||
"log",
|
||||
"rustls",
|
||||
"tokio-rustls",
|
||||
"webpki",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -261,6 +269,7 @@ dependencies = [
|
||||
"net2",
|
||||
"pin-project",
|
||||
"regex 1.3.7",
|
||||
"rustls",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@@ -336,7 +345,7 @@ dependencies = [
|
||||
"actix-http",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"base64",
|
||||
"base64 0.11.0",
|
||||
"bytes",
|
||||
"derive_more",
|
||||
"futures-core",
|
||||
@@ -344,6 +353,7 @@ dependencies = [
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"rand",
|
||||
"rustls",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@@ -371,6 +381,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.11.0"
|
||||
@@ -424,6 +443,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
@@ -596,6 +621,7 @@ dependencies = [
|
||||
"diesel",
|
||||
"dotenv",
|
||||
"handlebars",
|
||||
"human_format",
|
||||
"meilisearch-sdk",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@@ -681,9 +707,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8"
|
||||
checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@@ -691,9 +717,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a"
|
||||
checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
@@ -708,15 +734,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6"
|
||||
checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7"
|
||||
checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
@@ -726,21 +752,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6"
|
||||
checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27"
|
||||
checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5"
|
||||
checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@@ -749,6 +778,7 @@ dependencies = [
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project",
|
||||
"pin-utils",
|
||||
"proc-macro-hack",
|
||||
"proc-macro-nested",
|
||||
@@ -864,6 +894,12 @@ version = "1.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
|
||||
|
||||
[[package]]
|
||||
name = "human_format"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86cce260d758a9aa3d7c4b99d55c815a540f8a37514ba6046ab6be402a157cb0"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.0"
|
||||
@@ -911,6 +947,15 @@ version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
@@ -992,15 +1037,18 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
|
||||
[[package]]
|
||||
name = "meilisearch-sdk"
|
||||
version = "0.1.1"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6873f8f9b90d8d451bf6e8af732ee1536a5fb69488eeef7fee4eda79ea0369fe"
|
||||
checksum = "4aaa1ca3bf32c1839814737b37dcf29021c9d2bec66ae36c339c6a3a4ed61ae8"
|
||||
dependencies = [
|
||||
"log",
|
||||
"minreq",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"urlencoding",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1132,6 +1180,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
@@ -1391,12 +1445,40 @@ dependencies = [
|
||||
"quick-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.16.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e"
|
||||
dependencies = [
|
||||
"base64 0.10.1",
|
||||
"log",
|
||||
"ring",
|
||||
"sct",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.4"
|
||||
@@ -1418,6 +1500,16 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.107"
|
||||
@@ -1513,6 +1605,12 @@ dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.18"
|
||||
@@ -1594,6 +1692,18 @@ dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3068d891551949b37681724d6b73666787cc63fa8e255c812a41d2513aff9775"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"rustls",
|
||||
"tokio",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.2.0"
|
||||
@@ -1718,6 +1828,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.1.1"
|
||||
@@ -1807,6 +1923,101 @@ version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a369c5e1dfb7569e14d62af4da642a3cbc2f9a3652fe586e26ac22222aa4b04"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki"
|
||||
version = "0.21.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b"
|
||||
dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "0.4.0"
|
||||
|
||||
@@ -7,14 +7,15 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0"
|
||||
actix-web = { version = "2.0", features = ["rustls"]}
|
||||
actix-rt = "1.1.1"
|
||||
handlebars = { version = "3.0.0", features = ["dir_source"] }
|
||||
serde_json = "1.0"
|
||||
serde_derive = "1.0.107"
|
||||
serde = {version="1.0", features=["derive"]}
|
||||
meilisearch-sdk = "0.1.1"
|
||||
meilisearch-sdk = "0.1.3"
|
||||
actix-files = "0.2.1"
|
||||
diesel = { version = "1.4.4", features = ["postgres", "serde_json", "chrono"] }
|
||||
dotenv = "0.9.0"
|
||||
chrono = "0.4.11"
|
||||
human_format = "1.0.3"
|
||||
|
||||
18
src/helpers/format_human.rs
Normal file
18
src/helpers/format_human.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
extern crate human_format;
|
||||
use handlebars::*;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct HumanFormatHelper;
|
||||
|
||||
impl HelperDef for HumanFormatHelper {
|
||||
fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, r: &'reg Handlebars<'_>, ctx: &'rc Context, rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> HelperResult {
|
||||
let param = h.param(0).and_then(|v| v.value().as_f64()).unwrap_or(0.0);
|
||||
|
||||
let mut formatted = human_format::Formatter::new().format(param);
|
||||
formatted.retain(|c| !c.is_whitespace());
|
||||
|
||||
out.write(formatted.to_uppercase().as_ref())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
mod contains;
|
||||
mod format_human;
|
||||
|
||||
pub use contains::ContainsHelper;
|
||||
pub use contains::ContainsHelper;
|
||||
pub use format_human::HumanFormatHelper;
|
||||
@@ -19,6 +19,7 @@ async fn main() -> std::io::Result<()> {
|
||||
let mut handlebars = Handlebars::new();
|
||||
|
||||
handlebars.register_helper("contains", Box::new(helpers::ContainsHelper));
|
||||
handlebars.register_helper("format", Box::new(helpers::HumanFormatHelper));
|
||||
handlebars
|
||||
.register_templates_directory(".hbs", "./templates")
|
||||
.unwrap();
|
||||
|
||||
@@ -8,14 +8,58 @@ use actix_web::client;
|
||||
|
||||
use crate::database::*;
|
||||
use diesel::prelude::*;
|
||||
use actix_web::client::Connector;
|
||||
use meilisearch_sdk::settings::Settings;
|
||||
use meilisearch_sdk::progress::SettingsUpdate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Attachment {
|
||||
url: String,
|
||||
isDefault: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Category {
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Author {
|
||||
name: String,
|
||||
url: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct CurseVersion {
|
||||
gameVersion: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct CurseForgeMod {
|
||||
id: i32,
|
||||
name: String,
|
||||
authors: Vec<Author>,
|
||||
attachments: Vec<Attachment>,
|
||||
websiteUrl: String,
|
||||
summary: String,
|
||||
downloadCount: f32,
|
||||
categories: Vec<Category>,
|
||||
gameVersionLatestFiles: Vec<CurseVersion>
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct SearchMod {
|
||||
mod_id: i32,
|
||||
author: String,
|
||||
title: String,
|
||||
description: String,
|
||||
keywords: Vec<String>,
|
||||
versions: Vec<String>,
|
||||
downloads: i32,
|
||||
page_url: String,
|
||||
icon_url: String,
|
||||
author_url: String,
|
||||
empty: String,
|
||||
}
|
||||
|
||||
impl Document for SearchMod {
|
||||
@@ -65,9 +109,9 @@ fn search(web::Query(info): web::Query<SearchRequest>) -> Vec<SearchMod> {
|
||||
let mut search_query = "".to_string();
|
||||
let mut filters = "".to_string();
|
||||
|
||||
|
||||
if let Some(q) = info.q {
|
||||
search_query = q;
|
||||
match info.q {
|
||||
Some(q) => search_query = q,
|
||||
None => search_query = "empty".to_string()
|
||||
}
|
||||
|
||||
if let Some(f) = info.f {
|
||||
@@ -100,7 +144,7 @@ pub async fn index_mods(conn : PgConnection) {
|
||||
let mut mods_index = client.get_or_create("mods").unwrap();
|
||||
|
||||
let results = mods.load::<Mod>(&conn).expect("Error loading mods!");
|
||||
let mut docs_to_add = vec![];
|
||||
let mut docs_to_add : Vec<SearchMod> = vec![];
|
||||
|
||||
for result in results {
|
||||
let mod_versions = versions.filter(mod_id.eq(result.id)).load::<Version>(&conn).expect("Error loading versions!");
|
||||
@@ -113,25 +157,142 @@ pub async fn index_mods(conn : PgConnection) {
|
||||
|
||||
docs_to_add.push(SearchMod {
|
||||
mod_id: result.id,
|
||||
author: result.author,
|
||||
title: result.title,
|
||||
description: result.description,
|
||||
keywords: result.categories,
|
||||
versions: mod_game_versions
|
||||
versions: mod_game_versions,
|
||||
downloads: result.downloads,
|
||||
page_url: "".to_string(),
|
||||
icon_url: "".to_string(),
|
||||
author_url: "".to_string(),
|
||||
empty: String::from("empty")
|
||||
});
|
||||
}
|
||||
|
||||
let mut client = client::Client::default();
|
||||
let mut client = aws::Client::default();
|
||||
|
||||
let mut response = client.get("https://addons-ecs.forgesvc.net/api/v2/addon/search?categoryId=0&gameId=432&index=0&pageSize=100§ionId=6&sort=5")
|
||||
let mut response = client.get("https://addons-ecs.forgesvc.net/api/v2/addon/search?categoryId=0&gameId=432&index=0&pageSize=25§ionId=6&sort=5")
|
||||
.header("User-Agent", "Actix-web")
|
||||
.header("Content-Type", "application/json")
|
||||
.send().await.unwrap();
|
||||
|
||||
println!("{:?}", response);
|
||||
|
||||
let body = response.body().await.unwrap();
|
||||
println!("Downloaded: {:?} bytes", body);
|
||||
println!("{:?}", body.len());
|
||||
|
||||
let curseforge_mods : Vec<CurseForgeMod> = serde_json::from_str(std::str::from_utf8(&body).unwrap()).unwrap();
|
||||
|
||||
for curseforge_mod in curseforge_mods {
|
||||
let mut mod_game_versions = vec![];
|
||||
for version in curseforge_mod.gameVersionLatestFiles {
|
||||
mod_game_versions.push(version.gameVersion);
|
||||
}
|
||||
|
||||
let mut mod_categories = vec![];
|
||||
for category in curseforge_mod.categories {
|
||||
match &category.name[..] {
|
||||
"World Gen" => mod_categories.push(String::from("worldgen")),
|
||||
"Biomes" => mod_categories.push(String::from("worldgen")),
|
||||
"Ores and Resources" => mod_categories.push(String::from("worldgen")),
|
||||
"Structures" => mod_categories.push(String::from("worldgen")),
|
||||
"Dimensions" => mod_categories.push(String::from("worldgen")),
|
||||
"Mobs" => mod_categories.push(String::from("worldgen")),
|
||||
"Technology" => mod_categories.push(String::from("technology")),
|
||||
"Processing" => mod_categories.push(String::from("technology")),
|
||||
"Player Transport" => mod_categories.push(String::from("technology")),
|
||||
"Energy, Fluid, and Item Transport" => mod_categories.push(String::from("technology")),
|
||||
"Farming" => mod_categories.push(String::from("technology")),
|
||||
"Energy" => mod_categories.push(String::from("technology")),
|
||||
"Redstone" => mod_categories.push(String::from("technology")),
|
||||
"Genetics" => mod_categories.push(String::from("technology")),
|
||||
"Magic" => mod_categories.push(String::from("magic")),
|
||||
"Storage" => mod_categories.push(String::from("technology")),
|
||||
"API and Library" => mod_categories.push(String::from("library")),
|
||||
"Adventure and RPG" => mod_categories.push(String::from("adventure")),
|
||||
"Map and Information" => mod_categories.push(String::from("adventure")),
|
||||
"Cosmetic" => mod_categories.push(String::from("decoration")),
|
||||
"Addons" => mod_categories.push(String::from("misc")),
|
||||
"Thermal Expansion" => mod_categories.push(String::from("misc")),
|
||||
"Tinker's Construct" => mod_categories.push(String::from("misc")),
|
||||
"Industrial Craft" => mod_categories.push(String::from("misc")),
|
||||
"Thaumcraft" => mod_categories.push(String::from("misc")),
|
||||
"Buildcraft" => mod_categories.push(String::from("misc")),
|
||||
"Forestry" => mod_categories.push(String::from("misc")),
|
||||
"Blood Magic" => mod_categories.push(String::from("misc")),
|
||||
"Lucky Blocks" => mod_categories.push(String::from("misc")),
|
||||
"Applied Energistics 2" => mod_categories.push(String::from("misc")),
|
||||
"CraftTweaker" => mod_categories.push(String::from("misc")),
|
||||
"Miscellaneous" => mod_categories.push(String::from("misc")),
|
||||
"Armor, Tools, and Weapons" => mod_categories.push(String::from("technology")),
|
||||
"Server Utility" => mod_categories.push(String::from("utility")),
|
||||
"Fabric" => mod_categories.push(String::from("fabric")),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
let mut mod_attachments = curseforge_mod.attachments;
|
||||
mod_attachments.retain(|x| x.isDefault);
|
||||
docs_to_add.push(SearchMod {
|
||||
mod_id: curseforge_mod.id,
|
||||
author: (&curseforge_mod.authors[0].name).to_string(),
|
||||
title: curseforge_mod.name,
|
||||
description: curseforge_mod.summary,
|
||||
keywords: mod_categories,
|
||||
versions: mod_game_versions,
|
||||
downloads: curseforge_mod.downloadCount as i32,
|
||||
page_url: curseforge_mod.websiteUrl,
|
||||
icon_url: (mod_attachments[0].url).to_string(),
|
||||
author_url: (&curseforge_mod.authors[0].url).to_string(),
|
||||
empty: String::from("empty")
|
||||
})
|
||||
}
|
||||
|
||||
println!("{:?}", docs_to_add);
|
||||
mods_index.add_documents(docs_to_add, Some("mod_id")).unwrap();
|
||||
|
||||
//Write Settings
|
||||
let settings = mods_index.get_settings().unwrap();
|
||||
|
||||
let mut ranking_rules = vec![
|
||||
"typo".to_string(),
|
||||
"words".to_string(),
|
||||
"proximity".to_string(),
|
||||
"attribute".to_string(),
|
||||
"wordsPosition".to_string(),
|
||||
"exactness".to_string(),
|
||||
"desc(downloads)".to_string()
|
||||
];
|
||||
|
||||
let displayed_attributes = vec![
|
||||
"mod_id".to_string(),
|
||||
"author".to_string(),
|
||||
"title".to_string(),
|
||||
"description".to_string(),
|
||||
"keywords".to_string(),
|
||||
"versions".to_string(),
|
||||
"downloads".to_string(),
|
||||
"page_url".to_string(),
|
||||
"icon_url".to_string(),
|
||||
"author_url".to_string(),
|
||||
"empty".to_string(),
|
||||
];
|
||||
|
||||
let searchable_attributes = vec![
|
||||
"author".to_string(),
|
||||
"title".to_string(),
|
||||
"description".to_string(),
|
||||
"keywords".to_string(),
|
||||
"versions".to_string(),
|
||||
"empty".to_string(),
|
||||
];
|
||||
|
||||
let write_settings = Settings::new()
|
||||
.with_displayed_attributes(displayed_attributes)
|
||||
.with_searchable_attributes(searchable_attributes)
|
||||
.with_accept_new_fields(settings.accept_new_fields.unwrap())
|
||||
.with_stop_words(settings.stop_words.unwrap())
|
||||
.with_synonyms(settings.synonyms.unwrap())
|
||||
.with_ranking_rules(ranking_rules);
|
||||
|
||||
mods_index.set_settings(&write_settings).unwrap();
|
||||
}
|
||||
@@ -119,7 +119,7 @@
|
||||
.mod-description div {
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
padding: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.mod-description img {
|
||||
|
||||
@@ -179,6 +179,7 @@
|
||||
}
|
||||
|
||||
.result-image {
|
||||
object-fit: scale-down;
|
||||
padding: 0 10px 0 5px;
|
||||
}
|
||||
|
||||
@@ -196,6 +197,17 @@
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.result-name {
|
||||
text-decoration: none;
|
||||
color: #0b75d8;
|
||||
}
|
||||
|
||||
.result-author {
|
||||
text-decoration: none;
|
||||
color: #2f92d8;
|
||||
}
|
||||
|
||||
.result-badges {
|
||||
@@ -278,4 +290,13 @@
|
||||
.cursed-badge {
|
||||
color: white;
|
||||
background-color: palevioletred;
|
||||
}
|
||||
|
||||
.cursed-badge img {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.misc-badge {
|
||||
color: white;
|
||||
background-color: deepskyblue;
|
||||
}
|
||||
1
static/images/icon/misc.svg
Normal file
1
static/images/icon/misc.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m491 128.984v254.034c0 12.6-7.252 24.078-18.638 29.498l-202.286 96.303c-4.448 2.124-9.268 3.181-14.076 3.181s-9.617-1.057-14.065-3.181l-202.296-96.303c-11.387-5.42-18.639-16.898-18.639-29.498v-254.034c0-6.546 1.952-12.788 5.441-18.038 3.206-4.858 7.731-8.866 13.204-11.459l202.29-96.31c8.897-4.237 19.234-4.237 28.142 0l202.29 96.31c5.473 2.592 9.987 6.601 13.193 11.459 3.488 5.25 5.44 11.491 5.44 18.038z" fill="#e53935"/><path d="m485.559 110.946c-3.206-4.858-7.72-8.866-13.193-11.459l-202.29-96.31c-8.908-4.237-19.244-4.237-28.142 0l-1.39.662 200.9 95.648c5.473 2.592 9.988 6.601 13.193 11.459 3.489 5.25 5.441 11.491 5.441 18.038v254.034c0 12.6-7.252 24.078-18.638 29.498l-200.896 95.641 1.39.662c4.449 2.124 9.258 3.181 14.066 3.181s9.628-1.057 14.076-3.181l202.286-96.303c11.386-5.42 18.638-16.898 18.638-29.498v-254.034c0-6.547-1.952-12.788-5.441-18.038z" fill="#d32f2f"/><path d="m256 220.239v291.761c-4.808 0-9.617-1.057-14.065-3.181l-202.296-96.303c-11.387-5.42-18.639-16.898-18.639-29.498v-254.034c0-6.546 1.952-12.788 5.441-18.038z" fill="#f44336"/><path d="m491 128.984v254.041c0 12.461-7.109 23.843-18.296 29.333-.109.054-.229.109-.338.163l-202.29 96.299c-4.448 2.123-9.268 3.18-14.076 3.18v-291.761l229.559-109.293c3.489 5.25 5.441 11.491 5.441 18.038z" fill="#d32f2f"/><path d="m485.559 110.946-25.994 12.376c.326 1.851.513 3.741.513 5.662v254.041c0 12.461-7.109 23.843-18.296 29.333-.109.054-.229.109-.338.163l-185.444 88.28v11.199c4.808 0 9.628-1.057 14.076-3.181l202.29-96.299c.109-.054.229-.109.338-.163 11.187-5.49 18.296-16.872 18.296-29.333v-254.04c0-6.547-1.952-12.788-5.441-18.038z" fill="#c62828"/><g fill="#f1f1f1"><ellipse cx="389.64" cy="306.507" rx="26.736" ry="19.708" transform="matrix(.134 -.991 .991 .134 33.735 651.612)"/><ellipse cx="190.492" cy="263.252" rx="19.607" ry="26.736" transform="matrix(.999 -.055 .055 .999 -14.066 10.775)"/><ellipse cx="78.302" cy="360.193" rx="19.607" ry="26.736" transform="matrix(.999 -.055 .055 .999 -19.517 4.803)"/><ellipse cx="161.083" cy="104.225" rx="26.736" ry="19.607" transform="matrix(.999 -.055 .055 .999 -5.442 8.935)"/><ellipse cx="253.668" cy="58.477" rx="26.736" ry="19.607" transform="matrix(.999 -.055 .055 .999 -2.81 13.914)"/><ellipse cx="350.609" cy="107.492" rx="26.736" ry="19.607" transform="matrix(.999 -.055 .055 .999 -5.338 19.27)"/><ellipse cx="260.203" cy="149.972" rx="26.736" ry="19.607" transform="matrix(.999 -.055 .055 .999 -7.788 14.406)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -9,6 +9,7 @@ let category_inputs = {
|
||||
"library": false,
|
||||
"worldgen": false,
|
||||
"cursed": false,
|
||||
"misc": false,
|
||||
"forge": false,
|
||||
"fabric": false,
|
||||
}
|
||||
@@ -141,9 +142,14 @@ function activateVersion(element) {
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
let safeName = encodeURIComponent(input.value).replace(/%20/g,'+');
|
||||
let queryString = "search";
|
||||
|
||||
if(input.value.length > 0) {
|
||||
queryString += "?q=" + encodeURIComponent(input.value).replace(/%20/g,'+');
|
||||
} else {
|
||||
queryString += "?q=empty"
|
||||
}
|
||||
|
||||
let queryString = "search?q=" + safeName;
|
||||
let filterString = "";
|
||||
let versionString = "";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
<link href="static/css/main.css" rel="stylesheet" type="text/css">
|
||||
<link href="static/css/search.css" rel="stylesheet" type="text/css">
|
||||
<link href="static/css/normalize.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<title>Search</title>
|
||||
</head>
|
||||
@@ -72,6 +73,10 @@
|
||||
<img alt="cursed" src="static/images/icon/cursed.png" class="result-image"/>
|
||||
<p>CURSED</p>
|
||||
</a>
|
||||
<a class="misc-badge category-badge" id="misc" onclick="activateCategory(this)">
|
||||
<img alt="misc" src="static/images/icon/misc.svg" class="result-image"/>
|
||||
<p>MISC</p>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="categories">
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{{#each results}}
|
||||
<div class="result gray-border rounded-border">
|
||||
<img src="..." width="75px" height="75px" class="result-image"/>
|
||||
<img src="{{this.icon_url}}" width="75px" height="75px" class="result-image"/>
|
||||
<div class="result-info">
|
||||
<div class="result-title">
|
||||
<h2>{{this.title}}</h2>
|
||||
<p class="muted"> by {{this.author}}</p>
|
||||
<a class="result-name" href="{{this.page_url}}"><h2>{{this.title}}</h2></a>
|
||||
<p class="muted"> by <a class="result-author" href="{{this.author_url}}">{{this.author}}</a></p>
|
||||
</div>
|
||||
<p>{{this.description}}</p>
|
||||
<div class="mod-info">
|
||||
<img src="static/images/icon/download.svg" alt="download" title="Downloads"/>
|
||||
<p title="Downloads">1.1M</p>
|
||||
<p title="Downloads">{{format this.downloads}}</p>
|
||||
|
||||
<img src="static/images/icon/updated.svg" alt="updated" title="Last Updated"/>
|
||||
<p title="Last Updated">5/13/20</p>
|
||||
@@ -76,6 +76,12 @@
|
||||
<p>CURSED</p>
|
||||
</div>
|
||||
{{/contains}}
|
||||
{{#contains this.keywords "misc"}}
|
||||
<div class="misc-badge result-badge">
|
||||
<img alt="misc" src="static/images/icon/misc.svg" class="result-image"/>
|
||||
<p>MISC</p>
|
||||
</div>
|
||||
{{/contains}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
Reference in New Issue
Block a user