Bit of a reorganization for output and template files

master
Wynd 2025-01-31 15:06:04 +02:00
parent 5f31996982
commit d06a629aff
8 changed files with 25 additions and 13 deletions

View File

@ -4,6 +4,8 @@ use itertools::Itertools;
use rinja::Template;
use serde::Deserialize;
use crate::create_file;
#[derive(Debug, Deserialize, PartialEq, Eq)]
enum Character {
#[serde(alias = "A")]
@ -119,7 +121,7 @@ struct Finisher {
}
#[derive(Template)]
#[template(path = "pages/bbs-commands.html")]
#[template(path = "pages/bbs/melding.html")]
struct CommandsTemplate {
pub commands: Vec<Command>,
pub crystals: Vec<String>,
@ -157,8 +159,8 @@ pub fn init() {
}
}
tracing::info!("Generating the BBS commands table template");
let template = CommandsTemplate { commands, crystals };
tracing::info!("Generating the BBS melding table template");
let melding_template = CommandsTemplate { commands, crystals };
std::fs::write("./out/bbs-commands.html", template.render().unwrap()).unwrap();
create_file("./out/bbs", "melding", melding_template.render().unwrap()).unwrap();
}

View File

@ -4,6 +4,8 @@ use itertools::Itertools;
use rinja::Template;
use serde::{Deserialize, Deserializer};
use crate::create_file;
#[derive(Debug, Deserialize, PartialEq, Eq)]
struct Board {
order: u32,
@ -348,7 +350,7 @@ impl Display for Interaction {
}
#[derive(Template)]
#[template(path = "pages/ddd-abilities.html")]
#[template(path = "pages/ddd/boards.html")]
struct AbilitiesTemplate {
pub boards: Vec<Board>,
}
@ -385,7 +387,7 @@ pub fn init() {
boards.sort_by(|a, b| a.order.cmp(&b.order));
tracing::info!("Generating the DDD ability boards template");
let template = AbilitiesTemplate { boards };
let boards_template = AbilitiesTemplate { boards };
std::fs::write("./out/ddd-abilities.html", template.render().unwrap()).unwrap();
create_file("./out/ddd", "boards", boards_template.render().unwrap()).unwrap();
}

View File

@ -3,6 +3,8 @@ use std::fmt::Display;
use rinja::Template;
use serde::Deserialize;
use crate::create_file;
#[derive(Debug, Deserialize, PartialEq, Eq)]
struct Recipes {
starters: Vec<Recipe>,
@ -55,7 +57,7 @@ impl Display for FoodStats {
}
#[derive(Template)]
#[template(path = "pages/kh3-recipes.html")]
#[template(path = "pages/kh3/food-sim.html")]
struct RecipesTemplate {
pub recipes: Recipes,
}
@ -68,7 +70,7 @@ pub fn init() {
let recipes = toml::from_str::<Recipes>(&recipes_str).unwrap();
tracing::info!("Generating the KH3 recipes template");
let template = RecipesTemplate { recipes };
let food_template = RecipesTemplate { recipes };
std::fs::write("./out/kh3-recipes.html", template.render().unwrap()).unwrap();
create_file("./out/kh3", "food-sim", food_template.render().unwrap()).unwrap();
}

View File

@ -39,3 +39,9 @@ fn main() {
#[cfg(feature = "kh3")]
kh3::init();
}
fn create_file(dir: &str, file: &str, buf: String) -> std::io::Result<()> {
std::fs::create_dir_all(dir)?;
std::fs::write(format!("{}/{}.html", dir, file), buf)?;
Ok(())
}

View File

@ -9,21 +9,21 @@
{% if cfg!(feature = "bbs") %}
<h1>Kingdom Hearts Birth by Sleep</h1>
<ul>
<li><a href="./bbs-commands.html">Command Melding</a></li>
<li><a href="./bbs/melding.html">Command Melding</a></li>
</ul>
{% endif %}
{% if cfg!(feature = "ddd") %}
<h1>Kingdom Hearts Dream Drop Distance</h1>
<ul>
<li><a href="./ddd-abilities.html">Spirit Boards</a></li>
<li><a href="./ddd/boards.html">Spirit Boards</a></li>
</ul>
{% endif %}
{% if cfg!(feature = "kh3") %}
<h1>Kingdom Hearts III</h1>
<ul>
<li><a href="./kh3-recipes.html">Food Simulator</a></li>
<li><a href="./kh3/food-sim.html">Food Simulator</a></li>
</ul>
{% endif %}
{% endblock %}