forked from unimatrix/web
59 lines
7.5 KiB
JavaScript
59 lines
7.5 KiB
JavaScript
import {SHARED_HEADER} from './portal-navigation.mjs';
|
||
const a='https://www.dunerealms.com/assets/';
|
||
export const REALM_PAGE_DESIGNS=Object.freeze(Object.fromEntries([
|
||
['clan-center-index','Clans & quests','Your organisation','Your household, its people, equipment and adventures.','nav-clan-v2.webp'],
|
||
['company-center-index','Company workspace','Your organisation','Your company, its members, trade and shared plans.','guild.webp'],
|
||
['login','Welcome back','My account','Sign in to your DuneRealms account and continue your journey.','nav-account-full-v2.webp'],
|
||
['passport','Citizen passport','People of the realm','Identity, honours and the story of a citizen of the realm.','nav-account-full-v2.webp'],
|
||
['clan','Clan register','Clans & households','The household, its people and its place in the realm.','nav-clan-v2.webp'],
|
||
['account-bans','Account ban register','Community records','Review account restrictions and the available appeal route.','portal-ban-gate-v1.png'],
|
||
['account','Your account','My account','Your identity, correspondence and services in one place.','nav-account-full-v2.webp'],
|
||
['admin','Staff workspace','Staff','Manage the realm through your authorised staff services.','nav-staff-v2.webp'],
|
||
['api','Developer portal','DuneForge','Documentation and service references for DuneRealms developers.','nav-manual-v2.webp'],
|
||
['armoury','The Rockhaven Armoury','Equipment','Discover equipment, kit designs and their place in the realm.','items/office_water.png'],
|
||
['arrakis','Arrakduin','Explore the worlds','The desert world: spice, survival and a story beneath the sands.','gui/guild-world-arrakis-v1.png'],
|
||
['bans','Network ban register','Community records','Public moderation records and the path to an appeal.','portal-ban-gate-v1.png'],
|
||
['corrino-group','Corporate register','Companies','Discover registered enterprises, their people and their work.','guild.webp'],
|
||
['diplomacy','Imperial diplomacy','The realm','Houses, diplomatic relations and the offices of the Imperium.','seals/office-landsraad.png'],
|
||
['discord','Around the campfire','Community','Meet the community, make plans and carry the conversation onward.','nav-discord-v2.webp'],
|
||
['donate','Support the caravan','Community','Ways to support the community and its next chapter.','nav-account-v2.webp'],
|
||
['dunemark-collection','The Dunemark Collection','Imperial Postbank','Explore the illustrated notes and the history behind their designs.','imperial-postbank-v2.png'],
|
||
['equipment','Equipment of the realm','Equipment','Read equipment details, qualities and upgrade marks.','items/office_water.png'],
|
||
['forums','Community boards','Community','Conversations, ideas and stories from across the realm.','nav-boards-v2.webp'],
|
||
['government','Houses & offices','The realm','Find the current offices, elections and political workspaces.','seals/office-landsraad.png'],
|
||
['install','Connect to the realm','Player guide','Prepare your client and find the current downloads.','nav-home-v2.webp'],
|
||
['item','Imperial item register','Exchange','Inspect an item’s artwork, lore, quality, mark and published details.','nav-exchange-v2.webp'],
|
||
['kits','The Imperial Tailor','Exchange','Explore published organisation equipment sets and their contents.','items/office_water.png'],
|
||
['link-account','Link your game account','My account','Connect your website identity to your Minecraft account.','nav-account-full-v2.webp'],
|
||
['manual','The Field Manual','Player guide','Your guide to the worlds, their services and your first steps.','nav-manual-v2.webp'],
|
||
['news-archive','The Imperial Dispatch','Community','News, milestones and updates from across DuneRealms.','nav-discord-v2.webp'],
|
||
['news','The Compact Dispatch','Community','Read the latest dispatch and follow the realm’s story.','nav-discord-v2.webp'],
|
||
['patch-note-1-0-0-7','Realm update','News & updates','Release details and changes to the DuneRealms experience.','nav-manual-v2.webp'],
|
||
['patch-notes','Release journal','News & updates','Browse published updates and the changes they brought.','nav-manual-v2.webp'],
|
||
['portal','Your journey','My account','Choose the next step in your DuneRealms story.','nav-account-full-v2.webp'],
|
||
['profile','Citizen profile','People of the realm','Your public identity, honours and story.','nav-account-full-v2.webp'],
|
||
['races','Choose your House','Explore the worlds','Discover the Houses and the worlds they call home.','nav-clan-v2.webp'],
|
||
['rates-and-charges','Rates & charges','Imperial Postbank','Published banking tariffs and service conditions.','imperial-postbank-v2.png'],
|
||
['shop-oscommerce','Imperial Heralds','Community shop','Ceremonial pieces and ways to support the community.','nav-exchange-full-v2.webp'],
|
||
['shop','Imperial Heralds','Community shop','Ceremonial pieces and ways to support the community.','nav-exchange-full-v2.webp'],
|
||
['smugglers','Beyond the official routes','Careers & stories','Discover the smuggler’s path through the realm.','nav-exchange-v2.webp'],
|
||
['staff','People of the realm','Community','Meet the people who keep the caravan moving.','nav-staff-v2.webp'],
|
||
['tickets','The Petition Hall','Support','Open a request, follow its progress and find help.','nav-support-v2.webp'],
|
||
['wiki','Our world & its story','The Dunopedia','Read the world guide, project background and unofficial-project information.','nav-manual-v2.webp']
|
||
].map(([id,title,section,description,icon])=>[id+'.html',Object.freeze({title,section,description,icon})])));
|
||
const esc=s=>s.replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||
const designHead='<link rel="stylesheet" data-realm-design href="https://www.dunerealms.com/realm-design.css?v=every-page-1"><script src="https://www.dunerealms.com/realm-design.js?v=every-page-1" defer></script>';
|
||
export function applyRealmPageDesign(html,file){
|
||
if(!/<link\b[^>]*data-realm-design/.test(html))html=html.replace('</head>',designHead+'</head>');
|
||
if(file==='manual.html')html=html.replaceAll('https://www.dunerealms.com/realm-design','/realm-design');
|
||
const page=REALM_PAGE_DESIGNS[file];if(!page)return html;
|
||
if(html.includes('data-realm-layout="2"'))return html;
|
||
html=html.replace(/<section class="dr-page-banner"[^>]*>[\s\S]*?<\/section>/g,'').replace(/\sdata-realm-page="[^"]*"/g,'');
|
||
html=html.replace(/<html\b([^>]*)>/,(_,attrs)=>'<html'+attrs.replace(/\sdata-dune-(?:portal-preview|realm-shell)(?:="[^"]*")?/g,'')+' data-dune-realm-shell>');
|
||
html=html.replace(/<body\b([^>]*)>/,(_,attrs)=>'<body'+(/class="/.test(attrs)?attrs.replace(/class="([^"]*)"/,(_,classes)=>'class="'+classes+' dr-design dr-interior"'):attrs+' class="dr-design dr-interior"')+' data-realm-layout="2" data-realm-page="'+file.replace('.html','')+'">');
|
||
const header=html.search(/<header\b/),main=html.search(/<main\b/);html=header>=0&&(main<0||header<main)?html.replace(/<header\b[^>]*>[\s\S]*?<\/header>/,SHARED_HEADER):html.replace(/<body\b[^>]*>/,m=>m+SHARED_HEADER);
|
||
const banner='<section class="dr-page-banner" aria-label="'+esc(page.title)+'"><img src="'+a+page.icon+'" alt="" width="80" height="92"><div><nav class="dr-breadcrumb" aria-label="Breadcrumb"><a href="https://www.dunerealms.com/">DuneRealms</a><span>/ '+esc(page.section)+'</span></nav><h1>'+esc(page.title)+'</h1><p>'+esc(page.description)+'</p></div></section>';
|
||
if(/<main\b/.test(html))html=html.replace(/<main\b([^>]*)>/,(_,attrs)=>'<main'+(/class="/.test(attrs)?attrs.replace(/class="([^"]*)"/,(_,classes)=>'class="'+classes+' dr-page-content"'):attrs+' class="dr-page-content"')+'>');
|
||
html=html.replace(SHARED_HEADER,SHARED_HEADER+banner);
|
||
return html;
|
||
}
|

Staff