From 985b1e872dcbf87ccf53a56a32fa09fd87c4751f Mon Sep 17 00:00:00 2001 From: feco Date: Sat, 21 Nov 2026 20:54:57 +0000 Subject: [PATCH] Free birth chart instead of the sign calculator; free tools in the header /szuletesi-horoszkop (was /aszcendens-kalkulator) shows the whole natal chart without an account: the wheel, Sun/Moon/Ascendant with links to the sign pages, the positions, houses, aspect grid and aspect list, the same views as the chart pages but without the AI parts. A calculation only, nothing saved, still 30 an hour per address (POST /v1/public/chart). The typed birth data are offered on the profile after sign-up. The visitors' header gets a separate 'Ingyenes' group (birth chart, signs) next to the paid sections, on phones in its own row; the home page links them under the hero buttons and in an 'Ingyenes' band. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL --- services/backend/README.md | 4 +- services/backend/src/routes/calculator.rs | 55 ++--- services/backend/src/routes/mod.rs | 2 +- services/backend/src/tests.rs | 25 +- services/frontend/src/app/Landing.tsx | 34 ++- .../src/app/csillagjegyek/[jegy]/page.tsx | 10 +- .../frontend/src/app/csillagjegyek/page.tsx | 10 +- services/frontend/src/app/globals.css | 32 +++ .../frontend/src/app/profil/BirthForm.tsx | 48 +++- services/frontend/src/app/sitemap.ts | 2 +- .../PublicChart.tsx} | 229 +++++++++++------- .../page.tsx | 42 ++-- .../frontend/src/components/PublicFooter.tsx | 2 +- .../frontend/src/components/SiteHeader.tsx | 25 +- services/frontend/src/lib/birth.ts | 12 + 15 files changed, 363 insertions(+), 169 deletions(-) rename services/frontend/src/app/{aszcendens-kalkulator/SignCalculator.tsx => szuletesi-horoszkop/PublicChart.tsx} (59%) rename services/frontend/src/app/{aszcendens-kalkulator => szuletesi-horoszkop}/page.tsx (58%) diff --git a/services/backend/README.md b/services/backend/README.md index 1129aa2..93f4b51 100644 --- a/services/backend/README.md +++ b/services/backend/README.md @@ -68,8 +68,8 @@ Felhasználók, belépés, mentett születési képletek, szinasztriák és megh | `POST /v1/auth/logout`, `/logout-all` | user | kijelentkezés erről, illetve minden eszközről | | `POST /v1/auth/password-reset` | – | `{email}`; mindig 202 | | `POST /v1/auth/set-password` | – | `{token, password}` a levélben kapott linkből (regisztráció vagy elfelejtett jelszó); a cím megerősítetté válik, minden más munkamenet megszűnik, és belép | -| `POST /v1/public/signs` | – | a nyilvános kalkulátor: `{date, time?, country, geonames_id, ambiguous_time?}` → Nap-, Hold- és aszcendensjegy (idő nélkül aszcendens nélkül, a határ közeli jegyek `uncertain` jelöléssel); csak számítás, AI nélkül, nem ment semmit; IP-címenként óránként 30 | -| `GET /v1/public/geo/countries`, `/v1/public/geo/places?country=&q=` | – | országlista és helykereső a kalkulátorhoz (a helykereső IP-címenként óránként 300 kérés) | +| `POST /v1/public/chart` | – | a nyilvános születési horoszkóp: `{date, time?, country, geonames_id, ambiguous_time?}` → a teljes képlet (`chart`), `highlights` és `uncertain` (idő nélkül a határ közeli Nap és Hold); csak számítás, AI nélkül, nem ment semmit; IP-címenként óránként 30 | +| `GET /v1/public/geo/countries`, `/v1/public/geo/places?country=&q=` | – | országlista és helykereső a nyilvános horoszkóphoz (a helykereső IP-címenként óránként 300 kérés) | | `GET`/`PATCH`/`DELETE /v1/me` | user | profil (`display_name`, `locale`); törlés: `{confirm: "DELETE"}` | | `POST /v1/me/password` | user | `{current_password?, new_password}`; Google-fiókhoz jelszót is ad | | `GET /v1/me/export` | user | GDPR: minden adat egy JSON-ban | diff --git a/services/backend/src/routes/calculator.rs b/services/backend/src/routes/calculator.rs index d95c444..a735473 100644 --- a/services/backend/src/routes/calculator.rs +++ b/services/backend/src/routes/calculator.rs @@ -1,8 +1,8 @@ -//! The public sign calculator (`/aszcendens-kalkulator`): the Sun, Moon and -//! Ascendant signs from birth data, without an account, plus the country list -//! and place search it needs. Nothing is stored. Each visitor address may -//! make a limited number of calculations and place searches an hour, so the -//! endpoints cannot serve as a free calculation service for other apps. +//! The public birth chart (`/szuletesi-horoszkop`): the whole natal chart from +//! birth data, without an account, plus the country list and place search it +//! needs. A calculation only: no AI, nothing is stored. Each visitor address +//! may make a limited number of calculations and place searches an hour, so +//! the endpoints cannot serve as a free calculation service for other apps. use axum::Json; use axum::extract::{Query, State}; @@ -13,6 +13,7 @@ use serde_json::{Value, json}; use super::{Body, St, client_ip}; use crate::error::{ApiError, ApiResult}; +use crate::views::chart_highlights; /// The limiter key of the visitor (all unknown addresses share one). fn visitor(headers: &HeaderMap) -> String { @@ -49,7 +50,7 @@ pub async fn places( #[derive(Deserialize)] #[serde(deny_unknown_fields)] -pub struct SignsRequest { +pub struct ChartRequest { date: String, /// "HH:MM"; without it there is no Ascendant. time: Option, @@ -59,20 +60,18 @@ pub struct SignsRequest { ambiguous_time: Option, } -/// One sign of the answer. `uncertain`: without a birth time the point may -/// have been in the neighbouring sign at the start or the end of the day. -fn sign(point: &Value, time_known: bool, default_speed: f64) -> Value { - let degree = point["degree_in_sign"].as_f64(); +/// Whether a point may have been in the neighbouring sign at the start or the +/// end of the birth day (when the birth time is unknown). +fn uncertain(point: &Value, default_speed: f64) -> bool { let speed = point["speed"].as_f64().unwrap_or(default_speed).abs(); - let uncertain = !time_known && degree.is_some_and(|d| d < speed / 2.0 || 30.0 - d < speed / 2.0); - json!({ "sign": point["sign"], "degree": degree.map(|d| d.floor()), "uncertain": uncertain }) + point["degree_in_sign"].as_f64().is_some_and(|d| d < speed / 2.0 || 30.0 - d < speed / 2.0) } -/// The Sun, Moon and Ascendant signs of the birth data. -pub async fn signs( +/// The natal chart of the birth data, as the chart pages show it. +pub async fn chart( State(state): St, headers: HeaderMap, - WithRejection(Json(req), _): Body, + WithRejection(Json(req), _): Body, ) -> ApiResult> { if !valid_country(&req.country) { return Err(ApiError::BadRequest("invalid country code".into())); @@ -97,14 +96,11 @@ pub async fn signs( .cloned() .unwrap_or(Value::Null) }; - let ascendant = &chart["angles"]["ascendant"]; - Ok(Json(json!({ - "sun": sign(&point("sun"), time_known, 1.0), - "moon": sign(&point("moon"), time_known, 13.2), - "ascendant": (time_known && ascendant["sign"].is_string()).then(|| sign(ascendant, true, 0.0)), - "time_known": time_known, - "place": chart["location"]["place"]["name"], - }))) + let uncertain = json!({ + "sun": !time_known && uncertain(&point("sun"), 1.0), + "moon": !time_known && uncertain(&point("moon"), 13.2), + }); + Ok(Json(json!({ "highlights": chart_highlights(&chart), "uncertain": uncertain, "chart": chart }))) } #[cfg(test)] @@ -112,13 +108,10 @@ mod tests { use super::*; #[test] - fn signs_near_a_border_are_uncertain_without_a_time() { - let moon = json!({"sign": "pisces", "degree_in_sign": 3.2, "speed": 12.6}); - assert_eq!(sign(&moon, false, 13.2)["uncertain"], true); - assert_eq!(sign(&moon, true, 13.2)["uncertain"], false); - let middle = json!({"sign": "pisces", "degree_in_sign": 15.0, "speed": 12.6}); - assert_eq!(sign(&middle, false, 13.2), json!({"sign": "pisces", "degree": 15.0, "uncertain": false})); - let sun = json!({"sign": "cancer", "degree_in_sign": 29.8}); - assert_eq!(sign(&sun, false, 1.0)["uncertain"], true); + fn signs_near_a_border_are_uncertain() { + assert!(uncertain(&json!({"degree_in_sign": 3.2, "speed": 12.6}), 13.2)); + assert!(!uncertain(&json!({"degree_in_sign": 15.0, "speed": 12.6}), 13.2)); + assert!(uncertain(&json!({"degree_in_sign": 29.8}), 1.0)); + assert!(!uncertain(&json!({"degree_in_sign": 29.0}), 1.0)); } } diff --git a/services/backend/src/routes/mod.rs b/services/backend/src/routes/mod.rs index 3a23ac7..1331e37 100644 --- a/services/backend/src/routes/mod.rs +++ b/services/backend/src/routes/mod.rs @@ -126,7 +126,7 @@ pub fn router(state: Arc) -> Router { .route("/v1/public/invitations/unsubscribe", post(invitations::unsubscribe)) .route("/v1/public/invitations/{token}", get(invitations::public_view)) .route("/v1/public/waitlist", post(invitations::join_waitlist)) - .route("/v1/public/signs", post(calculator::signs)) + .route("/v1/public/chart", post(calculator::chart)) .route("/v1/public/geo/countries", get(calculator::countries)) .route("/v1/public/geo/places", get(calculator::places)) // administration diff --git a/services/backend/src/tests.rs b/services/backend/src/tests.rs index cdd39b2..641207f 100644 --- a/services/backend/src/tests.rs +++ b/services/backend/src/tests.rs @@ -959,35 +959,36 @@ const PUBLIC_ROUTES: [&str; 19] = [ "/v1/public/invitations/unsubscribe", "/v1/public/invitations/{token}", "/v1/public/waitlist", - // The sign calculator (limited per visitor address). - "/v1/public/signs", + // The public birth chart (limited per visitor address). + "/v1/public/chart", "/v1/public/geo/countries", "/v1/public/geo/places", ]; #[sqlx::test(migrator = "db::MIGRATOR")] -async fn the_public_sign_calculator(pool: PgPool) { +async fn the_public_birth_chart(pool: PgPool) { let app = TestApp::new(pool).await; let visitor = ("x-real-ip", "203.0.113.9"); let birth = json!({"date": "1990-06-21", "time": "14:30", "country": "HU", "geonames_id": 715429}); - let r = app.call_with("POST", "/v1/public/signs", None, Some(birth.clone()), &[visitor]).await; + let r = app.call_with("POST", "/v1/public/chart", None, Some(birth.clone()), &[visitor]).await; assert_eq!(r.status, StatusCode::OK, "{}", r.body); assert_eq!( - (&r.body["sun"]["sign"], &r.body["moon"]["sign"], &r.body["ascendant"]["sign"]), - (&json!("cancer"), &json!("pisces"), &json!("aries")) + r.body["highlights"], + json!({"sun": "cancer", "moon": "pisces", "ascendant": "aries", "time_known": true}) ); + assert_eq!(r.body["chart"]["points"][0]["id"], "sun", "the whole chart comes back"); // Without a birth time there is no Ascendant. let r = app .call_with( "POST", - "/v1/public/signs", + "/v1/public/chart", None, Some(json!({"date": "1990-06-21", "country": "HU", "geonames_id": 715429})), &[visitor], ) .await; - assert_eq!((r.status, &r.body["ascendant"], &r.body["time_known"]), (StatusCode::OK, &Value::Null, &json!(false))); - let r = app.call_with("POST", "/v1/public/signs", None, Some(json!({"date": "1990-06-21"})), &[visitor]).await; + assert_eq!((r.status, &r.body["highlights"]["time_known"]), (StatusCode::OK, &json!(false))); + let r = app.call_with("POST", "/v1/public/chart", None, Some(json!({"date": "1990-06-21"})), &[visitor]).await; assert_eq!(r.status, StatusCode::BAD_REQUEST); // The place search passes the query on, with a capped limit. @@ -1000,12 +1001,12 @@ async fn the_public_sign_calculator(pool: PgPool) { // 30 calculations an hour per address (the malformed request did not count). for _ in 0..28 { - let r = app.call_with("POST", "/v1/public/signs", None, Some(birth.clone()), &[visitor]).await; + let r = app.call_with("POST", "/v1/public/chart", None, Some(birth.clone()), &[visitor]).await; assert_eq!(r.status, StatusCode::OK); } - let r = app.call_with("POST", "/v1/public/signs", None, Some(birth.clone()), &[visitor]).await; + let r = app.call_with("POST", "/v1/public/chart", None, Some(birth.clone()), &[visitor]).await; assert_eq!(r.status, StatusCode::TOO_MANY_REQUESTS); - let r = app.call_with("POST", "/v1/public/signs", None, Some(birth), &[("x-real-ip", "198.51.100.2")]).await; + let r = app.call_with("POST", "/v1/public/chart", None, Some(birth), &[("x-real-ip", "198.51.100.2")]).await; assert_eq!(r.status, StatusCode::OK); } diff --git a/services/frontend/src/app/Landing.tsx b/services/frontend/src/app/Landing.tsx index 0c144d0..30787f8 100644 --- a/services/frontend/src/app/Landing.tsx +++ b/services/frontend/src/app/Landing.tsx @@ -97,6 +97,10 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) { Példaelemzés +

+ Ingyenes + Nézd meg a születési horoszkópodat belépés nélkül → +

{inviteOnly ? ( <> @@ -137,6 +141,34 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) { +

+
+
+ Ingyenes +

+ Belépés nélkül is kipróbálhatod +

+
+
+ + Születési horoszkóp + + A teljes képleted percre pontosan: képletrajz, aszcendens, holdjegy, bolygók a jegyekben és a házakban, + fényszögek. + + Elkészítem → + + + A 12 csillagjegy + + Milyen a jegyed napjegyként, holdjegyként és aszcendensként? Párkapcsolat, munka, és ami nem igaz róla. + + Megnézem → + +
+
+
+
@@ -480,7 +512,7 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) {