Famous people: admin page, own prompt, one photo, public pages
CI / test (push) Successful in 2m21s
CI / build (push) Skipped
CI / deploy (push) Skipped

- Admin "Híres emberek": birth data, one photo (S3: DigitalOcean Spaces in
  production, RustFS in development), a face point that every crop keeps
  in view, publishing, and a detailed portrait written with its own
  `celebrity` prompt (third person, by name, from the chart alone).
- The photo is stored once (upright JPEG, at most 2000 px, no metadata);
  next/image makes the sizes from it, so Cloudflare can cache those.
- Public list and pages (/hires-emberek), in the sitemap, with a share
  image showing the face and the chart.
- Share images: the wheel's glyphs and numbers are drawn with the card's
  fonts (inside the SVG image they came out as boxes, on every card).

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 16:08:35 +00:00
co-authored by Claude Opus 5.5
parent 13e22a9c7d
commit 37cb0abf4b
47 changed files with 3008 additions and 77 deletions
+96 -6
View File
@@ -24,12 +24,16 @@ pub enum Kind {
Forecast,
/// The answer to a user's question about a finished natal analysis or forecast.
Question,
/// A detailed analysis of a famous person's chart, about them in the third
/// person, for the public pages (the name comes with the data, see [`with_name`]).
Celebrity,
}
impl Kind {
pub const ALL: [Kind; 5] = [Kind::Summary, Kind::Natal, Kind::Synastry, Kind::Forecast, Kind::Question];
pub const ALL: [Kind; 6] =
[Kind::Summary, Kind::Natal, Kind::Synastry, Kind::Forecast, Kind::Question, Kind::Celebrity];
/// The kinds stored as analyses (a question is stored with its analysis).
pub const ANALYSES: [Kind; 4] = [Kind::Summary, Kind::Natal, Kind::Synastry, Kind::Forecast];
pub const ANALYSES: [Kind; 5] = [Kind::Summary, Kind::Natal, Kind::Synastry, Kind::Forecast, Kind::Celebrity];
pub fn as_str(self) -> &'static str {
match self {
@@ -38,6 +42,7 @@ impl Kind {
Kind::Summary => "summary",
Kind::Forecast => "forecast",
Kind::Question => "question",
Kind::Celebrity => "celebrity",
}
}
@@ -48,6 +53,7 @@ impl Kind {
"summary" => Some(Kind::Summary),
"forecast" => Some(Kind::Forecast),
"question" => Some(Kind::Question),
"celebrity" => Some(Kind::Celebrity),
_ => None,
}
}
@@ -143,7 +149,7 @@ const FORECAST_SECTIONS_HU: [&str; 5] = [
/// (key, description) of the sections in the language of the user message.
fn sections_in(kind: Kind, language: &str) -> Vec<(&'static str, &'static str)> {
let hu: &[&str] = match kind {
Kind::Natal => &NATAL_SECTIONS_HU,
Kind::Natal | Kind::Celebrity => &NATAL_SECTIONS_HU,
Kind::Synastry => &SYNASTRY_SECTIONS_HU,
Kind::Forecast => &FORECAST_SECTIONS_HU,
Kind::Summary | Kind::Question => &[],
@@ -153,7 +159,7 @@ fn sections_in(kind: Kind, language: &str) -> Vec<(&'static str, &'static str)>
fn sections(kind: Kind) -> &'static [(&'static str, &'static str)] {
match kind {
Kind::Natal => &NATAL_SECTIONS,
Kind::Natal | Kind::Celebrity => &NATAL_SECTIONS,
Kind::Synastry => &SYNASTRY_SECTIONS,
Kind::Forecast => &FORECAST_SECTIONS,
Kind::Summary | Kind::Question => &[],
@@ -212,17 +218,27 @@ pub fn schema(kind: Kind) -> Value {
),
_ => ("3-5 key strengths, one sentence each", "3-5 key challenges, one sentence each"),
};
let (title, advice) = match kind {
Kind::Celebrity => (
"Short, evocative title for this portrait (at most 8 words)",
"A closing paragraph that draws the portrait together",
),
_ => (
"Short, evocative title for this analysis (at most 8 words)",
"A closing, encouraging paragraph with concrete guidance",
),
};
json!({
"type": "object",
"additionalProperties": false,
"required": ["title", "summary", "sections", "strengths", "challenges", "advice"],
"properties": {
"title": {"type": "string", "description": "Short, evocative title for this analysis (at most 8 words)"},
"title": {"type": "string", "description": title},
"summary": {"type": "string", "description": "3-4 sentence overview"},
"sections": {"type": "object", "additionalProperties": false, "required": keys, "properties": props},
"strengths": {"type": "array", "items": {"type": "string"}, "description": strengths},
"challenges": {"type": "array", "items": {"type": "string"}, "description": challenges},
"advice": {"type": "string", "description": "A closing, encouraging paragraph with concrete guidance"}
"advice": {"type": "string", "description": advice}
}
})
}
@@ -252,6 +268,11 @@ fn hungarian_system(kind: Kind) -> String {
előrejelzés kb. 1500–2000 szó.",
),
Kind::Question => unreachable!("questions have their own prompt"),
Kind::Celebrity => (
"portrét egy híres ember születési képletéről (az olvasó nem ő maga, hanem egy érdeklődő látogató)",
THIRD_PERSON_HU,
"Terjedelem: fejezetenként 2–4 bekezdés (kb. 150–250 szó); az egész elemzés kb. 1300–1800 szó.",
),
Kind::Synastry => (
"kapcsolati (szinasztria-) elemzést két ember számára",
"Egyszerre mindkettőjükhöz szólj, többes szám második személyben („ti”, „kettőtök”). Ha meg kell \
@@ -290,6 +311,9 @@ használhatsz.
if kind == Kind::Forecast {
text.push_str(FORECAST_RULES_HU);
}
if kind == Kind::Celebrity {
text.push_str(CELEBRITY_RULES_HU);
}
text.push_str(HUNGARIAN_TERMS);
if kind == Kind::Forecast {
text.push_str(HUNGARIAN_FORECAST_TERMS);
@@ -300,6 +324,22 @@ használhatsz.
const SECOND_PERSON_HU: &str =
"Közvetlenül a képlet tulajdonosához szólj, tegező formában (egyes szám második személyben, „te”).";
const THIRD_PERSON_HU: &str = "Egyes szám harmadik személyben írj róla, a nevén nevezve: az összefoglalóban a teljes \
nevén, később a megszokott rövidebb nevén is (vezetéknév vagy művésznév), de ne minden mondatban. Az olvasót ne szólítsd \
meg.";
const CELEBRITY_RULES_HU: &str = "
A híres emberekről szóló portré szabályai:
- Kizárólag a képletből dolgozz, mintha csak a nevét és a születési adatait ismernéd. Ne hivatkozz az életrajzára, a \
műveire, a sikereire, a kapcsolataira, a családjára, a nyilvános szerepléseire vagy a haláláról szóló tényekre, és ne \
próbáld a képletet ismert életeseményekkel igazolni.
- A képletről jelen időben írj („a képlete azt mutatja”), róla magáról általánosan, hajlamokként („olyan ember képe \
rajzolódik ki, aki…”), mert lehet, hogy már nem él. Ne állíts semmit az életéről, ami ne a képletből következne.
- Tisztelettel írj róla: ne ítélkezz, ne gúnyolódj, és ne tegyél egészségre, lelki betegségre vagy halálra vonatkozó \
kijelentést.
- Az „advice” mező nem neki szóló tanács, hanem zárógondolat: egy bekezdés, amely összefogja a portrét.";
const FORECAST_RULES_HU: &str = "
Az előrejelzés szabályai:
@@ -367,6 +407,11 @@ pub fn default_system(kind: Kind, language: &str) -> String {
}
let (role, reader) = match kind {
Kind::Question => unreachable!("questions have their own prompt"),
Kind::Celebrity => (
"a portrait of a famous person's natal chart (the reader is not that person but an interested visitor)",
"Write about them in the third person singular, by name: the full name in the summary, later also the \
usual shorter name (surname or stage name), but not in every sentence. Do not address the reader.",
),
Kind::Natal => (
"a personal natal chart interpretation",
"Speak to the owner of the chart directly, in the informal second person singular (in Hungarian: tegező forma, \"te\").",
@@ -419,9 +464,30 @@ and no medical, legal or financial advice.
if kind == Kind::Forecast {
text.push_str(FORECAST_RULES);
}
if kind == Kind::Celebrity {
text.push_str(CELEBRITY_RULES);
}
text
}
const CELEBRITY_RULES: &str = "
Rules for a famous person's portrait:
- Work from the chart alone, as if you knew only their name and birth data. Do not refer to their biography, works, \
successes, relationships, family, public appearances or the facts of their death, and do not try to prove the chart \
with known events of their life.
- Write about the chart in the present tense (\"the chart shows\") and about the person in general terms, as \
tendencies (\"the picture is of someone who…\"), since they may no longer be alive. Claim nothing about their life \
that does not follow from the chart.
- Write with respect: no judging, no mockery, and no statements about health, mental illness or death.
- The \"advice\" field is not advice to them but a closing thought: one paragraph that draws the portrait together.";
/// The chart data of a famous person with their name in front (the user
/// message of a [`Kind::Celebrity`] analysis).
pub fn with_name(language: &str, name: &str, chart_text: &str) -> String {
format!("{}: {}\n\n{chart_text}", if language == "hu" { "Név" } else { "Name" }, name.trim())
}
const FORECAST_RULES: &str = "
Forecast rules:
@@ -459,6 +525,9 @@ pub fn user_template(kind: Kind) -> String {
let history = [("{korábbi kérdés}".to_string(), "{korábbi válasz}".to_string())];
return build_question("hu", "{chart data}\n", "{az elemzés szövege}\n", &history, "{a kérdés}", None).user;
}
if kind == Kind::Celebrity {
return build(kind, "hu", &with_name("hu", "{név}", "{chart data}\n"), None).user;
}
build(kind, "hu", "{chart data}\n", None).user
}
@@ -590,6 +659,7 @@ pub fn build(kind: Kind, language: &str, chart_text: &str, system: Option<&str>)
user,
schema_name: match kind {
Kind::Natal => "natal_analysis",
Kind::Celebrity => "celebrity_analysis",
Kind::Synastry => "synastry_analysis",
Kind::Summary => "chart_summary",
Kind::Question => "question_answer",
@@ -669,6 +739,8 @@ pub fn polish(language: &str, content: &mut Value) {
pub fn to_markdown(kind: Kind, language: &str, content: &Value) -> String {
let (strengths, challenges, advice) = match (language, kind) {
("hu", Kind::Forecast) => ("Lehetőségek", "Kihívások", "Útravaló"),
("hu", Kind::Celebrity) => ("Erősségek", "Kihívások", "Összegzés"),
(_, Kind::Celebrity) => ("Strengths", "Challenges", "In sum"),
("hu", _) => ("Erősségek", "Kihívások", "Útravaló"),
(_, Kind::Forecast) => ("Opportunities", "Challenges", "Advice"),
_ => ("Strengths", "Challenges", "Advice"),
@@ -743,6 +815,24 @@ mod tests {
}
}
#[test]
fn celebrity_prompt() {
let text = with_name("hu", " Marilyn Monroe ", "SUN: Gemini\n");
assert!(text.starts_with("Név: Marilyn Monroe\n\nSUN: Gemini"));
let p = build(Kind::Celebrity, "hu", &text, None);
assert_eq!(p.schema_name, "celebrity_analysis");
assert!(p.system.contains("harmadik személyben") && p.system.contains("Kizárólag a képletből"));
assert!(!p.system.contains("tegező"));
assert!(p.user.contains("Név: Marilyn Monroe") && p.user.contains("- personality:"));
// the same sections as a natal analysis, so the pages show it the same way
assert_eq!(p.schema["properties"]["sections"], schema(Kind::Natal)["properties"]["sections"]);
assert!(p.schema["properties"]["advice"]["description"].as_str().unwrap().contains("portrait"));
let en = default_system(Kind::Celebrity, "en");
assert!(en.contains("third person") && en.contains("chart alone") && !en.contains("second person singular"));
assert!(user_template(Kind::Celebrity).contains("Név: {név}"));
assert!(to_markdown(Kind::Celebrity, "hu", &json!({"title": "C", "summary": "S"})).contains("## Összegzés"));
}
#[test]
fn question_prompt() {
let history = [("Mikor jó váltani?".to_string(), "Tavasszal.".to_string())];
+58
View File
@@ -0,0 +1,58 @@
-- Famous people: an admin adds their birth data, one photo and a detailed
-- analysis written with its own prompt (`celebrity` kind, about them in the
-- third person). Published ones have a public page and a list.
--
-- The chart is an ordinary `charts` row of kind 'celebrity' (so calculation,
-- recalculation and the worker work as for any chart), owned by the admin
-- who added it; the user's own lists leave these out.
ALTER TABLE charts DROP CONSTRAINT charts_kind_check;
ALTER TABLE charts ADD CONSTRAINT charts_kind_check CHECK (kind IN ('own', 'person', 'celebrity'));
ALTER TABLE analyses DROP CONSTRAINT analyses_kind_check;
ALTER TABLE analyses ADD CONSTRAINT analyses_kind_check
CHECK (kind IN ('natal', 'synastry', 'summary', 'forecast', 'tarot', 'celebrity'));
ALTER TABLE analyses DROP CONSTRAINT analyses_target;
ALTER TABLE analyses ADD CONSTRAINT analyses_target CHECK (
(kind IN ('natal', 'summary', 'celebrity') AND chart_id IS NOT NULL AND synastry_id IS NULL AND forecast_id IS NULL)
OR (kind = 'synastry' AND synastry_id IS NOT NULL AND chart_id IS NULL AND forecast_id IS NULL)
OR (kind = 'forecast' AND forecast_id IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL)
OR (kind = 'tarot' AND tarot IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL AND forecast_id IS NULL)
);
ALTER TABLE prompt_revisions DROP CONSTRAINT prompt_revisions_kind_check;
ALTER TABLE prompt_revisions ADD CONSTRAINT prompt_revisions_kind_check
CHECK (kind IN ('summary', 'natal', 'synastry', 'forecast', 'question', 'celebrity'));
ALTER TABLE prompt_previews DROP CONSTRAINT prompt_previews_target;
ALTER TABLE prompt_previews ADD CONSTRAINT prompt_previews_target CHECK (
(kind IN ('summary', 'natal', 'celebrity') AND chart_id IS NOT NULL AND synastry_id IS NULL AND forecast_id IS NULL)
OR (kind = 'synastry' AND synastry_id IS NOT NULL AND chart_id IS NULL AND forecast_id IS NULL)
OR (kind = 'forecast' AND forecast_id IS NOT NULL AND chart_id IS NULL AND synastry_id IS NULL)
);
CREATE TABLE celebrities (
id uuid PRIMARY KEY,
-- Deleting the chart deletes the famous person (and the analyses with it).
chart_id uuid NOT NULL UNIQUE REFERENCES charts (id) ON DELETE CASCADE,
name text NOT NULL CHECK (length(name) BETWEEN 1 AND 100),
-- One line under the name, e.g. "színésznő, énekesnő".
subtitle text CHECK (subtitle IS NULL OR length(subtitle) BETWEEN 1 AND 160),
-- The address of the public page: /hires-emberek/<slug>.
slug text NOT NULL UNIQUE CHECK (slug ~ '^[a-z0-9]+(-[a-z0-9]+)*$'),
-- The one photo in the object storage (a new upload gets a new key, so
-- caches never serve an old picture), its size, and the point of the face
-- (0..1 from the left and from the top) that every crop keeps in view.
photo_key text,
photo_width integer,
photo_height integer,
focus_x real NOT NULL DEFAULT 0.5 CHECK (focus_x BETWEEN 0 AND 1),
focus_y real NOT NULL DEFAULT 0.3 CHECK (focus_y BETWEEN 0 AND 1),
-- NULL: a draft, only admins see it.
published_at timestamptz,
created_by uuid REFERENCES users (id) ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
CONSTRAINT celebrities_photo CHECK ((photo_key IS NULL) = (photo_width IS NULL) AND (photo_key IS NULL) = (photo_height IS NULL))
);
CREATE INDEX celebrities_published_idx ON celebrities (published_at DESC) WHERE published_at IS NOT NULL;