diff --git a/README.md b/README.md index e0bcd3e..df89b30 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Balances are net amounts in the supplied history, without any inferred opening b ## Live social previews -`/api/share-image` generates a 1600×1200 PNG server-side from D1 and the baseline using the bundled `next/og` renderer. It shows balance, deposits/withdrawals, low-balance count, top eight members, eight members needing a refill and their required top-ups, the four most recent transactions, and the latest game timestamp. Both the image and ledger API bypass application caching. Root metadata reads the same data and adds a content-derived revision to the image URL. The revision changes for backdated imports too; duplicates leave it unchanged. The header's sharing button adds the current Unix time in seconds as `t` to the versioned page URL, then copies the URL. Root metadata propagates the same timestamp to the image URL, allowing a fresh Discord unfurl even if ledger data has not changed. If clipboard access is unavailable, a selectable URL is shown. Discord controls its own cache: embeds already posted are not guaranteed to refresh automatically. The image endpoint always reads current data, including when requested using an older revision query. +`/api/share-image` generates a 1600×1200 PNG server-side from D1 and the baseline using the bundled `next/og` renderer. It shows balance, deposits/withdrawals, low-balance count, top eight members, eight members needing a refill and their required top-ups, the four most recent transactions, and the latest game timestamp. Both the image and ledger API bypass application caching. Root metadata reads the same data and adds a content-derived revision to the image URL. The internal image revision changes for backdated imports too; duplicates leave it unchanged. Shared page links contain only the Unix timestamp (`?t=...`), without the internal revision. The header's sharing button adds the current Unix time in seconds as `t` to the clean page URL, then copies the URL. Root metadata propagates the same timestamp to the image URL, allowing a fresh Discord unfurl even if ledger data has not changed. If clipboard access is unavailable, a selectable URL is shown. Discord controls its own cache: embeds already posted are not guaranteed to refresh automatically. The image endpoint always reads current data, including when requested using an older revision query. The live card uses bundled OFL-licensed Vazirmatn regular/bold fonts. Persian labels are shaped into presentation forms for Satori, with explicit column ordering so player names and numbers retain their correct order. Persian numbers and dates use Persian digits; game timestamps are not converted to another timezone. The card edition is included in revisioned share links to invalidate earlier English previews. diff --git a/app/dashboard.tsx b/app/dashboard.tsx index 88d152b..108c4e2 100644 --- a/app/dashboard.tsx +++ b/app/dashboard.tsx @@ -18,7 +18,7 @@ export default function Dashboard({adminMode=false}:{adminMode?:boolean}){ const preview=useMemo(()=>{if(!log.trim())return null;try{const parsed=parseLog(log);const ids=new Set(rows.map(identity));let fresh=0;for(const r of parsed){const id=identity(r);if(!ids.has(id)){fresh++;ids.add(id);}}return {total:parsed.length,fresh,duplicates:parsed.length-fresh,error:''};}catch(e){return {error:(e as Error).message,total:0,fresh:0,duplicates:0};}},[log,rows]); async function shareLatest(){ setSharing(true);setShareNotice(''); - const url=withShareTimestamp(shareUrl,Math.floor(Date.now()/1000)); + const url=withShareTimestamp(new URL('/',shareUrl).href,Math.floor(Date.now()/1000)); try { try{if(!navigator.clipboard)throw Error('Clipboard unavailable');await navigator.clipboard.writeText(url);setShareNotice('لینک آخرین وضعیت کپی شد؛ در دیسکورد پیست کن.');} catch{setShareNotice(url);} diff --git a/lib/share.ts b/lib/share.ts index aadfd2a..715b51e 100644 --- a/lib/share.ts +++ b/lib/share.ts @@ -8,7 +8,7 @@ export async function ledgerSnapshot(rows: {date:string;player:string;reason:str return { revision, recent: rows.slice(0,4), - shareUrl: `${siteOrigin}/?v=${revision}`, + shareUrl: `${siteOrigin}/`, imageUrl: `${siteOrigin}/api/share-image?v=${revision}`, players, balance: players.reduce((n,p)=>n+p.balance,0),