forked from unimatrix/web
Fresh production baseline [skip ci]
This commit is contained in:
commit
0a11a18274
103 changed files with 229644 additions and 0 deletions
14
website/scripts/adopt-automated-news-author.mjs
Normal file
14
website/scripts/adopt-automated-news-author.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import {randomUUID} from 'node:crypto';import {fileURLToPath} from 'node:url';import {resolve} from 'node:path';
|
||||
import {openDatabase} from '../node/mysql.mjs';import {OFFICIAL_ACCOUNT} from '../node/official-account.mjs';
|
||||
export async function adoptAutomatedNewsAuthor(db,{actorId,apply=false}={}){
|
||||
if(![OFFICIAL_ACCOUNT.ownerId,'f7b88778-f0bc-41cc-9227-d8ef2f52264d'].includes(actorId))throw Error('Pinned Owner or Dev actor required.');
|
||||
return db.transaction(async tx=>{
|
||||
const account=await tx.first("SELECT id FROM site_accounts WHERE id=? AND username=? AND role='official_account' AND password_hash NOT LIKE '!%' FOR SHARE",[OFFICIAL_ACCOUNT.id,OFFICIAL_ACCOUNT.username]);if(!account)throw Error('Official publishing identity unavailable.');
|
||||
const actor=await tx.first("SELECT p.principal_kind FROM org_control_principals p JOIN site_accounts a ON a.id=p.user_id WHERE p.user_id=? AND a.password_hash NOT LIKE '!%' FOR SHARE",[actorId]);if(!['owner','service'].includes(actor?.principal_kind))throw Error('Current control actor required.');
|
||||
const rows=await tx.query("SELECT id,source_key FROM website_posts WHERE author_id='release-register' AND LEFT(source_key,8)='release:' FOR UPDATE");
|
||||
if(!apply)return {applied:false,automatedPosts:rows.length};
|
||||
for(const p of rows){await tx.query("UPDATE website_posts SET author_id=?,version=version+1 WHERE id=? AND author_id='release-register'",[OFFICIAL_ACCOUNT.id,p.id]);await tx.query('INSERT INTO account_audit(id,actor_id,action,details,created_at) VALUES(?,?,?,?,?)',[randomUUID(),actorId,'automated-news-author',JSON.stringify({postId:p.id,source:p.source_key,previousAuthor:'release-register',authorId:OFFICIAL_ACCOUNT.id}),Date.now()]);}
|
||||
return {applied:true,updated:rows.length,manualPostsChanged:false,newArticlesCreated:false};
|
||||
});
|
||||
}
|
||||
if(process.argv[1]&&fileURLToPath(import.meta.url)===resolve(process.argv[1])){const db=await openDatabase(process.env);try{console.log(JSON.stringify(await adoptAutomatedNewsAuthor(db,{actorId:process.argv.find(a=>a.startsWith('--actor='))?.slice(8),apply:process.argv.includes('--apply')})));}finally{await db.close();}}
|
||||
20
website/scripts/apply-button-style.mjs
Normal file
20
website/scripts/apply-button-style.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Surgical public-asset update. Never replaces application routes or database settings.
|
||||
import {readFileSync,writeFileSync,existsSync,mkdirSync} from 'node:fs';
|
||||
import {BUTTON_CSS,BUTTON_SCRIPT} from './dune-buttons.mjs';
|
||||
const release=process.argv[2];if(!release)throw Error('Release directory required');
|
||||
const add=(html,local=false)=>{if(html.includes('/dune-actions.css'))return html;const base=local?'':'https://www.dunerealms.com';return html.replace('</head>','<link rel="stylesheet" href="'+base+'/dune-actions.css?v=1"><script src="'+base+'/dune-actions.js?v=1" defer></script></head>');};
|
||||
mkdirSync(release+'/web',{recursive:true});writeFileSync(release+'/web/dune-actions.css',BUTTON_CSS);writeFileSync(release+'/web/dune-actions.js',BUTTON_SCRIPT);
|
||||
const cp=release+'/control-panel/public/cp-v2/index.html';if(existsSync(cp))writeFileSync(cp,add(readFileSync(cp,'utf8')));
|
||||
if(!process.argv.includes('--source-only')){
|
||||
const worker=release+'/dist/server/index.js',text=readFileSync(worker,'utf8'),prefix='const ASSET_DATA=',end=text.indexOf(';\n');if(!text.startsWith(prefix)||end<0)throw Error('Unrecognised public asset bundle');
|
||||
const assets=JSON.parse(text.slice(prefix.length,end));assets['/dune-actions.css']=['text/css; charset=utf-8',Buffer.from(BUTTON_CSS).toString('base64')];assets['/dune-actions.js']=['text/javascript; charset=utf-8',Buffer.from(BUTTON_SCRIPT).toString('base64')];
|
||||
for(const entry of Object.values(assets))if(entry[0].startsWith('text/html'))entry[1]=Buffer.from(add(Buffer.from(entry[1],'base64').toString())).toString('base64');
|
||||
writeFileSync(worker,prefix+JSON.stringify(assets)+text.slice(end));
|
||||
}
|
||||
const integrations=process.argv.find(arg=>arg.startsWith('--integrations='))?.slice(15);
|
||||
if(integrations){
|
||||
for(const app of ['osticket','mybb']){const path=integrations+'/'+app;if(existsSync(path)){writeFileSync(path+'/dune-actions.css',BUTTON_CSS);writeFileSync(path+'/dune-actions.js',BUTTON_SCRIPT);}}
|
||||
const helper=integrations+'/shared-header.php';let php=readFileSync(helper,'utf8');if(!php.includes('/dune-actions.css'))php=php.replace("if(stripos($html,'<html')===false)return $html;","if(stripos($html,'<html')===false)return $html;\n if(!str_contains($html,'/dune-actions.css'))$html=str_ireplace('</head>','<link rel=\"stylesheet\" href=\"/dune-actions.css?v=1\"><script src=\"/dune-actions.js?v=1\" defer></script></head>',$html);");php=php.replace(/dune-ticket-compose\.(css|js)\?v=\d+/g,'dune-ticket-compose.$1?v=4');writeFileSync(helper,php);
|
||||
}
|
||||
const git=process.argv.find(arg=>arg.startsWith('--forgejo='))?.slice(10);if(git){const file=git+'/templates/custom/header.tmpl';let html=readFileSync(file,'utf8');if(!html.includes('/dune-actions.css'))html+='\n<link rel="stylesheet" href="https://www.dunerealms.com/dune-actions.css?v=1"><script src="https://www.dunerealms.com/dune-actions.js?v=1" defer></script>\n';writeFileSync(file,html);}
|
||||
console.log('Public button assets updated; application and database code preserved');
|
||||
10
website/scripts/apply-item-catalogue.mjs
Normal file
10
website/scripts/apply-item-catalogue.mjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import {readFileSync,writeFileSync} from 'node:fs';
|
||||
const release=process.argv[2];if(!release)throw Error('Release directory required');
|
||||
const file=release+'/dist/server/index.js',source=readFileSync(file,'utf8'),prefix='const ASSET_DATA=',end=source.indexOf(';\n');if(!source.startsWith(prefix)||end<0)throw Error('Unexpected asset bundle');
|
||||
const assets=JSON.parse(source.slice(prefix.length,end));
|
||||
for(const[name,mime]of [['item-catalogue.js','text/javascript'],['item-catalogue.css','text/css']])assets['/'+name]=[mime+'; charset=utf-8',readFileSync(new URL('../web/'+name,import.meta.url)).toString('base64')];
|
||||
if(!assets['/armoury.html'])throw Error('Armoury page missing');
|
||||
const add=html=>html.includes('/item-catalogue.js')?html:html.replace('</head>','<link rel="stylesheet" href="/item-catalogue.css?v=1"><script src="/item-catalogue.js?v=1" defer></script></head>');
|
||||
assets['/armoury.html'][1]=Buffer.from(add(Buffer.from(assets['/armoury.html'][1],'base64').toString('utf8'))).toString('base64');
|
||||
writeFileSync(file,prefix+JSON.stringify(assets)+source.slice(end));
|
||||
console.log('Item catalogue added; existing assets and runtime preserved');
|
||||
10
website/scripts/apply-release-branding.mjs
Normal file
10
website/scripts/apply-release-branding.mjs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import {readFileSync,writeFileSync,existsSync} from 'node:fs';
|
||||
import {RELEASE_SCRIPT,RELEASE_CSS,RELEASE_VERSION} from './release-branding.mjs';
|
||||
const root=process.argv[2];if(!root)throw Error('Release directory required');
|
||||
const file=root+'/dist/server/index.js',before=readFileSync(file,'utf8'),prefix='const ASSET_DATA=',end=before.indexOf(';\n');if(!before.startsWith(prefix)||end<0)throw Error('Unknown asset bundle');const assets=JSON.parse(before.slice(prefix.length,end));
|
||||
for(const[key,extra]of [['/portal-navigation.js',RELEASE_SCRIPT],['/portal-navigation.css',RELEASE_CSS]]){if(!assets[key])throw Error('Shared header asset missing');const text=Buffer.from(assets[key][1],'base64').toString();assets[key][1]=Buffer.from(text.includes('.dune-release-badge')?text:text+extra).toString('base64');}
|
||||
const bump=s=>s.replace(/portal-navigation\.(js|css)\?v=hosting-9(?:-release-1002)?/g,'portal-navigation.$1?v=hosting-9-release-1002');
|
||||
for(const asset of Object.values(assets))if(asset[0].startsWith('text/html'))asset[1]=Buffer.from(bump(Buffer.from(asset[1],'base64').toString())).toString('base64');
|
||||
assets['/release.json']=['application/json; charset=utf-8',Buffer.from(JSON.stringify({version:RELEASE_VERSION,stage:'alpha',updatedAt:new Date().toISOString()})).toString('base64')];writeFileSync(file,prefix+JSON.stringify(assets)+before.slice(end));
|
||||
for(const path of [root+'/control-panel/public/cp-v2/index.html','/home/dunerealms/htdocs/clans.dunerealms.com/index.html','/home/dunerealms/apps/integrations/shared-header.php'])if(existsSync(path))writeFileSync(path,bump(readFileSync(path,'utf8')));
|
||||
console.log('Alpha '+RELEASE_VERSION+' shared badge published; logo and runtime preserved');
|
||||
20
website/scripts/assign-streamer-ranks.mjs
Normal file
20
website/scripts/assign-streamer-ranks.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import {readFileSync} from 'node:fs';
|
||||
import {randomUUID} from 'node:crypto';
|
||||
import {openDatabase} from '../node/mysql.mjs';
|
||||
import {initializeRanks,accessFor} from '../node/permissions.mjs';
|
||||
import {syncNativeAgents} from '../node/native-agents.mjs';
|
||||
const c=JSON.parse(readFileSync('/home/dunerealms/.config/integrations.json'));
|
||||
const db=await openDatabase({DB_HOST:c.host,DB_USER:c.username,DB_PASSWORD:c.password,DB_NAME:c.database});
|
||||
try{
|
||||
await initializeRanks(db);
|
||||
const owner=await db.prepare("SELECT id,role FROM site_accounts WHERE username='unimatrix999'").first();if(owner?.role!=='owners')throw Error('Retained Owner missing');
|
||||
for(const name of ['itsmrsui','unimatrix999']){
|
||||
const account=await db.prepare('SELECT id,username,role FROM site_accounts WHERE username=?').bind(name).first();if(!account)throw Error('Requested account missing');
|
||||
await db.batch([
|
||||
db.prepare("INSERT INTO cp_account_ranks(user_id,rank_key) VALUES(?,'web_streamer') ON CONFLICT(user_id,rank_key) DO UPDATE SET user_id=excluded.user_id").bind(account.id),
|
||||
db.prepare('INSERT INTO account_audit(id,actor_id,action,details,created_at) VALUES(?,?,?,?,?)').bind(randomUUID(),owner.id,'streamer-rank-assigned',name+' + web_streamer',Date.now())
|
||||
]);
|
||||
console.log(name+': '+(await accessFor(db,account)).label);
|
||||
}
|
||||
await syncNativeAgents(db);
|
||||
}finally{await db.close();}
|
||||
17
website/scripts/audit-cp-v2-design.mjs
Normal file
17
website/scripts/audit-cp-v2-design.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import {readFile,mkdir,writeFile} from 'node:fs/promises';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import path from 'node:path';
|
||||
import {DESIGN_PAGES} from '../control-panel/public/cp-v2/cp-v2-design-catalog.mjs';
|
||||
const menuSource=await readFile(new URL('../control-panel/public/cp-v2/v2.js',import.meta.url),'utf8');
|
||||
const menu=JSON.parse(menuSource.slice('const menu='.length,menuSource.indexOf(';')));
|
||||
const oldSource=await readFile(new URL('../control-panel/public/pages.mjs',import.meta.url),'utf8'),start=oldSource.indexOf('const pages=')+'const pages='.length;
|
||||
const oldIds=new Set(Object.keys(JSON.parse(oldSource.slice(start,oldSource.indexOf(';',start)))));
|
||||
const oldLayout=await readFile(new URL('../control-panel/public/panel-layout.mjs',import.meta.url),'utf8');for(const match of oldLayout.matchAll(/item\([^,]+,'([^']+)'/g))oldIds.add(match[1]);
|
||||
for(const id of ['dev-panel','dev-queue','dev-approvals','dev-new','dev-archive'])oldIds.add(id);
|
||||
export const designAliases={'realm/company-directory':'realm/companies','realm/company-registration':'realm/companies','realm/company-profile':'realm/companies','realm/company-members':'realm/companies','realm/company-finance':'realm/companies','realm/company-permissions':'realm/companies','realm/company-applications':'realm/companies','market/company-directory':'market/companies','market/company-profile':'market/companies'};
|
||||
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','tax-treasury','account-authorisations']);
|
||||
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'&&['server-projects','rihla','item-exchange','item-listings','item-post','dmpaint'].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;}
|
||||
13
website/scripts/bank-rates-page.mjs
Normal file
13
website/scripts/bank-rates-page.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import {ratesReferenceHTML,RATES_GUIDE_EDITION} from './rates-reference.mjs';
|
||||
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';
|
||||
import {CREDIT_PRODUCTS,CREDIT_VERSION} from '../node/postbank-credit-model.mjs';
|
||||
import {createHash} from 'node:crypto';
|
||||
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>Banking, taxation, reserve policy and the rules behind the realm economy.</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><a href="#tax-rules">Tax rules</a><a href="#publication-charges">Publication charges</a><a href="#reserve-instruments">Reserve & keys</a><a href="#economy-formulas">Formulas</a><a href="#payroll-tax">Payroll tax</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>Public register</strong><p>Configured VAT, account tax and payroll deductions are loaded from the public bank publication. The tax-rule tables below explain their application.</p></article></div></section>${rihlaRatesSection()}${claimRatesSection()}${ratesReferenceHTML()}<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. The live financial register supplies configured bank and tax values. The expanded handbook also records reserve instruments, calculation rules and availability.</p></div><div class="document-actions"><a class="pdf-download guide-download" href="/downloads/dunerealms-rates-guide-20261121.pdf">Download complete guide · PDF</a><span class="fine">Handbook ${RATES_GUIDE_EDITION}</span></div></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>`;
|
||||
}
|
||||
7
website/scripts/beta-launch-announcement.staged.json
Normal file
7
website/scripts/beta-launch-announcement.staged.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "beta-1-0-0-0",
|
||||
"publishedAt": null,
|
||||
"title": "Happy Beta! · DuneRealms Beta 1.0.0.0",
|
||||
"body": "The caravan endures. Welcome to DuneRealms Beta 1.0.0.0!\n\nThank you to our Alpha testers and the community that brought our worlds to life. The Beta era is now open. The realm’s worlds and economy remain intact as a new political chapter begins.\n\nYour House. Your destiny. Write your chapter.",
|
||||
"artwork": "assets/happy-beta-launch.png"
|
||||
}
|
||||
23
website/scripts/bootstrap-official-owner-alias.mjs
Normal file
23
website/scripts/bootstrap-official-owner-alias.mjs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import {randomUUID} from 'node:crypto';import {fileURLToPath} from 'node:url';import {resolve} from 'node:path';
|
||||
import {openDatabase} from '../node/mysql.mjs';import {initializeOrganisation} from '../node/organisation-model.mjs';import {OFFICIAL_ACCOUNT,organisationSubject} from '../node/official-account.mjs';
|
||||
import {nativeSyncMutation} from '../node/native-sync-outbox.mjs';
|
||||
const SERVICE_ID='f7b88778-f0bc-41cc-9227-d8ef2f52264d';
|
||||
export async function bootstrapOfficialAlias(db,{actorId,apply=false}={}){
|
||||
if(![OFFICIAL_ACCOUNT.ownerId,SERVICE_ID].includes(actorId))throw Error('Owner or pinned Dev actor required.');
|
||||
return db.transaction(async tx=>{
|
||||
const actor=await tx.first("SELECT p.principal_kind FROM org_control_principals p JOIN site_accounts a ON a.id=p.user_id WHERE p.user_id=? AND a.password_hash NOT LIKE '!%' FOR SHARE",[actorId]);
|
||||
if(actor?.principal_kind!==(actorId===SERVICE_ID?'service':'owner'))throw Error('Current control actor required.');
|
||||
const account=await tx.first("SELECT a.id FROM site_accounts a JOIN site_game_links l ON l.user_id=a.id WHERE a.id=? AND a.username=? AND a.role='official_account' AND a.password_hash NOT LIKE '!%' AND l.minecraft_uuid=? FOR SHARE",[OFFICIAL_ACCOUNT.id,OFFICIAL_ACCOUNT.username,OFFICIAL_ACCOUNT.minecraftUuid]);
|
||||
const owner=await tx.first("SELECT p.user_id FROM org_control_principals p JOIN site_accounts a ON a.id=p.user_id WHERE p.user_id=? AND p.principal_kind='owner' AND a.username='unimatrix999' AND a.password_hash NOT LIKE '!%' FOR SHARE",[OFFICIAL_ACCOUNT.ownerId]);
|
||||
if(!account||!owner)throw Error('Pinned official and owner identities must match.');
|
||||
const existing=await tx.first('SELECT principal_kind,created_by FROM org_control_principals WHERE user_id=? FOR UPDATE',[OFFICIAL_ACCOUNT.id]);
|
||||
if(existing&&(existing.principal_kind!=='owner_alias'||existing.created_by!==OFFICIAL_ACCOUNT.ownerId))throw Error('Existing control identity differs; refusing overwrite.');
|
||||
if(!apply)return {applied:false,aliasUserId:OFFICIAL_ACCOUNT.id,permissionPrincipalId:OFFICIAL_ACCOUNT.ownerId,alreadyLinked:!!existing};
|
||||
if(!existing){const now=Date.now();await tx.query('INSERT INTO org_control_principals(user_id,principal_kind,created_by,created_at) VALUES(?,?,?,?)',[OFFICIAL_ACCOUNT.id,'owner_alias',OFFICIAL_ACCOUNT.ownerId,now]);
|
||||
await tx.query('INSERT INTO org_assignment_events(id,user_id,actor_id,action,scope_type,scope_key,reason,after_json,created_at) VALUES(?,?,?,?,?,?,?,?,?)',[randomUUID(),OFFICIAL_ACCOUNT.id,actorId,'owner-alias-baseline','organisation','dunerealms','Owner explicitly authorised dunerealms Bedrock alternate account to follow the same function rights',JSON.stringify({permissionPrincipalId:OFFICIAL_ACCOUNT.ownerId,extraStaffAppointment:false}),now]);
|
||||
const sync=nativeSyncMutation(now);await tx.query(sync.sql,sync.values);}
|
||||
const subject=await organisationSubject(tx,OFFICIAL_ACCOUNT.id,{lock:true});if(!subject.alias)throw Error('Official identity verification failed.');
|
||||
return {applied:true,created:!existing,aliasUserId:OFFICIAL_ACCOUNT.id,permissionPrincipalId:subject.userId};
|
||||
});
|
||||
}
|
||||
if(process.argv[1]&&fileURLToPath(import.meta.url)===resolve(process.argv[1])){const db=await openDatabase(process.env);try{await initializeOrganisation(db);console.log(JSON.stringify(await bootstrapOfficialAlias(db,{actorId:process.argv.find(a=>a.startsWith('--actor='))?.slice(8),apply:process.argv.includes('--apply')})));}finally{await db.close();}}
|
||||
36
website/scripts/bootstrap-organisation-appointments.mjs
Normal file
36
website/scripts/bootstrap-organisation-appointments.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import {randomUUID} from 'node:crypto';
|
||||
import {fileURLToPath} from 'node:url';import {resolve} from 'node:path';
|
||||
import {openDatabase} from '../node/mysql.mjs';
|
||||
import {initializeOrganisation,validStaffRole} from '../node/organisation-model.mjs';
|
||||
import {MIGRATION_APPOINTMENTS} from '../node/organisation-appointments.mjs';
|
||||
const OWNER_ID='f3ffda37-01e4-41ea-b89d-fbeda82e453e';
|
||||
export async function bootstrapAppointments(db,{actorId,apply=false,clock=Date.now}={}){
|
||||
const names=[...new Set(MIGRATION_APPOINTMENTS.map(p=>p.username))];
|
||||
const {results:accounts}=await db.prepare(`SELECT a.id,a.username,p.game_link_exempt FROM site_accounts a LEFT JOIN site_account_policies p ON p.user_id=a.id WHERE a.username IN (${names.map(()=>'?')}) AND a.password_hash NOT LIKE '!%'`).bind(...names).all();
|
||||
if(accounts.length!==names.length||accounts.some(a=>a.game_link_exempt)||accounts.find(a=>a.username==='unimatrix999')?.id!==OWNER_ID)throw Error('Approved migration identities do not match the existing active accounts.');
|
||||
const plan=MIGRATION_APPOINTMENTS.map(p=>({...p,userId:accounts.find(a=>a.username===p.username).id})).sort((a,b)=>(a.scopeType+':'+a.scopeKey+':'+a.role+':'+a.userId).localeCompare(b.scopeType+':'+b.scopeKey+':'+b.role+':'+b.userId));
|
||||
if(plan.some(p=>!validStaffRole(p.scopeType,p.scopeKey,p.role)))throw Error('Invalid approved migration function.');
|
||||
if(!apply)return {applied:false,accounts:accounts.length,assignments:plan,permissionsChanged:false};
|
||||
return db.transaction(async tx=>{
|
||||
const actor=await tx.first("SELECT p.principal_kind FROM org_control_principals p JOIN site_accounts a ON a.id=p.user_id WHERE a.id=? AND a.password_hash NOT LIKE '!%' FOR SHARE",[actorId]);
|
||||
if(!actor||!['owner','executive','service'].includes(actor.principal_kind))throw Error('Existing control actor required.');
|
||||
let created=0,retained=0;
|
||||
for(const p of plan){
|
||||
await tx.query('INSERT IGNORE INTO org_scope_versions(scope_type,scope_key,version) VALUES(?,?,1)',[p.scopeType,p.scopeKey]);
|
||||
await tx.first('SELECT version FROM org_scope_versions WHERE scope_type=? AND scope_key=? FOR UPDATE',[p.scopeType,p.scopeKey]);
|
||||
const identity=await tx.first("SELECT a.id,p.game_link_exempt FROM site_accounts a LEFT JOIN site_account_policies p ON p.user_id=a.id WHERE a.id=? AND a.username=? AND a.password_hash NOT LIKE '!%' FOR SHARE",[p.userId,p.username]);
|
||||
if(!identity||identity.game_link_exempt)throw Error('Migration identity changed.');
|
||||
const now=clock(),current=await tx.query("SELECT user_id,role_key FROM org_assignments WHERE scope_type=? AND scope_key=? AND status='active' AND starts_at<=? AND (ends_at IS NULL OR ends_at>?) FOR UPDATE",[p.scopeType,p.scopeKey,now,now]);
|
||||
if(current.some(a=>a.user_id===p.userId&&a.role_key===p.role)){retained++;continue;}
|
||||
if(['branch_lead','department_head','owner_ceo'].includes(p.role)&¤t.some(a=>a.role_key===p.role))throw Error('A migration leadership position already has another holder.');
|
||||
const id=randomUUID();
|
||||
await tx.query('INSERT INTO org_assignments(id,user_id,scope_type,scope_key,role_key,source_kind,source_ref,status,starts_at,created_by,created_at,version) VALUES(?,?,?,?,?,?,?,?,?,?,?,1)',[id,p.userId,p.scopeType,p.scopeKey,p.role,'manual','great-migration-owner-approved','active',now,actorId,now]);
|
||||
await tx.query('UPDATE org_scope_versions SET version=version+1 WHERE scope_type=? AND scope_key=?',[p.scopeType,p.scopeKey]);
|
||||
await tx.query('INSERT INTO org_assignment_events(id,user_id,assignment_id,actor_id,action,scope_type,scope_key,reason,after_json,created_at) VALUES(?,?,?,?,?,?,?,?,?,?)',[randomUUID(),p.userId,id,actorId,'appointment-baseline',p.scopeType,p.scopeKey,'Owner-approved Great Migration appointment',JSON.stringify({...p,permissionsChanged:false}),now]);created++;
|
||||
}
|
||||
return {applied:true,created,retained,permissionsChanged:false};
|
||||
});
|
||||
}
|
||||
if(process.argv[1]&&fileURLToPath(import.meta.url)===resolve(process.argv[1])){
|
||||
const db=await openDatabase(process.env);try{await initializeOrganisation(db);console.log(JSON.stringify(await bootstrapAppointments(db,{actorId:process.argv.find(a=>a.startsWith('--actor='))?.slice(8),apply:process.argv.includes('--apply')})));}finally{await db.close();}
|
||||
}
|
||||
28
website/scripts/bootstrap-organisation-control.mjs
Normal file
28
website/scripts/bootstrap-organisation-control.mjs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// One-time, explicit Owner-authorised control baseline. Does not activate role grants.
|
||||
import {randomUUID} from 'node:crypto';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {resolve} from 'node:path';
|
||||
import {openDatabase} from '../node/mysql.mjs';
|
||||
import {initializeOrganisation} from '../node/organisation-model.mjs';
|
||||
const OWNER_ID='f3ffda37-01e4-41ea-b89d-fbeda82e453e';
|
||||
const SERVICE_ID='f7b88778-f0bc-41cc-9227-d8ef2f52264d';
|
||||
const desired={unimatrix999:'owner',grmacken:'executive',richwjr:'executive',mr_blueray:'executive',dev:'service'};
|
||||
export async function bootstrapControl(db,{apply=false}={}){
|
||||
const rows=(await db.prepare(`SELECT id,username,role FROM site_accounts WHERE username IN (${Object.keys(desired).map(()=>'?')}) AND password_hash NOT LIKE '!%'`).bind(...Object.keys(desired)).all()).results;
|
||||
if(rows.length!==5||new Set(rows.map(r=>r.username)).size!==5||rows.find(r=>r.username==='unimatrix999')?.id!==OWNER_ID||rows.find(r=>r.username==='dev')?.id!==SERVICE_ID)throw Error('Expected existing control identities do not match.');
|
||||
const policy=await db.prepare('SELECT service_uuid,game_link_exempt FROM site_account_policies WHERE user_id=?').bind(SERVICE_ID).first();
|
||||
if(!policy?.game_link_exempt||policy.service_uuid!=='00000000-0000-4000-8000-00000000de01')throw Error('Dev service exemption mismatch.');
|
||||
const plan=rows.map(r=>({id:r.id,username:r.username,kind:desired[r.username]}));if(!apply)return {applied:false,principals:plan};
|
||||
await db.transaction(async tx=>{
|
||||
for(const p of plan){
|
||||
const existing=await tx.first('SELECT principal_kind FROM org_control_principals WHERE user_id=? FOR UPDATE',[p.id]);
|
||||
if(existing){if(existing.principal_kind!==p.kind)throw Error('Existing control assignment differs; never overwrite automatically.');continue;}
|
||||
const account=await tx.first("SELECT id,username FROM site_accounts WHERE id=? AND password_hash NOT LIKE '!%' FOR SHARE",[p.id]);if(account?.username!==p.username)throw Error('Identity changed during bootstrap.');
|
||||
const now=Date.now();await tx.query('INSERT INTO org_control_principals(user_id,principal_kind,created_by,created_at) VALUES(?,?,?,?)',[p.id,p.kind,OWNER_ID,now]);
|
||||
await tx.query('INSERT INTO org_assignment_events(id,user_id,actor_id,action,scope_type,scope_key,reason,after_json,created_at) VALUES(?,?,?,?,?,?,?,?,?)',[randomUUID(),p.id,OWNER_ID,'control-baseline','organisation','dunerealms','Owner-approved existing Big Four and Dev service control baseline',JSON.stringify({principal:p.kind,livePermissionsChanged:false}),now]);
|
||||
}
|
||||
});return {applied:true,principals:plan,livePermissionsChanged:false};
|
||||
}
|
||||
if(process.argv[1]&&fileURLToPath(import.meta.url)===resolve(process.argv[1])){
|
||||
const db=await openDatabase(process.env);try{await initializeOrganisation(db);console.log(JSON.stringify(await bootstrapControl(db,{apply:process.argv.includes('--apply')})));}finally{await db.close();}
|
||||
}
|
||||
32
website/scripts/bootstrap-organisation-policies.mjs
Normal file
32
website/scripts/bootstrap-organisation-policies.mjs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import {randomUUID} from 'node:crypto';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {resolve} from 'node:path';
|
||||
import {openDatabase} from '../node/mysql.mjs';
|
||||
import {initializeOrganisation} from '../node/organisation-model.mjs';
|
||||
import {defaultOrganisationPolicies} from '../node/organisation-default-policies.mjs';
|
||||
export async function bootstrapPolicies(db,{actorId,apply=false,clock=Date.now}={}){
|
||||
if(!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(actorId||''))throw Error('An existing control actor UUID is required.');
|
||||
const templates=defaultOrganisationPolicies();
|
||||
if(!apply)return {applied:false,templates,permissionsChanged:false};
|
||||
return db.transaction(async tx=>{
|
||||
const actor=await tx.first("SELECT a.id,p.principal_kind FROM site_accounts a JOIN org_control_principals p ON p.user_id=a.id WHERE a.id=? AND a.password_hash NOT LIKE '!%' FOR SHARE",[actorId]);
|
||||
if(!actor||!['owner','executive','service'].includes(actor.principal_kind))throw Error('Current control principal required.');
|
||||
let created=0,retained=0;
|
||||
for(const p of templates){
|
||||
await tx.query('INSERT IGNORE INTO org_scope_versions(scope_type,scope_key,version) VALUES(?,?,1)',[p.scopeType,p.scopeKey]);
|
||||
await tx.first('SELECT version FROM org_scope_versions WHERE scope_type=? AND scope_key=? FOR UPDATE',[p.scopeType,p.scopeKey]);
|
||||
const existing=await tx.first('SELECT version FROM org_role_policies WHERE scope_type=? AND scope_key=? AND role_key=? FOR UPDATE',[p.scopeType,p.scopeKey,p.role]);
|
||||
if(existing){retained++;continue;}
|
||||
const now=clock();
|
||||
await tx.query('INSERT INTO org_role_policies(scope_type,scope_key,role_key,permissions_json,version,updated_by,updated_at) VALUES(?,?,?,?,1,?,?)',[p.scopeType,p.scopeKey,p.role,JSON.stringify(p.nodes),actorId,now]);
|
||||
await tx.query('UPDATE org_scope_versions SET version=version+1 WHERE scope_type=? AND scope_key=?',[p.scopeType,p.scopeKey]);
|
||||
await tx.query('INSERT INTO org_assignment_events(id,user_id,actor_id,action,scope_type,scope_key,reason,after_json,created_at) VALUES(?,?,?,?,?,?,?,?,?)',[randomUUID(),null,actorId,'policy-baseline',p.scopeType,p.scopeKey,'Owner-approved Great Migration explicit function mapping',JSON.stringify({role:p.role,nodes:p.nodes,permissionsChanged:false}),now]);
|
||||
created++;
|
||||
}
|
||||
return {applied:true,created,retained,permissionsChanged:false,enforcement:'preparing'};
|
||||
});
|
||||
}
|
||||
if(process.argv[1]&&fileURLToPath(import.meta.url)===resolve(process.argv[1])){
|
||||
const db=await openDatabase(process.env);
|
||||
try{await initializeOrganisation(db);console.log(JSON.stringify(await bootstrapPolicies(db,{actorId:process.argv.find(a=>a.startsWith('--actor='))?.slice(8),apply:process.argv.includes('--apply')})));}finally{await db.close();}
|
||||
}
|
||||
7
website/scripts/build-account.mjs
Normal file
7
website/scripts/build-account.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import {readFileSync,writeFileSync,readdirSync} from 'node:fs';
|
||||
const web=new URL('../web/',import.meta.url),home=readFileSync(new URL('index.html',web),'utf8');
|
||||
const header=home.match(/<header>[\s\S]*?<\/header>/)[0].replace(/ aria-current="page"/g,'');
|
||||
const footer=home.match(/<footer>[\s\S]*?<\/footer>/)[0];
|
||||
writeFileSync(new URL('account.html',web),'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Your account — dunerealms.com</title><link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="pages.css"><link rel="stylesheet" href="minecraft.css"><link rel="stylesheet" href="lore.css"><script src="pages.js" defer></script><script src="account-embed.js" defer></script></head><body>'+header+'<main id="main" class="account-embedded"><p class="eyebrow">DUNEREALMS.COM / YOUR ACCOUNT</p><h1>Your place in the caravan</h1><p>Sign in, register, link your Minecraft UUID and manage your community rewards. <a href="https://cp.dunerealms.com/" target="_blank" rel="noopener">Open the standalone account panel ↗</a></p><iframe id="account-panel" src="https://cp.dunerealms.com/?embedded=1" title="dunerealms.com account control panel" height="1400" referrerpolicy="no-referrer" allow="clipboard-write https://cp.dunerealms.com"></iframe><noscript><p><a href="https://cp.dunerealms.com/">Open the account panel</a>. JavaScript is required to use account features.</p></noscript></main>'+footer+'</body></html>');
|
||||
for(const file of readdirSync(web).filter(file=>file.endsWith('.html'))){const url=new URL(file,web);let html=readFileSync(url,'utf8');html=html.replace(/<a href="account.html" class="account-nav">Account<\/a>/g,'');html=html.replace(/(<nav[^>]*aria-label="Main navigation"[^>]*>)/,'$1<a href="account.html" class="account-nav">Account</a>');writeFileSync(url,html);}
|
||||
const portal=new URL('portal.html',web);let html=readFileSync(portal,'utf8');html=html.replace(/<p class="account-panel-entry">[\s\S]*?<\/p>/g,'').replace('<main>','<main><p class="account-panel-entry"><a href="account.html">Account control panel: UUID linking, rewards & security →</a></p>');writeFileSync(portal,html);
|
||||
7
website/scripts/build-appointments.mjs
Normal file
7
website/scripts/build-appointments.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import {mkdirSync,readFileSync,writeFileSync} from 'node:fs';
|
||||
const web=new URL('../web/',import.meta.url),dir=new URL('assets/appointments/',web);mkdirSync(dir,{recursive:true});
|
||||
const icons={spice:'<path d="M128 78L96 124 128 167 160 124Z"/><path d="M128 78V167M96 124H160M108 59L113 72M148 59L143 72M76 81L87 90M180 81L169 90"/><circle cx="128" cy="57" r="12"/>',water:'<path d="M128 58C118 83 95 107 95 125A33 33 0 0 0 161 125C161 107 138 83 128 58Z"/><path d="M87 157H169L156 184H100ZM108 117Q100 137 120 145"/>',crown:'<path d="M76 102L90 158H166L180 102 153 122 128 84 103 122Z"/><path d="M91 174H165M112 139H144"/><circle cx="76" cy="98" r="5"/><circle cx="128" cy="80" r="5"/><circle cx="180" cy="98" r="5"/>'};
|
||||
for(const [id,shape]of Object.entries(icons)){const svg=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><title>Landsraad ${id} office emblem</title><g fill="none" stroke="#d9b66e" stroke-width="5" stroke-linejoin="round"><path d="M128 13L211 49V131Q211 192 128 235Q45 192 45 131V49Z" fill="#17362e"/><path d="M128 26L198 58V130Q198 181 128 219Q58 181 58 130V58Z" stroke-width="2"/>${shape}<path d="M28 86L37 102 28 117 40 133 34 152M228 86L219 102 228 117 216 133 222 152" stroke-width="3"/></g></svg>`;writeFileSync(new URL(id+'.svg',dir),svg);}
|
||||
const section='<section class="landsraad-appointments"><figure><img src="assets/landsraad-appointments.webp" width="1600" height="533" alt="Original imperial artwork: a gold crown above sealed spice and water appointment parchments, framed by a desert palace" loading="lazy"></figure><p class="eyebrow">BY APPOINTMENT OF THE EMPEROR</p><h2>Landsraad appointments</h2><p>The Emperor appoints a spice-trading house to the <strong>Specerhuis</strong> office and a water-selling house to the <strong>Welvaart House</strong> office. These are the Landsraad appointments. The ceremonial artwork represents the offices; it does not confirm that either office is currently occupied.</p><div class="appointment-emblems"><figure><img src="assets/appointments/spice.svg" alt="Gold spice office seal" width="128" height="128"><figcaption>Specerhuis · spice rights</figcaption></figure><figure><img src="assets/appointments/water.svg" alt="Gold water office seal" width="128" height="128"><figcaption>Welvaart House · water rights</figcaption></figure></div></section>';
|
||||
const page=new URL('diplomacy.html',web);let html=readFileSync(page,'utf8').replace(/<section class="landsraad-appointments">[\s\S]*?<\/section>/g,'');html=html.replace('</main>',section+'</main>').replaceAll('Spice Steward and House of Water','Specerhuis and Welvaart House Landsraad appointments');writeFileSync(page,html);
|
||||
const file=new URL('manual-data.json',web),manual=JSON.parse(readFileSync(file,'utf8'));const chapter=manual.find(c=>/politic/i.test(c.title));if(chapter)chapter.body=chapter.body.replace(/<section class="landsraad-appointments">[\s\S]*?<\/section>/g,'')+section;writeFileSync(file,JSON.stringify(manual)+'\n');
|
||||
5
website/scripts/build-clan-center.mjs
Normal file
5
website/scripts/build-clan-center.mjs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import {mkdir,writeFile} from 'node:fs/promises';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {SHARED_HEADER,SHARED_HEAD} from './portal-navigation.mjs';
|
||||
export function clanCenterHtml(){return '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>Clan Center · DuneRealms</title>'+SHARED_HEAD+'<link rel="stylesheet" href="/clan-shell.css"><script src="/clan-shell.js" defer></script></head><body>'+SHARED_HEADER+'<main class="clan-shell"><section class="clan-shell-intro"><p>THE CARAVANS TRAVEL TOGETHER</p><h1>Clan Center</h1><p>Raise a banner, find companions and keep your clan’s roster in order. Sign in with your existing DuneRealms account below.</p><a href="https://cp.dunerealms.com/#clans" target="_blank" rel="noopener">Open Clan Center separately ↗</a></section><iframe id="clan-workspace" src="https://cp.dunerealms.com/?embedded=1#clans" title="DuneRealms Clan Center account tools" height="1100" referrerpolicy="origin"></iframe><noscript><p><a href="https://cp.dunerealms.com/#clans">Open your Clan Center account tools</a>. JavaScript is required to manage clan membership.</p></noscript></main><footer><a href="https://www.dunerealms.com/">dunerealms.com</a> · <a href="https://support.dunerealms.com/">Support</a><p>Independent fan project · Not affiliated with Dune rights holders, Mojang or Microsoft.</p></footer></body></html>';}
|
||||
if(process.argv[1]&&fileURLToPath(import.meta.url)===process.argv[1]){const root=new URL('../integrations/clans/',import.meta.url);await mkdir(root,{recursive:true});await writeFile(new URL('index.html',root),clanCenterHtml(),'utf8');}
|
||||
4
website/scripts/build-contact.mjs
Normal file
4
website/scripts/build-contact.mjs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import {copyFileSync,readFileSync,writeFileSync} from 'node:fs';
|
||||
const root=new URL('../',import.meta.url);
|
||||
for(const [source,target] of [['dist/external/altcha.min.js','web/assets/altcha.js'],['dist/workers/pbkdf2.js','web/assets/altcha-pbkdf2.js'],['dist/external/altcha.css','web/assets/altcha.css']])copyFileSync(new URL('node_modules/altcha/'+source,root),new URL(target,root));
|
||||
writeFileSync(new URL('ALTCHA-LICENSE.txt',root),readFileSync(new URL('node_modules/altcha/LICENSE.txt',root)));
|
||||
7
website/scripts/build-donations.mjs
Normal file
7
website/scripts/build-donations.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import {readFileSync,writeFileSync} from 'node:fs';
|
||||
const web=new URL('../web/',import.meta.url);
|
||||
const home=readFileSync(new URL('index.html',web),'utf8');
|
||||
const header=home.match(/<header>[\s\S]*?<\/header>/)[0].replace(/ aria-current="page"/g,'');
|
||||
const footer=home.match(/<footer>[\s\S]*?<\/footer>/)[0];
|
||||
const body=`<main id="main" class="adaptation-wiki"><p class="eyebrow">DUNEREALMS.COM / COMMUNITY SUPPORT</p><h1>Keep the caravans moving</h1><p>Voluntary contributions help with hosting, backups and maintenance. When a community goal is reached, its fixed in-game currency reward will be available to every player, whether they contributed or not.</p><section aria-labelledby="donate"><h2 id="donate">Donations are not open yet</h2><p>We are setting up the payment provider, funding targets and public accounting. No payments are being collected through this page. We will publish the target, period, use of funds and reward before opening a campaign.</p><p>Contributing does not buy extra currency, power, access, priority or an exclusive reward. A successful monthly goal releases the same fixed currency reward to every player. This is support for an independently operated game server, not a claim of charitable status or tax deductibility.</p></section><section><h2>Monthly community goals</h2><div id="monthly-goals" aria-live="polite">Loading monthly goals…</div><p>Each calendar month in Europe/Brussels has its own target. Only verified contributions count. If that target is not reached during the month, its reward does not unlock. A reached goal stays unlocked; its codes have no expiry.</p></section><section><h2>Public reward codes</h2><p>After a goal is reached and verified, its public code appears above. No payment, receipt, donor account or mailing-list subscription will be required.</p><ol><li>Copy a public code above or an earned personal code from your account.</li><li>Join the gameplay server and enter <code>/communitycode CODE</code>.</li><li>The same fixed amount of in-game Dunemarks is credited once per Minecraft UUID for that monthly goal. A repeat claim cannot credit it again.</li></ol><p>Codes are intended to have no expiry and no shared redemption limit, including for players who join later. Every player receives the same reward; it cannot be cashed out or redeemed for real-world value. Accounts and unlocks are local to this gameplay server.</p></section><section><h2>Your website account</h2><p><a href="account.html">Sign in or register in the account control panel</a> and verify your Minecraft UUID in game. Only goals reached after your UUID first links generate personal codes; there is no backfill. Used codes move to claim history after the game confirms the credit. Unlinking, changing names or changing website accounts does not reset claims. Public codes remain available equally to players without a linked website account.</p></section><section><h2>Timing and transparency</h2><p>A campaign may have a clearly stated fundraising deadline. That is separate from code redemption: published reward codes will remain claimable while the reward service operates. If a campaign ends below its target, funds still support the published running costs; no reward is promised until its goal is reached. We will publish campaign totals and explain any changed plans.</p><p>Payment details, receipts and payment history must be available through the selected provider before donations open. Support and payment enquiries: <span class="operator-contact"><button type="button" class="contact-reveal">Show contact email</button></span>.</p><p><a href="https://www.minecraft.net/en-us/usage-guidelines">Minecraft Usage Guidelines</a> allow shared rewards when donation goals are met. This page is not a claim of approval or a licence to third-party artwork or branding.</p></section></main>`;
|
||||
writeFileSync(new URL('donate.html',web),'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Community support — dunerealms.com</title><link rel="icon" href="assets/favicon.svg"><link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="pages.css"><script src="pages.js" defer></script><script src="community-goals.js" defer></script></head><body><a class="skip" href="#main">Skip to content</a>'+header+body+footer+'</body></html>');
|
||||
15
website/scripts/build-dunemarks.mjs
Normal file
15
website/scripts/build-dunemarks.mjs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import {readFileSync,writeFileSync} from 'node:fs';
|
||||
import {renderDunemarkCollection} from '../control-panel/public/cp-v2/dunemark-catalogue.mjs';
|
||||
import {updatePortalNavigation} from './portal-navigation.mjs';
|
||||
const web=new URL('../web/',import.meta.url);
|
||||
const exchangeFile=new URL('exchange.html',web);
|
||||
writeFileSync(exchangeFile,readFileSync(exchangeFile,'utf8').replace(/<section class="dunemark-art"[\s\S]*?<\/section>/g,''));
|
||||
const manualFile=new URL('manual-data.json',web),chapters=JSON.parse(readFileSync(manualFile,'utf8'));
|
||||
const currency=chapters.find(c=>c.id==='solaris-spice-sales-and-guild-travel');
|
||||
if(!currency)throw Error('Currency chapter missing');
|
||||
currency.body=currency.body.replace(/<section class="dunemark-art"[\s\S]*?<\/section>/g,'').replace(/<p data-dunemark-collection>[\s\S]*?<\/p>/g,'');
|
||||
currency.body='<p data-dunemark-collection><a href="https://cp.dunerealms.com/#bank/dunemark-collection">View the Dunemark Collection at Imperial Postbank →</a></p>'+currency.body;
|
||||
writeFileSync(manualFile,JSON.stringify(chapters)+'\n');
|
||||
const html='<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>The Dunemark Collection · Imperial Postbank</title><link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="dunemark-collection.css"></head><body><main class="dm-public"><header><p>FEDERAL IMPERIAL RESERVE</p><h1>The Dunemark Collection</h1><p><a href="https://cp.dunerealms.com/#bank/dunemark-collection">Open at Imperial Postbank →</a></p></header>'+'<!-- currency-artwork-start -->'+renderDunemarkCollection()+'<!-- currency-artwork-end -->'+'</main></body></html>';
|
||||
writeFileSync(new URL('dunemark-collection.html',web),updatePortalNavigation(html));
|
||||
console.log('Built Federal Imperial Reserve collection under Postbank; removed Exchange gallery.');
|
||||
7
website/scripts/build-forgejo-shell.mjs
Normal file
7
website/scripts/build-forgejo-shell.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import {SHARED_HEADER,SHARED_HEAD} from './portal-navigation.mjs';
|
||||
import {mkdirSync,writeFileSync} from 'node:fs';
|
||||
const path=new URL('../integrations/forgejo/templates/custom/',import.meta.url);
|
||||
mkdirSync(path,{recursive:true});
|
||||
writeFileSync(new URL('header.tmpl',path),SHARED_HEAD+'\n<link rel="stylesheet" href="https://www.dunerealms.com/git/assets/css/theme-dunerealms.css?v=6">\n<script src="https://www.dunerealms.com/git/assets/js/dune-shell.js?v=1" defer></script>\n');
|
||||
writeFileSync(new URL('body_outer_pre.tmpl',path),SHARED_HEADER+'\n');
|
||||
writeFileSync(new URL('footer.tmpl',path),'<div class="dune-git-footer-note">DuneGit · Build, collaborate and share with the caravan.</div>\n');
|
||||
14
website/scripts/build-home-news.mjs
Normal file
14
website/scripts/build-home-news.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import {readFileSync,writeFileSync} from 'node:fs';
|
||||
const web=new URL('../web/',import.meta.url),file=new URL('index.html',web);let html=readFileSync(file,'utf8');
|
||||
const hero=html.match(/<section class="hero"[\s\S]*?<\/section>/)?.[0],menu=html.match(/<nav id="realm-menu"[\s\S]*?<\/nav>/)?.[0]||'';
|
||||
if(!hero)throw Error('The original 01 / Get the plugin hero must be preserved');
|
||||
function module(title,id,kind,archive=false){return '<section class="dispatch-module" id="'+id+'"><div class="dispatch-heading"><h2>'+title+'</h2><a href="'+(kind==='forum'?'https://forums.dunerealms.com/':'news-archive.html')+'">'+(kind==='forum'?'All discussions':'News archive')+' →</a></div><div data-news-module="'+kind+'"'+(archive?' data-archive="true"':'')+'></div></section>';}
|
||||
function assets(s){if(!s.includes('href="home-news.css"'))s=s.replace('</head>','<link rel="stylesheet" href="home-news.css"><script src="home-news.js" defer></script></head>');return s;}
|
||||
html=assets(html).replace('<body>','<body class="home-news">').replace(/<main id="main">[\s\S]*?<\/main>/,'<main id="main">'+module('News from the realms','home-news','news')+hero+module('Latest forum posts','home-forum','forum')+menu+'<section class="dispatch-module" id="home-bans"><div class="dispatch-heading"><h2>Latest bans</h2><span>PUBLIC MODERATION REGISTER · LATEST 12</span></div><div id="portal-ban-cards" class="dispatch-grid"><p>Loading moderation records…</p></div><p><a class="button" href="/bans.html">See full ban list →</a></p></section><section class="dispatch-module" id="home-appeals"><div class="dispatch-heading"><h2>Latest appeal decisions</h2><span>APPROVED & DENIED</span></div><div id="portal-appeal-cards" class="dispatch-grid"></div><nav id="appeal-pagination" aria-label="Appeal decisions pagination"></nav></section></main>');
|
||||
html=html.replace(/<section class="faction-frieze"[\s\S]*?<\/section>/g,'').replace(/<figure class="lore-frieze"[\s\S]*?<\/figure>/g,'');writeFileSync(file,html);
|
||||
const archive=html.replace(/<title>[^<]+<\/title>/,'<title>News archive — dunerealms.com</title>').replace(/<main id="main">[\s\S]*?<\/main>/,'<main id="main">'+hero+menu+'<article id="news-full-post" class="dispatch-full" hidden></article>'+module('News archive','archive-news','news',true)+'</main>');writeFileSync(new URL('news-archive.html',web),archive);
|
||||
for(const [name,title,section] of [['exchange','Exchange','exchange-content'],['forums','Community forums','forum-section'],['tickets','Support tickets','portal-section']]){
|
||||
const path=new URL(name+'.html',web);let page=assets(readFileSync(path,'utf8')).replace('<body>','<body class="tool-page">').replace(/<section class="(?:choam-hero|page-intro[^"]*)"[\s\S]*?<\/section>/g,'').replace(/<section class="faction-frieze"[\s\S]*?<\/section>/g,'');
|
||||
if(!page.includes('class="tool-title"'))page=page.replace('<section class="'+section+'">','<section class="'+section+'"><h1 class="tool-title">'+title+'</h1>');writeFileSync(path,page);
|
||||
}
|
||||
console.log('Built news portal, chronological archive and compact community tool pages.');
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue

Staff