diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | static/style.css (renamed from html/style.css) | 4 |
3 files changed, 13 insertions, 4 deletions
@@ -4,4 +4,4 @@ kanjidic*.xml JMdict*.xml examples.utf -html/*.html +public 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> diff --git a/html/style.css b/static/style.css index 35c7948..329817f 100644 --- a/html/style.css +++ b/static/style.css @@ -11,6 +11,10 @@ td { vertical-align: top; } +.chars { + color: #007700; +} + .ja { text-align: center; font-size: 2rem; |