mirror of
https://github.com/redstrate/Auracite.git
synced 2025-04-26 06:17:44 +00:00
Add back support for writing the character HTML file
Now it's written into the ZIP.
This commit is contained in:
parent
27d422cd78
commit
6b9922fbdf
2 changed files with 11 additions and 17 deletions
|
@ -5,7 +5,7 @@ use std::io;
|
||||||
|
|
||||||
/// Writes a visual HTML for `char_data` to `file_path`.
|
/// Writes a visual HTML for `char_data` to `file_path`.
|
||||||
/// This vaguely represents Lodestone and designed to visually check your character data.
|
/// 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();
|
let mut env = Environment::new();
|
||||||
env.add_template(
|
env.add_template(
|
||||||
"character.html",
|
"character.html",
|
||||||
|
@ -13,7 +13,7 @@ pub fn write_html(char_data: &CharacterData, file_path: &str) -> io::Result<()>
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let template = env.get_template("character.html").unwrap();
|
let template = env.get_template("character.html").unwrap();
|
||||||
let character_html = template
|
template
|
||||||
.render(context! {
|
.render(context! {
|
||||||
name => char_data.name,
|
name => char_data.name,
|
||||||
world => char_data.world,
|
world => char_data.world,
|
||||||
|
@ -24,7 +24,5 @@ pub fn write_html(char_data: &CharacterData, file_path: &str) -> io::Result<()>
|
||||||
nameday => char_data.nameday,
|
nameday => char_data.nameday,
|
||||||
city_state => char_data.city_state
|
city_state => char_data.city_state
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
|
||||||
write(file_path, &character_html)
|
|
||||||
}
|
}
|
||||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -14,7 +14,7 @@ use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use zip::write::SimpleFileOptions;
|
use zip::write::SimpleFileOptions;
|
||||||
use zip::ZipWriter;
|
use zip::ZipWriter;
|
||||||
use crate::downloader::download;
|
use crate::downloader::download;
|
||||||
use crate::html::write_html;
|
use crate::html::{create_html, write_html};
|
||||||
use crate::parser::parse_search;
|
use crate::parser::parse_search;
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
use base64::prelude::*;
|
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?
|
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();
|
zip.finish();
|
||||||
|
|
||||||
return buf;
|
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.
|
/// Archives the character named `character_name` and converts the ZIP file to Base64. Useful for downloading via data URIs.
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
|
|
Loading…
Add table
Reference in a new issue