From 67cb3c6b8cd0d54a20e0aa16d3417c0f3103a86b Mon Sep 17 00:00:00 2001 From: feco Date: Thu, 26 Nov 2026 16:57:04 +0000 Subject: [PATCH] Forum: the attached chart's wheel in the question A question with a shared chart shows the chart's wheel, one with a shared synastry the two charts on one wheel, at a fixed size beside the details (above them on phones). The forum sends the wheel's data (positions, angles, houses, aspects; never birth date, time or place) to logged-in members only. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL --- services/forum/src/routes/attachments.rs | 48 +++++++++- services/forum/src/tests.rs | 2 + services/frontend/src/app/forum/forum.css | 9 ++ .../src/components/forum/ShareCard.tsx | 88 +++++++++++-------- services/frontend/src/lib/forum.ts | 6 ++ 5 files changed, 114 insertions(+), 39 deletions(-) diff --git a/services/forum/src/routes/attachments.rs b/services/forum/src/routes/attachments.rs index 5fee90c..8d640c0 100644 --- a/services/forum/src/routes/attachments.rs +++ b/services/forum/src/routes/attachments.rs @@ -26,6 +26,10 @@ struct CardRow { natal: Option, year: Option, summary_title: Option, + /// A synastry: the two charts and the aspects between them. + chart1: Option, + chart2: Option, + pair_aspects: Option, } const CARD_SELECT: &str = "SELECT s.id, s.slug, s.kind, s.revoked_at IS NOT NULL AS revoked, \ @@ -35,11 +39,15 @@ const CARD_SELECT: &str = "SELECT s.id, s.slug, s.kind, s.revoked_at IS NOT NULL AND a.kind = 'summary' AND a.status = 'done' ORDER BY a.completed_at DESC LIMIT 1) \ WHEN 'forecast' THEN (SELECT a.content->>'title' FROM analyses a WHERE a.forecast_id = s.forecast_id \ AND a.kind = 'forecast' AND a.status = 'done' ORDER BY a.completed_at DESC LIMIT 1) \ - END AS summary_title \ + END AS summary_title, \ + c1.result AS chart1, c2.result AS chart2, sy.result->'aspects' AS pair_aspects \ FROM shares s \ LEFT JOIN charts c ON c.id = s.chart_id \ LEFT JOIN forecasts f ON f.id = s.forecast_id \ - LEFT JOIN charts fc ON fc.id = f.chart_id"; + LEFT JOIN charts fc ON fc.id = f.chart_id \ + LEFT JOIN synastries sy ON sy.id = s.synastry_id \ + LEFT JOIN charts c1 ON c1.id = sy.chart1_id \ + LEFT JOIN charts c2 ON c2.id = sy.chart2_id"; /// Sun, Moon and (with a known birth time) the Ascendant: sign, degree, house. fn big_three(natal: &Value) -> (Vec, bool) { @@ -68,6 +76,21 @@ fn big_three(natal: &Value) -> (Vec, bool) { (points, time_known) } +/// What the wheel is drawn from: the positions, angles, houses and aspects +/// (never the birth date, time or place). +fn wheel(chart: &Value) -> Value { + json!({ + "points": chart["points"], + "angles": chart["angles"], + "houses": chart["houses"], + "aspects": chart["aspects"], + }) +} + +fn time_known(chart: &Value) -> bool { + chart.pointer("/time/time_known").and_then(Value::as_bool).unwrap_or(false) +} + fn card(row: &CardRow) -> Value { if row.revoked { return json!({ "slug": row.slug, "kind": row.kind, "revoked": true }); @@ -77,7 +100,22 @@ fn card(row: &CardRow) -> Value { ("forecast", Some(year)) => format!("Éves előrejelzés · {year}–{}", year + 1), _ => "Születési képlet".to_string(), }; - let (points, time_known) = row.natal.as_ref().map(big_three).unwrap_or_default(); + let (points, known) = row.natal.as_ref().map(big_three).unwrap_or_default(); + // The drawing itself: the chart's wheel, or the two charts on one wheel. + let chart = match (row.kind.as_str(), &row.natal) { + ("chart", Some(natal)) => wheel(natal), + _ => Value::Null, + }; + let pair = match (&row.chart1, &row.chart2) { + (Some(a), Some(b)) if row.kind == "synastry" => json!({ + "chart1": wheel(a), + "chart2": wheel(b), + "time1": time_known(a), + "time2": time_known(b), + "aspects": row.pair_aspects.clone().unwrap_or(Value::Array(Vec::new())), + }), + _ => Value::Null, + }; json!({ "slug": row.slug, "kind": row.kind, @@ -85,7 +123,9 @@ fn card(row: &CardRow) -> Value { "title": title, "summary": row.summary_title, "points": points, - "time_known": time_known, + "time_known": known, + "chart": chart, + "pair": pair, }) } diff --git a/services/forum/src/tests.rs b/services/forum/src/tests.rs index c20f670..5e048a7 100644 --- a/services/forum/src/tests.rs +++ b/services/forum/src/tests.rs @@ -1261,6 +1261,8 @@ async fn a_question_about_ones_chart(pool: PgPool) { assert_eq!(preview["title"], "Születési képlet"); assert_eq!(preview["points"][0], json!({"id": "sun", "sign": "leo", "degree": 12, "house": 10})); assert_eq!(preview["points"][2]["id"], "ascendant"); + assert_eq!(preview["chart"]["points"][1]["sign"], "pisces", "the wheel's data"); + assert!(preview["chart"].get("time").is_none(), "no birth time"); assert!(!preview.to_string().contains("Kovács"), "no names"); for (slug, who) in [("annaplain000001", &anna), ("annaforum000001", &bea), ("nincsilyen", &anna)] { let (status, _) = app.call("GET", &format!("/v1/forum/share-card/{slug}"), Some(who), Value::Null).await; diff --git a/services/frontend/src/app/forum/forum.css b/services/frontend/src/app/forum/forum.css index 83f64bb..412bbb5 100644 --- a/services/frontend/src/app/forum/forum.css +++ b/services/frontend/src/app/forum/forum.css @@ -725,3 +725,12 @@ a.fh-online-item:hover { color: var(--gold); } .flink-frame { position: relative; aspect-ratio: 16 / 9; background: #000; } .flink-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; } .flink .fp-link { display: inline-flex; align-items: center; padding: 0; text-decoration: none; } + +/* The attached chart's wheel: a fixed size, beside the details (above them on phones). */ +.fshare-info { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; } +.fshare-drawn { flex-direction: column; align-items: center; } +.fshare-wheel { flex: none; width: 240px; height: 240px; } +.fshare-wheel svg { display: block; width: 100%; height: 100%; } +@media (min-width: 640px) { + .fshare-drawn { flex-direction: row; align-items: center; gap: 18px; } +} diff --git a/services/frontend/src/components/forum/ShareCard.tsx b/services/frontend/src/components/forum/ShareCard.tsx index c7c8adf..8c95c32 100644 --- a/services/frontend/src/components/forum/ShareCard.tsx +++ b/services/frontend/src/components/forum/ShareCard.tsx @@ -1,5 +1,7 @@ import Link from "next/link"; +import { ChartWheel } from "@/components/ChartWheel"; +import { SynastryWheel } from "@/components/SynastryWheel"; import { POINTS, SIGNS, signName } from "@/lib/astro"; import type { ShareCardData } from "@/lib/forum"; @@ -36,44 +38,60 @@ export function ShareCard({ share, onRemove }: { share: ShareCardData; onRemove? ); } const points = share.points ?? []; + const drawing = share.chart ? ( + + ) : share.pair ? ( + + ) : null; return ( -
-
- {EYEBROW[share.kind]} - {onRemove && ( - +
+ {drawing &&
{drawing}
} +
+
+ {EYEBROW[share.kind]} + {onRemove && ( + + )} +
+ {share.title} + {share.summary && „{share.summary}”} + {points.length > 0 && ( +
    + {points.map((p) => ( +
  • + {" "} + {POINT_LABEL[p.id] ?? p.id}{" "} + {" "} + {signName(p.sign)} + {p.degree !== null && ` ${p.degree}°`} + {p.house !== null && · {p.house}. ház} +
  • + ))} +
+ )} + {share.kind !== "synastry" && share.time_known === false && ( + A születési idő ismeretlen, ezért házak és Aszcendens nincsenek. + )} + {share.slug && ( + + Megnyitom › + )}
- {share.title} - {share.summary && „{share.summary}”} - {points.length > 0 && ( -
    - {points.map((p) => ( -
  • - {" "} - {POINT_LABEL[p.id] ?? p.id}{" "} - {" "} - {signName(p.sign)} - {p.degree !== null && ` ${p.degree}°`} - {p.house !== null && · {p.house}. ház} -
  • - ))} -
- )} - {share.kind !== "synastry" && share.time_known === false && ( - A születési idő ismeretlen, ezért házak és Aszcendens nincsenek. - )} - {share.slug && ( - - Megnyitom › - - )}
); } diff --git a/services/frontend/src/lib/forum.ts b/services/frontend/src/lib/forum.ts index addd7f6..02fee2f 100644 --- a/services/frontend/src/lib/forum.ts +++ b/services/frontend/src/lib/forum.ts @@ -2,6 +2,8 @@ // by its server and client components. /** The forum's colours: light by default, dark on request (a cookie). */ +import type { ChartResult, InterAspect } from "./types"; + export const FORUM_THEME_COOKIE = "sf_forum_theme"; export type ForumTheme = "light" | "dark"; @@ -149,6 +151,10 @@ export interface ShareCardData { summary?: string | null; points?: { id: string; sign: string; degree: number | null; house: number | null }[]; time_known?: boolean; + /** The chart's wheel (a shared chart). */ + chart?: ChartResult | null; + /** The two charts on one wheel (a shared synastry). */ + pair?: { chart1: ChartResult; chart2: ChartResult; time1: boolean; time2: boolean; aspects: InterAspect[] } | null; } export interface ThreadPage {