Click macros (Marty 2026-11-13): a spot's Target link can carry {clickid}, {spot} and {type} (gate/organic), filled on every click, for LinkSpin's Downline Banners source; hint on My Spots, my.js?v=4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 08:25:54 -06:00
parent bdb2aacf27
commit 289fcaf2c8
3 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
const head = kind === 'spot' ? '<div class="row" style="justify-content:space-between"><b>Spot #' + s.id + '</b><span class="muted small">' + esc(KIND[s.kind] || '') + ' &middot; ' + s.views + ' of ' + s.owed + ' views'
+ (s.kind === 3 ? '' : s.delivering ? ' &middot; ' + s.daysLeft + ' days left' : ' &middot; delivery finished') + ' &middot; clicks ' + (s.clicks.organic + s.clicks.gate) + '</span></div>' : '';
el.innerHTML = head + '<div class="lots" style="align-items:flex-start"></div>'
+ '<div class="field"><label class="small muted">Target link (https)</label><input data-k="link" placeholder="https://your-site.com/page" value="' + esc(s.link || '') + '"></div>'
+ '<div class="field"><label class="small muted">Target link (https)</label><input data-k="link" placeholder="https://your-site.com/page" value="' + esc(s.link || '') + '"><span class="small muted">Tracking: {clickid}, {spot} and {type} in your link are filled on every click (LinkSpin has a Downline Banners source ready for this).</span></div>'
+ '<div class="field"><label class="small muted">Image address (https), or upload below</label><input data-k="img" placeholder="https://your-site.com/image.png" value="' + esc(String(s.img || '').startsWith('/art/u/') ? '' : s.img || '') + '"></div>'
+ '<div class="row"><button class="btn small" data-a="save">Save</button><label class="btn sec small">Upload image<input type="file" accept="image/png,image/jpeg,image/gif" hidden></label></div>';
const prev = el.querySelector('.lots'); prev.appendChild(BL.tile({ t: 'x', img: (s.showing && s.showing.img) || '/art/house-line.svg', href: s.link || '#' }));
+1 -1
View File
@@ -28,6 +28,6 @@
</main>
<script src="/assets/common.js?v=2"></script>
<script src="/assets/wallet.js?v=1"></script>
<script src="/assets/my.js?v=3"></script>
<script src="/assets/my.js?v=4"></script>
</body>
</html>
+7 -2
View File
@@ -203,12 +203,17 @@ const server = http.createServer(async (req, res) => {
if (/^\/go\/[\w-]+$/.test(p)) {
const ref = p.slice(4); const t = board.target(ref);
if (!t) { res.writeHead(302, { Location: '/' }); return res.end(); }
let kind = 'organic';
if (t.spotId && !isBot(req)) {
const g = gates.get(u.searchParams.get('g') || ''); const gi = Number(u.searchParams.get('i'));
const isGate = g && g.vk === visitorKey(req) && g.steps[gi] && g.steps[gi].ref === ref;
store.addClick(t.spotId, visitorKey(req), isGate ? 'gate' : 'organic');
kind = isGate ? 'gate' : 'organic';
store.addClick(t.spotId, visitorKey(req), kind);
}
const loc = t.link.startsWith('/') ? t.link : t.link;
// tracking macros in a member's link (2026-11-13, LinkSpin's "Downline Banners" source): {clickid} a fresh id per click,
// {spot} the spot number, {type} gate or organic
const loc = !t.spotId || t.link.indexOf('{') < 0 ? t.link : t.link
.replace(/\{clickid\}/g, crypto.randomBytes(8).toString('hex')).replace(/\{spot\}/g, String(t.spotId)).replace(/\{type\}/g, kind);
res.writeHead(302, { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
}
}