1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-04-25 13:57:45 +00:00

Add back support for writing the character HTML file

Now it's written into the ZIP.
This commit is contained in:
Joshua Goins 2024-10-31 18:20:45 -04:00
parent 27d422cd78
commit 6b9922fbdf
2 changed files with 11 additions and 17 deletions

View file

@ -5,7 +5,7 @@ use std::io;
/// Writes a visual HTML for `char_data` to `file_path`.
/// This vaguely represents Lodestone and designed to visually check your character data.
pub fn write_html(char_data: &CharacterData, file_path: &str) -> io::Result<()> {
pub fn create_html(char_data: &CharacterData) -> String {
let mut env = Environment::new();
env.add_template(
"character.html",
@ -13,7 +13,7 @@ pub fn write_html(char_data: &CharacterData, file_path: &str) -> io::Result<()>
)
.unwrap();
let template = env.get_template("character.html").unwrap();
let character_html = template
template
.render(context! {
name => char_data.name,
world => char_data.world,
@ -24,7 +24,5 @@ pub fn write_html(char_data: &CharacterData, file_path: &str) -> io::Result<()>
nameday => char_data.nameday,
city_state => char_data.city_state
})
.unwrap();
write(file_path, &character_html)
.unwrap()
}

View file

@ -14,7 +14,7 @@ use wasm_bindgen::prelude::wasm_bindgen;
use zip::write::SimpleFileOptions;
use zip::ZipWriter;
use crate::downloader::download;
use crate::html::write_html;
use crate::html::{create_html, write_html};
use crate::parser::parse_search;
#[cfg(target_family = "wasm")]
use base64::prelude::*;
@ -127,22 +127,18 @@ pub async extern fn archive_character(character_name: &str, use_dalamud: bool) -
char_data.player_commendations = package.player_commendations; // TODO: fetch from the lodestone?
}
let html = create_html(
&char_data
);
zip.start_file("character.html", options);
zip.write_all(html.as_ref());
zip.finish();
return buf;
/*write_html(
&char_data,
&character_folder
.join("character.html")
.into_os_string()
.into_string()
.unwrap(),
)
.expect("Failed to write the character HTML file.");*/
}
/// Archives the character named `character_name` and converts the ZIP file to Base64. Useful for downloading via data URIs.
#[cfg(target_family = "wasm")]
#[wasm_bindgen]