Restore the published Discover header and its guide pages

This commit is contained in:
unimatrixgit 2026-11-28 19:38:40 +01:00
commit 0358190edf
3 changed files with 442 additions and 4 deletions

View file

@ -1,3 +1,4 @@
import {recipeCatalogue,recipeIcons} from './recipe-catalogue.mjs';
import {applySharedHeader,applySharedFooter,SHARED_FOOTER_SCRIPT,cleanLegacyChromeScript,assertSharedChrome,sharedFooterBrandScript} from './site-chrome.mjs';
import {SHARED_HEADER} from './portal-navigation.mjs';
import {sharedHomepageHeaderScript} from './homepage-header.mjs';
@ -56,7 +57,7 @@ publishExchangeAssets(path.join(root,'control-panel/public'),web);
writeFileSync(path.join(web,'rates-and-charges.html'),applyRealmPageDesign(bankRatesPage(),'rates-and-charges.html'));
let assetCount=0;let assetWriter=null,shardSize=0;const shardNames=[];let shardTemporary;function openShard(){shardTemporary=path.join(dist,'server','.assets-build-'+process.pid);assetWriter=openSync(shardTemporary,'w');writeSync(assetWriter,'export default {');shardSize=0;}function closeShard(){writeSync(assetWriter,'};\n');closeSync(assetWriter);const hash=createHash('sha256').update(readFileSync(shardTemporary)).digest('hex'),name='assets-'+hash+'.mjs',target=path.join(dist,'server',name);if(existsSync(target))unlinkSync(shardTemporary);else renameSync(shardTemporary,target);shardNames.push(name);}function writeAsset(entry){if(shardSize>32*1024*1024){closeShard();openShard();}writeSync(assetWriter,entry);shardSize+=Buffer.byteLength(entry);}const types={'.html':'text/html; charset=utf-8','.css':'text/css; charset=utf-8','.js':'text/javascript; charset=utf-8','.mjs':'text/javascript; charset=utf-8','.json':'application/json; charset=utf-8','.webp':'image/webp','.png':'image/png','.mp4':'video/mp4','.pdf':'application/pdf','.zip':'application/zip','.svg':'image/svg+xml'};
function collect(directory){for(const entry of readdirSync(directory).sort()){const p=path.join(directory,entry);if(statSync(p).isDirectory())collect(p);else{const relative=path.relative(web,p).split(path.sep).join('/');if(/^assets\/seals\/[^/]+-provenance\.txt$/.test(relative)||/^assets\/organisation-deed(?:s)?-[a-z0-9-]+\.png$/.test(relative))continue;const type=types[path.extname(entry)];if(!type)throw Error('Unexpected asset: '+entry);const bytes=readFileSync(p);const payload=relative.endsWith('.html')?Buffer.from(preparePublicHtml(bytes.toString('utf8'),relative)):relative==='realm-design.js'?Buffer.from(sharedRealmRuntime):relative==='realm-design.css'?sharedRealmCSS:relative==='portal-navigation.js'?Buffer.from(SHARED_FOOTER_SCRIPT+withRealmSwitch(withCanonicalMenu(withMenuBadges(cleanLegacyChromeScript(bytes.toString('utf8')))))+sharedRealmRuntime):relative==='portal-navigation.css'?Buffer.concat([bytes,Buffer.from(HOUSE_STYLE_CSS+REALM_SWITCH_CSS+readFileSync(path.join(web,"realm-comfort.css"),"utf8"))]):bytes;writeAsset(JSON.stringify('/'+relative)+':['+JSON.stringify(type)+','+JSON.stringify(payload.toString('base64'))+'],');assetCount++}}}
mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.openai'),{recursive:true});const workerTemporary=path.join(dist,'server/index.js.build-'+process.pid);process.once('exit',()=>{if(existsSync(workerTemporary))try{unlinkSync(workerTemporary);}catch{}});openShard();collect(web);const buildCommit=process.env.GITHUB_SHA;if(buildCommit&&/^[0-9a-f]{40}$/.test(buildCommit)){writeAsset(JSON.stringify('/ci-build.json')+':'+JSON.stringify(['application/json; charset=utf-8',Buffer.from(JSON.stringify({commit:buildCommit})).toString('base64')])+',');}closeShard();
mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.openai'),{recursive:true});const workerTemporary=path.join(dist,'server/index.js.build-'+process.pid);process.once('exit',()=>{if(existsSync(workerTemporary))try{unlinkSync(workerTemporary);}catch{}});openShard();collect(web);const recipes=recipeCatalogue();for(const [url,image] of recipeIcons(recipes)){writeAsset(JSON.stringify(url)+":"+JSON.stringify(["image/png",image.toString("base64")])+",");assetCount++;}writeAsset(JSON.stringify('/recipe-catalogue.json')+':['+JSON.stringify(types['.json'])+','+JSON.stringify(Buffer.from(JSON.stringify(recipes)).toString('base64'))+'],');assetCount++;const buildCommit=process.env.GITHUB_SHA;if(buildCommit&&/^[0-9a-f]{40}$/.test(buildCommit)){writeAsset(JSON.stringify('/ci-build.json')+':'+JSON.stringify(['application/json; charset=utf-8',Buffer.from(JSON.stringify({commit:buildCommit})).toString('base64')])+',');}closeShard();
let api=['public-item-metadata.mjs','feed-api.mjs','exchange-api.mjs','forum-api.mjs','community-api.mjs','portal-api.mjs'].map(file=>readFileSync(path.join(root,'worker',file),'utf8').replace(/^import .*;$/gm,'').replace(/export /g,'')).join('\n');let runtime=readFileSync(path.join(root,'worker/runtime.mjs'),'utf8').replace(/^import .*;$/gm,'');
writeFileSync(path.join(dist,'server/index.js'),shardNames.map((name,i)=>'import DATA'+i+' from '+JSON.stringify('./'+name)+';').join('\n')+'\nconst ASSET_DATA=Object.assign({},'+shardNames.map((_,i)=>'DATA'+i).join(',')+');\n'+api+'\n'+runtime);cpSync(path.join(root,'.openai/hosting.json'),path.join(dist,'.openai/hosting.json'));console.log('Built Worker with',assetCount,'embedded website assets');
if(existsSync(path.join(root,'drizzle')))cpSync(path.join(root,'drizzle'),path.join(dist,'.openai/drizzle'),{recursive:true});

View file

@ -1,5 +1,5 @@
export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Discover","https://wiki.dunerealms.com/","nav-manual-v2.webp"],["Community","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Trade","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["The realm","https://www.dunerealms.com/realm-hub.html","nav-clan-v2.webp"],["My Account","https://cp.dunerealms.com/","nav-account-v2.webp"]];
export const MAIN_MENU_GROUPS={"Discover":[["Explore worlds","https://www.dunerealms.com/#worlds","nav-home-v2.webp"],["New player guide","https://wiki.dunerealms.com/","nav-manual-v2.webp"]],"Community":[["Forums","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["People of the realm","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["News & updates","https://www.dunerealms.com/news-archive.html","nav-boards-v2.webp"],["Events","https://cp.dunerealms.com/#events/events-calendar","nav-home-v2.webp"],["Latest bans & appeals","https://www.dunerealms.com/community-records.html","nav-support-v2.webp"]],"Trade":[["Player Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Equipment & kits","https://www.dunerealms.com/exchange.html?type=kits","imperial-atelier-v1.webp"],["Imperial Postbank","https://cp.dunerealms.com/#bank/bank-overview","imperial-postbank-v2.png"],["Community shop","https://shop.dunerealms.com/","nav-shop-v1.webp"]],"The realm":[["Clans","https://www.dunerealms.com/realm-hub.html#clan","nav-clan-v2.webp"],["Companies","https://www.dunerealms.com/realm-hub.html#company","exchange-company-jobs-v1.png"],["Politics & offices","https://www.dunerealms.com/realm-hub.html#politics","seals/office-landsraad.png"]],"My Account":[["My dashboard","https://cp.dunerealms.com/","nav-account-v2.webp"],["Mail","https://cp.dunerealms.com/#post/mail-inbox","nav-support-v2.webp"],["Quests","https://clans.dunerealms.com/#quests/quests","exchange-quests-v1.png"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Staff sign in","https://cp.dunerealms.com/#bureau/user-management","nav-staff-v2.webp"]]};
export const MAIN_MENU_GROUPS={"Discover":[["Explore worlds","https://www.dunerealms.com/#worlds","nav-home-v2.webp"],["Let’s Play Manual","https://www.dunerealms.com/lets-play.html","nav-manual-v2.webp"],["Imperial Recipe Book","https://www.dunerealms.com/imperial-recipe-book.html","nav-manual-v2.webp"]],"Community":[["Forums","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["People of the realm","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["News & updates","https://www.dunerealms.com/news-archive.html","nav-boards-v2.webp"],["Events","https://cp.dunerealms.com/#events/events-calendar","nav-home-v2.webp"],["Latest bans & appeals","https://www.dunerealms.com/community-records.html","nav-support-v2.webp"]],"Trade":[["Player Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Equipment & kits","https://www.dunerealms.com/exchange.html?type=kits","imperial-atelier-v1.webp"],["Imperial Postbank","https://cp.dunerealms.com/#bank/bank-overview","imperial-postbank-v2.png"],["Community shop","https://shop.dunerealms.com/","nav-shop-v1.webp"]],"The realm":[["Clans","https://www.dunerealms.com/realm-hub.html#clan","nav-clan-v2.webp"],["Companies","https://www.dunerealms.com/realm-hub.html#company","exchange-company-jobs-v1.png"],["Politics & offices","https://www.dunerealms.com/realm-hub.html#politics","seals/office-landsraad.png"]],"My Account":[["My dashboard","https://cp.dunerealms.com/","nav-account-v2.webp"],["Mail","https://cp.dunerealms.com/#post/mail-inbox","nav-support-v2.webp"],["Quests","https://clans.dunerealms.com/#quests/quests","exchange-quests-v1.png"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Staff sign in","https://cp.dunerealms.com/#bureau/user-management","nav-staff-v2.webp"]]};
export const menuLeafLinks=rows=>rows.flatMap(row=>Array.isArray(row[3])?menuLeafLinks(row[3]):[row]);
export const ALL_MENU_LINKS=[...MAIN_MENU,...menuLeafLinks(Object.values(MAIN_MENU_GROUPS).flat())].filter((row,i,rows)=>rows.findIndex(r=>r[1]===row[1])===i);
export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';const kits=u.pathname==='/exchange.html'&&/^kits(?:-(?:clan|office|player|legendary))?$/.test(u.searchParams.get('type')||'');return u.origin+(u.pathname==='/index.html'?'/':u.pathname)+(kits?'?type=kits':'');}

View file

@ -0,0 +1,120 @@
import { existsSync, readdirSync, readFileSync } from 'node:fs';
const source = new URL('../../DuneRealmsGUI/executablecrafting/recipes/', import.meta.url);
const smoker = new URL('../../JarvisConnector/src/main/resources/survival-food-recipes.json', import.meta.url);
const repairParts = new URL('../../DuneTerrain/src/main/resources/starter-repair-parts.json', import.meta.url);
const arrakisItems = new URL('../../DuneRealmsGUI/executableitems/arrakis/', import.meta.url);
const vanillaFoodSaturation = { beef: 1.8, enchanted_golden_apple: 9.6 };
const itemSummaries = {
bio_paste: 'A concentrated blend of Spice Paste and Rehydrated Steak. Process it in a smoker to make Spice Bread.',
chukka_cooked_meat: 'Cooked meat from an Arrakis Chukka. Eat it to restore hunger and saturation.',
contaminated_spice_block: 'A block made by packing nine portions of contaminated spice together.',
dunesponge: 'A spice-treated sponge that can pick up one water source and place it elsewhere on Arrakis.',
jerboa_cooked_meat: 'Cooked meat from an Arrakis Jerboa. Eat it to restore hunger and saturation, or use it in Jerboa Stew.',
jerboa_hide_paste: 'Prepared Jerboa hide. Smoke it to make Jerboa Leather, or combine it with Melange to make a Weirding Module.',
jerboa_stew: 'A prepared meal made with Jerboa meat. Eat it to restore hunger and saturation.',
farmers_bucket: 'A one-use bucket for placing water on Arrakis.',
rehydrated_steak: 'Meat rehydrated with water. Eat it or combine it with Spice Paste to make Bio Paste.',
spice_cake: 'A finished spice food. Eat it to restore hunger and saturation.',
spice_dough: 'A prepared spice mixture used to make Spice Cake.',
spice_paste: 'A concentrated mix of Melange Spice and acacia. Use it to prepare Bio Paste.',
jerboa_egg: 'A throwable Weirding Module. It produces a harmful splash and smoke when it strikes a target.',
jerboa_leather: 'Leather made by processing Jerboa Hide Paste in a smoker.',
spice_bread: 'Food made by smoking Bio Paste. Eat it to restore hunger and saturation.',
'starter-repair-plate-v1': 'A starter equipment repair part used to restore protective plates.',
'starter-binding-patch-v1': 'A leather repair part used to patch worn stillsuit fabric.',
'starter-tool-fitting-v1': 'A copper repair part used to replace worn equipment fittings.',
'starter-calibration-piece-v1': 'A quartz repair part used to calibrate repaired suit systems.',
spice_block: 'Nine portions of Melange compressed into one block for storage and transport.',
smuggled_spice_block: 'Nine portions of Smuggled Spice compressed into one block. The block retains its smuggled origin.',
crafted_elytra: 'A pair of wings worn in the chest slot. Use them to glide.',
jerboa_water_vial: 'A portable supply of water. Use it in recipes or to fill a cauldron on Arrakis.',
water_of_life: 'A rare result of brewing a Blood Vial with spice. Drinking it can grant temporary combat effects, with a 1% chance of death.',
spice_boosted_potion: 'An imported potion enhanced with spice on Arrakis. Drink it for stronger effects where the rounded effect level increases.',
};
const foodIds = new Set(['chukka_cooked_meat', 'jerboa_cooked_meat', 'jerboa_stew', 'rehydrated_steak', 'spice_bread', 'spice_cake']);
const ecologyIcons = new URL('../../DuneRealmsGUI/ecology/food-icons/', import.meta.url);
function entry(id, name, material = id, custom = false) {
return { id, name, material, custom };
}
function item(command) {
const material = command.match(/^minecraft:([a-z0-9_]+)/)?.[1];
if (!material) throw Error('Unrecognised recipe item ' + command);
const custom = command.match(/"executableitems:ei-id":"([^"]+)"/)?.[1];
const name = command.match(/minecraft:custom_name=\{"text":"([^"]+)"/)?.[1]
?? material.replaceAll('_', ' ').replace(/\b\w/g, letter => letter.toUpperCase());
const result = entry(custom ?? material, name, material, Boolean(custom));
const quality = command.match(/"dunerealms:quality":"([a-z_]+)"/)?.[1];
const mark = command.match(/"dunerealms:equipment_mark":"(\d+)"/)?.[1];
const lore = command.match(/minecraft:lore=(\[[^\]]*\])/);
if (quality) result.quality = quality;
if (mark) result.equipmentMark = Number(mark);
if (lore) result.lore = JSON.parse(lore[1]).map(line => line.text).filter(line => !/ \| MK /.test(line));
return result;
}
export function recipeCatalogue() {
const recipes = [];
const spice = entry('spice', 'Melange Spice', 'orange_dye', true);
const requiresSpice = new Set(['dunesponge.yml', 'spice_paste.yml', 'spice_dough.yml', 'weirding_module.yml']);
for (const file of readdirSync(source).filter(name => name.endsWith('.yml')).sort()) {
const recipe = JSON.parse(readFileSync(new URL(file, source), 'utf8'));
const station = recipe.recipeType === 'FURNACE' ? 'Furnace' : 'Crafting table';
if (recipe.recipeType !== 'FURNACE' && recipe.typeOfCraftingTableRecipe !== 'SHAPELESS') {
throw Error('Unsupported recipe layout in ' + file);
}
const inputs = Object.entries(recipe)
.filter(([key]) => /^input\d+$/.test(key))
.sort(([a], [b]) => Number(a.slice(5)) - Number(b.slice(5)))
.map(([, command]) => command === 'minecraft:orange_dye' && requiresSpice.has(file) ? spice : item(command));
recipes.push({ id: file.slice(0, -4), station, inputs, output: item(recipe.result), amount: recipe.resultAmount ?? 1 });
}
for (const recipe of JSON.parse(readFileSync(smoker, 'utf8')).smoker) {
const output = recipes.find(entry => entry.output.id === recipe.result)?.output
?? entry(recipe.result, recipe.result.replaceAll('_', ' ').replace(/\b\w/g, letter => letter.toUpperCase()), recipe.result === 'spice_bread' ? 'bread' : 'leather', true);
recipes.push({ id: recipe.id + '-smoker', station: 'Smoker', inputs: [item(recipe.inputCommand)], output, amount: recipe.amount });
}
const smuggled = entry('smuggled_spice', 'Smuggled Spice', 'orange_dye', true);
const crafting = 'Crafting table';
for (const part of JSON.parse(readFileSync(repairParts, 'utf8'))) {
const ingredient = item(part.material.toLowerCase());
recipes.push({ id: part.id, station: crafting, inputs: [ingredient, spice], output: { ...entry(part.id, part.name, ingredient.material, true), quality: "uncommon", equipmentMark: 1, lore: [part.purpose] }, amount: 1, notes: part.purpose + ' Genuine Melange or Smuggled Spice works.' });
}
for (const [id, name, ingredient] of [['spice_block', 'Spice Block', spice], ['smuggled_spice_block', 'Smuggled Spice Block', smuggled]]) {
recipes.push({ id, station: crafting, inputs: Array(9).fill(ingredient), output: entry(id, name, 'dried_kelp_block', true), amount: 1, shaped: true, notes: 'Fill all nine slots with the same kind of genuine spice.' });
}
const flight = ['netherite_ingot', 'phantom_membrane', 'netherite_ingot', 'iron_ingot', 'diamond', 'iron_ingot', 'copper_ingot', 'phantom_membrane', 'copper_ingot'].map(material => item('minecraft:' + material));
recipes.push({ id: 'crafted_elytra', station: crafting, inputs: flight, output: entry('crafted_elytra', 'Elytra', 'elytra', true), amount: 1, shaped: true });
const water = entry('jerboa_water_vial', 'Vial of Water', 'potion', true);
const blood = entry('blood_vial', 'Blood Vial', 'potion', true);
const life = entry('water_of_life', 'Water of Life', 'potion', true);
recipes.push({ id: 'imported_water_vials', station: crafting, inputs: [entry('imported_water_bucket', 'Imported Water Bucket', 'water_bucket')], output: water, amount: 6, notes: 'Craft on Arrakis using a water bucket sourced from another world.' });
const brew = 'On Arrakis, brew genuine spice with a Blood Vial. Per vial: 50% Vial of Water, 5% Water of Life, 45% no output.';
recipes.push({ id: 'brew_water_vial', station: 'Brewing stand', inputs: [blood, spice], output: water, amount: 1, possible: true, notes: brew });
recipes.push({ id: 'brew_water_of_life', station: 'Brewing stand', inputs: [blood, spice], output: life, amount: 1, possible: true, notes: brew + ' Drinking Water of Life has a 1% fatal chance.' });
recipes.push({ id: 'spice_boosted_potion', station: 'Brewing stand', inputs: [entry('imported_potion', 'Imported Potion', 'potion'), spice], output: entry('spice_boosted_potion', 'Spice-Boosted Potion', 'potion', true), amount: 1, notes: 'Brew once on Arrakis. Effect levels are multiplied by 1.25 and rounded to the nearest whole level; duration stays the same.' });
for (const recipe of recipes) {
if (foodIds.has(recipe.output.id)) {
const definition = JSON.parse(readFileSync(new URL(recipe.output.id + '.yml', arrakisItems), 'utf8'));
const material = definition.material.toLowerCase();
const saturation = definition.foodFeatures?.saturation ?? vanillaFoodSaturation[material];
if (!Number.isFinite(saturation)) throw Error('Missing saturation for ' + recipe.output.id);
recipe.output = { ...recipe.output, material, stats: [{ label: 'Saturation per serving', value: '+' + saturation + ' points' }] };
}
const summary = itemSummaries[recipe.output.id];
if (!summary) throw Error('Missing item summary for ' + recipe.output.id);
recipe.output = { ...recipe.output, summary };
for (const ingredient of [...recipe.inputs, recipe.output]) {
if (ingredient.custom && existsSync(new URL(ingredient.id + '.png', ecologyIcons))) ingredient.icon = '/recipe-icons/' + ingredient.id + '.png';
}
}
return recipes;
}
export function recipeIcons(recipes) {
const icons = new Set(recipes.flatMap(recipe => [...recipe.inputs, recipe.output]).map(item => item.icon).filter(Boolean));
return [...icons].map(path => [path, readFileSync(new URL(path.split('/').at(-1), ecologyIcons))]);
}