Message-matched social previews: angle links rewrite og/twitter cards server-side with hook-frame images (no RM Circle branding before the click)

This commit is contained in:
martbost
2026-08-22 11:58:33 -05:00
parent 8869150312
commit 9c21cc3c99
5 changed files with 24 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

+24
View File
@@ -819,6 +819,30 @@ const server=http.createServer(async(req,res)=>{
if(pathname==='/')file=path.join(PUBLIC_DIR,'index.html');else if(pathname==='/start'||pathname==='/start/')file=path.join(PUBLIC_DIR,'start.html');else if(pathname==='/training'||pathname==='/training/')file=path.join(PUBLIC_DIR,'training.html');else if(pathname==='/admin'||pathname==='/admin/')file=path.join(PUBLIC_DIR,'admin.html');else if(pathname==='/my'||pathname==='/my/'||/^\/my\/\d{1,15}$/.test(pathname))file=path.join(PUBLIC_DIR,'my.html');else if(pathname==='/contract'||pathname==='/contract/')file=path.join(PUBLIC_DIR,'contract.html');else if(pathname==='/disclaimer'||pathname==='/disclaimer/')file=path.join(PUBLIC_DIR,'disclaimer.html');else if(pathname==='/how-pay-works'||pathname==='/how-pay-works/')file=path.join(PUBLIC_DIR,'how-pay-works.html');else if(pathname==='/tools'||pathname==='/tools/')file=path.join(PUBLIC_DIR,'tools.html');else if(pathname==='/fast-start'||pathname==='/fast-start/')file=path.join(PUBLIC_DIR,'fast-start.html');else if(pathname==='/weekly-rhythm'||pathname==='/weekly-rhythm/')file=path.join(PUBLIC_DIR,'weekly-rhythm.html');else if(pathname==='/direct-join'||pathname==='/direct-join/'){if(!getSession(req)){res.writeHead(302,{Location:'/admin'});return res.end();}file=path.join(ROOT,'private','direct-join.html');}else if(pathname==='/join-now'||pathname==='/join-now/'){if(!getConfig().dappFallbackPublic){res.writeHead(302,{Location:'/start'});return res.end();}file=path.join(ROOT,'private','join-now.html');}else if(/^\/join\/\d{1,15}$/.test(pathname))file=path.join(PUBLIC_DIR,'join.html');else if(pathname==='/join'||pathname==='/join/'){res.writeHead(302,{Location:'/join-now'});return res.end();}else{
const safe=path.normalize(pathname).replace(/^([.][.][/\\])+/, '').replace(/^[/\\]+/,'');file=path.join(PUBLIC_DIR,safe);if(!file.startsWith(PUBLIC_DIR))file='';
}
// angle links get message-matched social previews (crawlers don't run JS)
if(file&&file.endsWith('join.html')){
const av=new URL(req.url,'http://x').searchParams.get('v');
const OG={
pocket:{t:'You already spent it this week.',d:'The pocket-change illusion, called out in 105 seconds. Watch.',i:'og-angle-pocket.jpg'},
phone:{t:"Everybody's making money on your phone. Except you.",d:'90 seconds that flips it. Watch.',i:'og-angle-phone.jpg'},
two:{t:"You know two people. That's all this takes.",d:'The #1 excuse, retired in 90 seconds. Watch.',i:'og-angle-two.jpg'},
graveyard:{t:'Your side-hustle graveyard has enough tenants.',d:"This one's built different. 90 seconds. Watch.",i:'og-angle-graveyard.jpg'}
};
const a=OG[av];
if(a){
let html=fs.readFileSync(file,'utf8');
const esc=x=>x.replace(/&/g,'&').replace(/"/g,'"');
html=html
.replace(/<meta property="og:title" content="[^"]*">/,`<meta property="og:title" content="${esc(a.t)}">`)
.replace(/<meta property="og:description" content="[^"]*">/,`<meta property="og:description" content="${esc(a.d)}">`)
.replace(/<meta property="og:image" content="[^"]*">/,`<meta property="og:image" content="https://rmcircle.team/v/${a.i}">`)
.replace(/<meta property="og:site_name" content="[^"]*">/,'')
.replace(/<meta name="twitter:title" content="[^"]*">/,`<meta name="twitter:title" content="${esc(a.t)}">`)
.replace(/<meta name="twitter:description" content="[^"]*">/,`<meta name="twitter:description" content="${esc(a.d)}">`)
.replace(/<meta name="twitter:image" content="[^"]*">/,`<meta name="twitter:image" content="https://rmcircle.team/v/${a.i}">`);
return send(res,200,html,{'Content-Type':'text/html; charset=utf-8','Cache-Control':'public, max-age=300'});
}
}
if(file&&staticFile(req,res,file))return;return staticFile(req,res,path.join(PUBLIC_DIR,'404.html'),404);
}catch(e){console.error(e);json(res,500,{error:'Internal server error'});}
});