aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index d0f896d..837b7ff 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -76,6 +76,10 @@ fn main() {
.map_err(anyhow::Error::from)
.and_then(|x| Ok(serde_json::from_slice::<Vec<Batch>>(&x)?))
.expect("read/parse");
+
+ fs::create_dir_all("public").expect("mkdir public");
+ fs::copy("static/style.css", "public/style.css").expect("copy style.css");
+
batches.iter()
.enumerate()
.for_each(|x| format_batch(&jmdict_idx, batches.len(), x));
@@ -343,7 +347,7 @@ fn format_batch<'a>(dict_idx: &DictIndex<'a>, count: usize, (i, batch): (usize,
}
fn format_batch_aux<'a>(dict_idx: &DictIndex<'a>, count: usize, i: usize, batch: &Batch) -> Result<()> {
- let mut f = io::BufWriter::new(fs::File::create(format!("html/{:03}.html", i))?);
+ let mut f = io::BufWriter::new(fs::File::create(format!("public/{:03}.html", i))?);
write!(f, r#"<!DOCTYPE html>
<html>
<head>
@@ -363,7 +367,8 @@ fn format_batch_aux<'a>(dict_idx: &DictIndex<'a>, count: usize, i: usize, batch:
}
writeln!(f, r#"</p>"#)?;
writeln!(f, "<p>Level: {}</p>", batch.level)?;
- writeln!(f, "<p>Characters: {}</p>", batch.chars.to_string())?;
+
+ writeln!(f, r#"<p class="ja chars">【{}】</p>"#, batch.chars.to_string())?;
for ex in batch.examples.iter() {
writeln!(f, "<hr />")?;
@@ -461,7 +466,7 @@ fn dict_str<'a>(qkeb: &str, qreb: Option<&str>, ent: &roxmltree::Node<'a, 'a>) -
}
fn format_index(batches: &[Batch], kanji_levels: &[(String, String)]) -> Result<()> {
- let mut f = io::BufWriter::new(fs::File::create("html/index.html")?);
+ let mut f = io::BufWriter::new(fs::File::create("public/index.html")?);
write!(f, r#"<!DOCTYPE html>
<html>
<head>