From e72c760f7b913c75a04820cc0d35752c835ee12c Mon Sep 17 00:00:00 2001 From: kageru Date: Mon, 30 Jan 2023 11:39:42 +0100 Subject: [PATCH] add some css --- src/data.rs | 7 +++++- src/main.rs | 34 +++++--------------------- static/header.html | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 static/header.html diff --git a/src/data.rs b/src/data.rs index 0d2e99c..ac52e94 100644 --- a/src/data.rs +++ b/src/data.rs @@ -32,7 +32,12 @@ impl Display for Card { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} (", &self.name)?; if let Some(level) = self.level { - write!(f, "Level {level} ")?; + if self.card_type.contains("XYZ") { + f.write_str("Rank ")?; + } else { + f.write_str("Level ")?; + } + write!(f, "{level} ")?; } else if let Some(lr) = self.link_rating { write!(f, "Link {lr} ")?; } diff --git a/src/main.rs b/src/main.rs index ede04ea..693f494 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,8 @@ struct Query { q: String, } +const HEADER: &str = include_str!("../static/header.html"); + #[get("/")] async fn search(q: Option, web::Form>>) -> Result> { let q = match q { @@ -44,36 +46,12 @@ async fn search(q: Option, web::Form>>) -> Resul None => None, }; let mut res = String::with_capacity(10_000); + res.write_str(HEADER)?; write!( res, r#" - - - - -
- - +
"#, match &q { Some(q) => q, @@ -91,14 +69,14 @@ em {{ .collect(); write!( res, - "Showing {} results where {} (took {:?})


", + "Showing {} results where {} (took {:?})
", matches.len(), query.iter().map(|(f, _)| f.to_string()).join(" and "), now.elapsed() )?; for card in matches { res.push_str(&card.to_string()); - res.push_str("


"); + res.push_str("
"); } write!(res, "")?; } else { diff --git a/static/header.html b/static/header.html new file mode 100644 index 0000000..a1074bc --- /dev/null +++ b/static/header.html @@ -0,0 +1,60 @@ + + + + +