Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f037522052 | ||
|
|
c7600608d3 | ||
|
|
e476117c77 | ||
|
|
da533e8fa9 | ||
|
|
bc0227042b | ||
|
|
d758f5bf12 | ||
|
|
d46cd7a445 |
@@ -20,3 +20,7 @@ SIGNUP_MODE=invite
|
|||||||
|
|
||||||
# Image version; every deployment rewrites it
|
# Image version; every deployment rewrites it
|
||||||
TAG=latest
|
TAG=latest
|
||||||
|
|
||||||
|
# worker-ai: analyses and answers written at the same time.
|
||||||
|
# QUICK_CONCURRENCY=2 # summaries and answers
|
||||||
|
# ANALYSIS_CONCURRENCY=4 # detailed analyses and forecasts
|
||||||
|
|||||||
+2
-1
@@ -82,7 +82,8 @@ A Google OAuth kliensnél a `https://sorsfonalak.hu` címet fel kell venni az en
|
|||||||
|
|
||||||
## Üzemeltetés
|
## Üzemeltetés
|
||||||
|
|
||||||
- Naplók: `docker compose logs -f backend worker`
|
- Naplók: `docker compose logs -f backend worker worker-ai`
|
||||||
|
- A worker két konténerben fut, ugyanabból az image-ből: a `worker` küldi az e-maileket és takarít (`WORKER_TASKS=email,cleanup`, ide kerülnek a további háttérfeladatok is), a `worker-ai` írja az elemzéseket és a válaszokat (`WORKER_TASKS=analyses`, gyors és lassú sáv). A sávok mérete a szerver `.env` fájljában állítható (`QUICK_CONCURRENCY`, `ANALYSIS_CONCURRENCY`).
|
||||||
- Visszaállás korábbi verzióra: `.env`-ben `TAG=<régebbi hash>`, utána `docker compose up -d`
|
- Visszaállás korábbi verzióra: `.env`-ben `TAG=<régebbi hash>`, utána `docker compose up -d`
|
||||||
- Mentés: naponta egy `pg_dump` a `/opt/sorsfonalak/backups` mappába, 14 napig megmarad. A mentéseket érdemes a szerverről is elvinni (DigitalOcean backup, vagy `rsync` otthonra).
|
- Mentés: naponta egy `pg_dump` a `/opt/sorsfonalak/backups` mappába, 14 napig megmarad. A mentéseket érdemes a szerverről is elvinni (DigitalOcean backup, vagy `rsync` otthonra).
|
||||||
- Visszatöltés: `gunzip -c backups/sorsfonalak-<dátum>.sql.gz | docker compose exec -T postgres psql -U sorsfonalak sorsfonalak`
|
- Visszatöltés: `gunzip -c backups/sorsfonalak-<dátum>.sql.gz | docker compose exec -T postgres psql -U sorsfonalak sorsfonalak`
|
||||||
|
|||||||
@@ -99,10 +99,12 @@ services:
|
|||||||
logging: *logging
|
logging: *logging
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# E-mail delivery, cleanup and the other background jobs.
|
||||||
worker:
|
worker:
|
||||||
image: ${REGISTRY_PREFIX:-registry.sagifer.com/sagifer/sorsfonalak}-worker:${TAG:-latest}
|
image: ${REGISTRY_PREFIX:-registry.sagifer.com/sagifer/sorsfonalak}-worker:${TAG:-latest}
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgres://sorsfonalak:${POSTGRES_PASSWORD}@postgres:5432/sorsfonalak
|
DATABASE_URL: postgres://sorsfonalak:${POSTGRES_PASSWORD}@postgres:5432/sorsfonalak
|
||||||
|
WORKER_TASKS: email,cleanup
|
||||||
# SMTP_URL or the SES credentials come from .env.secrets (docs/levelkuldes.md);
|
# SMTP_URL or the SES credentials come from .env.secrets (docs/levelkuldes.md);
|
||||||
# listing them here with an empty default would override that file.
|
# listing them here with an empty default would override that file.
|
||||||
SES_REGION: ${SES_REGION:-eu-central-1}
|
SES_REGION: ${SES_REGION:-eu-central-1}
|
||||||
@@ -118,11 +120,33 @@ services:
|
|||||||
logging: *logging
|
logging: *logging
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# The same image writing the analyses and answers (quick and slow lane);
|
||||||
|
# OPENROUTER_API_KEY comes from .env.secrets.
|
||||||
|
worker-ai:
|
||||||
|
image: ${REGISTRY_PREFIX:-registry.sagifer.com/sagifer/sorsfonalak}-worker:${TAG:-latest}
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgres://sorsfonalak:${POSTGRES_PASSWORD}@postgres:5432/sorsfonalak
|
||||||
|
WORKER_TASKS: analyses
|
||||||
|
QUICK_CONCURRENCY: ${QUICK_CONCURRENCY:-2}
|
||||||
|
ANALYSIS_CONCURRENCY: ${ANALYSIS_CONCURRENCY:-4}
|
||||||
|
PUBLIC_BASE_URL: https://${DOMAIN}
|
||||||
|
env_file:
|
||||||
|
- path: .env.secrets
|
||||||
|
required: false
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
read_only: true
|
||||||
|
logging: *logging
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: ${REGISTRY_PREFIX:-registry.sagifer.com/sagifer/sorsfonalak}-frontend:${TAG:-latest}
|
image: ${REGISTRY_PREFIX:-registry.sagifer.com/sagifer/sorsfonalak}-frontend:${TAG:-latest}
|
||||||
environment:
|
environment:
|
||||||
BACKEND_URL: http://backend:8081
|
BACKEND_URL: http://backend:8081
|
||||||
HOROSCOPE_API_URL: http://horoscope-api:8080
|
HOROSCOPE_API_URL: http://horoscope-api:8080
|
||||||
|
# Absolute links of the share previews (og:image).
|
||||||
|
PUBLIC_BASE_URL: https://${DOMAIN}
|
||||||
depends_on:
|
depends_on:
|
||||||
backend:
|
backend:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Megosztás
|
||||||
|
|
||||||
|
A képletoldalon, a rövid összefoglaló alatt van a **Megosztás** gomb. Ez egy nyilvános linket ad (`/s/<kód>`), amelyen a képlet rajza és a legfrissebb rövid összefoglaló látszik. Név és születési adatok nem kerülnek rá.
|
||||||
|
|
||||||
|
- **Ugyanaz a link:** ha ugyanazt a képletet újra megosztod, a már nyitott link jön vissza (`POST /v1/shares`: új linknél 201, meglévőnél 200).
|
||||||
|
- **Visszavonás:** a „Link visszavonása” gomb után az oldal és a kép is 404-et ad.
|
||||||
|
- **Keresők:** az oldal `noindex`, a keresők nem listázzák.
|
||||||
|
|
||||||
|
## Előnézet (Facebook, Messenger, WhatsApp, LinkedIn, X)
|
||||||
|
|
||||||
|
Az oldal `og:` és `twitter:` meta tagjei:
|
||||||
|
|
||||||
|
| Tag | Tartalom |
|
||||||
|
|---|---|
|
||||||
|
| cím | az összefoglaló címe |
|
||||||
|
| leírás | az összefoglaló első ~200 karaktere |
|
||||||
|
| kép | `/s/<kód>/kep/<verzió>.png` |
|
||||||
|
|
||||||
|
A kép egy 1200×630-as PNG. A Next.js beépített képgenerálója (`next/og`) készíti kérésre, a következőkkel:
|
||||||
|
|
||||||
|
- a radix (`src/lib/wheelSvg.ts`; ugyanaz a `<ChartWheel>`, mint az oldalon, beégetett színekkel);
|
||||||
|
- a cím és a szöveg eleje;
|
||||||
|
- a Nap, a Hold és az Aszcendens jegye.
|
||||||
|
|
||||||
|
Működése:
|
||||||
|
|
||||||
|
- **Betűtípusok:** a `src/assets/og` mappából olvassa őket. Hiányzó karakter miatt soha nem tölt le fontot az internetről, mert a nem betű, szám vagy írásjel karaktereket kiszűri.
|
||||||
|
- **Verzió:** a fájlnévben lévő verzió az összefoglaló azonosítójából és elkészültének idejéből készül. Ha az összefoglaló újragenerálódik, új címet kap a kép, és a Facebook újra letölti.
|
||||||
|
- **Gyorsítótár:** `Cache-Control: public, max-age=3600, s-maxage=86400`. A Cloudflare egy napig tartja, így egy visszavont link képe legfeljebb egy napig marad ott. A Facebook a saját példányát a saját szabályai szerint tartja meg, nagyjából 30 napig.
|
||||||
|
- **Frissítés kézzel:** a Facebook megosztás-ellenőrzőjében (Sharing Debugger) a „Scrape Again” gombbal.
|
||||||
|
|
||||||
|
A frontend a `PUBLIC_BASE_URL` alapján írja az abszolút címeket; élesben ez `https://${DOMAIN}`.
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
//! Public sharing links. Creating and revoking a link needs login; opening
|
//! Public sharing links. Creating and revoking a link needs login; opening
|
||||||
//! one (`GET /v1/public/shares/{slug}`) does not. The public view never
|
//! one (`GET /v1/public/shares/{slug}`) does not. The public view never
|
||||||
//! contains birth data unless the owner allowed it for their own chart.
|
//! contains birth data unless the owner allowed it for their own chart.
|
||||||
|
//! A shared chart comes with its newest short summary (the share page and
|
||||||
|
//! its preview image show both). Sharing the same thing again returns the
|
||||||
|
//! link that is already open.
|
||||||
|
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use axum::extract::{Path, State};
|
use axum::extract::{Path, State};
|
||||||
@@ -109,6 +112,24 @@ pub async fn create(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let title = req.title.map(|t| t.trim().chars().take(120).collect::<String>()).filter(|t| !t.is_empty());
|
let title = req.title.map(|t| t.trim().chars().take(120).collect::<String>()).filter(|t| !t.is_empty());
|
||||||
|
let open: Option<ShareRow> = sqlx::query_as(&format!(
|
||||||
|
"SELECT {SHARE_COLUMNS} FROM shares WHERE owner_id = $1 AND kind = $2 AND revoked_at IS NULL \
|
||||||
|
AND chart_id IS NOT DISTINCT FROM $3 AND synastry_id IS NOT DISTINCT FROM $4 \
|
||||||
|
AND analysis_id IS NOT DISTINCT FROM $5 AND title IS NOT DISTINCT FROM $6 AND show_birth_data = $7 \
|
||||||
|
ORDER BY created_at DESC LIMIT 1"
|
||||||
|
))
|
||||||
|
.bind(auth.id())
|
||||||
|
.bind(kind)
|
||||||
|
.bind(chart_id)
|
||||||
|
.bind(synastry_id)
|
||||||
|
.bind(analysis_id)
|
||||||
|
.bind(&title)
|
||||||
|
.bind(req.show_birth_data)
|
||||||
|
.fetch_optional(&state.db)
|
||||||
|
.await?;
|
||||||
|
if let Some(row) = open {
|
||||||
|
return Ok((StatusCode::OK, Json(row.view(&state.config.public_base_url))));
|
||||||
|
}
|
||||||
let row: ShareRow = sqlx::query_as(&format!(
|
let row: ShareRow = sqlx::query_as(&format!(
|
||||||
"INSERT INTO shares (id, owner_id, slug, kind, chart_id, synastry_id, analysis_id, title, show_birth_data) \
|
"INSERT INTO shares (id, owner_id, slug, kind, chart_id, synastry_id, analysis_id, title, show_birth_data) \
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING {SHARE_COLUMNS}"
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING {SHARE_COLUMNS}"
|
||||||
@@ -175,6 +196,7 @@ async fn public_body(db: &PgPool, share: &ShareRow) -> Result<Value, ApiError> {
|
|||||||
if let Some(chart_id) = share.chart_id {
|
if let Some(chart_id) = share.chart_id {
|
||||||
let chart = find_chart(db, chart_id).await?.ok_or(ApiError::NotFound("share"))?;
|
let chart = find_chart(db, chart_id).await?.ok_or(ApiError::NotFound("share"))?;
|
||||||
body["chart"] = public_chart_block(&chart, share);
|
body["chart"] = public_chart_block(&chart, share);
|
||||||
|
body["summary"] = latest_summary(db, chart_id).await?;
|
||||||
} else if let Some(synastry_id) = share.synastry_id {
|
} else if let Some(synastry_id) = share.synastry_id {
|
||||||
let s = load_synastry(db, synastry_id).await?.ok_or(ApiError::NotFound("share"))?;
|
let s = load_synastry(db, synastry_id).await?.ok_or(ApiError::NotFound("share"))?;
|
||||||
body["synastry"] = public_synastry_block(&s, share);
|
body["synastry"] = public_synastry_block(&s, share);
|
||||||
@@ -198,6 +220,28 @@ async fn public_body(db: &PgPool, share: &ShareRow) -> Result<Value, ApiError> {
|
|||||||
Ok(body)
|
Ok(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The newest finished short summary of a chart (`null` if none).
|
||||||
|
async fn latest_summary(db: &PgPool, chart_id: Uuid) -> Result<Value, sqlx::Error> {
|
||||||
|
type Row = (Uuid, String, Option<Value>, Option<OffsetDateTime>);
|
||||||
|
let row: Option<Row> = sqlx::query_as(
|
||||||
|
"SELECT id, language, content, completed_at FROM analyses \
|
||||||
|
WHERE chart_id = $1 AND kind = 'summary' AND status = 'done' ORDER BY completed_at DESC LIMIT 1",
|
||||||
|
)
|
||||||
|
.bind(chart_id)
|
||||||
|
.fetch_optional(db)
|
||||||
|
.await?;
|
||||||
|
Ok(match row {
|
||||||
|
Some((id, language, content, completed_at)) => json!({
|
||||||
|
"id": id,
|
||||||
|
"language": language,
|
||||||
|
"title": content.as_ref().and_then(|c| c["title"].as_str()),
|
||||||
|
"summary": content.as_ref().and_then(|c| c["summary"].as_str()),
|
||||||
|
"completed_at": rfc3339_opt(completed_at),
|
||||||
|
}),
|
||||||
|
None => Value::Null,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Public: the shared content for the share page and its OG image.
|
/// Public: the shared content for the share page and its OG image.
|
||||||
pub async fn public_view(State(state): St, Path(slug): Path<String>) -> ApiResult<Json<Value>> {
|
pub async fn public_view(State(state): St, Path(slug): Path<String>) -> ApiResult<Json<Value>> {
|
||||||
let share: ShareRow = sqlx::query_as(&format!(
|
let share: ShareRow = sqlx::query_as(&format!(
|
||||||
|
|||||||
@@ -628,6 +628,30 @@ async fn public_shares(pool: PgPool) {
|
|||||||
for hidden in ["input", "location", "time", "astronomy", "birth"] {
|
for hidden in ["input", "location", "time", "astronomy", "birth"] {
|
||||||
assert!(shown.get(hidden).is_none(), "{hidden} must not be public");
|
assert!(shown.get(hidden).is_none(), "{hidden} must not be public");
|
||||||
}
|
}
|
||||||
|
assert!(r.body["summary"].is_null(), "no finished summary yet");
|
||||||
|
|
||||||
|
// the newest finished summary comes with the chart
|
||||||
|
sqlx::query(
|
||||||
|
"INSERT INTO analyses (id, kind, chart_id, requested_by, language, model, prompt_version, cache_key, \
|
||||||
|
credits_charged, status, content, completed_at) \
|
||||||
|
VALUES ($1, 'summary', $2::uuid, (SELECT id FROM users WHERE email = 'anna@example.com'), 'hu', 'm', 'v', \
|
||||||
|
'k', 0, 'done', $3, now())",
|
||||||
|
)
|
||||||
|
.bind(uuid::Uuid::now_v7())
|
||||||
|
.bind(chart_id)
|
||||||
|
.bind(json!({"title": "Csendes erő", "summary": "Rövid **összefoglaló**."}))
|
||||||
|
.execute(&app.pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let r = app.get(&format!("/v1/public/shares/{slug}"), None).await;
|
||||||
|
assert_eq!(r.body["summary"]["title"], "Csendes erő");
|
||||||
|
assert_eq!(r.body["summary"]["summary"], "Rövid **összefoglaló**.");
|
||||||
|
|
||||||
|
// sharing the same again gives the open link
|
||||||
|
let r = app
|
||||||
|
.post("/v1/shares", Some(&anna), json!({"kind": "chart", "target_id": chart_id, "title": "A radixom"}))
|
||||||
|
.await;
|
||||||
|
assert_eq!((r.status, r.body["slug"].as_str()), (StatusCode::OK, Some(slug.as_str())));
|
||||||
|
|
||||||
let r = app
|
let r = app
|
||||||
.post("/v1/shares", Some(&anna), json!({"kind": "chart", "target_id": chart_id, "show_birth_data": true}))
|
.post("/v1/shares", Some(&anna), json!({"kind": "chart", "target_id": chart_id, "show_birth_data": true}))
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<!-- BEGIN:nextjs-agent-rules -->
|
||||||
|
|
||||||
|
## This is NOT the Next.js you know
|
||||||
|
|
||||||
|
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
|
||||||
|
|
||||||
|
This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
|
||||||
|
|
||||||
|
<!-- END:nextjs-agent-rules -->
|
||||||
@@ -4,6 +4,8 @@ const config: NextConfig = {
|
|||||||
// Small self-contained server for the container image.
|
// Small self-contained server for the container image.
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
poweredByHeader: false,
|
poweredByHeader: false,
|
||||||
|
// The fonts of the share preview images are read from disk at run time.
|
||||||
|
outputFileTracingIncludes: { "/s/[slug]/kep/[file]": ["./src/assets/og/*.ttf"] },
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
@@ -37,67 +37,69 @@ export default async function PrivacyPage() {
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2>2. Milyen adatokat kezelünk, és miért?</h2>
|
<h2>2. Milyen adatokat kezelünk, és miért?</h2>
|
||||||
<table className="legal-table">
|
<div className="table-wrap">
|
||||||
<thead>
|
<table className="legal-table">
|
||||||
<tr>
|
<thead>
|
||||||
<th scope="col">Adat</th>
|
<tr>
|
||||||
<th scope="col">Cél</th>
|
<th scope="col">Adat</th>
|
||||||
<th scope="col">Jogalap</th>
|
<th scope="col">Cél</th>
|
||||||
</tr>
|
<th scope="col">Jogalap</th>
|
||||||
</thead>
|
</tr>
|
||||||
<tbody>
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<td>Google-fiókod neve, e-mail-címe és azonosítója (belépéskor a Google adja át)</td>
|
<tr>
|
||||||
<td>Fiókod létrehozása, belépés, kapcsolattartás</td>
|
<td>Google-fiókod neve, e-mail-címe és azonosítója (belépéskor a Google adja át)</td>
|
||||||
<td>Szerződés teljesítése (GDPR 6. cikk (1) b)</td>
|
<td>Fiókod létrehozása, belépés, kapcsolattartás</td>
|
||||||
</tr>
|
<td>Szerződés teljesítése (GDPR 6. cikk (1) b)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>Megjelenített név, az elemzések nyelve</td>
|
<tr>
|
||||||
<td>A szolgáltatás személyre szabása</td>
|
<td>Megjelenített név, az elemzések nyelve</td>
|
||||||
<td>Szerződés teljesítése</td>
|
<td>A szolgáltatás személyre szabása</td>
|
||||||
</tr>
|
<td>Szerződés teljesítése</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>Születési adataid: dátum, időpont, hely</td>
|
<tr>
|
||||||
<td>A születési képleted kiszámítása és az elemzések elkészítése</td>
|
<td>Születési adataid: dátum, időpont, hely</td>
|
||||||
<td>Szerződés teljesítése</td>
|
<td>A születési képleted kiszámítása és az elemzések elkészítése</td>
|
||||||
</tr>
|
<td>Szerződés teljesítése</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>Az általad felvett személyek neve és születési adatai</td>
|
<tr>
|
||||||
<td>Az ő képletük és elemzésük elkészítése a kérésedre</td>
|
<td>Az általad felvett személyek neve és születési adatai</td>
|
||||||
<td>Szerződés teljesítése; a felvételhez az érintett beleegyezése szükséges (lásd 4. pont)</td>
|
<td>Az ő képletük és elemzésük elkészítése a kérésedre</td>
|
||||||
</tr>
|
<td>Szerződés teljesítése; a felvételhez az érintett beleegyezése szükséges (lásd 4. pont)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>A képletek és az elkészült elemzések</td>
|
<tr>
|
||||||
<td>Hogy bármikor újra megnézhesd őket</td>
|
<td>A képletek és az elkészült elemzések</td>
|
||||||
<td>Szerződés teljesítése</td>
|
<td>Hogy bármikor újra megnézhesd őket</td>
|
||||||
</tr>
|
<td>Szerződés teljesítése</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>Vásárlásaid és felhasznált kereteid (elemzések, személyek)</td>
|
<tr>
|
||||||
<td>A megvásárolt szolgáltatás nyújtása, elszámolás</td>
|
<td>Vásárlásaid és felhasznált kereteid (elemzések, személyek)</td>
|
||||||
<td>Szerződés teljesítése; számviteli kötelezettség (6. cikk (1) c)</td>
|
<td>A megvásárolt szolgáltatás nyújtása, elszámolás</td>
|
||||||
</tr>
|
<td>Szerződés teljesítése; számviteli kötelezettség (6. cikk (1) c)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>Meghívott e-mail-címe, a meghívó neve és személyes üzenete</td>
|
<tr>
|
||||||
<td>A meghívó elküldése; amíg az oldal zártkörű, csak meghívottak regisztrálhatnak</td>
|
<td>Meghívott e-mail-címe, a meghívó neve és személyes üzenete</td>
|
||||||
<td>Jogos érdek (6. cikk (1) f)</td>
|
<td>A meghívó elküldése; amíg az oldal zártkörű, csak meghívottak regisztrálhatnak</td>
|
||||||
</tr>
|
<td>Jogos érdek (6. cikk (1) f)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>A várólistán megadott e-mail-cím</td>
|
<tr>
|
||||||
<td>Értesítés, ha megnyílik az oldal, vagy meghívót küldünk</td>
|
<td>A várólistán megadott e-mail-cím</td>
|
||||||
<td>Hozzájárulás (6. cikk (1) a)</td>
|
<td>Értesítés, ha megnyílik az oldal, vagy meghívót küldünk</td>
|
||||||
</tr>
|
<td>Hozzájárulás (6. cikk (1) a)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>Azok a címek, amelyek leiratkoztak a meghívókról (csak a cím egyirányú lenyomata, hash-e)</td>
|
<tr>
|
||||||
<td>Hogy ezekre a címekre ne küldjünk több meghívót</td>
|
<td>Azok a címek, amelyek leiratkoztak a meghívókról (csak a cím egyirányú lenyomata, hash-e)</td>
|
||||||
<td>Jogos érdek (6. cikk (1) f)</td>
|
<td>Hogy ezekre a címekre ne küldjünk több meghívót</td>
|
||||||
</tr>
|
<td>Jogos érdek (6. cikk (1) f)</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>IP-cím, böngésző adatai, a kérések ideje (szervernaplók)</td>
|
<tr>
|
||||||
<td>Biztonság, hibakeresés, visszaélések kiszűrése</td>
|
<td>IP-cím, böngésző adatai, a kérések ideje (szervernaplók)</td>
|
||||||
<td>Jogos érdek (6. cikk (1) f)</td>
|
<td>Biztonság, hibakeresés, visszaélések kiszűrése</td>
|
||||||
</tr>
|
<td>Jogos érdek (6. cikk (1) f)</td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<p>
|
<p>
|
||||||
Bankkártyaadatot nem kezelünk és nem tárolunk; a fizetést, amikor elindul, külső fizetési szolgáltató
|
Bankkártyaadatot nem kezelünk és nem tárolunk; a fizetést, amikor elindul, külső fizetési szolgáltató
|
||||||
végzi, akinek a neve itt lesz feltüntetve.
|
végzi, akinek a neve itt lesz feltüntetve.
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
html, body { margin: 0; }
|
html, body { margin: 0; }
|
||||||
body {
|
body {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
overflow-x: clip; /* nothing may push the page sideways on a phone */
|
||||||
|
overflow-wrap: break-word;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font: 400 15px/1.55 var(--font-body);
|
font: 400 15px/1.55 var(--font-body);
|
||||||
@@ -71,8 +73,8 @@ p { margin: 0; }
|
|||||||
.page-head { display: flex; flex-direction: column; gap: 6px; }
|
.page-head { display: flex; flex-direction: column; gap: 6px; }
|
||||||
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
|
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
|
||||||
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
|
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
|
||||||
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
|
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }
|
||||||
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
|
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
|
||||||
.facts dt { color: var(--muted); }
|
.facts dt { color: var(--muted); }
|
||||||
.facts dd { margin: 0; }
|
.facts dd { margin: 0; }
|
||||||
|
|
||||||
@@ -81,11 +83,11 @@ p { margin: 0; }
|
|||||||
.field label, .label { font-size: 14px; font-weight: 500; }
|
.field label, .label { font-size: 14px; font-weight: 500; }
|
||||||
.hint { font-size: 13px; color: var(--muted); }
|
.hint { font-size: 13px; color: var(--muted); }
|
||||||
.inp {
|
.inp {
|
||||||
width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--radius);
|
width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--radius);
|
||||||
border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink);
|
border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink);
|
||||||
font: 400 15px var(--font-body);
|
font: 400 15px var(--font-body);
|
||||||
}
|
}
|
||||||
select.inp { padding-right: 32px; }
|
select.inp { padding-right: 32px; text-overflow: ellipsis; }
|
||||||
.inp::placeholder { color: #8a93ab; }
|
.inp::placeholder { color: #8a93ab; }
|
||||||
.inp:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 180, 106, 0.25); }
|
.inp:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 180, 106, 0.25); }
|
||||||
.inp:disabled { opacity: 0.55; }
|
.inp:disabled { opacity: 0.55; }
|
||||||
@@ -190,7 +192,7 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|||||||
.analysis-section h3 { font-size: 24px; color: var(--gold); }
|
.analysis-section h3 { font-size: 24px; color: var(--gold); }
|
||||||
.analysis-section p, .analysis-lists li { font-size: 16px; line-height: 1.75; color: var(--ink-2); }
|
.analysis-section p, .analysis-lists li { font-size: 16px; line-height: 1.75; color: var(--ink-2); }
|
||||||
.analysis strong { color: var(--ink); font-weight: 600; }
|
.analysis strong { color: var(--ink); font-weight: 600; }
|
||||||
.analysis-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
|
.analysis-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 24px; }
|
||||||
.analysis-lists h3 { font-size: 22px; margin-bottom: 8px; }
|
.analysis-lists h3 { font-size: 22px; margin-bottom: 8px; }
|
||||||
.analysis-lists ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
|
.analysis-lists ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
|
||||||
.analysis-advice { border-top: 1px solid var(--line); padding-top: 24px; }
|
.analysis-advice { border-top: 1px solid var(--line); padding-top: 24px; }
|
||||||
@@ -308,7 +310,7 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|||||||
.w-point:hover .w-point-glyph { fill: var(--gold); }
|
.w-point:hover .w-point-glyph { fill: var(--gold); }
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.chart-layout { grid-template-columns: 1fr; }
|
.chart-layout { grid-template-columns: minmax(0, 1fr); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
@@ -342,7 +344,7 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|||||||
@media (max-width: 640px) { .tab { padding: 12px 10px; font-size: 14px; } .tabs { scroll-margin-top: 120px; } }
|
@media (max-width: 640px) { .tab { padding: 12px 10px; font-size: 14px; } .tabs { scroll-margin-top: 120px; } }
|
||||||
|
|
||||||
/* Charts list, persons */
|
/* Charts list, persons */
|
||||||
.chart-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
|
.chart-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 16px; }
|
||||||
.chart-card {
|
.chart-card {
|
||||||
background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column;
|
background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column;
|
||||||
transition: border-color 0.15s;
|
transition: border-color 0.15s;
|
||||||
@@ -485,14 +487,14 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|||||||
.nature-challenging { background: var(--tense); }
|
.nature-challenging { background: var(--tense); }
|
||||||
.nature-neutral { background: var(--gold); }
|
.nature-neutral { background: var(--gold); }
|
||||||
.nature-list { margin: 0; display: flex; flex-direction: column; gap: 8px; }
|
.nature-list { margin: 0; display: flex; flex-direction: column; gap: 8px; }
|
||||||
.nature-list > div { display: grid; grid-template-columns: 128px 1fr; gap: 8px; align-items: baseline; }
|
.nature-list > div { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 8px; align-items: baseline; }
|
||||||
.nature-list dt { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
|
.nature-list dt { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
|
||||||
.nature-list dd { margin: 0; }
|
.nature-list dd { margin: 0; }
|
||||||
.nature-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
|
.nature-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
|
||||||
|
|
||||||
.pair-card { gap: 4px; }
|
.pair-card { gap: 4px; }
|
||||||
.pair-row {
|
.pair-row {
|
||||||
display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0;
|
display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0;
|
||||||
color: inherit; text-decoration: none; border-bottom: 1px solid var(--line);
|
color: inherit; text-decoration: none; border-bottom: 1px solid var(--line);
|
||||||
}
|
}
|
||||||
.pair-row:last-child { border-bottom: 0; padding-bottom: 0; }
|
.pair-row:last-child { border-bottom: 0; padding-bottom: 0; }
|
||||||
@@ -501,7 +503,7 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.pair-text strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
|
.pair-text strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
|
||||||
|
|
||||||
.compare-new { gap: 16px; }
|
.compare-new { gap: 16px; }
|
||||||
.compare-form { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 12px; align-items: end; }
|
.compare-form { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 12px; align-items: end; }
|
||||||
.compare-swap { font-size: 20px; padding: 0 10px; }
|
.compare-swap { font-size: 20px; padding: 0 10px; }
|
||||||
.compare-tile { gap: 6px; padding: 16px 20px; }
|
.compare-tile { gap: 6px; padding: 16px 20px; }
|
||||||
.compare-tile strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
|
.compare-tile strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
|
||||||
@@ -509,12 +511,12 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.compare-tile .form-actions { margin-top: 6px; }
|
.compare-tile .form-actions { margin-top: 6px; }
|
||||||
.back-link { font-size: 14px; text-decoration: none; align-self: flex-start; }
|
.back-link { font-size: 14px; text-decoration: none; align-self: flex-start; }
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.compare-form { grid-template-columns: 1fr auto; }
|
.compare-form { grid-template-columns: minmax(0, 1fr) auto; }
|
||||||
.compare-form .field:first-child { grid-column: 1; }
|
.compare-form .field:first-child { grid-column: 1; }
|
||||||
.compare-swap { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
|
.compare-swap { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
|
||||||
.compare-form .field:nth-child(3) { grid-column: 1; }
|
.compare-form .field:nth-child(3) { grid-column: 1; }
|
||||||
.compare-form > .btn-primary { grid-column: 1 / -1; width: 100%; }
|
.compare-form > .btn-primary { grid-column: 1 / -1; width: 100%; }
|
||||||
.nature-list > div { grid-template-columns: 1fr; gap: 2px; }
|
.nature-list > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
|
||||||
.nav { overflow-x: auto; scrollbar-width: none; }
|
.nav { overflow-x: auto; scrollbar-width: none; }
|
||||||
.nav a { white-space: nowrap; padding: 10px 9px; }
|
.nav a { white-space: nowrap; padding: 10px 9px; }
|
||||||
.cross-grid td.cross-corner { min-width: 56px; font-size: 9px; }
|
.cross-grid td.cross-corner { min-width: 56px; font-size: 9px; }
|
||||||
@@ -522,7 +524,7 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
|
|
||||||
/* Packages */
|
/* Packages */
|
||||||
.pkg-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
|
.pkg-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
|
||||||
.pkg-grid-compact { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
|
.pkg-grid-compact { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 12px; }
|
||||||
.pkg {
|
.pkg {
|
||||||
position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px 20px 20px;
|
position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px 20px 20px;
|
||||||
background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius);
|
background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius);
|
||||||
@@ -589,7 +591,7 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.timeline-month h3 { font-size: 20px; margin: 0 0 8px; text-transform: capitalize; }
|
.timeline-month h3 { font-size: 20px; margin: 0 0 8px; text-transform: capitalize; }
|
||||||
.timeline-month ol, .transit-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
|
.timeline-month ol, .transit-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
|
||||||
.timeline-item {
|
.timeline-item {
|
||||||
display: grid; grid-template-columns: 64px 56px 1fr; gap: 10px; align-items: baseline;
|
display: grid; grid-template-columns: 64px 56px minmax(0, 1fr); gap: 10px; align-items: baseline;
|
||||||
padding: 8px 12px; border-left: 3px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, 0.02);
|
padding: 8px 12px; border-left: 3px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, 0.02);
|
||||||
}
|
}
|
||||||
.timeline-date { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
.timeline-date { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||||
@@ -599,15 +601,15 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.timeline-item.tone-harmonic, .transit-list .tone-harmonic { border-left-color: var(--harmonic); }
|
.timeline-item.tone-harmonic, .transit-list .tone-harmonic { border-left-color: var(--harmonic); }
|
||||||
.timeline-item.tone-neutral, .transit-list .tone-neutral { border-left-color: var(--gold); }
|
.timeline-item.tone-neutral, .transit-list .tone-neutral { border-left-color: var(--gold); }
|
||||||
.transit-list li {
|
.transit-list li {
|
||||||
display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: baseline;
|
display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; align-items: baseline;
|
||||||
padding: 8px 12px; border-left: 3px solid var(--line); border-radius: 4px;
|
padding: 8px 12px; border-left: 3px solid var(--line); border-radius: 4px;
|
||||||
}
|
}
|
||||||
.transit-list li > span:last-child { display: flex; flex-direction: column; gap: 2px; }
|
.transit-list li > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||||
.transit-list .sym { font-size: 17px; color: var(--gold); white-space: nowrap; }
|
.transit-list .sym { font-size: 17px; color: var(--gold); white-space: nowrap; }
|
||||||
.transit-list .pill { align-self: flex-start; font-size: 12px; padding: 1px 8px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); }
|
.transit-list .pill { align-self: flex-start; font-size: 12px; padding: 1px 8px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); }
|
||||||
.plain-list { margin: 8px 0 12px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
|
.plain-list { margin: 8px 0 12px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
|
||||||
@media (max-width: 560px) {
|
@media (max-width: 560px) {
|
||||||
.timeline-item { grid-template-columns: 52px 1fr; }
|
.timeline-item { grid-template-columns: 52px minmax(0, 1fr); }
|
||||||
.timeline-glyph { display: none; }
|
.timeline-glyph { display: none; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,7 +640,7 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.questions { display: flex; flex-direction: column; gap: 14px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
|
.questions { display: flex; flex-direction: column; gap: 14px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
|
||||||
.questions h3 { margin: 0; }
|
.questions h3 { margin: 0; }
|
||||||
.qa { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
|
.qa { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
|
||||||
.qa-question { margin: 0; display: flex; flex-direction: column; gap: 2px; font-weight: 600; white-space: pre-wrap; }
|
.qa-question { margin: 0; display: flex; flex-direction: column; gap: 2px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||||
.qa-answer { display: flex; flex-direction: column; gap: 6px; }
|
.qa-answer { display: flex; flex-direction: column; gap: 6px; }
|
||||||
.qa-answer p { margin: 0 0 8px; }
|
.qa-answer p { margin: 0 0 8px; }
|
||||||
.qa-form { display: flex; flex-direction: column; gap: 8px; }
|
.qa-form { display: flex; flex-direction: column; gap: 8px; }
|
||||||
@@ -657,3 +659,50 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.error-log .error-text { overflow-wrap: anywhere; max-width: 460px; }
|
.error-log .error-text { overflow-wrap: anywhere; max-width: 460px; }
|
||||||
.error-log .outcome { white-space: nowrap; }
|
.error-log .outcome { white-space: nowrap; }
|
||||||
.error-log .outcome.tone-tense { color: var(--tense); font-weight: 600; }
|
.error-log .outcome.tone-tense { color: var(--tense); font-weight: 600; }
|
||||||
|
|
||||||
|
/* Generated text (summaries, analyses, answers): justified, with hyphenation so
|
||||||
|
narrow screens get no wide gaps. The last line of a paragraph stays ragged. */
|
||||||
|
.analysis-lead, .analysis-section p, .analysis-lists li, .summary-text, .qa-answer p {
|
||||||
|
text-align: justify;
|
||||||
|
hyphens: auto;
|
||||||
|
-webkit-hyphens: auto;
|
||||||
|
hyphenate-limit-chars: 7 3 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Phones: tighter spacing, smaller headings, no sideways scrolling */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.page { padding: 20px 14px 48px; gap: 18px; }
|
||||||
|
.card { padding: 16px; gap: 14px; }
|
||||||
|
h2 { font-size: 24px; }
|
||||||
|
.analysis { gap: 22px; }
|
||||||
|
.analysis-head h2 { font-size: 28px; }
|
||||||
|
.analysis-section h3 { font-size: 21px; }
|
||||||
|
.analysis-lists h3 { font-size: 20px; }
|
||||||
|
.analysis-lead { font-size: 16px; line-height: 1.65; }
|
||||||
|
.analysis-section p, .analysis-lists li, .summary-text { font-size: 15.5px; line-height: 1.7; }
|
||||||
|
.analysis-lists ul { padding-left: 18px; }
|
||||||
|
.summary-title { font-size: 23px; }
|
||||||
|
.questions { margin-top: 22px; padding-top: 18px; }
|
||||||
|
.qa { padding: 12px; }
|
||||||
|
.pay-box { padding: 16px; }
|
||||||
|
.loading-wheel { width: 96px; height: 96px; }
|
||||||
|
.tagline { font-size: 32px; }
|
||||||
|
}
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
/* label above value: the label column would squeeze the values */
|
||||||
|
.facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
|
||||||
|
.facts dd + dt { margin-top: 8px; }
|
||||||
|
.site-header { gap: 8px 12px; }
|
||||||
|
.logo { font-size: 25px; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sharing a chart (summary card) and the public share page */
|
||||||
|
.share { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
|
||||||
|
.share-open { align-items: stretch; padding: 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); }
|
||||||
|
.share-link { display: flex; gap: 8px; }
|
||||||
|
.share-link .inp { min-height: 36px; font-size: 14px; }
|
||||||
|
.share-trio { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 14px; }
|
||||||
|
.share-trio .sym { color: var(--gold); }
|
||||||
|
.share-cta { gap: 12px; }
|
||||||
|
.share-cta h2 { font-size: 24px; }
|
||||||
|
.share-cta .btn { align-self: flex-start; }
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// The link preview image of a shared chart (og:image): 1200×630 PNG with the
|
||||||
|
// wheel, the title and the text of the short summary. The file name carries
|
||||||
|
// a version (see `imageVersion`), so a rewritten summary gets a new address
|
||||||
|
// and Facebook and co. fetch it again.
|
||||||
|
import { readFile } from "node:fs/promises";
|
||||||
|
import { join } from "node:path";
|
||||||
|
|
||||||
|
import { ImageResponse } from "next/og";
|
||||||
|
|
||||||
|
import { SIGNS, signName } from "@/lib/astro";
|
||||||
|
import { bigThree, loadShare, plain, shorten } from "@/lib/share";
|
||||||
|
import { wheelSvg } from "@/lib/wheelSvg";
|
||||||
|
|
||||||
|
const W = 1200;
|
||||||
|
const H = 630;
|
||||||
|
const WHEEL = 590;
|
||||||
|
|
||||||
|
const FONTS = join(process.cwd(), "src/assets/og");
|
||||||
|
let fonts: Promise<{ name: string; data: Buffer; weight: 400 | 600; style: "normal" }[]> | null = null;
|
||||||
|
|
||||||
|
function loadFonts() {
|
||||||
|
fonts ??= Promise.all(
|
||||||
|
(
|
||||||
|
[
|
||||||
|
["Cormorant Garamond", "CormorantGaramond-SemiBold.ttf", 600],
|
||||||
|
["Inter", "Inter-Regular.ttf", 400],
|
||||||
|
["Inter", "Inter-SemiBold.ttf", 600],
|
||||||
|
["DejaVu Sans", "DejaVuSans.ttf", 400],
|
||||||
|
] as const
|
||||||
|
).map(async ([name, file, weight]) => ({
|
||||||
|
name,
|
||||||
|
data: await readFile(join(FONTS, file)),
|
||||||
|
weight,
|
||||||
|
style: "normal" as const,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
return fonts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Letters, digits, punctuation and spaces only: a character missing from the
|
||||||
|
// fonts would make the renderer download a font from the internet.
|
||||||
|
const printable = (s: string) => s.replace(/[^\p{L}\p{N}\p{P}\p{Zs}+=<>°]/gu, "");
|
||||||
|
|
||||||
|
export async function GET(_req: Request, { params }: { params: Promise<{ slug: string; file: string }> }) {
|
||||||
|
const { slug } = await params;
|
||||||
|
const share = await loadShare(slug);
|
||||||
|
const chart = share?.chart?.chart;
|
||||||
|
if (!share || !chart) return new Response("Not found", { status: 404 });
|
||||||
|
|
||||||
|
const title = printable(share.summary?.title ?? "Születési képlet");
|
||||||
|
const text = printable(shorten(plain(share.summary?.summary ?? ""), 280));
|
||||||
|
const svg = wheelSvg(chart, chart.time_known, WHEEL);
|
||||||
|
const trio = bigThree(chart);
|
||||||
|
|
||||||
|
const image = new ImageResponse(
|
||||||
|
(
|
||||||
|
<div style={{ display: "flex", width: W, height: H, background: "#0d1220", color: "#ece6d8", fontFamily: "Inter" }}>
|
||||||
|
<div style={{ display: "flex", width: WHEEL + 40, height: H, alignItems: "center", justifyContent: "center" }}>
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
|
<img
|
||||||
|
src={`data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`}
|
||||||
|
width={WHEEL}
|
||||||
|
height={WHEEL}
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
flex: 1,
|
||||||
|
padding: "56px 56px 44px 8px",
|
||||||
|
gap: 18,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ display: "flex", fontSize: 17, fontWeight: 600, letterSpacing: 2.5, color: "#d9b46a" }}>
|
||||||
|
SZÜLETÉSI KÉPLET · RÖVIDEN
|
||||||
|
</div>
|
||||||
|
<div style={{ display: "flex", fontFamily: "Cormorant Garamond", fontSize: 56, lineHeight: 1.05 }}>{title}</div>
|
||||||
|
{text && <div style={{ display: "flex", fontSize: 23, lineHeight: 1.45, color: "#c9cfdc" }}>{text}</div>}
|
||||||
|
<div style={{ display: "flex", marginTop: "auto", gap: 22, fontSize: 21, color: "#c9cfdc" }}>
|
||||||
|
{trio.map((t) => (
|
||||||
|
<div key={t.label} style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
||||||
|
<span style={{ fontFamily: "DejaVu Sans", color: "#d9b46a" }}>
|
||||||
|
{(SIGNS[t.sign]?.glyph ?? "").replace(/︎/g, "")}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{t.label === "Aszcendens" ? "Asc" : t.label} {signName(t.sign)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div style={{ display: "flex", fontFamily: "Cormorant Garamond", fontSize: 30, color: "#ece6d8" }}>
|
||||||
|
sors<span style={{ color: "#d9b46a" }}>fonalak</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
{
|
||||||
|
width: W,
|
||||||
|
height: H,
|
||||||
|
fonts: await loadFonts(),
|
||||||
|
// A day at the edge: a revoked link's image goes away from there too.
|
||||||
|
headers: { "Cache-Control": "public, max-age=3600, s-maxage=86400" },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
|
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
|
||||||
|
import { Rich } from "@/components/Rich";
|
||||||
|
import { Logo } from "@/components/SiteHeader";
|
||||||
|
import { SIGNS, signName } from "@/lib/astro";
|
||||||
|
import { getMe } from "@/lib/server";
|
||||||
|
import { bigThree, imageVersion, loadShare, plain, shorten, siteUrl } from "@/lib/share";
|
||||||
|
|
||||||
|
type Props = { params: Promise<{ slug: string }> };
|
||||||
|
|
||||||
|
/** Title, description and preview image for Facebook, Messenger, WhatsApp and co. */
|
||||||
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||||
|
const { slug } = await params;
|
||||||
|
const share = await loadShare(slug);
|
||||||
|
if (!share?.chart) return { title: "A link nem érhető el", robots: { index: false } };
|
||||||
|
const base = await siteUrl();
|
||||||
|
const title = share.summary?.title ?? "Születési képlet";
|
||||||
|
const description = share.summary?.summary
|
||||||
|
? shorten(plain(share.summary.summary), 200)
|
||||||
|
: "Egy születési képlet a Sorsfonalakon.";
|
||||||
|
const url = `${base}/s/${slug}`;
|
||||||
|
const image = { url: `${base}/s/${slug}/kep/${imageVersion(share)}.png`, width: 1200, height: 630, alt: title };
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
// Personal content: shown when shared, not listed in search engines.
|
||||||
|
robots: { index: false, follow: false },
|
||||||
|
alternates: { canonical: url },
|
||||||
|
openGraph: { type: "website", siteName: "Sorsfonalak", locale: "hu_HU", url, title, description, images: [image] },
|
||||||
|
twitter: { card: "summary_large_image", title, description, images: [image.url] },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A shared chart: the wheel and its short summary, open to anyone with the link. */
|
||||||
|
export default async function SharedChartPage({ params }: Props) {
|
||||||
|
const { slug } = await params;
|
||||||
|
const [share, me] = await Promise.all([loadShare(slug), getMe()]);
|
||||||
|
const chart = share?.chart?.chart;
|
||||||
|
if (!share || !chart) notFound();
|
||||||
|
const summary = share.summary;
|
||||||
|
const trio = bigThree(chart);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!me && (
|
||||||
|
<header className="site-header">
|
||||||
|
<Logo />
|
||||||
|
<span style={{ flex: 1 }} />
|
||||||
|
<Link href="/belepes" className="btn btn-sm">
|
||||||
|
Belépés
|
||||||
|
</Link>
|
||||||
|
</header>
|
||||||
|
)}
|
||||||
|
<main className="page" style={{ maxWidth: 1180 }}>
|
||||||
|
<div className="page-head">
|
||||||
|
<span className="eyebrow">Megosztott születési képlet</span>
|
||||||
|
<h1>{summary?.title ?? "Születési képlet"}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section className="chart-layout" aria-label="A megosztott képlet">
|
||||||
|
<div className="card chart-wheel-card">
|
||||||
|
<ChartWheel chart={chart} timeKnown={chart.time_known} />
|
||||||
|
<WheelLegend />
|
||||||
|
</div>
|
||||||
|
<div className="field chart-side">
|
||||||
|
<section className="card summary-card" aria-label="Röviden">
|
||||||
|
<span className="eyebrow">Röviden</span>
|
||||||
|
{summary?.summary ? (
|
||||||
|
<p className="summary-text" lang={summary.language}>
|
||||||
|
<Rich text={summary.summary} />
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="muted">Ehhez a képlethez még nincs rövid összefoglaló.</p>
|
||||||
|
)}
|
||||||
|
{trio.length > 0 && (
|
||||||
|
<p className="share-trio">
|
||||||
|
{trio.map((t) => (
|
||||||
|
<span key={t.label}>
|
||||||
|
<span className="sym" aria-hidden="true">
|
||||||
|
{SIGNS[t.sign]?.glyph}
|
||||||
|
</span>{" "}
|
||||||
|
{t.label} {signName(t.sign)}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{!chart.time_known && (
|
||||||
|
<p className="hint">A születési idő nem ismert, ezért a képleten nincsenek házak és Aszcendens.</p>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
<section className="card share-cta">
|
||||||
|
<h2>És a te képleted mit mutat?</h2>
|
||||||
|
<p className="muted">
|
||||||
|
Add meg a születési adataidat, és megkapod a saját képletedet a rövid összefoglalóval együtt, ingyen.
|
||||||
|
</p>
|
||||||
|
<Link href={me ? "/keplet" : "/belepes"} className="btn btn-primary">
|
||||||
|
{me ? "A saját képletem" : "Elkészítem a sajátomat"}
|
||||||
|
</Link>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<p className="hint">
|
||||||
|
Ezt a képletet a tulajdonosa osztotta meg, név és születési adatok nélkül. A szöveget mesterséges intelligencia
|
||||||
|
írta a képlet alapján.
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,187 @@
|
|||||||
|
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||||
|
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
|
||||||
|
|
||||||
|
|
||||||
|
Bitstream Vera Fonts Copyright
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
|
||||||
|
a trademark of Bitstream, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of the fonts accompanying this license ("Fonts") and associated
|
||||||
|
documentation files (the "Font Software"), to reproduce and distribute the
|
||||||
|
Font Software, including without limitation the rights to use, copy, merge,
|
||||||
|
publish, distribute, and/or sell copies of the Font Software, and to permit
|
||||||
|
persons to whom the Font Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright and trademark notices and this permission notice shall
|
||||||
|
be included in all copies of one or more of the Font Software typefaces.
|
||||||
|
|
||||||
|
The Font Software may be modified, altered, or added to, and in particular
|
||||||
|
the designs of glyphs or characters in the Fonts may be modified and
|
||||||
|
additional glyphs or characters may be added to the Fonts, only if the fonts
|
||||||
|
are renamed to names not containing either the words "Bitstream" or the word
|
||||||
|
"Vera".
|
||||||
|
|
||||||
|
This License becomes null and void to the extent applicable to Fonts or Font
|
||||||
|
Software that has been modified and is distributed under the "Bitstream
|
||||||
|
Vera" names.
|
||||||
|
|
||||||
|
The Font Software may be sold as part of a larger software package but no
|
||||||
|
copy of one or more of the Font Software typefaces may be sold by itself.
|
||||||
|
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
|
||||||
|
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
|
||||||
|
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
|
||||||
|
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||||
|
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
|
||||||
|
FONT SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the names of Gnome, the Gnome
|
||||||
|
Foundation, and Bitstream Inc., shall not be used in advertising or
|
||||||
|
otherwise to promote the sale, use or other dealings in this Font Software
|
||||||
|
without prior written authorization from the Gnome Foundation or Bitstream
|
||||||
|
Inc., respectively. For further information, contact: fonts at gnome dot
|
||||||
|
org.
|
||||||
|
|
||||||
|
Arev Fonts Copyright
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the fonts accompanying this license ("Fonts") and
|
||||||
|
associated documentation files (the "Font Software"), to reproduce
|
||||||
|
and distribute the modifications to the Bitstream Vera Font Software,
|
||||||
|
including without limitation the rights to use, copy, merge, publish,
|
||||||
|
distribute, and/or sell copies of the Font Software, and to permit
|
||||||
|
persons to whom the Font Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright and trademark notices and this permission notice
|
||||||
|
shall be included in all copies of one or more of the Font Software
|
||||||
|
typefaces.
|
||||||
|
|
||||||
|
The Font Software may be modified, altered, or added to, and in
|
||||||
|
particular the designs of glyphs or characters in the Fonts may be
|
||||||
|
modified and additional glyphs or characters may be added to the
|
||||||
|
Fonts, only if the fonts are renamed to names not containing either
|
||||||
|
the words "Tavmjong Bah" or the word "Arev".
|
||||||
|
|
||||||
|
This License becomes null and void to the extent applicable to Fonts
|
||||||
|
or Font Software that has been modified and is distributed under the
|
||||||
|
"Tavmjong Bah Arev" names.
|
||||||
|
|
||||||
|
The Font Software may be sold as part of a larger software package but
|
||||||
|
no copy of one or more of the Font Software typefaces may be sold by
|
||||||
|
itself.
|
||||||
|
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
||||||
|
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Tavmjong Bah shall not
|
||||||
|
be used in advertising or otherwise to promote the sale, use or other
|
||||||
|
dealings in this Font Software without prior written authorization
|
||||||
|
from Tavmjong Bah. For further information, contact: tavmjong @ free
|
||||||
|
. fr.
|
||||||
|
|
||||||
|
TeX Gyre DJV Math
|
||||||
|
-----------------
|
||||||
|
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||||
|
|
||||||
|
Math extensions done by B. Jackowski, P. Strzelczyk and P. Pianowski
|
||||||
|
(on behalf of TeX users groups) are in public domain.
|
||||||
|
|
||||||
|
Letters imported from Euler Fraktur from AMSfonts are (c) American
|
||||||
|
Mathematical Society (see below).
|
||||||
|
Bitstream Vera Fonts Copyright
|
||||||
|
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera
|
||||||
|
is a trademark of Bitstream, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of the fonts accompanying this license (“Fonts”) and associated
|
||||||
|
documentation
|
||||||
|
files (the “Font Software”), to reproduce and distribute the Font Software,
|
||||||
|
including without limitation the rights to use, copy, merge, publish,
|
||||||
|
distribute,
|
||||||
|
and/or sell copies of the Font Software, and to permit persons to whom
|
||||||
|
the Font Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright and trademark notices and this permission notice
|
||||||
|
shall be
|
||||||
|
included in all copies of one or more of the Font Software typefaces.
|
||||||
|
|
||||||
|
The Font Software may be modified, altered, or added to, and in particular
|
||||||
|
the designs of glyphs or characters in the Fonts may be modified and
|
||||||
|
additional
|
||||||
|
glyphs or characters may be added to the Fonts, only if the fonts are
|
||||||
|
renamed
|
||||||
|
to names not containing either the words “Bitstream” or the word “Vera”.
|
||||||
|
|
||||||
|
This License becomes null and void to the extent applicable to Fonts or
|
||||||
|
Font Software
|
||||||
|
that has been modified and is distributed under the “Bitstream Vera”
|
||||||
|
names.
|
||||||
|
|
||||||
|
The Font Software may be sold as part of a larger software package but
|
||||||
|
no copy
|
||||||
|
of one or more of the Font Software typefaces may be sold by itself.
|
||||||
|
|
||||||
|
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
|
||||||
|
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
|
||||||
|
FOUNDATION
|
||||||
|
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL,
|
||||||
|
SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
|
||||||
|
ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
|
||||||
|
INABILITY TO USE
|
||||||
|
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
|
Except as contained in this notice, the names of GNOME, the GNOME
|
||||||
|
Foundation,
|
||||||
|
and Bitstream Inc., shall not be used in advertising or otherwise to promote
|
||||||
|
the sale, use or other dealings in this Font Software without prior written
|
||||||
|
authorization from the GNOME Foundation or Bitstream Inc., respectively.
|
||||||
|
For further information, contact: fonts at gnome dot org.
|
||||||
|
|
||||||
|
AMSFonts (v. 2.2) copyright
|
||||||
|
|
||||||
|
The PostScript Type 1 implementation of the AMSFonts produced by and
|
||||||
|
previously distributed by Blue Sky Research and Y&Y, Inc. are now freely
|
||||||
|
available for general use. This has been accomplished through the
|
||||||
|
cooperation
|
||||||
|
of a consortium of scientific publishers with Blue Sky Research and Y&Y.
|
||||||
|
Members of this consortium include:
|
||||||
|
|
||||||
|
Elsevier Science IBM Corporation Society for Industrial and Applied
|
||||||
|
Mathematics (SIAM) Springer-Verlag American Mathematical Society (AMS)
|
||||||
|
|
||||||
|
In order to assure the authenticity of these fonts, copyright will be
|
||||||
|
held by
|
||||||
|
the American Mathematical Society. This is not meant to restrict in any way
|
||||||
|
the legitimate use of the fonts, such as (but not limited to) electronic
|
||||||
|
distribution of documents containing these fonts, inclusion of these fonts
|
||||||
|
into other public domain or commercial font collections or computer
|
||||||
|
applications, use of the outline data to create derivative fonts and/or
|
||||||
|
faces, etc. However, the AMS does require that the AMS copyright notice be
|
||||||
|
removed from any derivative versions of the fonts which have been altered in
|
||||||
|
any way. In addition, to ensure the fidelity of TeX documents using Computer
|
||||||
|
Modern fonts, Professor Donald Knuth, creator of the Computer Modern faces,
|
||||||
|
has requested that any alterations which yield different font metrics be
|
||||||
|
given a different name.
|
||||||
|
|
||||||
|
$Id$
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2015 the Cormorant Project Authors (github.com/CatharsisFonts/Cormorant)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Fonts of the share preview images (`src/app/s/[slug]/kep`), read at run time.
|
||||||
|
|
||||||
|
- Cormorant Garamond SemiBold, Inter Regular and SemiBold: static instances from
|
||||||
|
Google Fonts, SIL Open Font License (LICENSE-OFL-*.txt).
|
||||||
|
- DejaVu Sans 2.37: the zodiac and planet glyphs (LICENSE-DejaVu.txt).
|
||||||
@@ -11,14 +11,17 @@ const ORDER = { natal: NATAL_ORDER, synastry: SYNASTRY_ORDER, forecast: FORECAST
|
|||||||
export function AnalysisView({
|
export function AnalysisView({
|
||||||
content,
|
content,
|
||||||
kind = "natal",
|
kind = "natal",
|
||||||
|
language,
|
||||||
}: {
|
}: {
|
||||||
content: AnalysisContent;
|
content: AnalysisContent;
|
||||||
kind?: "natal" | "synastry" | "forecast";
|
kind?: "natal" | "synastry" | "forecast";
|
||||||
|
/** The language of the text, for hyphenation. */
|
||||||
|
language?: string;
|
||||||
}) {
|
}) {
|
||||||
const order = ORDER[kind];
|
const order = ORDER[kind];
|
||||||
const sections = order.map((key) => content.sections?.[key]).filter((s) => s !== undefined);
|
const sections = order.map((key) => content.sections?.[key]).filter((s) => s !== undefined);
|
||||||
return (
|
return (
|
||||||
<article className="analysis">
|
<article className="analysis" lang={language}>
|
||||||
<header className="analysis-head">
|
<header className="analysis-head">
|
||||||
<h2>{content.title}</h2>
|
<h2>{content.title}</h2>
|
||||||
{content.summary && (
|
{content.summary && (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { AnalysisLoading } from "./AnalysisLoading";
|
|||||||
import { RegenerateButton } from "./RegenerateButton";
|
import { RegenerateButton } from "./RegenerateButton";
|
||||||
import { RetryNotice } from "./RetryNotice";
|
import { RetryNotice } from "./RetryNotice";
|
||||||
import { Rich } from "./Rich";
|
import { Rich } from "./Rich";
|
||||||
|
import { ShareChart } from "./ShareChart";
|
||||||
import { openTab } from "./Tabs";
|
import { openTab } from "./Tabs";
|
||||||
|
|
||||||
const POLL_MS = 3000;
|
const POLL_MS = 3000;
|
||||||
@@ -78,9 +79,10 @@ export function ChartSummary({
|
|||||||
<h2 id="summary-title" className="summary-title">
|
<h2 id="summary-title" className="summary-title">
|
||||||
{content.title}
|
{content.title}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="summary-text">
|
<p className="summary-text" lang={summary?.language}>
|
||||||
<Rich text={content.summary ?? ""} />
|
<Rich text={content.summary ?? ""} />
|
||||||
</p>
|
</p>
|
||||||
|
<ShareChart chartId={chartId} />
|
||||||
<a
|
<a
|
||||||
href="#elemzes"
|
href="#elemzes"
|
||||||
className="summary-more"
|
className="summary-more"
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export function DetailedAnalysis({
|
|||||||
<RegenerateButton<Analysis> url={`/admin/analyses/${analysis.id}/regenerate`} onStarted={setAnalysis} />
|
<RegenerateButton<Analysis> url={`/admin/analyses/${analysis.id}/regenerate`} onStarted={setAnalysis} />
|
||||||
)}
|
)}
|
||||||
{note && <p className="hint">{note}</p>}
|
{note && <p className="hint">{note}</p>}
|
||||||
<AnalysisView content={analysis.content} kind={target.kind} />
|
<AnalysisView content={analysis.content} kind={target.kind} language={analysis.language} />
|
||||||
{questionsLeft !== undefined && (
|
{questionsLeft !== undefined && (
|
||||||
<AnalysisQuestions
|
<AnalysisQuestions
|
||||||
analysisId={analysis.id}
|
analysisId={analysis.id}
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
import { api, errorText } from "@/lib/api";
|
||||||
|
|
||||||
|
interface Share {
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Share link of a chart with its short summary: copy, Facebook, the phone's share menu, revoke. */
|
||||||
|
export function ShareChart({ chartId }: { chartId: string }) {
|
||||||
|
const [share, setShare] = useState<Share | null>(null);
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [revoked, setRevoked] = useState(false);
|
||||||
|
|
||||||
|
async function open() {
|
||||||
|
setBusy(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
setShare(await api<Share>("/shares", { body: { kind: "chart", target_id: chartId } }));
|
||||||
|
setRevoked(false);
|
||||||
|
} catch (e) {
|
||||||
|
setError(errorText(e));
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function copy() {
|
||||||
|
if (!share) return;
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(share.url);
|
||||||
|
setCopied(true);
|
||||||
|
setTimeout(() => setCopied(false), 2000);
|
||||||
|
} catch {
|
||||||
|
setError("Nem sikerült másolni; jelöld ki a linket, és másold kézzel.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function nativeShare() {
|
||||||
|
if (!share) return;
|
||||||
|
try {
|
||||||
|
await navigator.share({ url: share.url });
|
||||||
|
} catch {
|
||||||
|
// closed by the user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function revoke() {
|
||||||
|
if (!share || !window.confirm("Visszavonod a linket? Aki megkapta, többé nem tudja megnyitni.")) return;
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
await api(`/shares/${share.id}`, { method: "DELETE" });
|
||||||
|
setShare(null);
|
||||||
|
setRevoked(true);
|
||||||
|
} catch (e) {
|
||||||
|
setError(errorText(e));
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!share) {
|
||||||
|
return (
|
||||||
|
<div className="share">
|
||||||
|
<button type="button" className="btn btn-sm" onClick={open} disabled={busy}>
|
||||||
|
{busy ? "Link készül…" : "Megosztás"}
|
||||||
|
</button>
|
||||||
|
{revoked && <p className="hint">A linket visszavontad.</p>}
|
||||||
|
{error && (
|
||||||
|
<p className="msg msg-error" role="alert">
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const facebook = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(share.url)}`;
|
||||||
|
return (
|
||||||
|
<div className="share share-open">
|
||||||
|
<p className="hint">
|
||||||
|
A linken a képleted rajza és ez az összefoglaló látszik, név és születési adatok nélkül. Bárki megnyithatja,
|
||||||
|
akinek elküldöd.
|
||||||
|
</p>
|
||||||
|
<div className="share-link">
|
||||||
|
<input
|
||||||
|
className="inp"
|
||||||
|
readOnly
|
||||||
|
value={share.url}
|
||||||
|
aria-label="Megosztási link"
|
||||||
|
onFocus={(e) => e.currentTarget.select()}
|
||||||
|
/>
|
||||||
|
<button type="button" className="btn btn-sm" onClick={copy}>
|
||||||
|
{copied ? "Kimásolva" : "Másolás"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="form-actions">
|
||||||
|
<a className="btn btn-sm btn-primary" href={facebook} target="_blank" rel="noopener noreferrer">
|
||||||
|
Megosztás Facebookon
|
||||||
|
</a>
|
||||||
|
{typeof navigator !== "undefined" && "share" in navigator && (
|
||||||
|
<button type="button" className="btn btn-sm" onClick={nativeShare}>
|
||||||
|
Küldés…
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<button type="button" className="btn btn-sm btn-ghost" onClick={revoke} disabled={busy}>
|
||||||
|
Link visszavonása
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{error && (
|
||||||
|
<p className="msg msg-error" role="alert">
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
// Public share links (`/s/<slug>`): loading the shared content and the
|
||||||
|
// texts of the page, its link preview and its preview image.
|
||||||
|
import "server-only";
|
||||||
|
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
import { cache } from "react";
|
||||||
|
|
||||||
|
import { BACKEND_URL } from "./server";
|
||||||
|
import type { ChartResult } from "./types";
|
||||||
|
|
||||||
|
export interface PublicSummary {
|
||||||
|
id: string;
|
||||||
|
language: string;
|
||||||
|
title: string | null;
|
||||||
|
summary: string | null;
|
||||||
|
completed_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `GET /v1/public/shares/{slug}` of a shared chart. */
|
||||||
|
export interface PublicShare {
|
||||||
|
kind: "chart" | "synastry" | "analysis";
|
||||||
|
title: string | null;
|
||||||
|
created_at: string;
|
||||||
|
chart?: { label: string; chart: ChartResult & { time_known: boolean } };
|
||||||
|
summary?: PublicSummary | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SLUG = /^[A-Za-z0-9_-]{8,64}$/;
|
||||||
|
|
||||||
|
/** The shared content, or `null` if the link is unknown or revoked (one backend call per request). */
|
||||||
|
export const loadShare = cache(async (slug: string): Promise<PublicShare | null> => {
|
||||||
|
if (!SLUG.test(slug)) return null;
|
||||||
|
const res = await fetch(`${BACKEND_URL}/v1/public/shares/${slug}`, { cache: "no-store" });
|
||||||
|
if (res.status === 404) return null;
|
||||||
|
if (!res.ok) throw new Error(`share ${slug}: HTTP ${res.status}`);
|
||||||
|
return (await res.json()) as PublicShare;
|
||||||
|
});
|
||||||
|
|
||||||
|
/** The site's own address, for absolute links in the preview tags. */
|
||||||
|
export async function siteUrl(): Promise<string> {
|
||||||
|
const fixed = process.env.PUBLIC_BASE_URL;
|
||||||
|
if (fixed) return fixed.replace(/\/$/, "");
|
||||||
|
const h = await headers();
|
||||||
|
const host = h.get("x-forwarded-host") ?? h.get("host") ?? "localhost:3001";
|
||||||
|
const proto = h.get("x-forwarded-proto") ?? (host.startsWith("localhost") ? "http" : "https");
|
||||||
|
return `${proto}://${host}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Model text without the `**bold**` marks. */
|
||||||
|
export function plain(text: string): string {
|
||||||
|
return text.replace(/\*\*/g, "").replace(/\s+/g, " ").trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** At most `max` characters, cut at a word, with an ellipsis. */
|
||||||
|
export function shorten(text: string, max: number): string {
|
||||||
|
if (text.length <= max) return text;
|
||||||
|
const cut = text.slice(0, max - 1);
|
||||||
|
const space = cut.lastIndexOf(" ");
|
||||||
|
return `${(space > max * 0.6 ? cut.slice(0, space) : cut).replace(/[\s,;:–-]+$/, "")}…`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Changes whenever the summary is rewritten, so link previews fetch the new image. */
|
||||||
|
export function imageVersion(share: PublicShare): string {
|
||||||
|
const s = share.summary;
|
||||||
|
if (!s) return "kep";
|
||||||
|
const time = s.completed_at ? Date.parse(s.completed_at).toString(36) : "0";
|
||||||
|
return `${s.id.replace(/-/g, "").slice(-8)}${time}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Nap Nyilas · Hold Bika · Aszcendens Mérleg" (the ascendant only with a known time). */
|
||||||
|
export function bigThree(chart: ChartResult & { time_known: boolean }): { label: string; sign: string }[] {
|
||||||
|
const sign = (id: string) => chart.points.find((p) => p.id === id)?.sign;
|
||||||
|
const asc = chart.angles?.ascendant;
|
||||||
|
const out: { label: string; sign: string }[] = [];
|
||||||
|
const sun = sign("sun");
|
||||||
|
const moon = sign("moon");
|
||||||
|
if (sun) out.push({ label: "Nap", sign: sun });
|
||||||
|
if (moon) out.push({ label: "Hold", sign: moon });
|
||||||
|
if (chart.time_known && typeof asc === "object" && asc) out.push({ label: "Aszcendens", sign: asc.sign });
|
||||||
|
return out;
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// The chart wheel as a standalone SVG document, for the share preview image.
|
||||||
|
// It reuses the page's <ChartWheel> and turns its element tree into markup
|
||||||
|
// with the colours inlined (no page CSS there).
|
||||||
|
import { Fragment, isValidElement, type ReactElement, type ReactNode } from "react";
|
||||||
|
|
||||||
|
import { ChartWheel, SIZE } from "@/components/ChartWheel";
|
||||||
|
import type { ChartResult } from "@/lib/types";
|
||||||
|
|
||||||
|
// The page's wheel rules (globals.css) with the colour tokens resolved.
|
||||||
|
const STYLE = `
|
||||||
|
.w-ring{fill:none;stroke:#2c3654;stroke-width:1.2}
|
||||||
|
.w-faint{stroke:#1f2740}
|
||||||
|
.w-inner{fill:#0f1426}
|
||||||
|
.w-sign{stroke:#2c3654;stroke-width:1}
|
||||||
|
.w-fire{fill:rgba(227,139,106,.09)}
|
||||||
|
.w-earth{fill:rgba(159,216,176,.07)}
|
||||||
|
.w-air{fill:rgba(217,180,106,.08)}
|
||||||
|
.w-water{fill:rgba(127,176,224,.09)}
|
||||||
|
.w-sign-glyph{fill:#d9b46a;font-family:'DejaVu Sans';font-size:22px}
|
||||||
|
.w-tick,.w-cusp{stroke:#2c3654;stroke-width:1}
|
||||||
|
.w-axis{stroke:#d9b46a;stroke-width:1.8}
|
||||||
|
.w-axis-label{fill:#d9b46a;font-family:Inter;font-weight:600;font-size:14px}
|
||||||
|
.w-house-num{fill:#a3abc0;font-family:Inter;font-size:12px}
|
||||||
|
.w-aspect{stroke-linecap:round}
|
||||||
|
.w-asp-trine{stroke:#7fb0e0}
|
||||||
|
.w-asp-sextile{stroke:#7fb0e0;stroke-dasharray:5 4}
|
||||||
|
.w-asp-square{stroke:#f0a35e}
|
||||||
|
.w-asp-opposition{stroke:#e38b8b}
|
||||||
|
.w-point-tick{stroke:#ece6d8;stroke-width:1.6}
|
||||||
|
.w-leader{stroke:#a3abc0;stroke-width:.7;stroke-opacity:.6}
|
||||||
|
.w-point-glyph{fill:#ece6d8;font-family:'DejaVu Sans';font-size:22px}
|
||||||
|
.w-point-deg{fill:#a3abc0;font-family:Inter;font-size:10.5px}
|
||||||
|
.w-end{fill:#c9cfdc}
|
||||||
|
.w-point-glyph,.w-point-deg,.w-house-num,.w-axis-label{paint-order:stroke;stroke:#111729;stroke-width:4px;stroke-linejoin:round}
|
||||||
|
`;
|
||||||
|
|
||||||
|
// React prop names that are not SVG attributes (or not wanted in the image).
|
||||||
|
const SKIP = new Set(["children", "key", "role", "id"]);
|
||||||
|
|
||||||
|
const escape = (s: string) =>
|
||||||
|
s.replace(/︎/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
||||||
|
|
||||||
|
function attribute(name: string): string {
|
||||||
|
if (name === "className") return "class";
|
||||||
|
if (name === "viewBox") return name;
|
||||||
|
return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function markup(node: ReactNode): string {
|
||||||
|
if (node === null || node === undefined || typeof node === "boolean") return "";
|
||||||
|
if (typeof node === "string" || typeof node === "number") return escape(String(node));
|
||||||
|
if (Array.isArray(node)) return node.map(markup).join("");
|
||||||
|
if (!isValidElement(node)) return "";
|
||||||
|
const { type, props } = node as ReactElement<Record<string, unknown>>;
|
||||||
|
if (type === Fragment) return markup(props.children as ReactNode);
|
||||||
|
if (typeof type === "function") return markup((type as (p: unknown) => ReactNode)(props));
|
||||||
|
if (typeof type !== "string" || type === "title" || type === "desc") return "";
|
||||||
|
const attrs = Object.entries(props)
|
||||||
|
.filter(([k, v]) => !SKIP.has(k) && !k.startsWith("aria-") && v !== undefined && v !== null && v !== false)
|
||||||
|
.map(([k, v]) => ` ${attribute(k)}="${escape(String(v))}"`)
|
||||||
|
.join("");
|
||||||
|
return `<${type}${attrs}>${markup(props.children as ReactNode)}</${type}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The wheel as an SVG document of `size` pixels. */
|
||||||
|
export function wheelSvg(chart: ChartResult, timeKnown: boolean, size = SIZE): string {
|
||||||
|
const body = markup(ChartWheel({ chart, timeKnown }))
|
||||||
|
.replace(/^<svg[^>]*>/, "")
|
||||||
|
.replace(/<\/svg>$/, "");
|
||||||
|
return (
|
||||||
|
`<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${SIZE} ${SIZE}">` +
|
||||||
|
`<style>${STYLE}</style>${body}</svg>`
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -21,6 +21,11 @@ Háttérmunkák a közös PostgreSQL-adatbázis fölött: e-mail-küldés, szöv
|
|||||||
|
|
||||||
**Szöveges elemzések** (`analyses`, `pending` → `running` → `done`/`failed`)
|
**Szöveges elemzések** (`analyses`, `pending` → `running` → `done`/`failed`)
|
||||||
- A backend létrehozza a `pending` sort, és levon egy elemzési egységet. Egy trigger (`NOTIFY analyses`) felébreszti a workert; egyszerre `ANALYSIS_CONCURRENCY` elemzés készül.
|
- A backend létrehozza a `pending` sort, és levon egy elemzési egységet. Egy trigger (`NOTIFY analyses`) felébreszti a workert; egyszerre `ANALYSIS_CONCURRENCY` elemzés készül.
|
||||||
|
- **Két sáv**, saját helyekkel, hogy egy rövid szöveg ne várjon a hosszúak mögött:
|
||||||
|
- *gyors sáv* (`QUICK_CONCURRENCY`, alapból 2): előbb a kérdések, aztán a rövid összefoglalók;
|
||||||
|
- *lassú sáv* (`ANALYSIS_CONCURRENCY`, alapból 4): a részletes elemzések és az előrejelzések. Ha nincs ilyen, a szabad hely gyors munkát vesz fel, végül az admin próbafuttatásait.
|
||||||
|
- A 0 kikapcsolja a sávot, így a két sáv külön telepítésként is futhat (például Kubernetesen: egy gyors és egy lassú deployment).
|
||||||
|
- **Több worker** is dolgozhat ugyanabból a sorból: a sorokat `FOR UPDATE SKIP LOCKED` foglalja, egy munkát csak egy worker kap meg. Leálláskor mindegyik csak a saját félbehagyott munkáit adja vissza a sorba, az elakadt (15 percnél régebben futó) munkákat bármelyik visszateszi. Az e-mail-küldés és a takarítás is biztonságos több példányban.
|
||||||
- A prompt a tárolt képletből készül (`src/analysis/compact.rs`). Ez egy tömör szöveg, amely csak a pozíciókat tartalmazza: jegyek, fokok, házak, fényszögek, elemek. **Név, születési dátum, idő, hely és koordináta nem megy ki.** Ismeretlen születési időnél nincsenek házak, Aszcendens és MC.
|
- A prompt a tárolt képletből készül (`src/analysis/compact.rs`). Ez egy tömör szöveg, amely csak a pozíciókat tartalmazza: jegyek, fokok, házak, fényszögek, elemek. **Név, születési dátum, idő, hely és koordináta nem megy ki.** Ismeretlen születési időnél nincsenek házak, Aszcendens és MC.
|
||||||
- **5 fokos szabály:** ha egy pont legfeljebb 5°-kal (`CUSP_ORB`) a következő ház csúcsa előtt áll, a szöveg már abban a házban adja meg, és odaírja, hogy formálisan az előzőben van („house 11 (on the cusp: 2°00' before it, formally house 10)”). Így olvassák az asztrológusok. A számított ház, a képlet rajza és a táblázatok nem változnak. Ugyanez érvényes az összevetés házátfedéseire, a szolár Aszcendensre, az év urára és a fogyatkozásokra.
|
- **5 fokos szabály:** ha egy pont legfeljebb 5°-kal (`CUSP_ORB`) a következő ház csúcsa előtt áll, a szöveg már abban a házban adja meg, és odaírja, hogy formálisan az előzőben van („house 11 (on the cusp: 2°00' before it, formally house 10)”). Így olvassák az asztrológusok. A számított ház, a képlet rajza és a táblázatok nem változnak. Ugyanez érvényes az összevetés házátfedéseire, a szolár Aszcendensre, az év urára és a fogyatkozásokra.
|
||||||
- A modell OpenRouteren keresztül válaszol, azzal a modellel, amely a sor `model` mezőjében áll. A válasznak kötött JSON-sémát kell követnie (`crates/analysis-prompt`, `PROMPT_VERSION = v3`; ha a sor `prompt_version`-je `v3-r<id>`, a system prompt az admin által szerkesztett `prompt_revisions` sorból jön):
|
- A modell OpenRouteren keresztül válaszol, azzal a modellel, amely a sor `model` mezőjében áll. A válasznak kötött JSON-sémát kell követnie (`crates/analysis-prompt`, `PROMPT_VERSION = v3`; ha a sor `prompt_version`-je `v3-r<id>`, a system prompt az admin által szerkesztett `prompt_revisions` sorból jön):
|
||||||
@@ -72,7 +77,9 @@ Ugyanazt a radix-elemzést több modellel is megírja, véletlenszerű betűkkel
|
|||||||
| `OPENROUTER_API_KEY` | – | OpenRouter-kulcs (compose-ban a `.env.secrets` fájlból); nélküle az elemzések várnak |
|
| `OPENROUTER_API_KEY` | – | OpenRouter-kulcs (compose-ban a `.env.secrets` fájlból); nélküle az elemzések várnak |
|
||||||
| `OPENROUTER_BASE_URL` | `https://openrouter.ai/api/v1` | |
|
| `OPENROUTER_BASE_URL` | `https://openrouter.ai/api/v1` | |
|
||||||
| `PUBLIC_BASE_URL` | – | `HTTP-Referer` fejléc az OpenRouter felé |
|
| `PUBLIC_BASE_URL` | – | `HTTP-Referer` fejléc az OpenRouter felé |
|
||||||
| `ANALYSIS_CONCURRENCY` | `4` | egyszerre írt elemzések |
|
| `WORKER_TASKS` | `email,cleanup,analyses` | a folyamat feladatai; élesben `worker`: `email,cleanup`, `worker-ai`: `analyses` |
|
||||||
|
| `ANALYSIS_CONCURRENCY` | `4` | lassú sáv: egyszerre írt részletes elemzések és előrejelzések (0: kikapcsolva) |
|
||||||
|
| `QUICK_CONCURRENCY` | `2` | gyors sáv: egyszerre írt rövid összefoglalók és válaszok (0: kikapcsolva) |
|
||||||
| `MAX_ANALYSIS_ATTEMPTS` | `3` | ennyi próbálkozás után sikertelen az elemzés (az egység visszajár) |
|
| `MAX_ANALYSIS_ATTEMPTS` | `3` | ennyi próbálkozás után sikertelen az elemzés (az egység visszajár) |
|
||||||
| `BIND_ADDR`, `LOG_FORMAT`, `RUST_LOG` | `0.0.0.0:8082`, `text`, `info` | |
|
| `BIND_ADDR`, `LOG_FORMAT`, `RUST_LOG` | `0.0.0.0:8082`, `text`, `info` | |
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,13 @@
|
|||||||
//! Admin test runs of an edited prompt (`prompt_previews`) go through the
|
//! Admin test runs of an edited prompt (`prompt_previews`) go through the
|
||||||
//! same loop when no analysis is due: one attempt, no credits, no retries.
|
//! same loop when no analysis is due: one attempt, no credits, no retries.
|
||||||
//!
|
//!
|
||||||
|
//! Two lanes, each with its own slots, so a short text never waits behind
|
||||||
|
//! the long ones: the quick lane writes summaries and answers questions, the
|
||||||
|
//! slow lane writes the detailed analyses and forecasts (and the test runs).
|
||||||
|
//! A free slow slot also takes quick work. A lane of size 0 is off, so the
|
||||||
|
//! lanes can run as separate deployments; several workers may share the
|
||||||
|
//! queue, rows are claimed with `FOR UPDATE SKIP LOCKED`.
|
||||||
|
//!
|
||||||
//! Fallback: when the model chosen on the admin page fails twice (or once with
|
//! Fallback: when the model chosen on the admin page fails twice (or once with
|
||||||
//! a permanent error), the default model (`fallback_model`) takes over with a
|
//! a permanent error), the default model (`fallback_model`) takes over with a
|
||||||
//! fresh set of attempts; only when that fails too is the unit refunded.
|
//! fresh set of attempts; only when that fails too is the unit refunded.
|
||||||
@@ -29,6 +36,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use self::openrouter::{Completion, LlmError, OpenRouter};
|
use self::openrouter::{Completion, LlmError, OpenRouter};
|
||||||
use self::prompt::{Kind, PROMPT_VERSION, Prompt};
|
use self::prompt::{Kind, PROMPT_VERSION, Prompt};
|
||||||
|
use self::questions::QuestionJob;
|
||||||
|
|
||||||
/// A `running` analysis older than this was left behind by a stopped worker.
|
/// A `running` analysis older than this was left behind by a stopped worker.
|
||||||
const STUCK_AFTER_MINUTES: i32 = 15;
|
const STUCK_AFTER_MINUTES: i32 = 15;
|
||||||
@@ -101,11 +109,36 @@ pub struct PreviewJob {
|
|||||||
pub system: String,
|
pub system: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Which analyses a claim may take.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub enum Lane {
|
||||||
|
/// The short summary of a chart (questions are claimed separately).
|
||||||
|
Quick,
|
||||||
|
/// The detailed analyses and the yearly forecast.
|
||||||
|
Slow,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Lane {
|
||||||
|
fn kinds(self) -> &'static [&'static str] {
|
||||||
|
match self {
|
||||||
|
Lane::Quick => &["summary"],
|
||||||
|
Lane::Slow => &["natal", "synastry", "forecast"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Slots per lane; 0 turns a lane off.
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct Lanes {
|
||||||
|
pub quick: usize,
|
||||||
|
pub slow: usize,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Analyzer {
|
pub struct Analyzer {
|
||||||
pub db: PgPool,
|
pub db: PgPool,
|
||||||
pub llm: OpenRouter,
|
pub llm: OpenRouter,
|
||||||
pub max_attempts: i32,
|
pub max_attempts: i32,
|
||||||
pub concurrency: usize,
|
pub lanes: Lanes,
|
||||||
/// Analyses and previews being written right now (released on shutdown).
|
/// Analyses and previews being written right now (released on shutdown).
|
||||||
running: Mutex<HashSet<Uuid>>,
|
running: Mutex<HashSet<Uuid>>,
|
||||||
}
|
}
|
||||||
@@ -117,19 +150,21 @@ pub fn backoff(attempts: i32) -> Duration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Analyzer {
|
impl Analyzer {
|
||||||
pub fn new(db: PgPool, llm: OpenRouter, max_attempts: i32, concurrency: usize) -> Self {
|
pub fn new(db: PgPool, llm: OpenRouter, max_attempts: i32, lanes: Lanes) -> Self {
|
||||||
Self { db, llm, max_attempts, concurrency: concurrency.max(1), running: Mutex::default() }
|
Self { db, llm, max_attempts, lanes, running: Mutex::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes the next due analysis, if any.
|
/// Takes the next due analysis of the lane, if any.
|
||||||
pub async fn claim(&self) -> Result<Option<Job>, sqlx::Error> {
|
pub async fn claim(&self, lane: Lane) -> Result<Option<Job>, sqlx::Error> {
|
||||||
let job: Option<Job> = sqlx::query_as(
|
let job: Option<Job> = sqlx::query_as(
|
||||||
"UPDATE analyses SET status = 'running', started_at = now(), attempts = attempts + 1 \
|
"UPDATE analyses SET status = 'running', started_at = now(), attempts = attempts + 1 \
|
||||||
WHERE id = (SELECT id FROM analyses WHERE status = 'pending' AND next_attempt_at <= now() \
|
WHERE id = (SELECT id FROM analyses WHERE status = 'pending' AND next_attempt_at <= now() \
|
||||||
|
AND kind = ANY($1) \
|
||||||
ORDER BY next_attempt_at LIMIT 1 FOR UPDATE SKIP LOCKED) \
|
ORDER BY next_attempt_at LIMIT 1 FOR UPDATE SKIP LOCKED) \
|
||||||
RETURNING id, kind, chart_id, synastry_id, forecast_id, language, model, prompt_version, attempts, \
|
RETURNING id, kind, chart_id, synastry_id, forecast_id, language, model, prompt_version, attempts, \
|
||||||
fallback_model, on_fallback, started_at",
|
fallback_model, on_fallback, started_at",
|
||||||
)
|
)
|
||||||
|
.bind(lane.kinds())
|
||||||
.fetch_optional(&self.db)
|
.fetch_optional(&self.db)
|
||||||
.await?;
|
.await?;
|
||||||
if let Some(job) = &job {
|
if let Some(job) = &job {
|
||||||
@@ -530,8 +565,46 @@ impl Analyzer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Work a free slot can take, in order of preference.
|
||||||
|
pub(crate) enum Work {
|
||||||
|
Analysis(Job),
|
||||||
|
Question(QuestionJob),
|
||||||
|
Preview(PreviewJob),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Analyzer {
|
||||||
|
/// Quick work: a question first (someone is waiting for a short answer),
|
||||||
|
/// then a summary.
|
||||||
|
pub(crate) async fn claim_quick(&self) -> Result<Option<Work>, sqlx::Error> {
|
||||||
|
if let Some(job) = self.claim_question().await? {
|
||||||
|
return Ok(Some(Work::Question(job)));
|
||||||
|
}
|
||||||
|
Ok(self.claim(Lane::Quick).await?.map(Work::Analysis))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Slow work: a detailed analysis, else quick work, else a test run.
|
||||||
|
pub(crate) async fn claim_slow(&self) -> Result<Option<Work>, sqlx::Error> {
|
||||||
|
if let Some(job) = self.claim(Lane::Slow).await? {
|
||||||
|
return Ok(Some(Work::Analysis(job)));
|
||||||
|
}
|
||||||
|
if let Some(work) = self.claim_quick().await? {
|
||||||
|
return Ok(Some(work));
|
||||||
|
}
|
||||||
|
Ok(self.claim_preview().await?.map(Work::Preview))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn work(&self, work: Work) {
|
||||||
|
match work {
|
||||||
|
Work::Analysis(job) => self.handle(job).await,
|
||||||
|
Work::Question(job) => self.handle_question(job).await,
|
||||||
|
Work::Preview(job) => self.handle_preview(job).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run(analyzer: Arc<Analyzer>, poll: Duration, stop: watch::Receiver<bool>) {
|
pub async fn run(analyzer: Arc<Analyzer>, poll: Duration, stop: watch::Receiver<bool>) {
|
||||||
let slots = Arc::new(Semaphore::new(analyzer.concurrency));
|
let quick = Arc::new(Semaphore::new(analyzer.lanes.quick));
|
||||||
|
let slow = Arc::new(Semaphore::new(analyzer.lanes.slow));
|
||||||
let mut tasks = tokio::task::JoinSet::new();
|
let mut tasks = tokio::task::JoinSet::new();
|
||||||
let mut listener = crate::listen(&analyzer.db, "analyses").await;
|
let mut listener = crate::listen(&analyzer.db, "analyses").await;
|
||||||
let mut last_requeue: Option<Instant> = None;
|
let mut last_requeue: Option<Instant> = None;
|
||||||
@@ -547,50 +620,27 @@ pub async fn run(analyzer: Arc<Analyzer>, poll: Duration, stop: watch::Receiver<
|
|||||||
Err(e) => tracing::error!(error = %e, "requeueing analyses"),
|
Err(e) => tracing::error!(error = %e, "requeueing analyses"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fill the free slots.
|
// Fill the free slots: the quick lane first, then the slow one.
|
||||||
while let Ok(permit) = slots.clone().try_acquire_owned() {
|
for lane in [Lane::Quick, Lane::Slow] {
|
||||||
// Questions first: someone is waiting for a short answer.
|
let slots = if lane == Lane::Quick { &quick } else { &slow };
|
||||||
match analyzer.claim_question().await {
|
while let Ok(permit) = slots.clone().try_acquire_owned() {
|
||||||
Ok(Some(job)) => {
|
let claimed = match lane {
|
||||||
let analyzer = analyzer.clone();
|
Lane::Quick => analyzer.claim_quick().await,
|
||||||
tasks.spawn(async move {
|
Lane::Slow => analyzer.claim_slow().await,
|
||||||
analyzer.handle_question(job).await;
|
};
|
||||||
drop(permit);
|
match claimed {
|
||||||
});
|
Ok(Some(work)) => {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Ok(None) => {}
|
|
||||||
Err(e) => {
|
|
||||||
tracing::error!(error = %e, "claiming a question");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
match analyzer.claim().await {
|
|
||||||
Ok(Some(job)) => {
|
|
||||||
let analyzer = analyzer.clone();
|
|
||||||
tasks.spawn(async move {
|
|
||||||
analyzer.handle(job).await;
|
|
||||||
drop(permit);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// No analysis is due: a prompt test run, if one waits.
|
|
||||||
Ok(None) => match analyzer.claim_preview().await {
|
|
||||||
Ok(Some(job)) => {
|
|
||||||
let analyzer = analyzer.clone();
|
let analyzer = analyzer.clone();
|
||||||
tasks.spawn(async move {
|
tasks.spawn(async move {
|
||||||
analyzer.handle_preview(job).await;
|
analyzer.work(work).await;
|
||||||
drop(permit);
|
drop(permit);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ok(None) => break,
|
Ok(None) => break,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!(error = %e, "claiming a prompt preview");
|
tracing::error!(error = %e, ?lane, "claiming work");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
tracing::error!(error = %e, "claiming an analysis");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,38 @@ use std::time::Duration;
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lettre::message::Mailbox;
|
use lettre::message::Mailbox;
|
||||||
|
|
||||||
|
/// The jobs a worker process runs (`WORKER_TASKS`, comma-separated).
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct Tasks {
|
||||||
|
/// Sending the e-mails of `email_outbox`.
|
||||||
|
pub email: bool,
|
||||||
|
/// The hourly removal of expired data.
|
||||||
|
pub cleanup: bool,
|
||||||
|
/// Writing the analyses and answers with the LLM (both lanes).
|
||||||
|
pub analyses: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Tasks {
|
||||||
|
pub const ALL: Tasks = Tasks { email: true, cleanup: true, analyses: true };
|
||||||
|
|
||||||
|
pub fn parse(raw: &str) -> anyhow::Result<Self> {
|
||||||
|
let mut tasks = Tasks { email: false, cleanup: false, analyses: false };
|
||||||
|
for name in raw.split(',').map(str::trim).filter(|n| !n.is_empty()) {
|
||||||
|
match name {
|
||||||
|
"email" => tasks.email = true,
|
||||||
|
"cleanup" => tasks.cleanup = true,
|
||||||
|
"analyses" => tasks.analyses = true,
|
||||||
|
other => anyhow::bail!("unknown task '{other}' in WORKER_TASKS (email, cleanup, analyses)"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
anyhow::ensure!(tasks != Tasks { email: false, cleanup: false, analyses: false }, "WORKER_TASKS names no task");
|
||||||
|
Ok(tasks)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
/// What this process does; all of it by default.
|
||||||
|
pub tasks: Tasks,
|
||||||
pub database_url: String,
|
pub database_url: String,
|
||||||
/// `smtp://host:port` (plain, e.g. Mailpit), `smtp://user:pass@host:587?tls=required`
|
/// `smtp://host:port` (plain, e.g. Mailpit), `smtp://user:pass@host:587?tls=required`
|
||||||
/// (STARTTLS) or `smtps://...` (TLS). Without it, Amazon SES from the AWS
|
/// (STARTTLS) or `smtps://...` (TLS). Without it, Amazon SES from the AWS
|
||||||
@@ -24,8 +55,10 @@ pub struct Config {
|
|||||||
pub openrouter_base_url: String,
|
pub openrouter_base_url: String,
|
||||||
/// Frontend address, sent to OpenRouter as `HTTP-Referer`.
|
/// Frontend address, sent to OpenRouter as `HTTP-Referer`.
|
||||||
pub public_base_url: Option<String>,
|
pub public_base_url: Option<String>,
|
||||||
/// Analyses written at the same time.
|
/// Detailed analyses and forecasts written at the same time (0: none).
|
||||||
pub analysis_concurrency: usize,
|
pub analysis_concurrency: usize,
|
||||||
|
/// Summaries and answers written at the same time (0: none).
|
||||||
|
pub quick_concurrency: usize,
|
||||||
/// After this many failed attempts an analysis fails and is refunded.
|
/// After this many failed attempts an analysis fails and is refunded.
|
||||||
pub max_analysis_attempts: i32,
|
pub max_analysis_attempts: i32,
|
||||||
}
|
}
|
||||||
@@ -55,6 +88,7 @@ impl Config {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
tasks: var("WORKER_TASKS").map(|raw| Tasks::parse(&raw)).transpose()?.unwrap_or(Tasks::ALL),
|
||||||
database_url: var("DATABASE_URL").context("DATABASE_URL is required")?,
|
database_url: var("DATABASE_URL").context("DATABASE_URL is required")?,
|
||||||
smtp_url,
|
smtp_url,
|
||||||
smtp_about,
|
smtp_about,
|
||||||
@@ -67,6 +101,7 @@ impl Config {
|
|||||||
.unwrap_or_else(|| crate::analysis::openrouter::DEFAULT_BASE_URL.into()),
|
.unwrap_or_else(|| crate::analysis::openrouter::DEFAULT_BASE_URL.into()),
|
||||||
public_base_url: var("PUBLIC_BASE_URL"),
|
public_base_url: var("PUBLIC_BASE_URL"),
|
||||||
analysis_concurrency: parsed("ANALYSIS_CONCURRENCY", 4)?,
|
analysis_concurrency: parsed("ANALYSIS_CONCURRENCY", 4)?,
|
||||||
|
quick_concurrency: parsed("QUICK_CONCURRENCY", 2)?,
|
||||||
max_analysis_attempts: parsed("MAX_ANALYSIS_ATTEMPTS", 3)?,
|
max_analysis_attempts: parsed("MAX_ANALYSIS_ATTEMPTS", 3)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
//! * hourly cleanup of expired sessions, tokens, invites and old e-mails
|
//! * hourly cleanup of expired sessions, tokens, invites and old e-mails
|
||||||
//! * writing the requested text analyses with an LLM (OpenRouter)
|
//! * writing the requested text analyses with an LLM (OpenRouter)
|
||||||
//!
|
//!
|
||||||
|
//! `WORKER_TASKS` (e.g. `email,cleanup` or `analyses`) picks the jobs of one
|
||||||
|
//! process, so they can run in separate containers; all of them by default.
|
||||||
|
//!
|
||||||
//! Configuration: see [`config::Config`]; plus `BIND_ADDR` (default
|
//! Configuration: see [`config::Config`]; plus `BIND_ADDR` (default
|
||||||
//! `0.0.0.0:8082`, only `/healthz`), `LOG_FORMAT` and `RUST_LOG`.
|
//! `0.0.0.0:8082`, only `/healthz`), `LOG_FORMAT` and `RUST_LOG`.
|
||||||
//! `worker healthcheck` performs a local health check (for Docker);
|
//! `worker healthcheck` performs a local health check (for Docker);
|
||||||
@@ -91,7 +94,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let (stop_tx, stop) = watch::channel(false);
|
let (stop_tx, stop) = watch::channel(false);
|
||||||
let mut jobs = tokio::task::JoinSet::new();
|
let mut jobs = tokio::task::JoinSet::new();
|
||||||
|
let tasks = config.tasks;
|
||||||
|
tracing::info!(email = tasks.email, cleanup = tasks.cleanup, analyses = tasks.analyses, "worker tasks");
|
||||||
match &config.smtp_url {
|
match &config.smtp_url {
|
||||||
|
_ if !tasks.email => {}
|
||||||
Some(url) => {
|
Some(url) => {
|
||||||
let delivery = email::Delivery::new(pool.clone(), email::Mailer::smtp(url)?, &config);
|
let delivery = email::Delivery::new(pool.clone(), email::Mailer::smtp(url)?, &config);
|
||||||
let via = config.smtp_about.clone().unwrap_or_else(|| "SMTP_URL".into());
|
let via = config.smtp_about.clone().unwrap_or_else(|| "SMTP_URL".into());
|
||||||
@@ -101,17 +107,24 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
None => tracing::warn!("neither SMTP_URL nor SES credentials are set: e-mails stay in the outbox"),
|
None => tracing::warn!("neither SMTP_URL nor SES credentials are set: e-mails stay in the outbox"),
|
||||||
}
|
}
|
||||||
match &config.openrouter_api_key {
|
match &config.openrouter_api_key {
|
||||||
|
_ if !tasks.analyses => {}
|
||||||
Some(key) => {
|
Some(key) => {
|
||||||
let llm =
|
let llm =
|
||||||
analysis::openrouter::OpenRouter::new(&config.openrouter_base_url, key, config.public_base_url.clone());
|
analysis::openrouter::OpenRouter::new(&config.openrouter_base_url, key, config.public_base_url.clone());
|
||||||
let analyzer =
|
let lanes = analysis::Lanes { quick: config.quick_concurrency, slow: config.analysis_concurrency };
|
||||||
analysis::Analyzer::new(pool.clone(), llm, config.max_analysis_attempts, config.analysis_concurrency);
|
if lanes.quick + lanes.slow == 0 {
|
||||||
tracing::info!(concurrency = analyzer.concurrency, "analyses enabled");
|
tracing::warn!("QUICK_CONCURRENCY and ANALYSIS_CONCURRENCY are both 0: this worker writes no analyses");
|
||||||
jobs.spawn(analysis::run(Arc::new(analyzer), config.poll_interval, stop.clone()));
|
} else {
|
||||||
|
let analyzer = analysis::Analyzer::new(pool.clone(), llm, config.max_analysis_attempts, lanes);
|
||||||
|
tracing::info!(quick = lanes.quick, slow = lanes.slow, "analyses enabled");
|
||||||
|
jobs.spawn(analysis::run(Arc::new(analyzer), config.poll_interval, stop.clone()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => tracing::warn!("OPENROUTER_API_KEY is not set: analyses stay pending"),
|
None => tracing::warn!("OPENROUTER_API_KEY is not set: analyses stay pending"),
|
||||||
}
|
}
|
||||||
jobs.spawn(cleanup::run(pool.clone(), stop.clone()));
|
if tasks.cleanup {
|
||||||
|
jobs.spawn(cleanup::run(pool.clone(), stop.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
let app = Router::new().route("/healthz", get(healthz)).with_state(pool);
|
let app = Router::new().route("/healthz", get(healthz)).with_state(pool);
|
||||||
let listener = tokio::net::TcpListener::bind(addr).await.with_context(|| format!("binding {addr}"))?;
|
let listener = tokio::net::TcpListener::bind(addr).await.with_context(|| format!("binding {addr}"))?;
|
||||||
|
|||||||
@@ -223,6 +223,16 @@ async fn cleanup_removes_only_expired_data(db: PgPool) {
|
|||||||
|
|
||||||
// --- analyses ----------------------------------------------------------------------------
|
// --- analyses ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn worker_tasks_are_chosen_by_name() {
|
||||||
|
use crate::config::Tasks;
|
||||||
|
let mail = Tasks::parse("email, cleanup").unwrap();
|
||||||
|
assert_eq!(mail, Tasks { email: true, cleanup: true, analyses: false });
|
||||||
|
assert_eq!(Tasks::parse("analyses").unwrap(), Tasks { email: false, cleanup: false, analyses: true });
|
||||||
|
assert!(Tasks::parse("emails").is_err());
|
||||||
|
assert!(Tasks::parse(" , ").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
mod analyses {
|
mod analyses {
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
@@ -235,7 +245,7 @@ mod analyses {
|
|||||||
|
|
||||||
use crate::analysis::openrouter::OpenRouter;
|
use crate::analysis::openrouter::OpenRouter;
|
||||||
use crate::analysis::prompt::{Kind, schema, validate};
|
use crate::analysis::prompt::{Kind, schema, validate};
|
||||||
use crate::analysis::{Analyzer, backoff};
|
use crate::analysis::{Analyzer, Lane, Lanes, backoff};
|
||||||
|
|
||||||
/// Scripted replies (then the last one forever) and the requests received.
|
/// Scripted replies (then the last one forever) and the requests received.
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
@@ -337,11 +347,11 @@ mod analyses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn analyzer(db: &PgPool, base_url: &str) -> Analyzer {
|
fn analyzer(db: &PgPool, base_url: &str) -> Analyzer {
|
||||||
Analyzer::new(db.clone(), OpenRouter::new(base_url, "test-key", None), 3, 2)
|
Analyzer::new(db.clone(), OpenRouter::new(base_url, "test-key", None), 3, Lanes { quick: 1, slow: 2 })
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run_once(a: &Analyzer) -> bool {
|
async fn run_once(a: &Analyzer) -> bool {
|
||||||
match a.claim().await.unwrap() {
|
match a.claim(Lane::Slow).await.unwrap() {
|
||||||
Some(job) => {
|
Some(job) => {
|
||||||
a.handle(job).await;
|
a.handle(job).await;
|
||||||
true
|
true
|
||||||
@@ -464,10 +474,10 @@ mod analyses {
|
|||||||
let a = analyzer(&db, &url);
|
let a = analyzer(&db, &url);
|
||||||
|
|
||||||
// the analysis goes first; the preview only when nothing else is due
|
// the analysis goes first; the preview only when nothing else is due
|
||||||
let job = a.claim().await.unwrap().expect("the analysis");
|
let job = a.claim(Lane::Slow).await.unwrap().expect("the analysis");
|
||||||
assert_eq!(job.id, analysis);
|
assert_eq!(job.id, analysis);
|
||||||
a.handle(job).await;
|
a.handle(job).await;
|
||||||
assert!(a.claim().await.unwrap().is_none());
|
assert!(a.claim(Lane::Slow).await.unwrap().is_none());
|
||||||
let job = a.claim_preview().await.unwrap().expect("the preview");
|
let job = a.claim_preview().await.unwrap().expect("the preview");
|
||||||
a.handle_preview(job).await;
|
a.handle_preview(job).await;
|
||||||
let (status, title, model, credits): (String, Option<String>, Option<String>, i64) = sqlx::query_as(
|
let (status, title, model, credits): (String, Option<String>, Option<String>, i64) = sqlx::query_as(
|
||||||
@@ -811,7 +821,7 @@ mod analyses {
|
|||||||
let id = request_analysis(&db, &s).await;
|
let id = request_analysis(&db, &s).await;
|
||||||
let (_, url) = fake_openrouter(vec![reply(&content(Kind::Natal))]).await;
|
let (_, url) = fake_openrouter(vec![reply(&content(Kind::Natal))]).await;
|
||||||
let a = analyzer(&db, &url);
|
let a = analyzer(&db, &url);
|
||||||
let job = a.claim().await.unwrap().expect("a job");
|
let job = a.claim(Lane::Slow).await.unwrap().expect("a job");
|
||||||
// an admin restarts it while the worker is still writing it
|
// an admin restarts it while the worker is still writing it
|
||||||
sqlx::query("UPDATE analyses SET status = 'pending', started_at = NULL, attempts = 0 WHERE id = $1")
|
sqlx::query("UPDATE analyses SET status = 'pending', started_at = NULL, attempts = 0 WHERE id = $1")
|
||||||
.bind(id)
|
.bind(id)
|
||||||
@@ -829,6 +839,40 @@ mod analyses {
|
|||||||
assert_eq!(status, "done");
|
assert_eq!(status, "done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||||
|
async fn summaries_have_their_own_lane(db: PgPool) {
|
||||||
|
let s = setup(&db).await;
|
||||||
|
let natal = request_analysis(&db, &s).await;
|
||||||
|
let summary = |id: Uuid| {
|
||||||
|
sqlx::query(
|
||||||
|
"INSERT INTO analyses (id, kind, chart_id, requested_by, language, model, prompt_version, cache_key, \
|
||||||
|
credits_charged) \
|
||||||
|
VALUES ($1, 'summary', $2, $3, 'hu', 'test/model', 'v1', 'key', 0)",
|
||||||
|
)
|
||||||
|
.bind(id)
|
||||||
|
.bind(s.chart)
|
||||||
|
.bind(s.user)
|
||||||
|
};
|
||||||
|
let first = Uuid::now_v7();
|
||||||
|
summary(first).execute(&db).await.unwrap();
|
||||||
|
let a = analyzer(&db, "http://127.0.0.1:9");
|
||||||
|
|
||||||
|
// the quick lane takes the summary, never the detailed analysis
|
||||||
|
let id_of = |work: Option<crate::analysis::Work>| match work {
|
||||||
|
Some(crate::analysis::Work::Analysis(job)) => Some(job.id),
|
||||||
|
Some(_) => panic!("not an analysis"),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
assert_eq!(id_of(a.claim_quick().await.unwrap()), Some(first));
|
||||||
|
assert_eq!(id_of(a.claim_quick().await.unwrap()), None);
|
||||||
|
// the slow lane prefers the detailed analysis, then helps with quick work
|
||||||
|
let second = Uuid::now_v7();
|
||||||
|
summary(second).execute(&db).await.unwrap();
|
||||||
|
assert_eq!(id_of(a.claim_slow().await.unwrap()), Some(natal));
|
||||||
|
assert_eq!(id_of(a.claim_slow().await.unwrap()), Some(second));
|
||||||
|
assert_eq!(id_of(a.claim_slow().await.unwrap()), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||||
async fn answers_a_question_about_a_relationship_with_both_charts(db: PgPool) {
|
async fn answers_a_question_about_a_relationship_with_both_charts(db: PgPool) {
|
||||||
let s = setup(&db).await;
|
let s = setup(&db).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user