forked from unimatrix/web
Complete shared People, Rihla, security, event and Realm navigation batch
This commit is contained in:
parent
b6eb59c5eb
commit
c352cc9f2c
7 changed files with 341 additions and 180 deletions
|
|
@ -12,6 +12,6 @@ export const designAliases={'realm/company-directory':'realm/companies','realm/c
|
|||
const electionPreview={tabs:['Applications','Voting','Results','Calendar'].map(label=>({label,fields:[]}))},advertisingPreview={tabs:['Booking agenda','Booking preview','Card templates'].map(label=>({label,fields:[]}))};
|
||||
const authoredPreviewPages={'realm/citizen-elections':electionPreview,'clan/clan-elections':electionPreview,'clan/clan-advertising':advertisingPreview};
|
||||
const implementedBankPages=new Set(['bank-authorisations','federal-reserve','dunemark-collection']);
|
||||
export function auditDesign(){return menu.workspaces.flatMap(w=>w.groups.flatMap(g=>g.items.map(item=>{const key=w.id+'/'+item.id,design=DESIGN_PAGES[key]||authoredPreviewPages[key],preserved=w.id==='realm'&&['item-exchange','item-listings','item-post'].includes(item.id)||['quests','kits'].includes(w.id)||w.id==='clan'&&!['clan-campaigns','clan-quests'].includes(item.id)||w.id==='bank'&&(item.id==='bank-information'||implementedBankPages.has(item.id))||w.id==='politics'||w.id==='market'&&['commodity-listings','commodity-mine'].includes(item.id)||w.id==='bureau'&&item.id!=='kit-claims'||w.id==='forge'&&['dev-panel','dev-queue','dev-approvals','dev-new','dev-archive','git-workspace','git-repositories','git-administration'].includes(item.id);return{workspace:w.label,group:g.label,key,title:item.label,existedInV1:oldIds.has(item.id),classification:w.id==='events'||['clan-campaigns','clan-quests'].includes(item.id)?'planned-placeholder':design?'new-design-only':preserved?'preserved-implemented':oldIds.has(item.id)?'v1-integration-next':'needs-design-spec',tabs:design?.tabs.map(t=>t.label)||[],fields:design?[...new Set(design.tabs.flatMap(t=>t.fields.map(f=>f.label)))]:[]};})));}
|
||||
export function auditDesign(){return menu.workspaces.flatMap(w=>w.groups.flatMap(g=>g.items.map(item=>{const key=w.id+'/'+item.id,design=DESIGN_PAGES[key]||authoredPreviewPages[key],preserved=w.id==='realm'&&['rihla','item-exchange','item-listings','item-post'].includes(item.id)||['quests','kits'].includes(w.id)||w.id==='clan'&&!['clan-campaigns','clan-quests'].includes(item.id)||w.id==='bank'&&(item.id==='bank-information'||implementedBankPages.has(item.id))||w.id==='politics'||w.id==='market'&&['commodity-listings','commodity-mine'].includes(item.id)||w.id==='bureau'&&item.id!=='kit-claims'||w.id==='forge'&&['dev-panel','dev-queue','dev-approvals','dev-new','dev-archive','git-workspace','git-repositories','git-administration'].includes(item.id);return{workspace:w.label,group:g.label,key,title:item.label,existedInV1:oldIds.has(item.id),classification:w.id==='events'||['clan-campaigns','clan-quests'].includes(item.id)?'planned-placeholder':design?'new-design-only':preserved?'preserved-implemented':oldIds.has(item.id)?'v1-integration-next':'needs-design-spec',tabs:design?.tabs.map(t=>t.label)||[],fields:design?[...new Set(design.tabs.flatMap(t=>t.fields.map(f=>f.label)))]:[]};})));}
|
||||
export async function writeDesignAudit(destination){const rows=auditDesign(),summary={menus:rows.length,designed:rows.filter(r=>r.classification==='new-design-only').length,integrationNext:rows.filter(r=>r.classification==='v1-integration-next').length,preserved:rows.filter(r=>r.classification==='preserved-implemented').length,uncovered:rows.filter(r=>r.classification==='needs-design-spec').map(r=>r.key),featureTabs:Object.values(DESIGN_PAGES).reduce((n,p)=>n+p.tabs.length,0)};await mkdir(destination,{recursive:true});await writeFile(path.join(destination,'design-batch.json'),JSON.stringify({summary,rows,aliases:designAliases},null,2));const lines=['DUNEREALMS V2 — NEW PAGE DESIGN BATCH','Design only. No API integration or live business changes.','',JSON.stringify(summary,null,2),''];for(const workspace of menu.workspaces){lines.push(workspace.label);for(const r of rows.filter(r=>r.workspace===workspace.label)){lines.push(' '+r.title+' ['+r.classification+'] — '+r.key);if(r.tabs.length)lines.push(' Tabs: '+r.tabs.join(' | '));}lines.push('');}lines.push('COMPANY BOOKMARK ALIASES');for(const [from,to]of Object.entries(designAliases))lines.push(from+' -> '+to);await writeFile(path.join(destination,'design-batch.txt'),lines.join('\n'));return summary;}
|
||||
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){const result=await writeDesignAudit(process.argv[2]||'output/cp-v2-design-batch');console.log(JSON.stringify(result));if(result.uncovered.length)process.exitCode=1;}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {rihlaRatesSection} from './rihla-rates-section.mjs';
|
||||
import {claimRatesSection} from './claim-rates-section.mjs';
|
||||
import {SHARED_HEADER} from './portal-navigation.mjs';
|
||||
import {PACKAGES,BANK_VERSION} from '../node/postbank-catalogue.mjs';
|
||||
|
|
@ -7,5 +8,5 @@ export function bankRatesPage(){
|
|||
const version=createHash('sha256').update(JSON.stringify([PACKAGES,CREDIT_PRODUCTS])).digest('hex').slice(0,10);
|
||||
const packages=PACKAGES.map(p=>`<tr><th>${p.name}</th><td>${p.kinds.join(' / ')}</td><td>${(p.monthly/100).toFixed(2)} DM</td><td>${p.extra}</td><td>${p.extra?(p.extraFee/100).toFixed(2)+' DM':'—'}</td><td>${p.unlimitedInstant?'Unlimited':p.instant}</td></tr>`).join('');
|
||||
const credit=CREDIT_PRODUCTS.filter(p=>!p.revolving).map(p=>`<tr><th>${p.name}</th><td>${(p.annualBps/100).toFixed(2)}%</td><td>${p.min}–${p.max} DM</td><td>${p.terms?p.terms.join(', '):'Up to '+p.maxMonths} months</td></tr>`).join('');
|
||||
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Rates & Charges | Imperial Postbank</title><meta name="description" content="Public Imperial Postbank package fees, credit rates, organisation claim tariffs and service conditions in Dunemarks."><link rel="stylesheet" href="/bank-rates.css"><link rel="stylesheet" href="/portal-navigation.css"><script src="/portal-navigation.js" defer></script><script src="/bank-rates.js" defer></script></head><body>${SHARED_HEADER}<main><section class="hero"><img src="/assets/imperial-postbank-v2.png" alt="Imperial Postbank"><div><p class="eyebrow">YOUR MONEY. CLEAR TERMS.</p><h1>Rates & Charges</h1><p>A clear guide to banking and organisation costs.</p><span class="stamp">PUBLIC TARIFF GUIDE · ${version}</span></div></section><nav class="sections" aria-label="Tariff sections"><a href="#packages">Accounts & packages</a><a href="#credit">Credit rates</a><a href="#services">Services & taxes</a><a href="#claims">Land claims</a></nav><aside class="notice"><strong>Alpha service notice</strong><p>All amounts are fictional Dunemarks (DM). Published monthly package prices are not yet collected automatically. This is a game economy, not a real-money banking service.</p></aside><section id="packages"><span class="eyebrow">01 / EVERYDAY BANKING</span><h2>Accounts & packages</h2><p>One current account is included in each package.</p><div class="table-wrap"><table><thead><tr><th>Package</th><th>Client</th><th>Monthly price</th><th>Extra current accounts¹</th><th>Each / month¹</th><th>Instant quota / month</th></tr></thead><tbody>${packages}</tbody></table></div><p class="fine">¹ Published additional-account limits and prices, subject to feature availability. Flow and Pro include a savings account. Pro includes unlimited instant payments with no per-transfer fee. Transfers have no package amount cap; available funds and payment security apply. Start has no instant payments. Instant quotas are server usage limits.</p></section><section id="credit"><span class="eyebrow">02 / BORROWING</span><h2>Credit rates</h2><p>Annual rates for new applications. Your accepted contract and repayment schedule govern your loan.</p><div class="table-wrap"><table><thead><tr><th>Product</th><th>Annual rate</th><th>Principal range</th><th>Available terms</th></tr></thead><tbody>${credit}</tbody></table></div><p class="fine">Launch grants are repayable at 0% interest. Ordinary loans require review and a first instalment of 5% from your own funds before issue. This instalment counts toward repayment and reduces the remaining loan balance. Eligibility, available funding and refinancing conditions apply. Existing fixed-rate contracts retain their agreed rate. Revolving credit is not available.</p></section><section id="services"><span class="eyebrow">03 / TRANSPARENCY</span><h2>Services & taxes</h2><div class="service-grid"><article><h3>Monthly statements</h3><strong>Free</strong><p>Automatically archived PDF statements after month-end.</p></article><article><h3>Balance Guard</h3><strong>1.00 DM / month</strong><p>Published optional price per eligible account. Preference saving is available; protection and charging are not active yet.</p></article><article><h3>Tax policy</h3><strong>Not yet published</strong><p>VAT and account-tax rates await central configuration. No unconfirmed rate is presented as active.</p></article></div></section>${claimRatesSection()}<section class="document"><div><h2>Your tariff guide</h2><p>Generated from the bank catalogues on each build. Version ${version}. Package terms: ${BANK_VERSION}. Credit terms: ${CREDIT_VERSION}.</p><p class="fine">Catalogue references identify source terms, not a new effective date. Administrative rate editing and automatic downloadable PDF publication are planned. You can print or save this guide as PDF now.</p></div><button onclick="window.print()">Print / Save as PDF</button></section><p class="fine">No private account or transaction data is published here.</p></main><footer><a href="/">DuneRealms</a><a href="/rates-and-charges.html">Rates & Charges</a><a href="https://support.dunerealms.com/">Contact support</a></footer></body></html>`;
|
||||
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Rates & Charges | Imperial Postbank</title><meta name="description" content="Public Imperial Postbank package fees, credit rates, organisation claim tariffs and service conditions in Dunemarks."><link rel="stylesheet" href="/bank-rates.css"><link rel="stylesheet" href="/portal-navigation.css"><script src="/portal-navigation.js" defer></script><script src="/bank-rates.js" defer></script></head><body>${SHARED_HEADER}<main><section class="hero"><img src="/assets/imperial-postbank-v2.png" alt="Imperial Postbank"><div><p class="eyebrow">YOUR MONEY. CLEAR TERMS.</p><h1>Rates & Charges</h1><p>A clear guide to banking and organisation costs.</p><span class="stamp">PUBLIC TARIFF GUIDE · ${version}</span></div></section><nav class="sections" aria-label="Tariff sections"><a href="#packages">Accounts & packages</a><a href="#credit">Credit rates</a><a href="#services">Services & taxes</a><a href="#claims">Land claims</a></nav><aside class="notice"><strong>Alpha service notice</strong><p>All amounts are fictional Dunemarks (DM). Published monthly package prices are not yet collected automatically. This is a game economy, not a real-money banking service.</p></aside><section id="packages"><span class="eyebrow">01 / EVERYDAY BANKING</span><h2>Accounts & packages</h2><p>One current account is included in each package.</p><div class="table-wrap"><table><thead><tr><th>Package</th><th>Client</th><th>Monthly price</th><th>Extra current accounts¹</th><th>Each / month¹</th><th>Instant quota / month</th></tr></thead><tbody>${packages}</tbody></table></div><p class="fine">¹ Published additional-account limits and prices, subject to feature availability. Flow and Pro include a savings account. Pro includes unlimited instant payments with no per-transfer fee. Transfers have no package amount cap; available funds and payment security apply. Start has no instant payments. Instant quotas are server usage limits.</p></section><section id="credit"><span class="eyebrow">02 / BORROWING</span><h2>Credit rates</h2><p>Annual rates for new applications. Your accepted contract and repayment schedule govern your loan.</p><div class="table-wrap"><table><thead><tr><th>Product</th><th>Annual rate</th><th>Principal range</th><th>Available terms</th></tr></thead><tbody>${credit}</tbody></table></div><p class="fine">Launch grants are repayable at 0% interest. Ordinary loans require review and a first instalment of 5% from your own funds before issue. This instalment counts toward repayment and reduces the remaining loan balance. Eligibility, available funding and refinancing conditions apply. Existing fixed-rate contracts retain their agreed rate. Revolving credit is not available.</p></section><section id="services"><span class="eyebrow">03 / TRANSPARENCY</span><h2>Services & taxes</h2><div class="service-grid"><article><h3>Monthly statements</h3><strong>Free</strong><p>Automatically archived PDF statements after month-end.</p></article><article><h3>Balance Guard</h3><strong>1.00 DM / month</strong><p>Published optional price per eligible account. Preference saving is available; protection and charging are not active yet.</p></article><article><h3>Tax policy</h3><strong>Not yet published</strong><p>VAT and account-tax rates await central configuration. No unconfirmed rate is presented as active.</p></article></div></section>${rihlaRatesSection()}${claimRatesSection()}<section class="document"><div><h2>Your tariff guide</h2><p>Generated from the bank catalogues on each build. Version ${version}. Package terms: ${BANK_VERSION}. Credit terms: ${CREDIT_VERSION}.</p><p class="fine">Catalogue references identify source terms, not a new effective date. Administrative rate editing and automatic downloadable PDF publication are planned. You can print or save this guide as PDF now.</p></div><button onclick="window.print()">Print / Save as PDF</button></section><p class="fine">No private account or transaction data is published here.</p></main><footer><a href="/">DuneRealms</a><a href="/rates-and-charges.html">Rates & Charges</a><a href="https://support.dunerealms.com/">Contact support</a></footer></body></html>`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {createHash} from 'node:crypto';
|
||||
import {withRealmSwitch,REALM_SWITCH_CSS} from './realm-switch.mjs';
|
||||
import {HOUSE_STYLE_CSS} from './house-style.mjs';
|
||||
import {bankRatesPage} from './bank-rates-page.mjs';
|
||||
|
|
@ -39,11 +40,11 @@ for(const [source,target] of [['cp-v2/cp-v2-exchange-design.mjs','codex-exchange
|
|||
writeFileSync(path.join(web,target),content);
|
||||
}
|
||||
writeFileSync(path.join(web,'rates-and-charges.html'),bankRatesPage());
|
||||
let assetCount=0;let assetWriter=null;const types={'.html':'text/html; charset=utf-8','.css':'text/css; charset=utf-8','.js':'text/javascript; charset=utf-8','.json':'application/json; charset=utf-8','.webp':'image/webp','.png':'image/png','.mp4':'video/mp4','.zip':'application/zip','.svg':'image/svg+xml'};
|
||||
function collect(directory){for(const entry of readdirSync(directory).sort()){const p=path.join(directory,entry);if(statSync(p).isDirectory())collect(p);else{const relative=path.relative(web,p).split(path.sep).join('/');if(/^assets\/seals\/[^/]+-provenance\.txt$/.test(relative)||/^assets\/organisation-deed(?:s)?-[a-z0-9-]+\.png$/.test(relative))continue;const type=types[path.extname(entry)];if(!type)throw Error('Unexpected asset: '+entry);const bytes=readFileSync(p);const payload=relative.endsWith('.html')?Buffer.from(preparePublicHtml(bytes.toString('utf8'))):relative==='portal-navigation.js'?Buffer.from(withRealmSwitch(withCanonicalMenu(withMenuBadges(bytes.toString('utf8'))))):relative==='portal-navigation.css'?Buffer.concat([bytes,Buffer.from(HOUSE_STYLE_CSS+REALM_SWITCH_CSS)]):bytes;writeSync(assetWriter,JSON.stringify('/'+relative)+':['+JSON.stringify(type)+','+JSON.stringify(payload.toString('base64'))+'],');assetCount++}}}
|
||||
mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.openai'),{recursive:true});const workerTemporary=path.join(dist,'server/index.js.build-'+process.pid);process.once('exit',()=>{if(existsSync(workerTemporary))try{unlinkSync(workerTemporary);}catch{}});assetWriter=openSync(workerTemporary,'w');writeSync(assetWriter,'const ASSET_DATA={');collect(web);const buildCommit=process.env.GITHUB_SHA;if(buildCommit&&/^[0-9a-f]{40}$/.test(buildCommit)){writeSync(assetWriter,JSON.stringify('/ci-build.json')+':'+JSON.stringify(['application/json; charset=utf-8',Buffer.from(JSON.stringify({commit:buildCommit})).toString('base64')])+',');}writeSync(assetWriter,'};\n');
|
||||
let assetCount=0;let assetWriter=null,shardSize=0;const shardNames=[];let shardTemporary;function openShard(){shardTemporary=path.join(dist,'server','.assets-build-'+process.pid);assetWriter=openSync(shardTemporary,'w');writeSync(assetWriter,'export default {');shardSize=0;}function closeShard(){writeSync(assetWriter,'};\n');closeSync(assetWriter);const hash=createHash('sha256').update(readFileSync(shardTemporary)).digest('hex'),name='assets-'+hash+'.mjs',target=path.join(dist,'server',name);if(existsSync(target))unlinkSync(shardTemporary);else renameSync(shardTemporary,target);shardNames.push(name);}function writeAsset(entry){if(shardSize>32*1024*1024){closeShard();openShard();}writeSync(assetWriter,entry);shardSize+=Buffer.byteLength(entry);}const types={'.html':'text/html; charset=utf-8','.css':'text/css; charset=utf-8','.js':'text/javascript; charset=utf-8','.json':'application/json; charset=utf-8','.webp':'image/webp','.png':'image/png','.mp4':'video/mp4','.zip':'application/zip','.svg':'image/svg+xml'};
|
||||
function collect(directory){for(const entry of readdirSync(directory).sort()){const p=path.join(directory,entry);if(statSync(p).isDirectory())collect(p);else{const relative=path.relative(web,p).split(path.sep).join('/');if(/^assets\/seals\/[^/]+-provenance\.txt$/.test(relative)||/^assets\/organisation-deed(?:s)?-[a-z0-9-]+\.png$/.test(relative))continue;const type=types[path.extname(entry)];if(!type)throw Error('Unexpected asset: '+entry);const bytes=readFileSync(p);const payload=relative.endsWith('.html')?Buffer.from(preparePublicHtml(bytes.toString('utf8'))):relative==='portal-navigation.js'?Buffer.from(withRealmSwitch(withCanonicalMenu(withMenuBadges(bytes.toString('utf8'))))):relative==='portal-navigation.css'?Buffer.concat([bytes,Buffer.from(HOUSE_STYLE_CSS+REALM_SWITCH_CSS)]):bytes;writeAsset(JSON.stringify('/'+relative)+':['+JSON.stringify(type)+','+JSON.stringify(payload.toString('base64'))+'],');assetCount++}}}
|
||||
mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.openai'),{recursive:true});const workerTemporary=path.join(dist,'server/index.js.build-'+process.pid);process.once('exit',()=>{if(existsSync(workerTemporary))try{unlinkSync(workerTemporary);}catch{}});openShard();collect(web);const buildCommit=process.env.GITHUB_SHA;if(buildCommit&&/^[0-9a-f]{40}$/.test(buildCommit)){writeAsset(JSON.stringify('/ci-build.json')+':'+JSON.stringify(['application/json; charset=utf-8',Buffer.from(JSON.stringify({commit:buildCommit})).toString('base64')])+',');}closeShard();
|
||||
let api=['feed-api.mjs','exchange-api.mjs','forum-api.mjs','community-api.mjs','portal-api.mjs'].map(file=>readFileSync(path.join(root,'worker',file),'utf8').replace(/export /g,'')).join('\n');let runtime=readFileSync(path.join(root,'worker/runtime.mjs'),'utf8').replace(/^import .*;$/gm,'');
|
||||
writeSync(assetWriter,api+'\n'+runtime);closeSync(assetWriter);renameSync(workerTemporary,path.join(dist,'server/index.js'));cpSync(path.join(root,'.openai/hosting.json'),path.join(dist,'.openai/hosting.json'));console.log('Built Worker with',assetCount,'embedded website assets');
|
||||
writeFileSync(path.join(dist,'server/index.js'),shardNames.map((name,i)=>'import DATA'+i+' from '+JSON.stringify('./'+name)+';').join('\n')+'\nconst ASSET_DATA=Object.assign({},'+shardNames.map((_,i)=>'DATA'+i).join(',')+');\n'+api+'\n'+runtime);cpSync(path.join(root,'.openai/hosting.json'),path.join(dist,'.openai/hosting.json'));console.log('Built Worker with',assetCount,'embedded website assets');
|
||||
if(existsSync(path.join(root,'drizzle')))cpSync(path.join(root,'drizzle'),path.join(dist,'.openai/drizzle'),{recursive:true});
|
||||
// Native applications consume the same compiled chrome as the public Worker.
|
||||
// nginx follows the atomically promoted current release, so no stale host copy
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Imperial Forums","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Guild Comms","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Imperial Directorate","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Starport","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Realm Nexus","https://www.dunerealms.com/realm-hub.html","nav-clan-v2.webp"],["Citizen Passport","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Imperial Archives","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];
|
||||
export const MAIN_MENU=[['Home','https://www.dunerealms.com/','nav-home-v2.webp'],['Shop','https://shop.dunerealms.com/','nav-shop-v1.webp'],['Community','https://www.dunerealms.com/staff.html','nav-boards-v2.webp'],['Starport','https://www.dunerealms.com/exchange.html','nav-exchange-v2.webp'],['Realm Hub','https://www.dunerealms.com/realm-hub.html','nav-clan-v2.webp'],['My Account','https://cp.dunerealms.com/','nav-account-v2.webp'],['Support','https://support.dunerealms.com/','nav-support-v2.webp'],['Wiki','https://wiki.dunerealms.com/','nav-manual-v2.webp']];
|
||||
export const MAIN_MENU_GROUPS={Community:[['Forums','https://forums.dunerealms.com/','nav-boards-v2.webp'],['Discord','https://www.dunerealms.com/discord.html','nav-discord-v2.webp'],['Staff & Teams','https://www.dunerealms.com/staff.html','nav-staff-v2.webp'],['Events','https://cp.dunerealms.com/#events/events-calendar','nav-home-v2.webp']],Starport:[['Browse Exchange','https://www.dunerealms.com/exchange.html','nav-exchange-v2.webp'],['Items','https://www.dunerealms.com/exchange.html?type=items','minecraft-items/diamond.png'],['Kits','https://www.dunerealms.com/exchange.html?type=kits','imperial-atelier-v1.webp'],['Recruitment','https://www.dunerealms.com/exchange.html?type=recruitment','exchange-clan-recruitment-v1.png'],['Political Positions','https://www.dunerealms.com/exchange.html?type=politics','exchange-political-positions-v1.png'],['Auctions','https://www.dunerealms.com/exchange.html?type=auctions','nav-exchange-v2.webp']],'Realm Hub':[['Clans & Houses','https://clans.dunerealms.com/','nav-clan-v2.webp'],['Companies','https://corp.dunerealms.com/','exchange-company-jobs-v1.png'],['Politics & Offices','https://www.dunerealms.com/government.html','seals/office-landsraad.png']],'My Account':[['My Profile','https://cp.dunerealms.com/#realm/site-profile','nav-account-v2.webp'],['User CP','https://cp.dunerealms.com/','nav-account-v2.webp'],['Messages','https://cp.dunerealms.com/#post/mail-inbox','nav-support-v2.webp'],['Imperial Postbank','https://cp.dunerealms.com/#bank/bank-overview','imperial-postbank-v2.png'],['Rihla Transfers','https://cp.dunerealms.com/#realm/rihla','rihla-brand-v1.png'],['Account Security','https://cp.dunerealms.com/#realm/security','nav-account-v2.webp']]};
|
||||
export const ALL_MENU_LINKS=[...MAIN_MENU,...Object.values(MAIN_MENU_GROUPS).flat()].filter((row,i,rows)=>rows.findIndex(r=>r[1]===row[1])===i);
|
||||
export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';const kits=u.pathname==='/exchange.html'&&/^kits(?:-(?:clan|office|player|legendary))?$/.test(u.searchParams.get('type')||'');return u.origin+(u.pathname==='/index.html'?'/':u.pathname)+(kits?'?type=kits':'');}
|
||||
export function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}};
|
||||
for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);}
|
||||
for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}}
|
||||
return changes;
|
||||
}
|
||||
export const CANONICAL_MENU_SCRIPT='\n/* Dune canonical menu begin */\n(()=>{if(window.top!==window.self)return;const MAIN_MENU='+JSON.stringify(MAIN_MENU)+';const canonicalMenuHref='+canonicalMenuHref.toString()+';const normalizeMainMenus='+normalizeMainMenus.toString()+';const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})();\n/* Dune canonical menu end */\n';
|
||||
|
||||
export function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU,groups=MAIN_MENU_GROUPS,authenticated=true){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}};
|
||||
const fill=(node,name,href,icon,link=true)=>{if(link)set(node,'href',href);let image=node.querySelector('img');if(!image){image=doc.createElement('img');node.insertBefore(image,node.firstChild);changes++;}for(const[k,v]of [['src','https://www.dunerealms.com/assets/'+icon],['alt',''],['width','42'],['height','42']])set(image,k,v);let label=[...node.children].find(n=>n.tagName==='SPAN'&&!n.classList.contains('dune-new-overlay')&&!n.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');node.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...node.childNodes])if(n.nodeType===3){n.remove();changes++;}const here=new URL(currentUrl,'https://www.dunerealms.com'),there=new URL(href,'https://www.dunerealms.com');const active=link&&(there.hash||there.search?here.href===there.href:canonicalMenuHref(currentUrl)===canonicalMenuHref(href));if(active)set(node,'aria-current','page');else if(node.hasAttribute('aria-current')){node.removeAttribute('aria-current');changes++;}};
|
||||
for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const existing=[...nav.children],ordered=[];for(const[name,href,icon]of links){const items=name==='My Account'&&!authenticated?[['Sign in','https://cp.dunerealms.com/','nav-account-v2.webp'],['Register','https://cp.dunerealms.com/#register','nav-account-v2.webp']]:groups[name];if(items){let group=existing.find(n=>n.getAttribute('data-dune-nav-group')===name);if(!group){group=doc.createElement('details');group.className='dune-menu-group';set(group,'data-dune-nav-group',name);group.append(doc.createElement('summary'));const box=doc.createElement('div');box.className='dune-menu-dropdown';group.append(box);changes++;}fill(group.firstElementChild,name,href,icon,false);const box=group.lastElementChild,previous=[...box.children],children=[];for(const child of items){let a=previous.find(n=>!children.includes(n)&&n.getAttribute('href')===child[1]);if(!a){a=doc.createElement('a');changes++;}fill(a,...child);children.push(a);}for(const a of previous)if(!children.includes(a)){a.remove();changes++;}let cursor=box.firstElementChild;for(const a of children){if(a!==cursor){box.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}ordered.push(group);}else{let a=existing.find(n=>n.tagName==='A'&&n.getAttribute('href')===href);if(!a){a=doc.createElement('a');changes++;}fill(a,name,href,icon);ordered.push(a);}}for(const node of existing)if(!ordered.includes(node)){node.remove();changes++;}let cursor=nav.firstElementChild;for(const node of ordered){if(node!==cursor){nav.insertBefore(node,cursor);changes++;}cursor=node.nextElementSibling;}}return changes;}
|
||||
export const CANONICAL_MENU_SCRIPT='\n/* Dune canonical menu begin */\n(()=>{if(window.top!==window.self)return;const MAIN_MENU='+JSON.stringify(MAIN_MENU)+';const MAIN_MENU_GROUPS='+JSON.stringify(MAIN_MENU_GROUPS)+';const canonicalMenuHref='+canonicalMenuHref.toString()+';const normalizeMainMenus='+normalizeMainMenus.toString()+';let authenticated=false;const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU,MAIN_MENU_GROUPS,authenticated);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});fetch("https://cp.dunerealms.com/api/auth/session",{credentials:"include",cache:"no-store"}).then(r=>r.ok?r.json():null).then(d=>{authenticated=!!d?.authenticated;if(d?.user?.username)MAIN_MENU_GROUPS["My Account"][0][1]="https://www.dunerealms.com/people/"+encodeURIComponent(d.user.username);sync();}).catch(()=>{});document.addEventListener("click",e=>{for(const group of document.querySelectorAll(".dune-menu-group[open]"))if(!group.contains(e.target))group.open=false;});document.addEventListener("keydown",e=>{if(e.key!=="Escape")return;for(const group of document.querySelectorAll(".dune-menu-group[open]")){group.open=false;group.firstElementChild.focus();}});})();\n/* Dune canonical menu end */\n';
|
||||
export function withCanonicalMenu(script){
|
||||
// Older published assets may contain a generated controller without its marker comments.
|
||||
// Remove both forms before installing the single current controller.
|
||||
return script.replace(/\n?\/\* Dune canonical menu begin \*\/[^]*?\/\* Dune canonical menu end \*\/\n?/g,'')
|
||||
return script.replace(/\(\(\)=>\{if\(window\.top!==window\.self\)return;const MAIN_MENU=[\s\S]*?\}\)\(\);/g,'').replace(/\n?\/\* Dune canonical menu begin \*\/[^]*?\/\* Dune canonical menu end \*\/\n?/g,'')
|
||||
.replace(/\(\(\)=>\{if\(window\.top!==window\.self\)return;const MAIN_MENU=[^]*?const sync=\(\)=>normalizeMainMenus\(document,location\.href,MAIN_MENU\);sync\(\);new MutationObserver\(sync\)\.observe\(document\.body,\{childList:true,subtree:true\}\);\}\)\(\);/g,'')+CANONICAL_MENU_SCRIPT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {MAIN_MENU} from './main-menu.mjs';
|
||||
import {ALL_MENU_LINKS as MAIN_MENU} from './main-menu.mjs';
|
||||
import{existsSync,readFileSync,writeFileSync}from'node:fs';import{execFileSync}from'node:child_process';import{fileURLToPath}from'node:url';import path from'node:path';import{RELEASE_VERSION}from'./release-branding.mjs';
|
||||
export function pagesForChanges(paths){const pages=new Set();for(let p of paths){p=p.replaceAll('\\','/');if(!p.includes('/tests/')){if(/^website\/(?:web\/portal-navigation\.(?:css|js)|scripts\/(?:portal-navigation|main-menu)\.mjs)$/.test(p))for(const href of [...MAIN_MENU.map(([,href])=>href),'https://clans.dunerealms.com/','https://corp.dunerealms.com/','https://www.dunerealms.com/government.html'])pages.add(href);const scopes=[[/postbank|bank-rates/,'bank'],[/politic|election|charter/,'politics'],[/internal-mail|mail-service|post-pages/,'post'],[/organisation-|citizen-directory|account-admin|honours|permissions/,'bureau'],[/forge-pages|dev-request|git-identity/,'forge'],[/exchange-public|commodity/,'market'],[/passport|personal-records|user-pages/,'realm']];for(const [pattern,scope]of scopes)if(pattern.test(p)){pages.add('https://cp.dunerealms.com/');pages.add('https://cp.dunerealms.com/#'+scope);}}if(/website\/node\/staff-roster\.mjs$/.test(p))pages.add('https://www.dunerealms.com/staff.html');if(/website\/node\/memorials\.mjs$|website\/node\/public\/memorial\./.test(p))pages.add('https://www.dunerealms.com/');if(/website\/control-panel\//.test(p)||/website\/node\/(auth|permissions|account-admin|account-archive|honours|profile)\.mjs$/.test(p))pages.add('https://cp.dunerealms.com/');if(/website\/integrations\/azuriom\//.test(p))pages.add('https://www.dunerealms.com/shop.html');if(/website\/integrations\/osticket\//.test(p))pages.add('https://support.dunerealms.com/');if(/website\/web\/([a-z-]+)\.html$/.test(p)){const name=p.match(/([^/]+)\.html$/)[1];pages.add('https://www.dunerealms.com/'+(['index','portal'].includes(name)?'':name+'.html'));}}return[...pages].sort();}
|
||||
export function recordPageUpdates({root=fileURLToPath(new URL('../',import.meta.url)),paths,newPages=[],version=RELEASE_VERSION}={}){if(!/^\d+(?:\.\d+){3}$/.test(version))throw Error('Invalid release');const repo=path.resolve(root,'..');const publication=path.join(root,'publication-changes.json');if(paths===undefined&&existsSync(publication)){const change=JSON.parse(readFileSync(publication,'utf8'));if(!Array.isArray(change.paths)||!Array.isArray(change.added))throw Error('Invalid publication change record.');paths=change.paths;newPages=pagesForChanges(change.added).filter(href=>!href.startsWith('https://cp.dunerealms.com/'));}if(paths===undefined){let changed='';try{const gitRoot=execFileSync('git',['rev-parse','--show-toplevel'],{cwd:repo,encoding:'utf8',stdio:['ignore','pipe','ignore']}).trim();if(path.resolve(gitRoot)===repo)changed=execFileSync('git',['diff','--name-only','HEAD'],{cwd:repo,encoding:'utf8'}).trim();}catch(error){if(error?.status!==128&&error?.status!==129&&error?.code!=='ENOENT')throw error;}paths=changed?changed.split('\n'):[];}const file=path.join(root,'web/menu-new-items.json'),data=JSON.parse(readFileSync(file,'utf8'));const pages=pagesForChanges(paths);if(paths.includes('website/web/release.json')){const releaseFile=path.join(root,'web/release.json');if(existsSync(releaseFile)){const release=JSON.parse(readFileSync(releaseFile,'utf8'));if(release.version===version&&Array.isArray(release.menuUpdates)){const allowed=new Set([...MAIN_MENU.map(([,href])=>href),'https://clans.dunerealms.com/','https://corp.dunerealms.com/','https://www.dunerealms.com/government.html',...['realm','bureau','forge','politics','post','bank','market'].map(id=>'https://cp.dunerealms.com/#'+id)]);for(const update of release.menuUpdates){if(!allowed.has(update.href)||!['NEW','UPDATE'].includes(update.badge))throw Error('Invalid release menu highlight.');if(!pages.includes(update.href))pages.push(update.href);if(update.badge==='NEW'&&!newPages.includes(update.href))newPages.push(update.href);}}}}if(paths.length||existsSync(publication)){for(const item of data.items)delete item.badge;}for(const href of pages){let entry=data.items.find(x=>x.href===href);if(!entry){entry={href};data.items.push(entry);}entry.updatedIn=version;entry.badge=newPages.includes(href)?'NEW':'UPDATE';}if(data.headerBadges){for(const item of data.items){if(!item.href.includes('/#')){delete item.badge;if(['NEW','UPDATE'].includes(data.headerBadges[item.href]))item.badge=data.headerBadges[item.href];}}}writeFileSync(file,JSON.stringify(data,null,2)+'\n');return pages;}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import{MAIN_MENU}from'./main-menu.mjs';
|
||||
import{MAIN_MENU,MAIN_MENU_GROUPS}from'./main-menu.mjs';
|
||||
export const PORTAL_LINKS=MAIN_MENU;
|
||||
export const PORTAL_NAV='<nav aria-label="Main navigation">'+PORTAL_LINKS.map(([name,url,icon])=>`<a href="${url}"><img src="https://www.dunerealms.com/assets/${icon}" alt="" width="34" height="34" decoding="async"><span>${name}</span></a>`).join('')+'</nav>';
|
||||
const menuLink=([name,url,icon])=>`<a href="${url}"><img src="https://www.dunerealms.com/assets/${icon}" alt="" width="42" height="42" decoding="async"><span>${name}</span></a>`;
|
||||
export const PORTAL_NAV='<nav aria-label="Main navigation">'+PORTAL_LINKS.map(([name,url,icon])=>MAIN_MENU_GROUPS[name]?`<details class="dune-menu-group" data-dune-nav-group="${name}"><summary><img src="https://www.dunerealms.com/assets/${icon}" alt="" width="42" height="42"><span>${name}</span></summary><div class="dune-menu-dropdown">${(name==='My Account'?[['Sign in','https://cp.dunerealms.com/','nav-account-v2.webp'],['Register','https://cp.dunerealms.com/#register','nav-account-v2.webp']]:MAIN_MENU_GROUPS[name]).map(menuLink).join('')}</div></details>`:menuLink([name,url,icon])).join('')+'</nav>';
|
||||
export const PORTAL_CSS=`
|
||||
body>header{position:relative;z-index:100;height:auto;min-height:82px;padding:14px 3%;display:flex;align-items:center;justify-content:space-between;gap:24px;background:#10251f;border-bottom:1px solid #806e45;box-shadow:none;box-sizing:border-box}
|
||||
body>header>.wordmark{flex:0 0 auto;font:700 19px/1.2 system-ui,sans-serif;letter-spacing:.025em;color:#f2e6c9;white-space:nowrap}
|
||||
|
|
|
|||
1
website/scripts/rihla-rates-section.mjs
Normal file
1
website/scripts/rihla-rates-section.mjs
Normal file
|
|
@ -0,0 +1 @@
|
|||
export function rihlaRatesSection(){return `<section id="rihla"><span class="eyebrow">RIHLA · CORRINO GROUP</span><h2>Rihla Money Transfer</h2><p>Separate private account for every user. No bank package, activation fee or starting funds. View your account and statement in User CP; send and collect transfers in-game.</p><div class="table-wrap"><table><thead><tr><th>Amount sent</th><th>Transfer tax</th><th>Recipient receives</th></tr></thead><tbody><tr><td>Up to and including 3,000 DM</td><td>1% of the full amount</td><td>The full amount sent</td></tr><tr><td>Above 3,000 DM</td><td>5% of the full amount</td><td>The full amount sent</td></tr></tbody></table></div><p class="fine">Tax is added to the sender’s amount and paid to I.D. Taxes upon collection. Fractional cents round up to the next cent. Created transfers reserve amount plus tax; cancellation releases the reservation. Example: sending 3,000 DM costs 3,030 DM; sending 4,000 DM costs 4,200 DM. In-game execution will be connected separately.</p></section>`;}
|
||||
Loading…
Reference in a new issue

Staff