Fix #11 and Cleanup dependencies
This commit is contained in:
parent
6e301601f9
commit
8540e09ba7
20
Cargo.toml
20
Cargo.toml
@ -9,17 +9,25 @@ edition = "2018"
|
||||
[dependencies]
|
||||
actix-web = "2.0"
|
||||
actix-rt = "1.1.1"
|
||||
actix-files = "0.2.1"
|
||||
actix-files = "0.2.2"
|
||||
|
||||
reqwest = "0.10.4"
|
||||
|
||||
meilisearch-sdk = "0.1.4"
|
||||
|
||||
handlebars = { version = "3.0.0", features = ["dir_source"] }
|
||||
serde_json = "1.0"
|
||||
serde = {version="1.0", features=["derive"]}
|
||||
meilisearch-sdk = "0.1.4"
|
||||
human_format = "1.0.3"
|
||||
reqwest = "0.10.4"
|
||||
|
||||
dotenv = "0.15"
|
||||
log = "0.4.8"
|
||||
env_logger = "0.7.1"
|
||||
|
||||
mongodb = "1.0.0"
|
||||
bson = "1.0.0"
|
||||
|
||||
futures = "0.3.5"
|
||||
dotenv = "0.15"
|
||||
pulldown-cmark = "0.7.1"
|
||||
futures-timer = "3.0.2"
|
||||
|
||||
pulldown-cmark = "0.7.1"
|
||||
human_format = "1.0.3"
|
||||
36
src/helpers/equals.rs
Normal file
36
src/helpers/equals.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use handlebars::*;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct EqualsHelper;
|
||||
|
||||
impl HelperDef for EqualsHelper {
|
||||
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 a = h
|
||||
.param(0)
|
||||
.map(|v| v.value().as_object().unwrap())
|
||||
.ok_or_else(|| RenderError::new("Parameter not found!"))?;
|
||||
|
||||
let b = h
|
||||
.param(1)
|
||||
.map(|v| v.value().as_object().unwrap())
|
||||
.ok_or_else(|| RenderError::new("Parameter not found!"))?;
|
||||
|
||||
let tmpl = if a == b {
|
||||
h.template()
|
||||
} else {
|
||||
h.inverse()
|
||||
};
|
||||
|
||||
match tmpl {
|
||||
Some(ref t) => t.render(r, ctx, rc, out),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,13 @@
|
||||
mod contains;
|
||||
mod format_human;
|
||||
mod equals;
|
||||
|
||||
use handlebars::*;
|
||||
|
||||
pub fn register_helpers(handlebars: &mut Handlebars) {
|
||||
handlebars.register_helper("contains", Box::new(contains::ContainsHelper));
|
||||
handlebars.register_helper("format", Box::new(format_human::HumanFormatHelper));
|
||||
|
||||
//This helper is not used yet, but could be useful in many circumstances
|
||||
handlebars.register_helper("equals", Box::new(equals::EqualsHelper));
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@ use std::collections::{HashMap, VecDeque};
|
||||
use std::error::Error;
|
||||
|
||||
use crate::database::*;
|
||||
use futures_timer::Delay;
|
||||
use futures::TryFutureExt;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -175,10 +178,10 @@ TODO This method needs a lot of refactoring. Here's a list of changes that need
|
||||
- Remove code fragment duplicates
|
||||
*/
|
||||
|
||||
pub async fn index_mods(client: mongodb::Client) -> Result<(), Box<dyn Error>>{
|
||||
pub async fn index_mods(db: mongodb::Client) -> Result<(), Box<dyn Error>>{
|
||||
let mut docs_to_add: Vec<SearchMod> = vec![];
|
||||
|
||||
docs_to_add.append(&mut index_database(client).await?);
|
||||
docs_to_add.append(&mut index_database(db.clone()).await?);
|
||||
//docs_to_add.append(&mut index_curseforge(1, 400000).await?);
|
||||
|
||||
//Write Indexes
|
||||
|
||||
@ -224,8 +224,6 @@ function handleSearch(index) {
|
||||
|
||||
if(input.value.length > 0) {
|
||||
queryString += "?q=" + encodeURIComponent(input.value).replace(/%20/g,'+');
|
||||
} else {
|
||||
queryString += "?q={}{}{}"
|
||||
}
|
||||
|
||||
let filterString = "";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user