Merge pull request 'Match Political CP to the shared CP design with its approved palette' (#325) from dev/MC:dev/alpha-1.0.0.7-the-great-migration into main
All checks were successful
DuneRealms Web CI / web (push) Successful in 1m50s
All checks were successful
DuneRealms Web CI / web (push) Successful in 1m50s
This commit is contained in:
commit
6e6874aa45
9 changed files with 60 additions and 29 deletions
16
website/control-panel/politics-cp-shell.mjs
Normal file
16
website/control-panel/politics-cp-shell.mjs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Use the same authored shell and layout as User/Dev CP. Only the palette,
|
||||
// political navigation and public-page chrome differ on this surface.
|
||||
export function politicsCPDocument(source){
|
||||
return source.replace('<title>DuneRealms · Account Centre</title>','<title>DuneRealms · Political CP</title>')
|
||||
.replace(/<header class="dune-site-header">[\s\S]*?<\/header>/,'')
|
||||
.replace(/<footer class="site-footer">[\s\S]*?<\/footer>/,'')
|
||||
.replace(/<script src="https:\/\/www\.dunerealms\.com\/portal-navigation\.js" defer><\/script>/,'')
|
||||
.replace(/<link rel="stylesheet" href="https:\/\/www\.dunerealms\.com\/portal-navigation\.css">/,'')
|
||||
.replace('<body>','<body class="politics-cp-shell" data-cp-mode="politics">')
|
||||
.replace('<strong>✦ DuneRealms</strong>','<strong>✦ Political CP</strong>')
|
||||
.replace('CONTROL PANEL V2<small>Your imperial workspace</small>','REALMS · COURT · LANDSRAAD<small>Elections, Offices & Tools</small>')
|
||||
.replace('class="portals" aria-label="Workspace portals"','class="portals" role="tablist" aria-label="Political workspace"')
|
||||
.replace('aria-controls="sidebar"','aria-controls="sidebar sidebar-right"')
|
||||
.replace(/<script src="\/v2\/v2\.js(?:\?[^\"]*)?" defer><\/script>/,'<script type="module" src="/v2/cp-v2-politics-shell.mjs"></script>')
|
||||
.replace('</head>','<link rel="stylesheet" href="/v2/cp-v2-politics-shell.css"></head>');
|
||||
}
|
||||
|
|
@ -1 +1,3 @@
|
|||
body[data-service=politics]{color-scheme:light;background:#fffcf6;color:#34271f;font-family:Georgia,serif;min-height:0}body[data-service=politics] a{color:#71342d}body[data-service=politics] h1,body[data-service=politics] h2,body[data-service=politics] h3,body[data-service=politics] h4{color:#632f2c}body[data-service=politics] .politics-card,body[data-service=politics] .politics-charter,body[data-service=politics] .politics-candidate,body[data-service=politics] .politics-calendar-card,body[data-service=politics] .politics-leaders,body[data-service=politics] table{background:#f6eddd;color:#34271f;border-color:#bfa77b;box-shadow:none}body[data-service=politics] input,body[data-service=politics] textarea,body[data-service=politics] select,body[data-service=politics] button{background:#fffcf6;color:#4b3229;border:1px solid #aa8755}body[data-service=politics] button:disabled{opacity:.6}body[data-service=politics] .politics-calendar li,body[data-service=politics] .politics-calendar time,body[data-service=politics] th,body[data-service=politics] td{background:#f3e7d1;color:#4b3229;border-color:#c5ae83}body[data-service=politics] .politics-demo-note{color:#755326;background:#ede0c7}body[data-service=politics] .politics-oath{color:#71342d}
|
||||
|
||||
body[data-service=politics] .politics-card,body[data-service=politics] .politics-charter,body[data-service=politics] .politics-candidate,body[data-service=politics] .politics-calendar-card,body[data-service=politics] .politics-leaders{border:3px double #c7a05a;border-radius:7px;box-shadow:inset 0 0 0 3px #efe0c0}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
:root:has(.politics-cp-shell){color-scheme:light;--text:#34271f;--gold:#8a5b20;--line:#b89c68;--green:#f4ecdc}
|
||||
html:has(body.politics-cp-embedded){overflow:hidden}body.politics-cp-shell{display:flow-root;min-height:0;background:#f6f0e5;color:#34271f;font:15px/1.55 Georgia,serif}.politics-cp-shell [hidden]{display:none!important}.politics-cp-shell a{color:#71342d}.politics-cp-shell button:focus-visible,.politics-cp-shell a:focus-visible{outline:3px solid #84372f;outline-offset:3px}
|
||||
.politics-masthead{display:flex;gap:20px;align-items:center;padding:24px 30px;background:linear-gradient(110deg,#3c1b21,#672c32 60%,#3c1b21);color:#ffedc5;border-bottom:5px double #b89753}.politics-masthead h1{font:36px Georgia,serif;margin:2px 0}.politics-masthead p{margin:0;letter-spacing:.06em}.politics-masthead p:first-child{font:11px Arial,sans-serif;letter-spacing:.18em}.politics-masthead>a{margin-left:auto;color:#ffedc5;font:13px Arial,sans-serif}
|
||||
.politics-tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:0;padding:0;background:#e7dcc7;border-bottom:1px solid #b69b6b}.politics-tabs button{font:21px Georgia,serif;min-height:62px;background:#e7dcc7;border:0;border-right:1px solid #b69b6b;color:#5b3730}.politics-tabs button[aria-selected=true]{background:#f6f0e5;box-shadow:inset 0 4px #84372f;font-weight:bold}
|
||||
.politics-cp-shell .layout{display:grid;grid-template-columns:225px minmax(0,1fr);min-height:0}.politics-cp-shell .side{background:#eee4d2;border-right:1px solid #c5ae83;padding:20px 12px}.politics-sidebar-title{color:#7b5c3a;letter-spacing:.12em;font:12px Arial,sans-serif;padding:8px}.politics-cp-shell .navitem{font:15px Georgia,serif;color:#4b3229;border-bottom:1px solid #cdbb98;min-height:48px;text-decoration:none}.politics-cp-shell .navitem:hover,.politics-cp-shell .navitem[aria-current=page]{background:#e0ceb0;outline-color:#a27842}
|
||||
.politics-cp-shell .content{padding:24px;min-width:0}.politics-cp-shell .hero{background:#f0e5d1;border:1px solid #b69b6b;border-radius:0;box-shadow:none;color:#512c2a;min-height:110px;display:flex;gap:18px;align-items:center;padding:20px}.politics-cp-shell .hero img{width:70px;height:70px;object-fit:contain}.politics-cp-shell .hero h1{color:#512c2a;font:28px Georgia,serif;margin:0}.politics-cp-shell .hero p{margin:6px 0 0;color:#64503d}.politics-cp-shell .card{background:#fffcf6;color:#34271f;border:1px solid #cdbb98;border-radius:0;box-shadow:none;padding:20px;margin-top:18px;min-width:0}.politics-cp-shell .cp-v2-template-tabs,.politics-cp-shell .cp-v2-template-heading{display:none}.politics-cp-shell .cp-v2-template-page,.politics-cp-shell .cp-v2-template-panel,.politics-cp-shell .cp-v2-template-panels{background:transparent;color:inherit;border:0;padding:0}.politics-cp-shell .cp-v2-account-bar{background:#e7dcc7;color:#4b3229;border-bottom:1px solid #c5ae83}.politics-cp-shell button,.politics-cp-shell .cp-v2-auth input,.politics-cp-shell .cp-v2-auth select{background:#f6ecda;color:#4b3229;border:1px solid #aa8755}.politics-cp-shell .cp-v2-auth{background:#fffcf6;color:#34271f;border-color:#b69b6b}.politics-cp-shell .alpha-stat{background:#f4ebdb;color:#4b3229;border-color:#c5ae83}.politics-cp-shell .alpha-stat strong,.politics-cp-shell h2,.politics-cp-shell h3{color:#632f2c}.politics-cp-shell .cp-v2-native-frame iframe{width:100%;border:0}.politics-office-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.politics-office-card{border:1px solid #c5ae83;background:#f6eddd;padding:22px;display:flex;flex-direction:column;align-items:flex-start;gap:9px}.politics-office-card h2,.politics-office-card p{margin:0}.politics-office-card small{letter-spacing:.08em;text-transform:uppercase;font:11px Arial,sans-serif}
|
||||
.politics-cp-shell .content{background:#f6f0e5}.politics-cp-shell .card p,.politics-cp-shell .card small,.politics-cp-shell .cp-v2-native-workspace{color:#4b3b2d}.politics-cp-shell .politics-office-card h2{font-size:23px}.politics-cp-shell .politics-office-card img{object-fit:contain}
|
||||
@media(max-width:720px){.politics-masthead{padding:18px 14px;gap:12px;flex-wrap:wrap}.politics-masthead h1{font-size:28px}.politics-masthead>a{margin-left:0}.politics-masthead img{width:56px;height:56px}.politics-tabs button{font-size:18px;min-height:54px}.politics-cp-shell .layout{display:block}.politics-cp-shell .side{display:none}.politics-cp-shell .side.open{display:block;max-height:none;overflow:visible}.politics-cp-shell .content{padding:12px}.politics-cp-shell .card{padding:12px}.politics-office-grid{grid-template-columns:1fr}.politics-cp-shell .mobile-tools{background:#eee4d2}}
|
||||
/* Shared v2.css owns CP structure, spacing and gold framing. Palette only. */
|
||||
:root:has(.politics-cp-shell){color-scheme:light;--text:#38271f;--gold:#d5ad61;--line:#b89756;--green:#f4ecdc}
|
||||
html:has(body.politics-cp-embedded){overflow:hidden}body.politics-cp-shell{display:flow-root;min-height:0;background:#f6f0e5;color:#38271f}.politics-cp-shell [hidden]{display:none!important}.politics-cp-shell a{color:#71342d}.politics-cp-shell button:focus-visible,.politics-cp-shell a:focus-visible{outline:3px solid #b88b37;outline-offset:3px}
|
||||
.politics-cp-shell .command-banner{background:linear-gradient(100deg,#3c1b21,#672c32 60%,#3c1b21);border-color:#d5ad61}.politics-cp-shell .command-banner strong,.politics-cp-shell .command-banner div{color:#ffedc5}.politics-cp-shell .cp-v2-account-bar{background:#e7dcc7;color:#4b3229;border-color:#b89756}
|
||||
.politics-cp-shell .portals{grid-template-columns:repeat(3,minmax(0,1fr));background:#eadfc9;border-color:#d5ad61}.politics-cp-shell .portal{background:linear-gradient(155deg,#fff6df,#e7d5b3);color:#632f2c;border-color:#c7a05a;box-shadow:inset 0 0 0 3px #f6ecd8,0 6px 12px #3c1b2126}.politics-cp-shell .portal[aria-selected=true]{background:linear-gradient(155deg,#783d43,#3c1b21);color:#ffedc5;border-color:#e5be70;box-shadow:inset 0 0 0 3px #52272b,0 6px 12px #3c1b2133}
|
||||
.politics-cp-shell .side{background:linear-gradient(#eee4d2,#f6f0e5);border-color:#b89756}.politics-cp-shell .side-hero{background:linear-gradient(100deg,#6b343b,#3c1b21);color:#ffedc5;border-color:#d5ad61}.politics-cp-shell .category-block{background:#f7eddb;border-color:#b89756}.politics-cp-shell .category-heading{background:linear-gradient(100deg,#e7d5b3,#f6ecda);color:#632f2c;border-color:#b89756}.politics-cp-shell .category-count{background:#6b343b;color:#ffedc5}.politics-cp-shell .navitem{color:#4b3229;border-color:#cdbb98;text-decoration:none}.politics-cp-shell .navitem:hover,.politics-cp-shell .navitem[aria-current=page]{background:linear-gradient(90deg,#dfc99e,#f1e5cb);outline-color:#d5ad61;color:#632f2c}
|
||||
.politics-cp-shell .content{background:radial-gradient(ellipse at top,#fff8e9,#f0e6d3 70%)}.politics-cp-shell .content .hero{background:linear-gradient(100deg,#672c32,#3c1b21);border:4px double #d5ad61;box-shadow:inset 0 0 0 4px #52272b,0 8px 18px #3c1b2126;color:#ffedc5}.politics-cp-shell .content .hero h1{color:#ffe0a1}.politics-cp-shell .content .hero p{color:#f4e6c6}.politics-cp-shell .card{background:linear-gradient(140deg,#fffcf6,#f4ead7);color:#38271f;border-color:#c7a05a;box-shadow:inset 0 0 0 4px #efe0c0,0 7px 16px #3c1b211a}.politics-cp-shell .card p,.politics-cp-shell .card small,.politics-cp-shell .cp-v2-native-workspace{color:#4b3b2d}.politics-cp-shell h2,.politics-cp-shell h3,.politics-cp-shell .alpha-stat strong{color:#632f2c}.politics-cp-shell .cp-v2-template-page,.politics-cp-shell .cp-v2-template-panel,.politics-cp-shell .cp-v2-template-panels{background:transparent;color:inherit;border:0;padding:0}.politics-cp-shell .cp-v2-template-tabs,.politics-cp-shell .cp-v2-template-heading{display:none}
|
||||
.politics-cp-shell button,.politics-cp-shell input,.politics-cp-shell select{background:#f6ecda;color:#4b3229;border-color:#aa8755}.politics-cp-shell .cp-v2-auth{background:#fffcf6;color:#38271f;border-color:#c7a05a}.politics-cp-shell .alpha-stat{background:#f4ebdb;color:#4b3229;border-color:#c7a05a}.politics-cp-shell .cp-v2-native-frame iframe{width:100%;border:0}.politics-office-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.politics-office-card{border:3px double #c7a05a;border-radius:7px;box-shadow:inset 0 0 0 3px #efe0c0;background:linear-gradient(145deg,#fff7e5,#f0e2c7);padding:22px;display:flex;flex-direction:column;align-items:flex-start;gap:9px;min-width:0}.politics-office-card h2,.politics-office-card p{margin:0}.politics-cp-shell .politics-office-card h2{font-size:23px}.politics-office-card img{object-fit:contain}.politics-office-card small{letter-spacing:.08em;text-transform:uppercase;font:11px Arial,sans-serif}
|
||||
.politics-cp-shell .content .cards>.card.citizen-page-full{background:linear-gradient(140deg,#fffcf6,#f4ead7)!important;border:4px double #c7a05a!important;box-shadow:inset 0 0 0 4px #efe0c0,0 7px 16px #3c1b211a!important}
|
||||
@media(max-width:1100px){.politics-office-grid{grid-template-columns:1fr}}@media(max-width:720px){.politics-cp-shell .portals{grid-template-columns:repeat(3,minmax(0,1fr))}.politics-cp-shell .mobile-tools{background:#eee4d2}.politics-cp-shell .side.open{max-height:none;overflow:visible}}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import {startCPAuthentication} from './cp-v2-auth.mjs';
|
|||
import {mountPoliticsPage} from './cp-v2-politics-pages.mjs';
|
||||
import {element as el} from './cp-v2-page-template.mjs';
|
||||
import {POLITICAL_TABS,politicalRoute} from './cp-v2-politics-navigation.mjs';
|
||||
const outer='https://www.dunerealms.com',content=document.querySelector('#content'),sidebar=document.querySelector('#sidebar'),tabs=document.querySelector('#portals');
|
||||
const outer='https://www.dunerealms.com',content=document.querySelector('#content'),sidebar=document.querySelector('#sidebar'),sidebarRight=document.querySelector('#sidebar-right'),tabs=document.querySelector('#portals');
|
||||
const artwork={elections:'seals/office-house_leader.png',offices:'seals/office-landsraad.png',tools:'seals/emperor-v1.png'};
|
||||
const icon=tab=>{const image=el('img');image.src=outer+'/assets/'+artwork[tab];image.alt='';return image;};
|
||||
let ready=false,dispose=()=>{},current='',queued=false,lastHeight=0;
|
||||
document.body.classList.toggle('politics-cp-embedded',parent!==window);
|
||||
function measure(){queued=false;if(parent===window)return;const height=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height))+2;if(height!==lastHeight&&height>=100&&height<=200000){lastHeight=height;parent.postMessage({type:'dune-embed-size',height},outer);}}
|
||||
|
|
@ -14,13 +16,17 @@ function show(){
|
|||
const tab=POLITICAL_TABS.find(t=>t.id===route.tab),page=tab.pages.find(([id])=>id===route.page);
|
||||
content.setAttribute('role','tabpanel');content.setAttribute('aria-labelledby','politics-tab-'+tab.id);
|
||||
for(const button of tabs.children){const selected=button.dataset.tab===tab.id;button.setAttribute('aria-selected',String(selected));button.tabIndex=selected?0:-1;}
|
||||
sidebar.replaceChildren(el('p',tab.label.toUpperCase(),'politics-sidebar-title'));
|
||||
for(const [id,label]of tab.pages){const link=el('a',label,'navitem');link.href='#'+tab.id+'/'+id;if(id===page[0])link.setAttribute('aria-current','page');sidebar.append(link);}
|
||||
sidebar.replaceChildren(el('div',tab.label.toUpperCase(),'side-hero'));sidebarRight.replaceChildren(el('div',tab.label.toUpperCase()+' · DIRECTORY','side-hero'));
|
||||
const split=Math.ceil(tab.pages.length/2);
|
||||
for(const [index,pages]of [tab.pages.slice(0,split),tab.pages.slice(split)].entries()){
|
||||
const block=el('details',undefined,'category-block');block.open=matchMedia('(min-width:721px)').matches||pages.some(([id])=>id===page[0]);const heading=el('summary',undefined,'category-heading');heading.append(icon(tab.id),el('span',index?'Directory':'Chambers','category-name'),el('span',String(pages.length),'category-count'));block.append(heading);const links=el('div',undefined,'category-links');
|
||||
for(const [id,label]of pages){const link=el('a',undefined,'navitem');link.href='#'+tab.id+'/'+id;link.append(icon(tab.id),el('span',label));if(id===page[0])link.setAttribute('aria-current','page');links.append(link);}block.append(links);(index?sidebarRight:sidebar).append(block);
|
||||
}
|
||||
const hero=el('header',undefined,'hero'),seal=el('img'),heading=el('div');seal.src=outer+'/assets/seals/office-landsraad.png';seal.alt='';heading.append(el('h1',page[1]),el('p',tab.id==='elections'?'Candidatures, verified eligibility and the existing ballots.':tab.id==='offices'?'The offices, councils and elected representatives of the realms.':'Proclamations and the existing government instruments.'));hero.append(seal,heading);
|
||||
const card=el('article',undefined,'card'),host=el('div',undefined,'citizen-live-host');card.append(host);content.replaceChildren(hero,card);
|
||||
const cards=el('div',undefined,'cards'),card=el('article',undefined,'card full citizen-page-full'),host=el('div',undefined,'citizen-live-host');card.append(host);cards.append(card);content.replaceChildren(hero,cards);
|
||||
dispose=page[0]==='office-register'?mountOfficeRegister(host):mountPoliticsPage(host,page[0]);
|
||||
history.replaceState(null,'','#'+key);if(parent!==window)parent.postMessage({type:'dune-politics-route',tab:route.tab,page:route.page},outer);
|
||||
sidebar.classList.remove('open');document.querySelector('#politics-menu').setAttribute('aria-expanded','false');schedule();
|
||||
sidebar.classList.remove('open');sidebarRight.classList.remove('open');document.querySelector('#mobile-menu').setAttribute('aria-expanded','false');schedule();
|
||||
}
|
||||
function mountOfficeRegister(host){
|
||||
const controller=new AbortController();let active=true;const status=el('p','Checking the public office register…');status.setAttribute('role','status');host.append(status);
|
||||
|
|
@ -29,7 +35,7 @@ function mountOfficeRegister(host){
|
|||
host.replaceChildren(grid);
|
||||
}).catch(error=>{if(active)status.textContent=error.message;});return()=>{active=false;controller.abort();};
|
||||
}
|
||||
for(const tab of POLITICAL_TABS){const button=el('button',tab.label);button.type='button';button.dataset.tab=tab.id;button.id='politics-tab-'+tab.id;button.setAttribute('role','tab');button.setAttribute('aria-controls','content');button.onclick=()=>{location.hash=tab.id+'/'+tab.pages[0][0];};button.onkeydown=event=>{if(!['ArrowLeft','ArrowRight','Home','End'].includes(event.key))return;event.preventDefault();const index=POLITICAL_TABS.indexOf(tab),next=event.key==='Home'?0:event.key==='End'?POLITICAL_TABS.length-1:(index+(event.key==='ArrowRight'?1:POLITICAL_TABS.length-1))%POLITICAL_TABS.length;tabs.children[next].click();tabs.children[next].focus();};tabs.append(button);}
|
||||
document.querySelector('#politics-menu').onclick=()=>{const open=sidebar.classList.toggle('open');document.querySelector('#politics-menu').setAttribute('aria-expanded',String(open));};
|
||||
for(const tab of POLITICAL_TABS){const button=el('button',undefined,'portal');button.append(icon(tab.id),el('span',tab.label));button.type='button';button.dataset.tab=tab.id;button.id='politics-tab-'+tab.id;button.setAttribute('role','tab');button.setAttribute('aria-controls','content');button.onclick=()=>{location.hash=tab.id+'/'+tab.pages[0][0];};button.onkeydown=event=>{if(!['ArrowLeft','ArrowRight','Home','End'].includes(event.key))return;event.preventDefault();const index=POLITICAL_TABS.indexOf(tab),next=event.key==='Home'?0:event.key==='End'?POLITICAL_TABS.length-1:(index+(event.key==='ArrowRight'?1:POLITICAL_TABS.length-1))%POLITICAL_TABS.length;tabs.children[next].click();tabs.children[next].focus();};tabs.append(button);}
|
||||
document.querySelector('#mobile-menu').onclick=()=>{const open=sidebar.classList.toggle('open');sidebarRight.classList.toggle('open',open);document.querySelector('#mobile-menu').setAttribute('aria-expanded',String(open));};
|
||||
window.addEventListener('hashchange',show);window.addEventListener('pagehide',()=>{dispose();observer.disconnect();},{once:true});
|
||||
startCPAuthentication(user=>{if(!user.permissions?.includes('web.menu.game')){tabs.hidden=true;sidebar.hidden=true;content.replaceChildren(el('p','Your account does not have access to the political chambers.'));return;}ready=true;show();});
|
||||
startCPAuthentication(user=>{if(!user.permissions?.includes('web.menu.game')){tabs.hidden=true;sidebar.hidden=true;sidebarRight.hidden=true;content.replaceChildren(el('p','Your account does not have access to the political chambers.'));return;}ready=true;show();});
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
<!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>Political CP · DuneRealms</title><link rel="stylesheet" href="/v2/v2.css"><link rel="stylesheet" href="/v2/cp-v2-politics-shell.css"><script type="module" src="/v2/cp-v2-politics-shell.mjs"></script></head>
|
||||
<body class="politics-cp-shell" data-cp-mode="politics">
|
||||
<header class="politics-masthead"><img src="https://www.dunerealms.com/assets/seals/office-landsraad.png" width="76" height="76" alt=""><div><p>THE REALMS · THE COURT · THE LANDSRAAD</p><h1>Political CP</h1><p>Your voice in the government of DuneRealms.</p></div><a href="https://cp.dunerealms.com/" target="_top">Account Centre →</a></header>
|
||||
<nav id="portals" class="politics-tabs" role="tablist" aria-label="Political workspace" hidden></nav><div class="mobile-tools" hidden><button id="politics-menu" type="button" aria-expanded="false" aria-controls="sidebar">Chamber menu</button></div>
|
||||
<main class="layout" hidden><aside id="sidebar" class="side" aria-label="Political chamber pages"></aside><section id="content" class="content" tabindex="-1"></section></main>
|
||||
<noscript><p>Enable JavaScript to sign in and use the existing election and government services.</p><p><a href="https://www.dunerealms.com/government.html#public-register" target="_top">Public office register</a></p></noscript>
|
||||
</body></html>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -78,6 +78,7 @@ import {createOrganisationManagement} from '../node/organisation-management.mjs'
|
|||
import {initializeRanks,initializeCommunityAccess,initializeQuestAccess,initializeBankAccess,can,accessFor} from '../node/permissions.mjs';
|
||||
import {createServer} from 'node:http';
|
||||
import {clanCPDocument} from './clan-cp-shell.mjs';
|
||||
import {politicsCPDocument} from './politics-cp-shell.mjs';
|
||||
import {createV1PersonalBank} from './api-v1-personal-bank.mjs';
|
||||
import {readFile} from 'node:fs/promises';
|
||||
import {pathToFileURL} from 'node:url';
|
||||
|
|
@ -264,7 +265,7 @@ export function createPanel(db,settings={},dependencies={}){
|
|||
if(path==='/federal-reserve'||path==='/federal-reserve/')return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/reserve-ledger.html',import.meta.url)),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}});
|
||||
// V2 shell is public; private data and writes retain their authenticated API gates.
|
||||
if(path==='/clan-cp')return new Response(request.method==='HEAD'?null:clanCPDocument(await readFile(new URL('./public/cp-v2/index.html',import.meta.url),'utf8')),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}});
|
||||
if(path==='/politics-cp')return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/politics-cp.html',import.meta.url)),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}});
|
||||
if(path==='/politics-cp')return new Response(request.method==='HEAD'?null:politicsCPDocument(await readFile(new URL('./public/cp-v2/index.html',import.meta.url),'utf8')),{headers:{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'}});
|
||||
// All authored cp-v2 browser modules share this bounded public directory.
|
||||
// New components must not require a second, manually maintained route list.
|
||||
if(/^\/v2\/cp-v2-[a-z0-9-]+\.(?:mjs|css)$/.test(path)){
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
# Political CP
|
||||
|
||||
Government at `https://www.dunerealms.com/government.html` hosts the independent
|
||||
`https://cp.dunerealms.com/politics-cp` shell. It has its own burgundy, parchment
|
||||
and gold styling, with Elections, Offices and Tools tabs. The public office
|
||||
`https://cp.dunerealms.com/politics-cp` shell. It reuses the authored User/Dev CP
|
||||
layout, illustrated portals, left/right menus and gold framing, with a burgundy
|
||||
and parchment palette and Elections, Offices and Tools tabs. The public office
|
||||
directory remains available below the workspace in a disclosure panel.
|
||||
|
||||
Politics is excluded from both normal User CP and Clan CP portal lists. Old
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {readFile} from 'node:fs/promises';
|
||||
import {Script,runInNewContext} from 'node:vm';
|
||||
import {LocalD1} from './d1-adapter.mjs';
|
||||
import {createPanel} from '../control-panel/server.mjs';
|
||||
import {POLITICAL_TABS,politicalRoute,politicsDestination} from '../control-panel/public/cp-v2/cp-v2-politics-navigation.mjs';
|
||||
import {governmentRoute,politicalFrameMessage} from '../web/government-cp.js';
|
||||
import {workspacesForSurface} from '../control-panel/public/cp-v2/cp-v2-surface.mjs';
|
||||
import {politicsCPDocument} from '../control-panel/politics-cp-shell.mjs';
|
||||
|
||||
test('Political CP exposes exactly Elections, Offices and Tools with every existing chamber',()=>{
|
||||
assert.deepEqual(POLITICAL_TABS.map(t=>t.label),['Elections','Offices','Tools']);
|
||||
|
|
@ -22,13 +24,21 @@ test('Politics is removed from the User and Clan CP surfaces and legacy routing
|
|||
|
||||
test('the real server serves an independent Political CP and styles without the normal CP router',async()=>{
|
||||
const db=new LocalD1(),app=createPanel(db);try{
|
||||
const response=await app(new Request('https://cp.dunerealms.com/politics-cp'));assert.equal(response.status,200);assert.match(response.headers.get('content-type'),/text\/html/);const html=await response.text();assert.match(html,/data-cp-mode="politics"/);assert.match(html,/cp-v2-politics-shell.mjs/);assert.doesNotMatch(html,/src="\/v2\/v2.js"|class="command-banner"|class="dune-site-header"/);
|
||||
const response=await app(new Request('https://cp.dunerealms.com/politics-cp'));assert.equal(response.status,200);assert.match(response.headers.get('content-type'),/text\/html/);const html=await response.text();assert.match(html,/data-cp-mode="politics"/);assert.match(html,/cp-v2-politics-shell.mjs/);assert.match(html,/class="command-banner"/);assert.match(html,/id="sidebar-right"/);assert.doesNotMatch(html,/src="\/v2\/v2.js|class="dune-site-header"/);
|
||||
assert.equal((await app(new Request('https://cp.dunerealms.com/politics-cp',{method:'HEAD'}))).status,200);assert.equal((await app(new Request('https://cp.dunerealms.com/politics-cp',{method:'POST'}))).status,405);
|
||||
for(const file of ['cp-v2-politics-shell.mjs','cp-v2-politics-shell.css','cp-v2-politics-navigation.mjs','cp-v2-politics-native.css'])assert.equal((await app(new Request('https://cp.dunerealms.com/v2/'+file))).status,200,file);
|
||||
assert.equal((await app(new Request('https://cp.dunerealms.com/api/public/government?user=other'))).status,400);assert.equal((await app(new Request('https://cp.dunerealms.com/api/public/government',{method:'POST'}))).status,405);
|
||||
}finally{db.close();}
|
||||
});
|
||||
|
||||
test('Political CP reuses the authored CP layout and normal CP remains a valid classic script',async()=>{
|
||||
const template=await readFile(new URL('../control-panel/public/cp-v2/index.html',import.meta.url),'utf8'),html=politicsCPDocument(template);
|
||||
const layout=template.slice(template.indexOf('<div class="layout"'),template.indexOf('<footer'));assert(html.includes(layout));assert.match(html,/class="portals" role="tablist"/);assert.match(html,/type="module" src="\/v2\/cp-v2-politics-shell.mjs"/);
|
||||
const source=await readFile(new URL('../control-panel/public/cp-v2/v2.js',import.meta.url),'utf8');assert.doesNotThrow(()=>new Script(source));
|
||||
const redirect=runInNewContext(source.slice(source.indexOf('function politicsDestination('),source.indexOf('const requestedPolitics='))+';politicsDestination');
|
||||
for(const tab of POLITICAL_TABS)for(const [page]of tab.pages)assert.equal(redirect('politics',page),politicsDestination('politics',page));
|
||||
});
|
||||
|
||||
test('Government hosts the Political CP while retaining the public office directory',async()=>{
|
||||
const html=await readFile(new URL('../web/government.html',import.meta.url),'utf8');assert.match(html,/id="political-workspace"/);assert.match(html,/src="https:\/\/cp.dunerealms.com\/politics-cp#elections\/house-elections"/);assert.match(html,/id="public-register"/);assert.match(html,/id="imperial-offices"/);assert.doesNotMatch(html,/cp.dunerealms.com\/#politics\//);assert.match(html,/government-cp.css/);assert.match(html,/government-cp.js/);
|
||||
const entry=await readFile(new URL('../control-panel/public/user-service-entry.mjs',import.meta.url),'utf8');assert.match(entry,/v2\/cp-v2-politics-native.css/);assert.match(entry,/politicsDestination\('politics',page\)/);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff