Files
vbb/promokit.js
T
martbost 43e8dac257 Promo kit: add 336x280 (Large box) for every angle (Marty 2026-11-16, Network Ad Space gaps)
New kit shapes rendered from HTML in the site's own look by tools/kit-art.mjs (a shape list now renders only those shapes and leaves the other art alone). Listed in promokit.js SHAPES, so /promote, /api/promo-kit and InstantAdPay's Network sites tab show them. Smoke test counts updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 04:56:15 -06:00

110 lines
7.1 KiB
JavaScript

// Promo kit (Marty 2026-11-14): the ONE place the Viral Banner Blitz creatives and swipe copy live. Published as a small public JSON
// feed, GET /api/promo-kit?u=<network username or wallet>, read by this site's /promote page and by InstantAdPay's promo center
// ("Network sites"). Change a line or a creative here and every place that shows the kit updates.
// Facts come from config.js (free post credit per day for network members, visitors per shift, network ad views per cycle, prize
// floor). The prize pot is shown only as "at least" the floor: the cap is internal and never shown. Packages are coming soon, so
// nothing here sells anything. Copy rules: advertising, not income; no em dashes.
// Creatives: public/art/kit/vbb-<angle>-<shape>.png, rendered by tools/kit-art.mjs (neutral names: no IAB size tokens).
'use strict';
const fs = require('fs');
const path = require('path');
const C = require('./config').get();
const netsites = require('./netsites'); // tracked links: LinkSpin network link for this site, ?src=<this site> (2026-11-14)
const KIT_DIR = path.join(__dirname, 'public', 'art', 'kit');
const SHAPES = { tile: [125, 125, 'Square button (loop size)'], 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 = { free: 'Free daily banner post', loop: 'Every visitor pushes the loop', prize: 'Weekly leaderboard prizes' };
function copy() {
const n = x => Number(x || 0).toLocaleString('en-US');
const floor = '$' + n(C.prizePot.floorUsd);
const shift = C.perShift === 1 ? 'Every verified visitor shifts' : 'Every ' + n(C.perShift) + ' verified visitors shift';
const views = n(C.viewsPerCycle) + ' network ad views';
return {
lines: [
'InstantAdPay or LinkSpin member? Post a 125x125 banner on Viral Banner Blitz free every day you sign in. {{LINK}}',
'Every real visitor pushes the Viral Banner Blitz loop forward. When your banner rides out, it earns network ad views. {{LINK}}',
'Weekly leaderboards for the most visitors sent. The prize pot is at least ' + floor + ' a week, paid in POL. {{LINK}}',
'No subscription. Sign in with InstantAdPay or LinkSpin, post your banner, share your link. {{LINK}}',
'One shared loop of 125x125 banners. Real visitors only, bots and repeat visits do not count. {{LINK}}'
],
headlines: ['Post a Banner Free Every Day', 'Every Visitor Pushes the Loop', 'Send Visitors, Climb the Weekly Leaderboard'],
email: {
subject: 'Post your banner free every day',
body: [
'Hi,',
'',
'Viral Banner Blitz is one shared loop of 125x125 banners, and every visitor moves it.',
'',
'If you are an InstantAdPay or LinkSpin member, you get a free post credit every day you sign in. Post a banner and a link and it joins the loop.',
'',
shift + ' every banner one place. When yours rides out the end, it has cycled and earns ' + views + '. Bots and repeat visits do not count.',
'',
'There are weekly leaderboards too, for the most visitors sent and the most traffic sources. The prize pot is at least ' + floor + ' a week, paid in POL to the top three on each board.',
'',
'It is advertising, not an income program, and there is no subscription.',
'',
'Here is my link:',
'{{LINK}}'
].join('\n')
},
posts: [
'If you are on InstantAdPay or LinkSpin, you can post a 125x125 banner on Viral Banner Blitz free every day. Real visitors push the loop, and when your banner rides out it earns network ad views.\n\n{{LINK}}',
'Viral Banner Blitz has weekly leaderboards: most visitors sent and most traffic sources. The prize pot is at least ' + floor + ' a week, paid in POL. Share your link and climb.\n\n{{LINK}}'
]
};
}
const NOTE = 'A banner that cycles earns advertising across the network, not cash. Nothing here is an income opportunity.';
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 => /^vbb-[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 = 'vbb-' + 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 q = ref ? '?ref=' + encodeURIComponent(ref) : '';
const link = base() + '/' + q;
const fill = s => s.split('{{LINK}}').join(link);
// the same page through LinkSpin (Marty 2026-11-14: each network site its own traffic source): counted under this site, lands with ?ref=
const track = seg => netsites.tracked('vbb', 'vbb', { s1: ref, s2: seg });
const t = copy();
return {
v: 1, site: C.site, name: C.siteName, updated: '2026-11-16', username: ref || null,
tagline: 'One shared loop of 125x125 banners. Real visitors push it.',
links: [
{ key: 'home', label: 'Your link (the loop)', url: link, tracked: track('') },
{ key: 'how', label: 'How it works', url: base() + '/how' + q, tracked: track('how') },
{ key: 'leaders', label: 'Weekly leaderboards', url: base() + '/leaders' + q, tracked: track('leaders') }
],
linkTemplate: base() + '/?ref={username}', trackedTemplate: netsites.tracked('vbb', 'vbb') + '&s1={username}',
creatives: creatives().map(c => Object.assign({}, c, { html: '<a href="' + link + '" target="_blank" rel="noopener"><img src="' + c.url + '" width="' + c.w + '" height="' + c.h + '" alt="Viral Banner Blitz"></a>' })),
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'
};
}
// GET /api/promo-kit: public, CORS open (InstantAdPay reads it from the member's browser). /art/kit/* is served by the /art/ route.
// GET /promote: the member Promote page (public/promote.html).
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 };