forked from unimatrix/web
Unify shared chrome and add colour-coded V2 workspace publication badges
This commit is contained in:
parent
458125d04d
commit
ee6e8be908
5 changed files with 68 additions and 8 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import {SHARED_HEADER} from './portal-navigation.mjs';
|
||||
import {PACKAGES,BANK_VERSION} from '../node/postbank-catalogue.mjs';
|
||||
import {CREDIT_PRODUCTS,CREDIT_VERSION} from '../node/postbank-credit-model.mjs';
|
||||
import {createHash} from 'node:crypto';
|
||||
|
|
@ -5,5 +6,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.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 and service conditions in Dunemarks."><link rel="stylesheet" href="/bank-rates.css"><script src="/portal-navigation.js" defer></script></head><body><header><a href="/">DuneRealms</a></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 your banking 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></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 includes a savings account. 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 25% blocked DM collateral. 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><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 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></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 your banking 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></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 includes a savings account. 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 25% blocked DM collateral. 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><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 {SHARED_CHROME_STYLE} from './shared-chrome-style.mjs';
|
||||
import{CANONICAL_MENU_SCRIPT}from'./main-menu.mjs';
|
||||
import{recordPageUpdates,menuBadgeScript}from'./menu-updates.mjs';
|
||||
import {RELEASE_SCRIPT,RELEASE_CSS} from './release-branding.mjs';
|
||||
|
|
@ -5,7 +6,7 @@ import {BUTTON_CSS,BUTTON_SCRIPT} from './dune-buttons.mjs';
|
|||
import {readFileSync,writeFileSync,readdirSync} from 'node:fs';
|
||||
import {updatePortalNavigation,PORTAL_CSS,PORTAL_SCRIPT,CONTEXT_SCRIPT,CONTEXT_CSS} from './portal-navigation.mjs';
|
||||
const web=new URL('../web/',import.meta.url);
|
||||
writeFileSync(new URL('portal-navigation.css',web),PORTAL_CSS+CONTEXT_CSS+BUTTON_CSS+RELEASE_CSS);
|
||||
writeFileSync(new URL('portal-navigation.css',web),PORTAL_CSS+CONTEXT_CSS+BUTTON_CSS+RELEASE_CSS+SHARED_CHROME_STYLE);
|
||||
recordPageUpdates();
|
||||
writeFileSync(new URL('portal-navigation.js',web),PORTAL_SCRIPT+CONTEXT_SCRIPT+BUTTON_SCRIPT+RELEASE_SCRIPT+menuBadgeScript()+CANONICAL_MENU_SCRIPT);
|
||||
writeFileSync(new URL('dune-actions.css',web),BUTTON_CSS);
|
||||
|
|
|
|||
|
|
@ -27,3 +27,7 @@ console.log('Shared header installed in CP and native integration templates');
|
|||
// The Clan center serves local copies to retain the same masthead styles.
|
||||
const clans='/home/dunerealms/htdocs/clans.dunerealms.com';
|
||||
if(existsSync(clans+'/index.html')){writeFileSync(clans+'/dune-navigation.css',PORTAL_CSS+CONTEXT_CSS+BUTTON_CSS+RELEASE_CSS);writeFileSync(clans+'/dune-navigation.js',PORTAL_SCRIPT+CONTEXT_SCRIPT+BUTTON_SCRIPT+RELEASE_SCRIPT);}
|
||||
|
||||
// Persistent shared nginx aliases read these exact files on every site.
|
||||
const chrome='/var/lib/dunerealms-public-rates';
|
||||
if(existsSync(chrome)){for(const file of ['portal-navigation.js','portal-navigation.css','menu-new-items.json'])copyFileSync(release+'/web/'+file,chrome+'/'+file);}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import{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(/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,version=RELEASE_VERSION}={}){if(!/^\d+(?:\.\d+){3}$/.test(version))throw Error('Invalid release');const repo=path.resolve(root,'..');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);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=entry.introducedIn===version?'NEW':'UPDATE';}writeFileSync(file,JSON.stringify(data,null,2)+'\n');return pages;}
|
||||
export function menuBadgeScript(){const data=JSON.parse(readFileSync(new URL('../web/menu-new-items.json',import.meta.url),'utf8'));return `\n/* Central automatic release menu badges */\n(()=>{let items=${JSON.stringify(data.items)};function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\\d+(?:\\.\\d+){3}/)?.[0];if(!release)return;for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a')){const item=items.find(x=>x.href===a.href),label=item?.introducedIn===release?'NEW':item?.updatedIn===release?'UPDATE':null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://www.dunerealms.com/menu-new-items.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})();\n`;}
|
||||
export function menuBadgeScript(){const data=JSON.parse(readFileSync(new URL('../web/menu-new-items.json',import.meta.url),'utf8'));return `\n/* Central automatic release menu badges */\n(()=>{let items=${JSON.stringify(data.items)};function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\\d+(?:\\.\\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?'https://cp.dunerealms.com/#'+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:item?.introducedIn===release?'NEW':item?.updatedIn===release?'UPDATE':null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://www.dunerealms.com/menu-new-items.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})();\n`;}
|
||||
export function withMenuBadges(s){return s.replace(/\n?\/\* Central automatic release menu badges \*\/[\s\S]*?(?=\n\/\*|$)/,'').replace(/\(\(\)=>\{const items=\[[\s\S]*?new MutationObserver\(mark\)\.observe\(document.body,\{childList:true,subtree:true,characterData:true\}\);\}\)\(\);/,'')+menuBadgeScript();}
|
||||
export function patchMenuBadges(root=fileURLToPath(new URL('../',import.meta.url))){const file=path.join(root,'web/portal-navigation.js');writeFileSync(file,withMenuBadges(readFileSync(file,'utf8')));}
|
||||
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){const pages=recordPageUpdates();patchMenuBadges();console.log('Central release badges updated for '+pages.length+' changed pages.');}
|
||||
|
|
|
|||
1
website/scripts/shared-chrome-style.mjs
Normal file
1
website/scripts/shared-chrome-style.mjs
Normal file
|
|
@ -0,0 +1 @@
|
|||
export const SHARED_CHROME_STYLE="\n/* Shared chrome must not inherit native forum/support link decorations. */\nheader.dune-site-header nav[aria-label=\"Main navigation\"] a,header.dune-site-header .wordmark,.dune-shared-footer a{text-decoration:none!important}header.dune-site-header nav[aria-label=\"Main navigation\"] a{font-family:Arial,sans-serif!important;line-height:1.35!important}.dune-shared-footer{font-family:Arial,sans-serif!important}.dune-shared-footer a:hover{text-decoration:underline!important}\n\n#portals .portal{position:relative}#portals .portal>.dune-new-overlay{position:absolute;top:9px;right:10px;padding:3px 8px;border:1px solid #c7a65c;border-radius:12px;background:#bba05c;color:#10251f;font:700 10px/1.2 Arial,sans-serif;letter-spacing:.06em}#portals .portal>.dune-update-overlay{background:#1b4d43;color:#bfe4d3;border-color:#6ba58e}\n\n/* One V2 banking-style surface, seven recognisable workspace accents. */\n#portals .portal{--workspace-accent:#d2b66d;isolation:isolate;overflow:hidden;background:linear-gradient(145deg,color-mix(in srgb,var(--workspace-accent) 15%,#142e24),#10251f)!important;border-color:color-mix(in srgb,var(--workspace-accent) 70%,#475841)!important;box-shadow:inset 0 1px 0 #ffffff0b,0 4px 12px #0002}\n#portals .portal::before{content:'';position:absolute;inset:0;z-index:-1;background:radial-gradient(ellipse at 85% 0%,color-mix(in srgb,var(--workspace-accent) 17%,transparent),transparent 65%);pointer-events:none}\n#portals .portal[data-id=\"realm\"]{--workspace-accent:#8dcbb1}#portals .portal[data-id=\"bureau\"]{--workspace-accent:#cbb680}#portals .portal[data-id=\"forge\"]{--workspace-accent:#a9a1d6}#portals .portal[data-id=\"politics\"]{--workspace-accent:#d0a56b}#portals .portal[data-id=\"post\"]{--workspace-accent:#86bacd}#portals .portal[data-id=\"bank\"]{--workspace-accent:#e1c66c}#portals .portal[data-id=\"market\"]{--workspace-accent:#cb9b7d}\n#portals .portal>span:not(.dune-new-overlay){color:var(--workspace-accent)}#portals .portal.active,#portals .portal[aria-current=\"page\"]{outline:2px solid var(--workspace-accent);outline-offset:-2px}#portals .portal:focus-visible{outline:3px solid #fff1c1;outline-offset:3px}\n";
|
||||
Loading…
Reference in a new issue

Staff