One-card tarot readings pass validation; free-tools row fits on phones
CI / test (push) Successful in 1m46s
CI / build (push) Successful in 6m10s
CI / deploy (push) Skipped

- The answer check wanted two items in every list, so the one-card daily
  reading always failed ($.cards: too few items). Two items are now asked
  only of string lists; other lists must not be empty.
- The visitors' header row (Ingyenes · Születési horoszkóp · Csillagjegyek)
  overflowed and scrolled sideways below 412 px; it fits down to 320 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-22 11:06:01 +00:00
co-authored by Claude Opus 5.5
parent 9716f503bc
commit f7b9af5e8c
3 changed files with 23 additions and 3 deletions
+4 -2
View File
@@ -601,7 +601,7 @@ pub fn build(kind: Kind, language: &str, chart_text: &str, system: Option<&str>)
/// Checks an answer against our schema subset (objects with required /// Checks an answer against our schema subset (objects with required
/// properties, strings with at least three letters, string arrays with at /// properties, strings with at least three letters, string arrays with at
/// least two items). A placeholder such as "x" counts as missing. /// least two items, other arrays not empty). A placeholder such as "x" counts as missing.
pub fn validate(schema: &Value, value: &Value) -> Result<(), String> { pub fn validate(schema: &Value, value: &Value) -> Result<(), String> {
fn walk(schema: &Value, value: &Value, path: &str) -> Result<(), String> { fn walk(schema: &Value, value: &Value, path: &str) -> Result<(), String> {
match schema["type"].as_str() { match schema["type"].as_str() {
@@ -615,7 +615,9 @@ pub fn validate(schema: &Value, value: &Value) -> Result<(), String> {
} }
Some("array") => { Some("array") => {
let items = value.as_array().ok_or_else(|| format!("{path}: expected an array"))?; let items = value.as_array().ok_or_else(|| format!("{path}: expected an array"))?;
if items.len() < 2 { // Lists of strings need two items; other lists (a one-card reading's cards) one.
let min = if schema["items"]["type"] == "string" { 2 } else { 1 };
if items.len() < min {
return Err(format!("{path}: too few items")); return Err(format!("{path}: too few items"));
} }
items.iter().enumerate().try_for_each(|(i, v)| walk(&schema["items"], v, &format!("{path}[{i}]"))) items.iter().enumerate().try_for_each(|(i, v)| walk(&schema["items"], v, &format!("{path}[{i}]")))
+8
View File
@@ -464,4 +464,12 @@ mod tests {
assert!(Reading::parse(&wrong).is_err()); assert!(Reading::parse(&wrong).is_err());
assert!(Reading::parse(&json!({"spread": "daily", "cards": [{"card": "nincs"}]})).is_err()); assert!(Reading::parse(&json!({"spread": "daily", "cards": [{"card": "nincs"}]})).is_err());
} }
#[test]
fn a_one_card_answer_is_valid() {
let text = "Egy bekezdés a lapról.";
let answer = |cards: Value| json!({"title": "Napi üzenet", "summary": text, "cards": cards, "synthesis": text, "advice": text});
assert_eq!(crate::validate(&tarot_schema(), &answer(json!([{"body": text}]))), Ok(()));
assert!(crate::validate(&tarot_schema(), &answer(json!([]))).is_err());
}
} }
+11 -1
View File
@@ -977,9 +977,19 @@ a.pair-row:hover strong { color: var(--gold); }
.lp-nav { display: none; } .lp-nav { display: none; }
/* On phones the free tools get their own row under the logo. */ /* On phones the free tools get their own row under the logo. */
.lp-header { flex-wrap: wrap; row-gap: 4px; } .lp-header { flex-wrap: wrap; row-gap: 4px; }
.lp-free { order: 3; flex-basis: 100%; padding-left: 0; border-left: 0; overflow-x: auto; scrollbar-width: none; } .lp-free { order: 3; flex-basis: 100%; padding-left: 0; border-left: 0; overflow-x: auto; scrollbar-width: none; gap: 0; }
.lp-free a { padding: 10px 7px; }
.lp-free-label { margin-right: 4px; }
.lp-header > .btn { margin-left: auto; } .lp-header > .btn { margin-left: auto; }
} }
/* The free-tools row fits on narrow phones too, without sideways scrolling */
@media (max-width: 380px) {
.lp-free a { font-size: 14px; padding: 10px 5px; }
.lp-free-label { font-size: 10px; padding: 2px 6px; letter-spacing: 0.5px; }
}
@media (max-width: 350px) {
.lp-free-label { display: none; }
}
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.lp *, .lp-orbit { animation: none !important; } .lp *, .lp-orbit { animation: none !important; }
.lp-rise, .lp-wheel .w-point { opacity: 1; transform: none; } .lp-rise, .lp-wheel .w-point { opacity: 1; transform: none; }