Page designer on the Branded Voice design system: palette x design (dark/light/editorial/ignition) x layout (stacked/split hero) + six niche presets with house hero images, procedural split visual with price chip, Look panel in the editor; ad zones + banner campaigns gain 336x280, 250x250, 125x125, 120x600 with house banners
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ const http = require('http');
|
||||
const dns = require('dns').promises;
|
||||
const net = require('net');
|
||||
const render = require('./pagerender');
|
||||
const style = require('./pagestyle');
|
||||
const formrestyle = require('./formrestyle');
|
||||
|
||||
let DATA_DIR = null, ownHosts = () => [], keyFn = () => '';
|
||||
@@ -39,18 +40,27 @@ function sanitizeContent(c, type) {
|
||||
out.cta = { text: String(c.cta && c.cta.text || '').slice(0, 60), url: cleanUrl(c.cta && c.cta.url) };
|
||||
out.image = cleanUrl(c.image); out.imageAlt = String(c.imageAlt || '').slice(0, 120);
|
||||
out.privacy = String(c.privacy || '').slice(0, 200); out.disclaimer = String(c.disclaimer || '').slice(0, 300);
|
||||
out.price = String(c.price || '').slice(0, 24); // optional '$17' chip on the split visual
|
||||
if (type === 'review') { out.rating = Math.max(0, Math.min(5, Number(c.rating) || 0)); out.pros = strs(c.pros, 6, 140); out.cons = strs(c.cons, 6, 140); out.verdict = String(c.verdict || '').slice(0, 400); }
|
||||
if (type === 'bridge') { out.bonus = String(c.bonus || '').slice(0, 2000); out.bonusTitle = String(c.bonusTitle || '').slice(0, 100); }
|
||||
if (type === 'squeeze') { out.formEmbed = String(c.formEmbed || '').slice(0, formrestyle.EMBED_MAX_CHARS); }
|
||||
return out;
|
||||
}
|
||||
// the three knobs + niche; a niche preset sets design + palette unless the body overrides them (a preset is a start, not a lock)
|
||||
function designFrom(body, cur) {
|
||||
cur = cur || {}; const niche = body.niche != null ? style.nicheKey(body.niche) : (cur.niche || ''); const preset = niche ? style.NICHES[niche] : null;
|
||||
const palette = body.palette != null ? style.paletteKey(body.palette) : (body.niche != null && preset ? preset.palette : style.paletteKey(cur.palette));
|
||||
const design = body.design != null ? style.designKey(body.design) : (body.niche != null && preset ? preset.design : style.designKey(cur.design));
|
||||
const layout = body.layout != null ? style.layoutKey(body.layout) : style.layoutKey(cur.layout || (body.niche != null && preset ? 'split' : 'stack'));
|
||||
return { palette, design, layout, niche };
|
||||
}
|
||||
async function create(owner, body) {
|
||||
if (J.db.pages.filter(p => p.owner === norm(owner)).length >= 200) return { error: 'That is a lot of pages. Remove some first.' };
|
||||
const type = TYPES.includes(body.type) ? body.type : 'bridge';
|
||||
const title = String(body.title || (body.content && body.content.headline) || 'Untitled page').trim().slice(0, 100);
|
||||
const content = sanitizeContent(body.content, type);
|
||||
if (type === 'squeeze' && content.formEmbed) { const why = formrestyle.problem(content.formEmbed); if (why) return { error: why }; }
|
||||
const p = { id: crypto.randomBytes(5).toString('hex'), owner: norm(owner), slug: slugify(title), type, title, status: 'draft', design: { palette: render.PALETTE_NAMES.includes(body.palette) ? body.palette : 'graphite' }, content, scan: body.scan && typeof body.scan === 'object' ? { url: cleanUrl(body.scan.url), title: String(body.scan.title || '').slice(0, 200), description: String(body.scan.description || '').slice(0, 300), h1: String(body.scan.h1 || '').slice(0, 200), image: cleanUrl(body.scan.image), headings: strs(body.scan.headings, 8, 120), bullets: strs(body.scan.bullets, 8, 140) } : null, angle: String(body.angle || '').slice(0, 160), created: Date.now(), updated: Date.now() };
|
||||
const p = { id: crypto.randomBytes(5).toString('hex'), owner: norm(owner), slug: slugify(title), type, title, status: 'draft', design: designFrom(body, null), content, scan: body.scan && typeof body.scan === 'object' ? { url: cleanUrl(body.scan.url), title: String(body.scan.title || '').slice(0, 200), description: String(body.scan.description || '').slice(0, 300), h1: String(body.scan.h1 || '').slice(0, 200), image: cleanUrl(body.scan.image), headings: strs(body.scan.headings, 8, 120), bullets: strs(body.scan.bullets, 8, 140) } : null, angle: String(body.angle || '').slice(0, 160), created: Date.now(), updated: Date.now() };
|
||||
J.db.pages.push(p); J.save(); return { ok: true, page: pub(p) };
|
||||
}
|
||||
async function update(owner, id, body) {
|
||||
@@ -58,7 +68,7 @@ async function update(owner, id, body) {
|
||||
if (body.remove) { J.db.pages = J.db.pages.filter(x => x !== p); J.save(); return { ok: true, removed: true }; }
|
||||
if (body.title != null) p.title = String(body.title).trim().slice(0, 100) || p.title;
|
||||
if (body.type != null && TYPES.includes(body.type)) p.type = body.type;
|
||||
if (body.palette != null && render.PALETTE_NAMES.includes(body.palette)) p.design.palette = body.palette;
|
||||
if (body.palette != null || body.design != null || body.layout != null || body.niche != null) p.design = designFrom(body, p.design || {});
|
||||
if (body.angle != null) p.angle = String(body.angle).slice(0, 160);
|
||||
if (body.content != null) { const c = sanitizeContent(Object.assign({}, p.content, body.content), p.type); if (p.type === 'squeeze' && c.formEmbed) { const why = formrestyle.problem(c.formEmbed); if (why) return { error: why }; } p.content = c; }
|
||||
if (body.status != null) { if (body.status === 'published') { if (!p.content.headline) return { error: 'Give the page a headline before publishing.' }; if (p.type !== 'squeeze' && !p.content.cta.url) return { error: 'Add the button link (where the page sends people) before publishing.' }; p.status = 'published'; } else p.status = 'draft'; }
|
||||
|
||||
Reference in New Issue
Block a user