diff --git a/README.md b/README.md index e0325e7..08e2eee 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,6 @@ Balances are net amounts in the supplied history, without any inferred opening b ## Live social previews -`/api/share-image` generates a 1200×630 PNG server-side from D1 and the baseline using the bundled `next/og` renderer. It shows balance, deposits/withdrawals, low-balance count, top three members, names needing a refill, 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 footer's copy button fetches a fresh versioned page URL immediately before copying, allowing a new Discord unfurl after updates. 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 revision changes for backdated imports too; duplicates leave it unchanged. The footer's copy button fetches a fresh versioned page URL immediately before copying, allowing a new Discord unfurl after updates. 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/api/share-image/route.ts b/app/api/share-image/route.ts index d9634f7..be94e03 100644 --- a/app/api/share-image/route.ts +++ b/app/api/share-image/route.ts @@ -2,16 +2,17 @@ import { ImageResponse } from 'next/og'; import { createElement } from 'react'; import { readLedger } from '../../../lib/server'; import { ledgerSnapshot } from '../../../lib/share'; -import { ShareCard } from '../../../lib/share-card'; +import { socialFonts } from '../../../lib/social-fonts'; +import { ShareCard, cardWidth, cardHeight } from '../../../lib/share-card'; export const dynamic = 'force-dynamic'; export async function GET() { try { const data = await ledgerSnapshot(await readLedger()); return new ImageResponse(createElement(ShareCard, {data}), { - width:1200,height:630, + width:cardWidth,height:cardHeight,fonts:[...socialFonts], headers:{'Cache-Control':'no-store, max-age=0','X-Ledger-Revision':data.revision}, }); } catch { - return new Response('Live vault image is temporarily unavailable.',{status:503,headers:{'Cache-Control':'no-store'}}); + return new Response('تصویر زنده خزانه موقتاً در دسترس نیست.',{status:503,headers:{'Cache-Control':'no-store'}}); } } diff --git a/app/dashboard.tsx b/app/dashboard.tsx index 2f42b84..e2a979f 100644 --- a/app/dashboard.tsx +++ b/app/dashboard.tsx @@ -3,7 +3,8 @@ import {useEffect,useState,useMemo} from 'react'; import {Shield,ArrowUpRight,ArrowDownLeft,Search,ChevronLeft,Trophy,Flame,Coins,History,Lock,Upload,CheckCircle2,AlertTriangle,X,RefreshCw,Copy} from 'lucide-react'; import {seed,summarize,parseLog,identity,minimum} from '../lib/ledger.mjs'; type Row={id:string;date:string;player:string;reason:string;amount:number}; -const num=(n:number)=>n.toLocaleString('en-US'); +const num=(n:number)=>n.toLocaleString('fa-IR'); +const digits=(s:string)=>s.replace(/[0-9]/g,n=>'۰۱۲۳۴۵۶۷۸۹'[Number(n)]); function status(n:number){return n<0?'بدهکار':n(seed as Row[]),[loading,setLoading]=useState(true),[error,setError]=useState(''),[query,setQuery]=useState(''),[tab,setTab]=useState('all'),[selected,setSelected]=useState(null),[log,setLog]=useState(''),[message,setMessage]=useState(''),[saving,setSaving]=useState(false),[admin,setAdmin]=useState(false),[view,setView]=useState('leaderboard'),[shareUrl,setShareUrl]=useState(''),[shareNotice,setShareNotice]=useState(''),[sharing,setSharing]=useState(false); @@ -15,15 +16,15 @@ export default function Dashboard({adminMode=false}:{adminMode?:boolean}){ const profile=players.find(p=>p.name.toLowerCase()===selected?.toLowerCase()); 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 copyShareLink(){setSharing(true);setShareNotice('');try{const response=await fetch('/api/ledger',{cache:'no-store'});const data=await response.json() as {shareUrl:string;error?:string};if(!response.ok)throw Error(data.error||'دریافت آخرین وضعیت ممکن نشد.');setShareUrl(data.shareUrl);try{await navigator.clipboard.writeText(data.shareUrl);setShareNotice('لینک آخرین وضعیت کپی شد؛ در دیسکورد پیست کن.');}catch{setShareNotice(data.shareUrl);}}catch(e){setShareNotice((e as Error).message);}finally{setSharing(false);}} - async function importLog(){setSaving(true);setMessage('');try{const r=await fetch('/api/import',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({log})});const d=await r.json() as {error?:string;added:number;duplicates:number};if(!r.ok)throw Error(d.error);setMessage(`${d.added} تراکنش جدید ثبت شد؛ ${d.duplicates} رکورد تکراری کنار گذاشته شد.`);setLog('');await refresh();}catch(e){setMessage((e as Error).message);}finally{setSaving(false);}} - return
-
گیلد خزانهٔ Siphoned
نمای عمومی
THE GUILD'S LIFEBLOOD

خزانه پُر. گیلد قدرتمند.

سهمت را ببین، جایگاهت را بشناس و برای نبرد بعدی آماده باش.

شفاف برای همهٔ اعضا به‌روزرسانی با لاگ بازی
+ async function importLog(){setSaving(true);setMessage('');try{const r=await fetch('/api/import',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({log})});const d=await r.json() as {error?:string;added:number;duplicates:number};if(!r.ok)throw Error(d.error);setMessage(`${num(d.added)} تراکنش جدید ثبت شد؛ ${num(d.duplicates)} رکورد تکراری کنار گذاشته شد.`);setLog('');await refresh();}catch(e){setMessage((e as Error).message);}finally{setSaving(false);}} + return
+
گیلد خزانهٔ سایفوند
نمای عمومی
قدرت گیلد، از خزانه شروع می‌شود

خزانه پُر. گیلد قدرتمند.

سهمت را ببین، جایگاهت را بشناس و برای نبرد بعدی آماده باش.

شفاف برای همهٔ اعضا به‌روزرسانی با لاگ بازی
{error&&
{error} داده‌های اولیه نمایش داده می‌شوند.
} -
بالانس خزانه
{num(total)}SIPHONEDخالص واریز و برداشت اعضا
کل واریزها
{num(deposits)}+ DEPOSITسهم اعضا در قدرت گیلد
کل برداشت‌ها
{num(withdrawals)}WITHDRAWAL{num(rows.length)} تراکنش ثبت‌شده
اعضای نیازمند اقدام
{num(low.length)}از {num(players.length)} عضوبالانس کمتر از {minimum} Siphoned
- {adminMode&&
KEEP THE VAULT UP TO DATE

ورود لاگ خزانه

خروجی بازی را همراه عنوان ستون‌ها اینجا پیست کن. پیش‌نمایش را بررسی و سپس ثبت کن.