You've already forked AstralRinth
forked from didirus/AstralRinth
Static content serving from non-root routes
This commit is contained in:
@@ -13,15 +13,17 @@ impl HelperDef for HumanFormatHelper {
|
||||
_rc: &mut RenderContext<'reg, 'rc>,
|
||||
out: &mut dyn Output,
|
||||
) -> HelperResult {
|
||||
let param = h.param(0).and_then(|v| v.value().as_str()).unwrap_or("0.0");
|
||||
let param = h.param(0).and_then(|v| v.value().as_f64()).unwrap_or(0.0);
|
||||
|
||||
if param.len() > 3 {
|
||||
let mut formatted = human_format::Formatter::new().format(param.parse().unwrap());
|
||||
let string = ¶m.to_string();
|
||||
|
||||
if string.len() > 3 {
|
||||
let mut formatted = human_format::Formatter::new().format(param);
|
||||
formatted.retain(|c| !c.is_whitespace());
|
||||
|
||||
out.write(formatted.to_uppercase().as_ref())?;
|
||||
} else {
|
||||
out.write(param)?;
|
||||
out.write(string)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -46,7 +46,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.service(routes::index_get)
|
||||
.service(routes::search_post)
|
||||
.service(routes::search_get)
|
||||
.service(routes::mod_editor_get)
|
||||
.service(routes::mod_page_get)
|
||||
})
|
||||
.bind("127.0.0.1:8000")?
|
||||
.run()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
mod index;
|
||||
mod mod_editor;
|
||||
mod mod_page;
|
||||
mod search;
|
||||
|
||||
pub use self::mod_editor::mod_editor_get;
|
||||
pub use self::mod_page::mod_page_get;
|
||||
|
||||
pub use self::search::index_mods;
|
||||
pub use self::search::search_get;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use actix_web::{get, web, HttpResponse};
|
||||
use handlebars::*;
|
||||
|
||||
#[get("modeditor")]
|
||||
pub async fn mod_editor_get(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
|
||||
#[get("mod/testmod")]
|
||||
pub async fn mod_page_get(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
|
||||
let data = json!({
|
||||
"name": "Handlebars"
|
||||
});
|
||||
@@ -174,8 +174,8 @@ TODO This method needs a lot of refactoring. Here's a list of changes that need
|
||||
pub async fn index_mods(client: 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_curseforge().await);
|
||||
/*docs_to_add.append(&mut index_database(client).await?);
|
||||
docs_to_add.append(&mut index_curseforge().await?);*/
|
||||
|
||||
//Write Indexes
|
||||
//Relevance Index
|
||||
@@ -252,7 +252,7 @@ async fn index_database(client: mongodb::Client) -> Result<Vec<SearchMod>, Box<
|
||||
versions: mod_game_versions,
|
||||
downloads: result.downloads,
|
||||
page_url: "".to_string(),
|
||||
icon_url: "".to_string(),
|
||||
icon_url: result.icon_path,
|
||||
author_url: "".to_string(),
|
||||
date_created: "".to_string(),
|
||||
created: 0,
|
||||
|
||||
Reference in New Issue
Block a user