Filed ${fmt(p.date)} · ${kind} · ${wc} words
${over(main)}
${sub ? `${sub}
` : ''}/* PATENTS PENDING — a riso zine. two inks per page, a drawing per post, nothing quite in register. */
const $ = (s, el = document) => el.querySelector(s);
const $$ = (s, el = document) => [...el.querySelectorAll(s)];
const KIND = {
'css-grid-lanes': 'code', 'spool': 'code', 'ferrotype': 'code', 'building-ui-in-gpui': 'code',
'the-black-magic-of-canvas-and-text-editing': 'note', 'fig-gen-making-generative-art-in-figma': 'image',
'writing-with-adhd': 'prose', 'design-workshop': 'image',
};
const kindOf = p => KIND[p.slug] || ((p.html.match(/ 3 ? 'image' : (p.html.match(/
1 ? 'code' : p.html.length < 2500 ? 'note' : 'prose');
const ABSTRACT = {
'css-grid-lanes': 'A layout in which items fall into the shortest column, with a tolerance.',
'spool': 'A task tracker comprising append-only event logs, stored with the work itself.',
'ferrotype': 'An apparatus for developing Rust types onto TypeScript plates, generics intact.',
'building-ui-in-gpui': 'A loose collection of methods for constructing interfaces in GPUI.',
'the-black-magic-of-canvas-and-text-editing': 'A list of prior art concerning canvases, scene graphs and text.',
'fig-gen-making-generative-art-in-figma': 'A method for producing sixty generative works in two hours, using sin, cos and tan.',
'writing-with-adhd': 'A first-person account of impulsivity, detail, and feeling misunderstood in writing.',
'design-workshop': 'A process of making without a brief: voxels, posters and lost worlds.',
};
const SPAN = ['', 'tall', 'wide', 'big', '', 'tall', 'tall', 'wide'];
let posts = [];
const app = $('#app');
const fmt = d => new Date(d + 'T12:00:00').toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });
const short = d => new Date(d + 'T12:00:00').toLocaleDateString('en-US', { month: '2-digit', day: '2-digit', year: '2-digit' });
const words = html => html.replace(//g, '').replace(/<[^>]+>/g, ' ').split(/\s+/).filter(Boolean).length;
const strip = (html, title) => html.replace(/^\s*]*>([\s\S]*?)<\/h1>\s*/, (m, i) => i.replace(/<[^>]+>/g, '').trim().toLowerCase() === title.toLowerCase() ? '' : m);
const fig = p => FIGS[p.slug] || { panel: 'paper', spot: 'pink' };
const num = i => String(i + 1).padStart(2, '0');
const over = (text, cls = '') => `${text}`;
// ---------------------------------------------------------------
function renderIndex() {
document.body.dataset.view = 'index';
document.body.dataset.spot = 'pink';
app.innerHTML = `
vol. 08 — filed ${short(posts[0].date)} — patents pending
${over('NATE.RIP')}
A zine of things made
by Nate Butler.
Eight figures, two inks,
nothing in register.
PRINTED
MATTER
${Array(4).fill('★ HAND-PULLED ON A RISOGRAPH ★ 8 FIGURES ENCLOSED ★ PLEASE DO NOT BEND ★ PRIOR ART WELCOME').join(' ')}
${posts.map((p, i) => { const f = fig(p); return `
-
${figure(p.slug)}
FIG. ${num(i)}
${kindOf(p)} · ${short(p.date)}
${p.title}
`; }).join('')}
`;
register();
}
// ---------------------------------------------------------------
function renderPost(p) {
const f = fig(p), kind = kindOf(p);
const i = posts.indexOf(p), next = posts[(i + 1) % posts.length];
document.body.dataset.view = 'post';
document.body.dataset.spot = f.spot;
const html = strip(p.html, p.title);
const wc = words(p.html);
const [main, sub] = p.title.includes(':') ? [p.title.split(':')[0], p.title.split(':').slice(1).join(':').trim()] : [p.title, ''];
app.innerHTML = `
← contents
${figure(p.slug, 'big')}
FIG. ${num(i)}
Filed ${fmt(p.date)} · ${kind} · ${wc} words
${over(main)}
${sub ? `${sub}
` : ''}
ABSTRACT — ${ABSTRACT[p.slug] || ''}
${html}
next — FIG. ${num((i + 1) % posts.length)}
${next.title}
${figure(next.slug)}
`;
const body = $('.body', app);
$$('a[href^="http"]', body).forEach(a => { a.target = '_blank'; a.rel = 'noopener'; });
$$('img', body).forEach(im => { im.loading = 'lazy'; });
shape[kind]?.(body, p, f);
register();
watchDraw();
}
// shiki colours → two inks
const INK = {
'#F47067': 'ink-spot', '#DCBDFB': 'ink-spot', '#F69D50': 'ink-2', '#96D0FF': 'ink-3', '#6CB6FF': 'ink-3',
'#8DDB8C': 'ink-3', '#768390': 'ink-dim', '#ADBAC7': '', '#E5534B': 'ink-spot', '#F0A1A0': 'ink-spot',
};
const shape = {
code(body) {
let n = 0;
$$('pre', body).forEach(pre => {
$$('span[style]', pre).forEach(s => {
const c = (s.style.color || '').trim();
const hex = c.startsWith('rgb') ? '#' + c.match(/\d+/g).slice(0, 3).map(x => (+x).toString(16).padStart(2, '0')).join('').toUpperCase() : c.toUpperCase();
s.removeAttribute('style');
if (INK[hex]) s.className = INK[hex];
});
pre.removeAttribute('style');
const lines = $$('.line', pre).length;
const w = document.createElement('figure'); w.className = 'patfig';
w.innerHTML = `FIG. ${num(n++)}${String.fromCharCode(65 + (n % 26))}${lines} line${lines > 1 ? 's' : ''} `;
pre.replaceWith(w); w.prepend(pre);
});
// h3s become marginal notes
$$('h3', body).forEach(h => h.classList.add('margin'));
$$('p', body).forEach(par => { if ($$('img', par).length && !par.textContent.trim()) { par.className = 'duo-row'; $$('img', par).forEach(im => { const fg = document.createElement('figure'); fg.className = 'duo'; im.replaceWith(fg); fg.append(im); if (im.alt) fg.insertAdjacentHTML('beforeend', `${im.alt} `); }); } });
},
image(body, p) {
const colors = p.slug.startsWith('fig-gen') ? ['yellow', 'pinklt', 'orange', 'green', 'pink', 'yellow', 'blue', 'orange', 'pinklt'] : ['pink', 'yellow', 'blue', 'orange', 'green', 'pinklt'];
let k = 0;
$$('p', body).forEach(par => {
const imgs = $$('img', par);
if (!imgs.length || par.textContent.trim()) return;
const row = document.createElement('div'); row.className = 'duo-row';
imgs.forEach(im => {
const fg = document.createElement('figure');
fg.className = `duo c-${colors[k++ % colors.length]}`;
fg.append(im);
if (im.alt) fg.insertAdjacentHTML('beforeend', `${im.alt} `);
row.append(fg);
});
par.replaceWith(row);
});
if (p.slug.startsWith('fig-gen')) {
// the favourite gens: a sheet of stamps, like a contact print
const rows = $$('.duo-row', body).slice(3);
const sheet = document.createElement('div'); sheet.className = 'stamps';
rows.forEach(r => { $$('figure', r).forEach(fg => sheet.append(fg)); r.remove(); });
const anchor = $$('p', body).find(x => /favorite gens/i.test(x.textContent));
if (anchor) { anchor.classList.add('shout'); anchor.after(sheet); } else body.append(sheet);
body.classList.add('gens');
}
},
prose(body) {
// h2s become full-width banners; the four points become stickers
const ul = $('ul', body);
if (ul) {
ul.classList.add('stickers');
$$('li', ul).forEach((li, i) => { li.style.setProperty('--r', `${[-4, 3, -2, 5][i % 4]}deg`); li.insertAdjacentHTML('afterbegin', `${i + 1}`); });
}
$$('h2', body).forEach((h, i) => { h.dataset.n = `§${i + 1}`; });
// pull a few lines into the margin, in pen
const cand = $$('p', body).map(par => [par, par.textContent.split(/(?<=[.!?)])\s/)[0]]).filter(([par, s]) => s.length > 30 && s.length < 150 && !par.closest('li'));
[2, 7, 12, 17].forEach((ix, j) => {
const c = cand[ix]; if (!c) return;
const q = document.createElement('aside'); q.className = `pull ${j % 2 ? 'r' : 'l'}`;
q.innerHTML = `${c[1]}`;
c[0].before(q);
});
$('p', body)?.classList.add('lead');
},
note(body, p) {
// a flyer with tear-off tabs
const links = [];
$$('p', body).forEach(par => {
const a = par.firstElementChild;
if (a?.tagName === 'A' && a.querySelector('strong')) links.push({ href: a.href, t: a.textContent, by: par.textContent.replace(a.textContent, '').replace(/^\s*[-–]\s*/, '').trim() });
});
const tabs = document.createElement('div'); tabs.className = 'tabs';
tabs.innerHTML = links.map((l, i) => `${l.t}${l.by.slice(0, 40)}`).join('');
body.append(tabs);
body.insertAdjacentHTML('afterbegin', `
★ FREE ★ TAKE ONE ★
`);
},
};
// misregistration: every plate lands slightly off, then settles
function register() {
$$('.plate, .over, .spread-fig, .duo', app).forEach((el, i) => {
el.style.setProperty('--mx', `${(Math.random() - .5) * 18}px`);
el.style.setProperty('--my', `${(Math.random() - .5) * 14}px`);
el.style.setProperty('--rx', `${(Math.random() - .5) * 3.2}px`);
el.style.setProperty('--ry', `${(Math.random() - .5) * 3.2}px`);
});
}
function watchDraw() {
const io = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add('drawn'); io.unobserve(e.target); } }), { rootMargin: '0px 0px -10% 0px' });
$$('.fig, .patfig, .duo, .stickers li, .pull, .body > h2', app).forEach(el => io.observe(el));
}
function route() {
const slug = decodeURIComponent(location.hash.slice(1));
const p = posts.find(x => x.slug === slug);
app.classList.remove('feed'); void app.offsetWidth;
scrollTo(0, 0);
if (p) renderPost(p); else { renderIndex(); watchDraw(); }
app.classList.add('feed');
}
addEventListener('hashchange', route);
(async () => {
posts = await fetch('../content/posts.json').then(r => r.json());
route();
})();