// Promo kit (the VBB / ViralAdSource pattern): the ONE place the YourProgramBuilder creatives and swipe copy live. Published as a // public JSON feed, GET /api/promo-kit?u=, read by /promote and by InstantAdPay's promo center // ("Network sites"). Facts come from config.js. Copy rules: a directory of programs, not income; nothing is promised; no em dashes; // no earnings caps; wallets = "SafePal or any other crypto wallet". // Creatives: public/art/kit/ypb--.png, rendered by tools/kit-art.mjs (neutral names: no size tokens, no ad words). 'use strict'; const fs = require('fs'); const path = require('path'); const C = require('./config').get(); const netsites = require('./netsites'); const KIT_DIR = path.join(__dirname, 'public', 'art', 'kit'); const SHAPES = { tile: [125, 125, 'Square button'], strip: [468, 60, 'Strip'], leader: [728, 90, 'Leaderboard'], box: [300, 250, 'Box'], panel: [336, 280, 'Large box'], tower: [160, 600, 'Skyscraper'], social: [1200, 630, 'Social share'], square: [1080, 1080, 'Square post'] }; const ANGLES = { plant: 'Bring your program', grow: 'Save your ID, grow the bed', spot: 'Spotlight a packet' }; function copy() { return { lines: [ 'Bring your program. The network grows it. Plant it free in the Seed Bed and let members save their IDs. {{LINK}}', 'One place to find the programs your network actually joins, with your own referral link first for everyone you bring. {{LINK}}', 'YourProgramBuilder: plant a program, save your IDs, and see which ones grow into the Crypto Team Build Network builder. {{LINK}}' ], headlines: ['Bring your program. The network grows it.', 'Plant it free in the Seed Bed', 'Your link first, for everyone you bring', 'Watch a program sprout'], email: { subject: 'Plant your program in the Seed Bed', body: ['Hi,', '', 'YourProgramBuilder is the network\'s Seed Bed. Plant a program you like (its name and your referral link), and members across the network save their own ID in it.', '', 'Anyone who comes through you sees your link first. When ' + C.reviewSaves + ' members have saved an ID, the program goes to review for the Crypto Team Build Network builder, and every saved ID moves with it.', '', 'It is a directory of programs, not an income opportunity. Read each program\'s own terms before you join.', '', '{{LINK}}'].join('\n') }, posts: [ 'Most builders are a list one person edits. The Seed Bed is open: plant a program, the network saves IDs in it, and the ones that grow are reviewed for the Crypto Team Build Network builder. Free.' + '\n\n{{LINK}}', 'Spotlight a packet: $' + C.spotlight.usd + ' one-time for ' + C.spotlight.views.toLocaleString('en-US') + ' guaranteed views at the top of the Seed Bed. Paid in POL with SafePal or any other crypto wallet.' + '\n\n{{LINK}}' ] }; } const NOTE = 'A directory of programs, not an income opportunity. Nothing is promised.'; const REF_RE = /^(?:[A-Za-z0-9_.-]{2,40}|0x[0-9a-fA-F]{40})$/; const base = () => 'https://' + C.site; let files = null; function creatives() { if (files) return files; let names = []; try { names = fs.readdirSync(KIT_DIR).filter(f => /^ypb-[a-z]+-[a-z]+\.png$/.test(f)); } catch (e) {} const out = []; for (const angle of Object.keys(ANGLES)) for (const shape of Object.keys(SHAPES)) { const f = 'ypb-' + angle + '-' + shape + '.png'; if (!names.includes(f)) continue; const [w, h, label] = SHAPES[shape]; out.push({ key: angle + '-' + shape, angle, angleLabel: ANGLES[angle], shape, label, w, h, url: base() + '/art/kit/' + f }); } return (files = out); } function kit(u) { const ref = REF_RE.test(String(u || '')) ? String(u) : ''; const link = ref && !/^0x/i.test(ref) ? base() + '/' + encodeURIComponent(ref) : base() + '/' + (ref ? '?ref=' + encodeURIComponent(ref) : ''); const q = ref ? '?ref=' + encodeURIComponent(ref) : ''; // the LinkSpin-tracked network link (netsites CODES) when LinkSpin has one for this site; until then the plain member page const track = seg => netsites.tracked(C.siteId, C.siteId, { s1: ref, s2: seg }); const share = (ref && !/^0x/i.test(ref) ? track(ref) : track('')) || link; const fill = s => s.split('{{LINK}}').join(share); const t = copy(); return { v: 1, site: C.site, name: C.siteName, updated: '2026-11-17', username: ref || null, tagline: 'Bring your program. The network grows it.', links: [ { key: 'page', label: 'Your page', url: link, tracked: share }, { key: 'plant', label: 'Plant a program', url: base() + '/my' + q + (q ? '&' : '?') + 'tab=plant', tracked: track('plant') || null }, { key: 'ledger', label: 'Live ledger', url: base() + '/ledger' + q, tracked: track('ledger') || null } ], linkTemplate: base() + '/{username}', trackedTemplate: netsites.tracked(C.siteId, C.siteId) ? netsites.tracked(C.siteId, C.siteId) + '&s1={username}' : null, creatives: creatives().map(c => Object.assign({}, c, { link: share, html: 'YourProgramBuilder' })), lines: t.lines.map(fill), headlines: t.headlines, email: { subject: t.email.subject, body: fill(t.email.body) }, posts: t.posts.map(fill), note: NOTE, promotePage: base() + '/promote' }; } function handle(req, res, u, sendFile) { if (u.pathname === '/promote' && (req.method === 'GET' || req.method === 'HEAD') && sendFile) { sendFile(res, path.join(__dirname, 'public', 'promote.html')); return true; } if (u.pathname !== '/api/promo-kit') return false; const cors = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', 'Access-Control-Allow-Headers': 'Content-Type' }; if (req.method === 'OPTIONS') { res.writeHead(204, cors); res.end(); return true; } if (req.method !== 'GET' && req.method !== 'HEAD') return false; res.writeHead(200, Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' }, cors)); res.end(JSON.stringify(kit(u.searchParams.get('u')))); return true; } module.exports = { kit, handle, creatives, SHAPES, ANGLES, copy };