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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -26,6 +26,10 @@ struct CardRow {
|
||||
natal: Option<Value>,
|
||||
year: Option<i32>,
|
||||
summary_title: Option<String>,
|
||||
/// A synastry: the two charts and the aspects between them.
|
||||
chart1: Option<Value>,
|
||||
chart2: Option<Value>,
|
||||
pair_aspects: Option<Value>,
|
||||
}
|
||||
|
||||
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<Value>, bool) {
|
||||
@@ -68,6 +76,21 @@ fn big_three(natal: &Value) -> (Vec<Value>, 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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
|
||||
@@ -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 ? (
|
||||
<ChartWheel chart={share.chart} timeKnown={share.time_known ?? false} title="A csatolt képlet" />
|
||||
) : share.pair ? (
|
||||
<SynastryWheel
|
||||
chart1={share.pair.chart1}
|
||||
chart2={share.pair.chart2}
|
||||
time1={share.pair.time1}
|
||||
time2={share.pair.time2}
|
||||
aspects={share.pair.aspects}
|
||||
name1="Első képlet"
|
||||
name2="Második képlet"
|
||||
/>
|
||||
) : null;
|
||||
return (
|
||||
<div className="fshare">
|
||||
<div className="fshare-head">
|
||||
<span className="eyebrow">{EYEBROW[share.kind]}</span>
|
||||
{onRemove && (
|
||||
<button type="button" className="fp-link" onClick={onRemove} aria-label="Képlet levétele">
|
||||
×
|
||||
</button>
|
||||
<div className={drawing ? "fshare fshare-drawn" : "fshare"}>
|
||||
{drawing && <div className="fshare-wheel">{drawing}</div>}
|
||||
<div className="fshare-info">
|
||||
<div className="fshare-head">
|
||||
<span className="eyebrow">{EYEBROW[share.kind]}</span>
|
||||
{onRemove && (
|
||||
<button type="button" className="fp-link" onClick={onRemove} aria-label="Képlet levétele">
|
||||
×
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<strong className="fshare-title">{share.title}</strong>
|
||||
{share.summary && <span className="fshare-summary">„{share.summary}”</span>}
|
||||
{points.length > 0 && (
|
||||
<ul className="fshare-points">
|
||||
{points.map((p) => (
|
||||
<li key={p.id}>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[p.id]?.glyph ?? ""}
|
||||
</span>{" "}
|
||||
{POINT_LABEL[p.id] ?? p.id}{" "}
|
||||
<span className="sym" aria-hidden="true">
|
||||
{SIGNS[p.sign]?.glyph ?? ""}
|
||||
</span>{" "}
|
||||
{signName(p.sign)}
|
||||
{p.degree !== null && ` ${p.degree}°`}
|
||||
{p.house !== null && <span className="hint"> · {p.house}. ház</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{share.kind !== "synastry" && share.time_known === false && (
|
||||
<span className="hint">A születési idő ismeretlen, ezért házak és Aszcendens nincsenek.</span>
|
||||
)}
|
||||
{share.slug && (
|
||||
<Link href={`/s/${share.slug}`} className="btn btn-sm fshare-open" target="_blank" rel="noopener">
|
||||
Megnyitom ›
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<strong className="fshare-title">{share.title}</strong>
|
||||
{share.summary && <span className="fshare-summary">„{share.summary}”</span>}
|
||||
{points.length > 0 && (
|
||||
<ul className="fshare-points">
|
||||
{points.map((p) => (
|
||||
<li key={p.id}>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[p.id]?.glyph ?? ""}
|
||||
</span>{" "}
|
||||
{POINT_LABEL[p.id] ?? p.id}{" "}
|
||||
<span className="sym" aria-hidden="true">
|
||||
{SIGNS[p.sign]?.glyph ?? ""}
|
||||
</span>{" "}
|
||||
{signName(p.sign)}
|
||||
{p.degree !== null && ` ${p.degree}°`}
|
||||
{p.house !== null && <span className="hint"> · {p.house}. ház</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{share.kind !== "synastry" && share.time_known === false && (
|
||||
<span className="hint">A születési idő ismeretlen, ezért házak és Aszcendens nincsenek.</span>
|
||||
)}
|
||||
{share.slug && (
|
||||
<Link href={`/s/${share.slug}`} className="btn btn-sm fshare-open" target="_blank" rel="noopener">
|
||||
Megnyitom ›
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user