forked from unimatrix/web
Add Company CP, office decision menus and clan directory cards
This commit is contained in:
parent
4ccea57a01
commit
3263573f2f
3 changed files with 754 additions and 36 deletions
|
|
@ -1,5 +1,5 @@
|
|||
export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://www.dunerealms.com/shop.html","nav-exchange-full-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/kits.html","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];
|
||||
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://www.dunerealms.com/shop.html';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);}
|
||||
export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://www.dunerealms.com/shop.html","nav-exchange-full-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/kits.html","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Companies","https://corp.dunerealms.com/","guild.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];
|
||||
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://www.dunerealms.com/shop.html';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+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);}
|
||||
export function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}};
|
||||
for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);}
|
||||
for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from pathlib import Path
|
|||
import os
|
||||
import sys
|
||||
source=Path(__file__).resolve().parents[1]/'ops'
|
||||
target=Path('/home/dunerealms/htdocs/clans.dunerealms.com')
|
||||
target=Path('/var/www/dunerealms-clans')
|
||||
files={'index.html':(source/'clan-center-index.html').read_bytes(),'clan-shell.js':(source/'clan-cp-shell.js').read_bytes()}
|
||||
if '--apply' not in sys.argv:print('Plan: publish separate Clan CP shell');sys.exit(0)
|
||||
if os.geteuid()!=0:raise RuntimeError('Deployment operator required')
|
||||
|
|
|
|||
24
website/scripts/publish-company-cp.py
Normal file
24
website/scripts/publish-company-cp.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"""Publish the Company CP outer shell from a verified release, without changing DNS or TLS."""
|
||||
from pathlib import Path
|
||||
import os
|
||||
import pwd
|
||||
import sys
|
||||
source = Path(__file__).resolve().parents[1] / 'ops'
|
||||
target = Path('/var/www/dunerealms-corp')
|
||||
files = {'index.html': 'company-center-index.html', 'company-shell.js': 'company-cp-shell.js', 'company-shell.css': 'company-shell.css'}
|
||||
if '--apply' not in sys.argv:
|
||||
print('Plan: publish Company CP to its dedicated host directory')
|
||||
sys.exit(0)
|
||||
if os.geteuid() != 0:
|
||||
raise RuntimeError('Deployment operator required')
|
||||
owner = pwd.getpwnam('dunerealms')
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
os.chown(target, owner.pw_uid, owner.pw_gid)
|
||||
for name, origin in files.items():
|
||||
path = target / name
|
||||
temporary = path.with_name(name + '.company-new')
|
||||
temporary.write_bytes((source / origin).read_bytes())
|
||||
temporary.chmod(0o644)
|
||||
os.chown(temporary, owner.pw_uid, owner.pw_gid)
|
||||
os.replace(temporary, path)
|
||||
print('Published Company CP outer shell')
|
||||
Loading…
Reference in a new issue

Staff