Merge pull request 'Restore quest and organisation modules; show Exchange details in page' (#478) from fix/quest-module-routes-20261122 into main
This commit is contained in:
commit
d07c68ffbf
4 changed files with 44 additions and 3 deletions
|
|
@ -35,3 +35,5 @@ body.exchange-starport:has(.codex-exchange-public){background:#061e1b}
|
|||
.codex-exchange-public .codex-exchange-categories button[data-subcategory=true]{margin-left:18px;width:calc(100% - 18px);border-left:1px solid #88784b;border-radius:0;font-size:13px;min-height:38px;padding:7px 8px}.codex-exchange-public .codex-exchange-categories button[data-subcategory=true] img{width:22px;height:22px}
|
||||
|
||||
.codex-exchange-public .jarvis-victory{margin:16px 0;padding:12px 16px;border:1px solid #8d774447;border-radius:10px;background:#0d261d;color:#b9c7b4}.jarvis-victory summary{cursor:pointer;font-size:.82rem;letter-spacing:.04em}.jarvis-victory figure{max-width:960px;margin:18px auto 4px}.jarvis-victory img{display:block;width:100%;height:auto;border:1px solid #b59a57;border-radius:10px}.jarvis-victory figcaption{padding:12px 4px;text-align:center;color:#e5cb80;font-family:Georgia,serif}
|
||||
|
||||
.codex-exchange-dialog{box-sizing:border-box;width:min(760px,calc(100vw - 28px));max-width:calc(100vw - 28px);max-height:calc(100dvh - 28px);overflow:auto;border:1px solid #baa15d;border-radius:12px;padding:16px;background:#0c291f;color:#eddfb8;box-shadow:0 24px 90px #000a}.codex-exchange-dialog::backdrop{background:#020e0ab8;backdrop-filter:blur(4px)}.exchange-detail-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}.exchange-detail-bar h3{margin:0;color:#eed89c;font:700 23px Georgia,serif}.exchange-detail-bar>button{flex:none;min-height:44px;padding:8px 12px;border:1px solid #baa15d;border-radius:6px;background:#183c2c;color:#eddfb8;cursor:pointer}.exchange-detail-content>.item-lore-card{max-width:580px;margin:auto}.exchange-detail-offer{display:grid;grid-template-columns:minmax(90px,1fr) minmax(0,2fr);gap:10px;padding:16px;border:1px solid #78906b66;border-radius:7px;background:#071f17}.exchange-detail-offer dt{color:#b5c7b7}.exchange-detail-offer dd{margin:0;overflow-wrap:anywhere}.exchange-detail-action{display:block;margin:10px 0;padding:11px 14px;border:1px solid #b69d58;border-radius:7px;background:#173b2b;color:#f2dfa3;text-decoration:none}.exchange-detail-content p{line-height:1.6}.exchange-detail-bar>button:focus-visible,.exchange-detail-action:focus-visible{outline:3px solid #f3d680;outline-offset:2px}@media(max-width:600px){.codex-exchange-dialog{padding:12px}.exchange-detail-bar h3{font-size:19px}}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {itemLoreCard} from '../item-lore-view.mjs';
|
||||
import {itemPublicHref} from '../item-lore-model.mjs';
|
||||
import {createCardGallery,createListingCard} from './cp-v2-exchange-cards.mjs';
|
||||
import {JARVIS_EXPANSION} from '../jarvis-brand.mjs';
|
||||
|
|
@ -28,7 +29,27 @@ export function mountExchangeDesign(host,{context='public',view='browse',fetcher
|
|||
let selectPost;const groups=[{id:'browse',title:'Browse',content:browse}];if(context!=='public'){groups.push({id:'mine',title:'My listings',content:mine},{id:'post',title:context==='user'?'Post an item':'Post a listing',content:post});if(context==='clan')groups.push({id:'applications',title:'Applications',content:applications},{id:'promotions',title:'Promotions',content:promotions});}const tabbed=organisationTabs(groups,{label:'Exchange sections',initial:view});selectPost=()=>tabbed.querySelector('[role=tab][aria-controls$="-post-panel"]')?.click();root.append(tabbed);
|
||||
const footer=el('footer',undefined,'codex-exchange-logistics');footer.append(el('span',context==='public'?'Logistics by SPost':'Exchange logistics supplied by'),image('spost-logo-v1.svg'),el('small','part of'),image('corrino-group-v4.png'));root.append(footer);if(context==='public'){const egg=el('details',undefined,'jarvis-victory'),summary=el('summary','J.A.R.V.I.S. · Archive fragment'),figure=el('figure'),art=image('jarvis-victory-v1.png');art.alt='Minecraft-style Jem’Hadar warrior holding a command crystal. J.A.R.V.I.S. is victory. Victory is life.';art.width=960;art.height=640;figure.append(art,el('figcaption','J.A.R.V.I.S. is victory. Victory is life.'));egg.append(summary,figure);root.append(egg);}const cardDesigns=el('details',undefined,'codex-exchange-legend');cardDesigns.append(el('summary','Card design previews · items, kits, campaigns, jobs and more'),createCardGallery());root.append(cardDesigns);host.replaceChildren(root);
|
||||
function render(){for(const [node,id]of buttons)node.setAttribute('aria-pressed',String(id===category));let matches=[...rows,...kitRows,...jarvisRows,...auctionRows,...campaignRows,...politicalRows,...(examples?SAMPLES.filter(row=>context!=='clan'||['recruitment','quests','events'].includes(row.type)):[])].filter(row=>(category==='all'||row.category===category||row.type===category&&!(category==='recruitment'&&row.organisationKind==='company')||row.kitCategory===category)&&[row.title,row.owner,row.world].join(' ').toLowerCase().includes(search.input.value.toLowerCase()));if(stage.input.selectedIndex>0)matches=matches.filter(row=>row.edition?.stage===stage.input.value.toLowerCase());if(season.input.selectedIndex>0)matches=matches.filter(row=>row.edition&¤tEdition&&(season.input.selectedIndex===1?row.edition.season===currentEdition.season:row.edition.season!==currentEdition.season));if(quality.input.selectedIndex>0)matches=matches.filter(row=>words(row.quality).toLowerCase()===quality.input.value.toLowerCase());matches.sort((a,b)=>sort.input.selectedIndex===1?a.price-b.price:sort.input.selectedIndex===2?b.price-a.price:sort.input.selectedIndex===3?a.title.localeCompare(b.title):Number(b.createdAt||b.created_at||b.id)-Number(a.createdAt||a.created_at||a.id)||0);page=Math.min(page,Math.max(0,Math.ceil(matches.length/8)-1));cards.replaceChildren();if(!matches.length)cards.append(el('p',season.input.selectedIndex||quality.input.selectedIndex||stage.input.selectedIndex?'No listings match these edition and quality filters. Goods without edition metadata are excluded.':'No matching listings. Design examples can be enabled separately.','codex-exchange-empty'));for(const row of matches.slice(page*8,page*8+8)){const sample=String(row.id).startsWith('preview-'),type=TYPES.find(([id])=>id===(row.category||row.type)),cardType=({'items':'item','kits':'kit','recruitment':'job','quests':'quest','events':'event','deeds':'deed','auctions':'auction','campaign':'campaign','political-job':'job'})[row.type]||'ad',art=row.type==='recruitment'&&row.organisationKind==='company'?'exchange-company-jobs-v1.png':row.type==='items'?'minecraft-items/'+String(row.material).toLowerCase()+'.png':row.type==='kits'?'minecraft-items/'+(row.quality==='legendary'?'netherite_chestplate':'leather_chestplate')+'.png':type?.[2]||'nav-exchange-v2.webp',facts=[row.world,...(row.edition?[words(row.edition.stage)+' '+row.edition.version+' · '+row.edition.season]:[]),...(row.type==='items'?[row.quantity+' available']:row.type==='kits'?[words(row.quality)]:[])].filter(Boolean),card=createListingCard({item:row,type:cardType,featured:row.featured===true,title:row.title,owner:row.owner,subtitle:row.subtitle||row.owner,message:row.description||'',image:row.image||asset+art,facts:row.type==='auctions'?['Highest bid: '+(row.highestMinor/100).toFixed(2)+' DM','Closes: '+new Date(row.closesAt).toLocaleString('en-GB'),'3 hour office auction']:facts,price:['items','kits','deeds'].includes(row.type)?Number(row.price).toFixed(2)+' DM':null},{preview:sample,onOpen:()=>detail(row,sample)});card.classList.add('codex-exchange-card');cards.append(card);}pager.replaceChildren(button('← Previous',()=>{page--;render();},page===0),el('span',(page+1)+' / '+Math.max(1,Math.ceil(matches.length/8))),button('Next →',()=>{page++;render();},(page+1)*8>=matches.length));}
|
||||
function detail(row,sample){if(!sample&&['items','kits'].includes(row.type)){const href=itemPublicHref(row);if(href){location.href=href;return;}}if(row.type==='deeds'&&!sample){const dialog=el('dialog',undefined,'codex-exchange-dialog');dialog.append(el('h3',row.title),el('p',Number(row.price).toFixed(2)+' DM'),el('p',row.description||'Organisation deed offer'),el('p',row.purchaseAvailable?'Acquire patronage through the existing deed key and ordinary bank processing.':'Deed purchasing is currently unavailable.'),button('Close',()=>dialog.close()));if(row.purchaseAvailable){const checkout=el('a','Review deed purchase →');checkout.href='https://cp.dunerealms.com/deed-purchase?listing='+encodeURIComponent(row.id);checkout.target='_top';dialog.append(checkout);}dialog.onclose=()=>dialog.remove();root.append(dialog);dialog.showModal();return;}if(['campaign','political-job'].includes(row.type)&&!sample){window.location.href=row.url;return;}if(row.type==='auctions'&&!sample){window.location.href='https://cp.dunerealms.com/jarvis-auction?id='+encodeURIComponent(row.id);return;}const dialog=el('dialog',undefined,'codex-exchange-dialog');dialog.append(el('h3',row.title),el('p',row.description||row.owner+' · '+row.world),el('p',sample?'Design example. Applications and purchases are disabled.':row.type==='kits'?(row.purchaseAvailable?'Continue to the existing kit checkout.':'Published design · purchase or delivery is not available yet.'):row.type==='recruitment'?'Applications are free. The organisation reviews your request before membership starts.':'Trade in Minecraft: /exchange buy '+row.id),button('Close',()=>dialog.close()));if(row.type==='kits'&&row.purchaseAvailable){const checkout=el('a','Open kit checkout →');checkout.href='https://cp.dunerealms.com/?kit-listing='+encodeURIComponent(row.listingId)+'#realm/kits-exchange';dialog.append(checkout);}if(!sample&&row.type==='recruitment'){const apply=el('a','Apply to this '+(row.organisationKind==='company'?'company':'clan')+' →');apply.href='https://cp.dunerealms.com/jarvis-application?listing='+encodeURIComponent(row.id);apply.target='_top';dialog.append(apply);}dialog.onclose=()=>dialog.remove();root.append(dialog);dialog.showModal();}
|
||||
function detail(row,sample){
|
||||
const dialog=el('dialog',undefined,'codex-exchange-dialog'),bar=el('div',undefined,'exchange-detail-bar'),close=button('Close ×',()=>dialog.close()),copy=el('div',undefined,'exchange-detail-content'),returnFocus=document.activeElement;
|
||||
close.setAttribute('aria-label','Close listing details');bar.append(el('h3',row.title),close);dialog.setAttribute('aria-label',row.title||'Listing details');dialog.append(bar,copy);
|
||||
const link=(label,href)=>{const a=el('a',label);a.href=href;a.target='_top';a.className='exchange-detail-action';copy.append(a);};
|
||||
if(['items','kits'].includes(row.type)){
|
||||
copy.append(itemLoreCard(row));const offer=el('dl',undefined,'exchange-detail-offer');for(const [label,value]of [['Seller',row.owner||row.ownerName||'Registered seller'],['World',row.world||'Published catalogue'],['Quantity',row.quantity??'See current offer'],['Price',Number.isFinite(Number(row.price))?Number(row.price).toFixed(2)+' DM':'See current offer']])offer.append(el('dt',label),el('dd',String(value)));copy.append(offer);
|
||||
if(!sample&&row.type==='kits'&&row.purchaseAvailable)link('Review kit purchase →','https://cp.dunerealms.com/?kit-listing='+encodeURIComponent(row.listingId)+'#realm/kits-exchange');
|
||||
if(!sample&&row.type==='items')copy.append(el('p','Purchase this listing through the ingame Exchange. Opening these details does not reserve or buy it.'));
|
||||
const href=!sample?itemPublicHref(row):null;if(href)link('Full item dashboard →',href);
|
||||
}else{
|
||||
copy.append(el('p',row.description||row.message||'Published listing details.'));
|
||||
if(row.owner)copy.append(el('p','Published by '+row.owner));
|
||||
if(row.type==='deeds'){copy.append(el('p',Number(row.price).toFixed(2)+' DM'),el('p',row.purchaseAvailable?'Acquire patronage through the existing deed key and ordinary bank processing.':'Deed purchasing is currently unavailable.'));if(!sample&&row.purchaseAvailable)link('Review deed purchase →','https://cp.dunerealms.com/deed-purchase?listing='+encodeURIComponent(row.id));}
|
||||
else if(row.type==='recruitment'){copy.append(el('p','Applications are free. The organisation reviews your request before membership starts.'));if(!sample)link('Apply to this '+(row.organisationKind==='company'?'company':'clan')+' →','https://cp.dunerealms.com/jarvis-application?listing='+encodeURIComponent(row.id));}
|
||||
else if(row.type==='political-job'){copy.append(el('p','This is a political appointment. The officeholder reviews applications through the existing appointment flow.'));if(!sample)link('Apply for this role →','https://cp.dunerealms.com/political-job?id='+encodeURIComponent(row.id));}
|
||||
else if(row.type==='campaign'&&!sample){try{const u=new URL(row.url);if(u.origin==='https://www.dunerealms.com'&&u.pathname==='/government.html')link('Open voting directory →',u.href);}catch{}}
|
||||
else if(row.type==='auctions'&&!sample)link('Review auction →','https://cp.dunerealms.com/jarvis-auction?id='+encodeURIComponent(row.id));
|
||||
}
|
||||
if(sample)copy.append(el('p','Design example. Applications and purchases are disabled.'));
|
||||
dialog.onclose=()=>{dialog.remove();if(returnFocus?.isConnected)returnFocus.focus();};dialog.onclick=event=>{if(event.target!==dialog)return;const r=dialog.getBoundingClientRect();if(event.clientX<r.left||event.clientX>r.right||event.clientY<r.top||event.clientY>r.bottom)dialog.close();};root.append(dialog);dialog.showModal();close.focus();
|
||||
}
|
||||
search.input.oninput=()=>{page=0;render();};sort.input.onchange=quality.input.onchange=stage.input.onchange=season.input.onchange=()=>{page=0;render();};
|
||||
async function load(){try{const response=await fetcher(context==='public'?'/api/exchange/listings':'/api/exchange/listings?view=all',{credentials:'same-origin',signal:controller.signal});if(!response.ok)throw Error('unavailable');const data=await response.json();const source=Array.isArray(data)?data:Array.isArray(data.listings)?data.listings:Array.isArray(data.items)?data.items:[];rows=source.filter(row=>Number.isFinite(Number(row.price))&&Number.isFinite(Number(row.quantity))&&/^[A-Za-z0-9_]+$/.test(row.material||'')&&/^\d+$/.test(String(row.id))).map(row=>({...row,type:'items',title:row.displayName||words(row.material),owner:row.seller||row.seller_name||'Player listing',world:words(row.origin),price:Number(row.price),quantity:Number(row.quantity)}));if(!active)return;goodsState='ready';updateStatus();render();}catch{if(!active)return;rows=[];goodsState='error';updateStatus();render();}}
|
||||
if(context==='clan')import('./cp-v2-jarvis-recruitment.mjs').then(({mountJarvisRecruitment})=>{if(active)disposeJarvis=mountJarvisRecruitment({mine,post,applications,promotions,banner,eligibility,scope:organisationScope||{kind:'clan'},fetcher,signal:controller.signal,onChanged:()=>void loadJarvis()});}).catch(()=>{if(active)banner.textContent='Recruitment services could not be opened.';});
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ export function createPanel(db,settings={},dependencies={}){
|
|||
if(/^\/(?:v2|cp-v2)\/cp-v2-[a-z0-9-]+\.(?:mjs|css)$/.test(path)){
|
||||
try{const bytes=await readFile(new URL('./public/cp-v2/'+path.slice(path.lastIndexOf('/')+1),import.meta.url));return new Response(request.method==='HEAD'?null:bytes,{headers:{'Content-Type':path.endsWith('.css')?'text/css; charset=utf-8':'text/javascript; charset=utf-8','Cache-Control':'private, no-store','X-Content-Type-Options':'nosniff'}});}catch(error){if(error.code==='ENOENT')return new Response('Not found',{status:404});throw error;}
|
||||
}
|
||||
if(['/v2/cp-v2-codex-management.mjs','/v2/cp-v2-codex-management.css','/v2/cp-v2-exchange-design.mjs','/v2/cp-v2-exchange-design.css'].includes(path))return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/'+path.slice(4),import.meta.url)),{headers:{'Content-Type':path.endsWith('.css')?'text/css; charset=utf-8':'text/javascript; charset=utf-8','Cache-Control':'no-store','Access-Control-Allow-Origin':'*'}});
|
||||
if(['/v2/faith-theme-loader.mjs','/v2/faith-theme.css','/v2/cp-v2-codex-management.mjs','/v2/cp-v2-codex-management.css','/v2/cp-v2-exchange-design.mjs','/v2/cp-v2-exchange-design.css'].includes(path))return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/'+path.slice(4),import.meta.url)),{headers:{'Content-Type':path.endsWith('.css')?'text/css; charset=utf-8':'text/javascript; charset=utf-8','Cache-Control':'no-store','Access-Control-Allow-Origin':'*'}});
|
||||
if(['/jarvis-master-keys.mjs','/jarvis-brand.mjs','/organisation-tabs.mjs','/organisation-tabs.css','/codex-code-format.mjs','/codex-dossier-format.mjs'].includes(path))return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/'+path.slice(1),import.meta.url)),{headers:{'Content-Type':path.endsWith('.css')?'text/css; charset=utf-8':'text/javascript; charset=utf-8','Cache-Control':'no-store','Access-Control-Allow-Origin':'*'}});
|
||||
if(['/v2/citizen-directory.mjs','/v2/citizen-directory.css','/v2/organisation-permissions.mjs'].includes(path))return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/'+path.slice('/v2/'.length),import.meta.url)),{headers:{'Content-Type':path.endsWith('.css')?'text/css; charset=utf-8':'text/javascript; charset=utf-8','Cache-Control':'private, no-store','X-Content-Type-Options':'nosniff'}});
|
||||
if(['/','/index.html','/v2','/v2/','/v2/cp-v2-politics-pages.mjs','/v2/cp-v2-auth.mjs','/v2/cp-v2-access.mjs','/v2/citizens-registry.mjs','/v2/cp-v2-page-template.mjs','/v2/imperial-permissions.mjs','/v2/honours-seals.mjs','/v2/cp-v2-planned-pages.mjs','/v2/cp-v2-choam-pages.mjs','/v2/cp-v2-bureau-pages.mjs','/v2/cp-v2-service-pages.mjs','/v2/cp-v2-newsroom.mjs','/v2/cp-v2-moderation.mjs','/v2/cp-v2-native-services.mjs','/v2/cp-v2-exchange-authority.mjs','/v2/cp-v2-crysknife.mjs','/v2/cp-v2-post-menu.mjs','/v2/cp-v2-postbank-foundation.mjs','/v2/cp-v2-postbank-payments.mjs','/v2/cp-v2-postbank-admin.mjs','/v2/cp-v2-authorisations.mjs','/v2/cp-v2-tax-treasury.mjs','/v2/cp-v2-reserve-ledger.mjs','/v2/cp-v2-reserve-entry.mjs','/v2/cp-v2-postbank-credit.mjs','/v2/cp-v2-postbank-beneficiaries.mjs','/v2/cp-v2-postbank-statement-archive.mjs','/v2/cp-v2-bank-pages.mjs','/v2/cp-v2-post-pages.mjs','/v2/cp-v2-code-redemption.mjs','/v2/cp-v2-rewards.mjs','/v2/cp-v2-user-commerce.mjs','/v2/cp-v2-user-pages.mjs','/v2/cp-v2-user-api.mjs','/v2/cp-v2-security.mjs','/v2/cp-v2-passport.mjs','/v2/cp-v2-personal-records.mjs','/v2/cp-v2-design-pages.mjs','/v2/cp-v2-design-catalog.mjs','/v2/cp-v2-forge-pages.mjs','/v2/cp-v2-hosting.mjs','/v2/cp-v2-community-treasury.mjs','/v2/cp-v2-item-register.mjs','/v2/cp-v2-kit-directorate.mjs','/v2/cp-v2-campaigns.mjs','/v2/cp-v2-imperial-revenue.mjs','/v2/cp-v2-read-register.mjs','/v2/cp-v2-bureau-data.mjs','/v2/cp-v2-company-actions.mjs','/v2/v2.css','/v2/v2.js'].includes(path)){
|
||||
|
|
@ -472,7 +472,7 @@ export function createPanel(db,settings={},dependencies={}){
|
|||
return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/cp-v2/'+file,import.meta.url)),{headers:{'Content-Type':moduleFile?'text/javascript; charset=utf-8':file.endsWith('.css')?'text/css; charset=utf-8':'text/html; charset=utf-8','Cache-Control':'private, no-store','X-Content-Type-Options':'nosniff'}});
|
||||
}
|
||||
const file=path==='/'?'index.html':path==='/servers'?'servers.html':path.slice(1);
|
||||
if(!['item-lore-model.mjs','item-lore-view.mjs','item-lore.css','organisation-editor.mjs','organisation-register.mjs','user-service.html','user-service-entry.mjs','user-service.css','kit-receipt-status.mjs','clan-center.html','clan-center-entry.mjs','clan-center.css','bank-transfer-view.mjs','bank-dashboard.mjs','mail-service-ui.mjs','mail-workspace.css','hosting-control.mjs','internal-mail.mjs','internal-mail.css','election-voting-view.mjs','imperial-charters-view.mjs','proclamations-view.mjs','electoral-roll-view.mjs','election-applications-view.mjs','election-rules.mjs','political-catalog.mjs','menu-ribbons.mjs','council-preview.mjs','politics.mjs','crysknife.mjs','x-news-draft.mjs','terms.html','admin-registration.mjs','mail-signature.mjs','webmail.mjs','git-control.mjs','git-control.css','site-profile.mjs','site-profile.css','servers.html','servers.js','servers.css','pages.mjs','user-page-hero.mjs','commerce-settings.mjs','shop-management.mjs','center-portals.mjs','panel-layout.mjs','embed-size.mjs','dev-request-access.mjs','center-portals.css','overview.mjs','overview.css','page-groups.mjs','ban-register.mjs','moderation-form-response.mjs','ban-record-cards.css','ban-evidence.mjs','ban-evidence.css','ranks.mjs','ranks.css','staff-manual.mjs','luckperms.mjs','community-admin.mjs','native-community.mjs','exchange.mjs','exchange.css','clans.mjs','clan-shop.mjs','house-tailor.mjs','banking.mjs','banking.css','game-ranks.mjs','upgrade-shop.mjs','kit-generator.mjs','kit-design-model.mjs','starter-kit-policy.mjs','kit-equipment-editor.mjs','kit-texture-preview.mjs','kit-generator.css','kit-market.mjs','kit-market.css','kit-cart.mjs','imperial-atelier.mjs','quests.mjs','quests.css','clans.css','clan-request-gate.mjs','clan-directory-model.mjs','clan-directory-view.mjs','clan-profile-panels.mjs','clan-titles.mjs','dynastic-address.mjs','organisation-palette.mjs','organisation-palette-model.mjs','organisation-palette.css','clan-dynasty.mjs','clan-dynasty.css','clan-deed-settings.mjs','dune-date.mjs','organisation-settings.mjs','organisation-settings.css','organisation-dashboard.mjs','organisation-dashboard.css','organisation-activity.mjs','clan-dashboard-data.mjs','quest-rewards.mjs','quest-rewards.css','inventory/inventory-view.mjs','inventory/inventory-mount.mjs','inventory/inventory.css'].includes(file))return new Response('Not found',{status:404});
|
||||
if(!['action-cooldown-policy.mjs','faith-pol-policy.mjs','item-lore-model.mjs','item-lore-view.mjs','item-lore.css','organisation-editor.mjs','organisation-register.mjs','user-service.html','user-service-entry.mjs','user-service.css','kit-receipt-status.mjs','clan-center.html','clan-center-entry.mjs','clan-center.css','bank-transfer-view.mjs','bank-dashboard.mjs','mail-service-ui.mjs','mail-workspace.css','hosting-control.mjs','internal-mail.mjs','internal-mail.css','election-voting-view.mjs','imperial-charters-view.mjs','proclamations-view.mjs','electoral-roll-view.mjs','election-applications-view.mjs','election-rules.mjs','political-catalog.mjs','menu-ribbons.mjs','council-preview.mjs','politics.mjs','crysknife.mjs','x-news-draft.mjs','terms.html','admin-registration.mjs','mail-signature.mjs','webmail.mjs','git-control.mjs','git-control.css','site-profile.mjs','site-profile.css','servers.html','servers.js','servers.css','pages.mjs','user-page-hero.mjs','commerce-settings.mjs','shop-management.mjs','center-portals.mjs','panel-layout.mjs','embed-size.mjs','dev-request-access.mjs','center-portals.css','overview.mjs','overview.css','page-groups.mjs','ban-register.mjs','moderation-form-response.mjs','ban-record-cards.css','ban-evidence.mjs','ban-evidence.css','ranks.mjs','ranks.css','staff-manual.mjs','luckperms.mjs','community-admin.mjs','native-community.mjs','exchange.mjs','exchange.css','clans.mjs','clan-shop.mjs','house-tailor.mjs','banking.mjs','banking.css','game-ranks.mjs','upgrade-shop.mjs','kit-generator.mjs','kit-design-model.mjs','starter-kit-policy.mjs','kit-equipment-editor.mjs','kit-texture-preview.mjs','kit-generator.css','kit-market.mjs','kit-market.css','kit-cart.mjs','imperial-atelier.mjs','quests.mjs','quests.css','clans.css','clan-request-gate.mjs','clan-directory-model.mjs','clan-directory-view.mjs','clan-profile-panels.mjs','clan-titles.mjs','dynastic-address.mjs','organisation-palette.mjs','organisation-palette-model.mjs','organisation-palette.css','clan-dynasty.mjs','clan-dynasty.css','clan-deed-settings.mjs','dune-date.mjs','organisation-settings.mjs','organisation-settings.css','organisation-dashboard.mjs','organisation-dashboard.css','organisation-activity.mjs','clan-dashboard-data.mjs','quest-rewards.mjs','quest-rewards.css','inventory/inventory-view.mjs','inventory/inventory-mount.mjs','inventory/inventory.css'].includes(file))return new Response('Not found',{status:404});
|
||||
return new Response(request.method==='HEAD'?null:await readFile(new URL('./public/'+file,import.meta.url)),{headers:{'Content-Type':types[file.slice(file.lastIndexOf('.'))],'Cache-Control':'no-store'}});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
18
website/tests/progression-module-routes.test.mjs
Normal file
18
website/tests/progression-module-routes.test.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import test from 'node:test';import assert from 'node:assert/strict';
|
||||
import {createPanel} from '../control-panel/server.mjs';
|
||||
import {LocalD1} from './d1-adapter.mjs';
|
||||
|
||||
test('quest and organisation browser import graphs are served through the real CP asset routes',async()=>{
|
||||
const db=new LocalD1(),app=createPanel(db),origin='https://cp.dunerealms.com',seen=new Set(),queue=['/v2/cp-v2-progression.mjs','/v2/cp-v2-organisation-shell.mjs','/v2/cp-v2-play-workspaces.mjs','/v2/cp-v2-exchange-design.mjs'];
|
||||
try{while(queue.length){const path=queue.shift();if(seen.has(path))continue;seen.add(path);assert(seen.size<400,'Unexpectedly unbounded browser module graph');
|
||||
const response=await app(new Request(origin+path));assert.equal(response.status,200,path);assert.match(response.headers.get('content-type')||'',/javascript/,path);const source=await response.text();
|
||||
for(const match of source.matchAll(/\b(?:from\s*|import\s*(?:\(\s*)?)['"]([^'"]+)['"]/g)){
|
||||
const spec=match[1];if(!spec.startsWith('.'))continue;const url=new URL(spec,origin+path);if(url.origin===origin&&/\.(?:mjs|js)$/.test(url.pathname))queue.push(url.pathname);
|
||||
}
|
||||
}
|
||||
assert(seen.has('/action-cooldown-policy.mjs'));assert(seen.has('/faith-pol-policy.mjs'));
|
||||
for(const path of ['/action-cooldown-policy.mjs','/faith-pol-policy.mjs']){const head=await app(new Request(origin+path,{method:'HEAD'}));assert.equal(head.status,200);assert.equal(await head.text(),'');}
|
||||
const theme=await app(new Request(origin+'/v2/faith-theme.css'));assert.equal(theme.status,200);assert.match(await theme.text(),/new-faith/);
|
||||
for(const path of ['/not-a-public-module.mjs','/node/progression-runtime.mjs'])assert.equal((await app(new Request(origin+path))).status,404);
|
||||
}finally{db.close();}
|
||||
});
|
||||
Loading…
Reference in a new issue

Staff