Connect website to the new DuneRealms Discord community
This commit is contained in:
parent
e48a7ad08d
commit
32f1ab850f
6 changed files with 18 additions and 6 deletions
|
|
@ -5,5 +5,5 @@ for(const file of readdirSync(web).filter(x=>x.endsWith('.html'))){let text=read
|
|||
const base=readFileSync(new URL('index.html',web),'utf8'),header=base.match(/<header>[\s\S]*?<\/header>/)[0].replace(/ aria-current="page"/g,''),menu=base.match(/<nav id="realm-menu"[\s\S]*?<\/nav>/)[0],footer=base.match(/<footer>[\s\S]*?<\/footer>/)[0];
|
||||
const roster=data.staff.length?'<div class="staff-roster">'+data.staff.map(person=>'<article><h3>'+esc(person.displayName)+'</h3><p class="staff-role">'+esc(person.role)+'</p><p>'+esc(person.bio||'')+'</p></article>').join('')+'</div>':'<div class="staff-roster-note"><h3>Public roster awaiting confirmation</h3><p>No individual staff names have been confirmed for publication yet. Use the private support portal for help; this directory will list staff once their public details are supplied.</p></div>';
|
||||
const contributor=data.contributor;
|
||||
const page='<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Staff & Contributors — dunerealms.com</title><meta name="description" content="dunerealms.com staff support, public roster and clearly identified AI development credits."><link rel="icon" href="assets/favicon.svg">'+['styles','pages','minecraft','lore','staff'].map(x=>'<link rel="stylesheet" href="'+x+'.css">').join('')+'<script src="pages.js" defer></script></head><body><a class="skip" href="#staff-content">Skip to content</a>'+header+'<main><section class="page-intro intro-staff"><p class="eyebrow">dunerealms.com / THE ROCKHAVEN COUNCIL</p><h1>Staff & Contributors</h1><p>The people who support the community, and the development work behind the dunes.</p></section>'+menu+'<div id="staff-content" class="staff-content"><section class="staff-help"><div><p class="eyebrow">YOUR PRIVATE LINE TO STAFF</p><h2>Need a hand in the desert?</h2><p>For a ban appeal or account-specific help, open a private ticket under your player profile. Keep personal details in your ticket; public forum topics are visible to everyone.</p></div><div class="staff-help-links"><a class="button gold" href="tickets.html">Open support tickets →</a><a href="profile.html">Your player profile →</a><a href="discord.html">YouSMP Discord community →</a></div></section><section aria-labelledby="roster-heading"><p class="eyebrow">HUMAN COMMUNITY STAFF</p><h2 id="roster-heading">The staff roster</h2>'+roster+'<div class="staff-responsibilities"><article><h3>Player support</h3><p>Help requests and ban appeals are handled through private support tickets. Authorised staff can reply and update a case’s review status.</p></article><article><h3>Community moderation</h3><p>Public forum reports are reviewed by website moderators. Use the report action on the relevant post to provide context.</p></article><article><h3>Server administration</h3><p>Minecraft operators maintain the game server and plugin configuration. In-game rank, elected office and website staff access are separate roles.</p></article></div><p class="staff-small">Staff members can use the <a href="tickets.html?view=staff">support queue</a> after signing in with an authorised account.</p></section><section class="staff-ai" aria-labelledby="ai-heading"><div class="staff-medal"><img src="assets/dune-contributor-medal.svg" alt="Gold desert-style AI contributor medal for 2 of 14"><p>dunerealms.com<br>DEVELOPMENT RECOGNITION</p></div><div class="staff-ai-copy"><p class="eyebrow">AI CONTRIBUTOR · SEPARATE FROM HUMAN STAFF</p><h2 id="ai-heading">'+esc(contributor.name)+'</h2><p class="staff-designation">'+esc(contributor.designation)+'</p><p class="staff-role">'+esc(contributor.kind)+' · '+esc(contributor.platform)+'</p><p>'+esc(contributor.description)+'</p><p class="staff-ai-label">This is an AI contribution credit, not a player account or staff appointment. It grants no game or website permissions and is not a channel for handling support tickets.</p></div></section><section class="staff-contributions"><p class="eyebrow">TRACEABLE PROJECT HISTORY</p><h2>A record of contribution</h2><p>Selected repository changes document the work. These are contribution records rather than newly announced releases.</p><div class="staff-contribution-grid">'+data.contributions.map(x=>'<article><h3>'+esc(x.title)+'</h3><p>'+esc(x.description)+'</p><a href="https://github.com/thomasv6545-glitch/MC/commit/'+esc(x.commit)+'" target="_blank" rel="noopener">Repository change '+esc(x.commit)+' ↗</a></article>').join('')+'</div></section></div></main>'+footer+'<div class="toast" role="status" aria-live="polite"></div></body></html>';
|
||||
const page='<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Staff & Contributors — dunerealms.com</title><meta name="description" content="dunerealms.com staff support, public roster and clearly identified AI development credits."><link rel="icon" href="assets/favicon.svg">'+['styles','pages','minecraft','lore','staff'].map(x=>'<link rel="stylesheet" href="'+x+'.css">').join('')+'<script src="pages.js" defer></script></head><body><a class="skip" href="#staff-content">Skip to content</a>'+header+'<main><section class="page-intro intro-staff"><p class="eyebrow">dunerealms.com / THE ROCKHAVEN COUNCIL</p><h1>Staff & Contributors</h1><p>The people who support the community, and the development work behind the dunes.</p></section>'+menu+'<div id="staff-content" class="staff-content"><section class="staff-help"><div><p class="eyebrow">YOUR PRIVATE LINE TO STAFF</p><h2>Need a hand in the desert?</h2><p>For a ban appeal or account-specific help, open a private ticket under your player profile. Keep personal details in your ticket; public forum topics are visible to everyone.</p></div><div class="staff-help-links"><a class="button gold" href="tickets.html">Open support tickets →</a><a href="profile.html">Your player profile →</a><a href="discord.html">DuneRealms Discord community →</a></div></section><section aria-labelledby="roster-heading"><p class="eyebrow">HUMAN COMMUNITY STAFF</p><h2 id="roster-heading">The staff roster</h2>'+roster+'<div class="staff-responsibilities"><article><h3>Player support</h3><p>Help requests and ban appeals are handled through private support tickets. Authorised staff can reply and update a case’s review status.</p></article><article><h3>Community moderation</h3><p>Public forum reports are reviewed by website moderators. Use the report action on the relevant post to provide context.</p></article><article><h3>Server administration</h3><p>Minecraft operators maintain the game server and plugin configuration. In-game rank, elected office and website staff access are separate roles.</p></article></div><p class="staff-small">Staff members can use the <a href="tickets.html?view=staff">support queue</a> after signing in with an authorised account.</p></section><section class="staff-ai" aria-labelledby="ai-heading"><div class="staff-medal"><img src="assets/dune-contributor-medal.svg" alt="Gold desert-style AI contributor medal for 2 of 14"><p>dunerealms.com<br>DEVELOPMENT RECOGNITION</p></div><div class="staff-ai-copy"><p class="eyebrow">AI CONTRIBUTOR · SEPARATE FROM HUMAN STAFF</p><h2 id="ai-heading">'+esc(contributor.name)+'</h2><p class="staff-designation">'+esc(contributor.designation)+'</p><p class="staff-role">'+esc(contributor.kind)+' · '+esc(contributor.platform)+'</p><p>'+esc(contributor.description)+'</p><p class="staff-ai-label">This is an AI contribution credit, not a player account or staff appointment. It grants no game or website permissions and is not a channel for handling support tickets.</p></div></section><section class="staff-contributions"><p class="eyebrow">TRACEABLE PROJECT HISTORY</p><h2>A record of contribution</h2><p>Selected repository changes document the work. These are contribution records rather than newly announced releases.</p><div class="staff-contribution-grid">'+data.contributions.map(x=>'<article><h3>'+esc(x.title)+'</h3><p>'+esc(x.description)+'</p><a href="https://github.com/thomasv6545-glitch/MC/commit/'+esc(x.commit)+'" target="_blank" rel="noopener">Repository change '+esc(x.commit)+' ↗</a></article>').join('')+'</div></section></div></main>'+footer+'<div class="toast" role="status" aria-live="polite"></div></body></html>';
|
||||
writeFileSync(new URL('staff.html',web),page);console.log('Built staff page and public footer links; human roster entries:',data.staff.length);
|
||||
|
|
|
|||
12
website/tests/discord-community.test.mjs
Normal file
12
website/tests/discord-community.test.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {readFile} from 'node:fs/promises';
|
||||
const code=await readFile(new URL('../worker/community-api.mjs',import.meta.url),'utf8');
|
||||
async function fresh(){return import('data:text/javascript;base64,'+Buffer.from(code+'\n//'+Math.random()).toString('base64'));}
|
||||
test('community verifies the new guild and exposes only public aggregate counts',async()=>{
|
||||
const original=globalThis.fetch;try{globalThis.fetch=async url=>{assert.equal(String(url),'https://discord.com/api/v10/invites/tRgcyZAxzt?with_counts=true');return Response.json({guild:{id:'1567229433033531462',name:'DuneRealms',private:'hidden'},approximate_member_count:2,approximate_presence_count:1});};const {handleCommunity}=await fresh();const body=await(await handleCommunity(new Request('https://www.dunerealms.com/api/community'))).json();assert.deepEqual(body,{status:'connected',name:'DuneRealms',inviteUrl:'https://discord.gg/tRgcyZAxzt',memberCount:2,onlineCount:1});}finally{globalThis.fetch=original;}
|
||||
});
|
||||
test('wrong guild and Discord failure retain the correct invitation without fabricated counts',async()=>{
|
||||
const original=globalThis.fetch;try{for(const response of [Response.json({guild:{id:'old-guild'}}),new Response('',{status:429})]){globalThis.fetch=async()=>response;const{handleCommunity}=await fresh();const r=await handleCommunity(new Request('https://www.dunerealms.com/api/community'));assert.deepEqual(await r.json(),{status:'unavailable',name:'DuneRealms',inviteUrl:'https://discord.gg/tRgcyZAxzt'});assert.equal(r.headers.get('cache-control'),'no-store');}}finally{globalThis.fetch=original;}
|
||||
});
|
||||
test('Discord page uses DuneRealms branding and the new invite',async()=>{const html=await readFile(new URL('../web/discord.html',import.meta.url),'utf8');assert(html.includes('https://discord.gg/tRgcyZAxzt'));assert(!/yousmp|jS4cx7eSGh/i.test(html));});
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
fetch('/api/community').then(r=>r.json()).then(data=>{document.querySelector('#discord-name').textContent=data.name||'YouSMP';if(data.status==='connected'){document.querySelector('#discord-state').textContent='YouSMP Discord · Invite verified';document.querySelector('#discord-members').textContent=data.memberCount.toLocaleString();document.querySelector('#discord-online').textContent=data.onlineCount.toLocaleString()}else document.querySelector('#discord-state').textContent='Discord counts are temporarily unavailable.'}).catch(()=>document.querySelector('#discord-state').textContent='Discord counts are temporarily unavailable.');
|
||||
fetch('/api/community').then(r=>r.json()).then(data=>{document.querySelector('#discord-name').textContent=data.name||'DuneRealms';if(data.status==='connected'){document.querySelector('#discord-state').textContent='DuneRealms Discord · Invite verified';document.querySelector('#discord-members').textContent=data.memberCount.toLocaleString();document.querySelector('#discord-online').textContent=data.onlineCount.toLocaleString()}else document.querySelector('#discord-state').textContent='Discord counts are temporarily unavailable.'}).catch(()=>document.querySelector('#discord-state').textContent='Discord counts are temporarily unavailable.');
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
const communityInvite='jS4cx7eSGh',communityGuild='356127541632958477';let communityCached=null;
|
||||
export async function handleCommunity(request){if(request.method!=='GET')return Response.json({error:'method_not_allowed'},{status:405});if(communityCached&&Date.now()-communityCached.time<300000)return Response.json(communityCached.data,{headers:{'Cache-Control':'public, max-age=60'}});try{const response=await fetch(`https://discord.com/api/v10/invites/${communityInvite}?with_counts=true`,{signal:AbortSignal.timeout(8000)});if(!response.ok)throw Error();const invite=await response.json();if(invite.guild?.id!==communityGuild)throw Error();const data={status:'connected',name:invite.guild.name,inviteUrl:`https://discord.gg/${communityInvite}`,memberCount:Number(invite.approximate_member_count)||0,onlineCount:Number(invite.approximate_presence_count)||0};communityCached={time:Date.now(),data};return Response.json(data,{headers:{'Cache-Control':'public, max-age=60'}})}catch{return Response.json({status:'unavailable',name:'YouSMP',inviteUrl:`https://discord.gg/${communityInvite}`},{headers:{'Cache-Control':'no-store'}})}}
|
||||
const communityInvite='tRgcyZAxzt',communityGuild='1567229433033531462';let communityCached=null;
|
||||
export async function handleCommunity(request){if(request.method!=='GET')return Response.json({error:'method_not_allowed'},{status:405});if(communityCached&&Date.now()-communityCached.time<300000)return Response.json(communityCached.data,{headers:{'Cache-Control':'public, max-age=60'}});try{const response=await fetch(`https://discord.com/api/v10/invites/${communityInvite}?with_counts=true`,{signal:AbortSignal.timeout(8000)});if(!response.ok)throw Error();const invite=await response.json();if(invite.guild?.id!==communityGuild)throw Error();const data={status:'connected',name:invite.guild.name,inviteUrl:`https://discord.gg/${communityInvite}`,memberCount:Number(invite.approximate_member_count)||0,onlineCount:Number(invite.approximate_presence_count)||0};communityCached={time:Date.now(),data};return Response.json(data,{headers:{'Cache-Control':'public, max-age=60'}})}catch{return Response.json({status:'unavailable',name:'DuneRealms',inviteUrl:`https://discord.gg/${communityInvite}`},{headers:{'Cache-Control':'no-store'}})}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff