From 22bd3b7e415c5a33e8101bc38acaaab22de5b316 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 18 Sep 2023 18:56:51 +0200 Subject: change characters appearance --- .gitignore | 2 +- html/style.css | 42 ------------------------------------------ src/main.rs | 11 ++++++++--- static/style.css | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 46 deletions(-) delete mode 100644 html/style.css create mode 100644 static/style.css diff --git a/.gitignore b/.gitignore index 6067da8..d77b1f4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ kanjidic*.xml JMdict*.xml examples.utf -html/*.html +public diff --git a/html/style.css b/html/style.css deleted file mode 100644 index 35c7948..0000000 --- a/html/style.css +++ /dev/null @@ -1,42 +0,0 @@ -a { - color: blue; - text-decoration: none; -} - -tr:hover { - background: #EEE; -} - -td { - vertical-align: top; -} - -.ja { - text-align: center; - font-size: 2rem; -} - -.ja:hover .char_cur { - color: red; -} - -.ja:hover .char_p1 { - color: magenta; -} - -.ja:hover .char_p2 { - color: blue; -} - -.ja:hover .char_bad { - color: grey; -} - -.en { - text-align: center; - font-size: 1.2rem; -} - -details .chars { - font-size: 3rem; -} 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::>(&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#" @@ -363,7 +367,8 @@ fn format_batch_aux<'a>(dict_idx: &DictIndex<'a>, count: usize, i: usize, batch: } writeln!(f, r#"

"#)?; writeln!(f, "

Level: {}

", batch.level)?; - writeln!(f, "

Characters: {}

", batch.chars.to_string())?; + + writeln!(f, r#"

【{}】

"#, batch.chars.to_string())?; for ex in batch.examples.iter() { writeln!(f, "
")?; @@ -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#" diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..329817f --- /dev/null +++ b/static/style.css @@ -0,0 +1,46 @@ +a { + color: blue; + text-decoration: none; +} + +tr:hover { + background: #EEE; +} + +td { + vertical-align: top; +} + +.chars { + color: #007700; +} + +.ja { + text-align: center; + font-size: 2rem; +} + +.ja:hover .char_cur { + color: red; +} + +.ja:hover .char_p1 { + color: magenta; +} + +.ja:hover .char_p2 { + color: blue; +} + +.ja:hover .char_bad { + color: grey; +} + +.en { + text-align: center; + font-size: 1.2rem; +} + +details .chars { + font-size: 3rem; +} -- cgit v1.2.3