View as Markdown

9. Recipes: everyday needs without any server

Many needs of a small business, an association or a family are covered by ordinary links and files, opened by the apps the person already has (mail, messages, phone, maps, calendar, payment page). Nothing to configure, nothing to install, nothing for Blackslate to run. This chapter gives the code for each, ready for an AI to reuse.

9.1 How links work in a tool

A tool runs in a locked frame: it can't open a tab or start an app by itself. Blackslate does it for it, after a click or a tap by the person:

  • an ordinary link <a href="…"> to mailto:, sms:, tel:, https://wa.me/… opens the person's mail, messages, phone or WhatsApp;
  • any other https:// link opens in a new tab, after a confirmation showing the site's address;
  • in code, call window.leavenit.open(url) inside a click handler (outside a click, nothing opens);
  • links to javascript:, data: or relative paths are ignored; jumps inside the page (href="#…") work as usual.

Outside Blackslate (the file opened on its own), links behave normally.

9.2 Sending a message

The tool prepares the text; the person sends it from their own app, in one tap.

const enc = encodeURIComponent;
const email = (to, subject, body) => `mailto:${to}?subject=${enc(subject)}&body=${enc(body)}`;
const sms = (phone, body) => `sms:${phone}?body=${enc(body)}`;           // +33612345678
const whatsapp = (phone, text) => `https://wa.me/${phone.replace(/\D/g, '')}?text=${enc(text)}`;   // 33612345678
const call = (phone) => `tel:${phone}`;

button.onclick = () => window.leavenit?.open(sms('+33612345678', 'Your order #42 is ready.'))
                    ?? (location.href = sms('+33612345678', 'Your order #42 is ready.'));

Several recipients: mailto:a@x.fr,b@y.fr. Keep messages short: some phones cut long sms: bodies.

To send an e-mail automatically, without the person clicking Send, the folder needs a Runner set up for e-mail: see window.leavenit.mail (chapter 5.4) and chapter 7.9. A prepared mailto: link is the fallback when there is none.

9.3 Adding to a calendar, with a reminder (.ics)

A .ics file opens in the person's calendar (Google, Apple, Outlook). With an alarm, their calendar reminds them: no server needed.

function ics({ title, start, end, place = '', notes = '', remindMinutes = 60 }) {
  const t = (d) => d.toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, '');   // 20261029T183000Z
  const esc = (s) => String(s).replace(/\\/g, '\\\\').replace(/[,;]/g, (c) => '\\' + c).replace(/\n/g, '\\n');
  return [
    'BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//Blackslate tool//EN',
    'BEGIN:VEVENT', `UID:${crypto.randomUUID()}`, `DTSTAMP:${t(new Date())}`,
    `DTSTART:${t(start)}`, `DTEND:${t(end)}`, `SUMMARY:${esc(title)}`, `LOCATION:${esc(place)}`, `DESCRIPTION:${esc(notes)}`,
    'BEGIN:VALARM', 'ACTION:DISPLAY', `DESCRIPTION:${esc(title)}`, `TRIGGER:-PT${remindMinutes}M`, 'END:VALARM',
    'END:VEVENT', 'END:VCALENDAR',
  ].join('\r\n');
}
function download(name, text, type) {
  const a = document.createElement('a');
  a.href = URL.createObjectURL(new Blob([text], { type }));
  a.download = name;
  a.click();
}
download('appointment.ics', ics({ title: 'Haircut', start: new Date('2026-11-03T09:00'), end: new Date('2026-11-03T09:30') }), 'text/calendar');

Blackslate asks the person to confirm each download. A customer can receive the same file by mail: prepare the message (9.2) and tell them to open the attachment.

With a Runner set up for e-mail, the tool can also send the reminder itself, the day before: window.leavenit.mail.send({ to, subject, text, at }), and cancel it if the appointment is cancelled (chapter 5.4).

For a whole schedule (a gîte's bookings, a teacher's lessons), publish a calendar feed instead: window.leavenit.calendar.set(…) for each event, and the subscription address from Workshop (chapter 5.4). Added once to a calendar, it keeps following the changes.

A gîte on several platforms: import the Airbnb and Booking calendars into the tool (Workshop → Public link → Imported calendars), read them with window.leavenit.calendar.imported(), block those dates in the tool's own bookings, and publish the result as a feed that you paste back into Airbnb and Booking ("import a calendar" on their side). Each platform then sees the others' bookings within about an hour: fine for a gîte, not for last-minute bookings.

9.4 Getting paid

The money never goes through Blackslate. The person creates a payment link in their own account (Stripe Payment Links, SumUp, PayPal.me, Lydia Pro…) and pastes it into the tool, which shows it, or sends it with a message (9.2).

const payLink = await window.leavenit?.get('settings/payment_link');   // pasted once by the person, e.g. https://buy.stripe.com/…
if (payLink) payButton.onclick = () => window.leavenit.open(payLink);

Knowing whether it was paid: the person marks it in the tool (a "Paid" button). Automatic follow-up needs a Runner (not available yet).

9.5 Directions and maps

const maps = (address) => `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(address)}`;
const waze = (address) => `https://waze.com/ul?q=${encodeURIComponent(address)}&navigate=yes`;

The tool can't show a live map from the internet (no network); a link opens the map app.

9.6 A QR code

Useful for a table number, a menu, a payment link or a page to share. Libraries load from the allowed CDNs:

<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<div id="qr"></div>
<script>new QRCode(document.getElementById('qr'), { text: 'https://buy.stripe.com/…', width: 180, height: 180 });</script>

9.7 A PDF (quote, receipt, list)

Made in the browser, then downloaded (Blackslate asks for confirmation).

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script>
  const doc = new window.jspdf.jsPDF();
  doc.setFontSize(18); doc.text('Quote Q-2026-014', 20, 25);
  doc.setFontSize(11); doc.text('3 × Margherita 32 cm      33,00 €', 20, 45);
  const a = document.createElement('a');
  a.href = URL.createObjectURL(doc.output('blob'));
  a.download = 'quote-Q-2026-014.pdf';
  a.click();
</script>

9.8 Numbering without gaps (quotes, orders)

A shared counter in the folder's data, protected against two people taking the same number:

async function nextNumber(prefix) {
  for (let i = 0; i < 5; i++) {
    const cur = await window.leavenit.get(`counter/${prefix}`, { scope: 'shared', withMeta: true });
    const n = (cur?.value ?? 0) + 1;
    try {
      await window.leavenit.set(`counter/${prefix}`, n, { scope: 'shared', ...(cur ? { ifVersion: cur.version } : {}) });
      return `${prefix}-${String(n).padStart(4, '0')}`;
    } catch (e) { if (e.code !== 'conflict') throw e; }   // someone took it: try the next one
  }
  throw new Error('Try again in a moment.');
}

Invoices: in France, electronic invoicing between companies goes through approved platforms. Receiving electronic invoices is mandatory for every company since 1 September 2026; issuing them, since 1 September 2026 for large and mid-sized companies, and from 1 September 2027 for small companies and micro-enterprises. A Blackslate tool can prepare quotes and invoices and export them, but it is not an invoicing platform.

9.9 Photos

Use window.leavenit.files (chapter 5.3): it shrinks photos before sending them (a phone photo of 3 MB often becomes 150–400 KB) and keeps them out of your tables.

input.onchange = async () => {
  const f = await window.leavenit.files.put(input.files[0], { scope: 'shared' });
  await window.leavenit.set(`photos/${itemId}`, f.id, { scope: 'shared' });
  img.src = await window.leavenit.files.url(f.id);
};

Outside Blackslate (no window.leavenit.files), keep a small data URL instead, made with a canvas, and say that photos are not saved.

9.10 Orders, bookings and sign-ups from the public

With a public link (chapter 5.4), the same tool shows a form to visitors and a list to the folder's members.

  • Orders (a pizzeria, a bakery): the visitor picks items and a pick-up time, then inbox.send(order, { unique: 'slot:' + time }) if each time can only be taken once; members see inbox.list({ status: 'new' }), mark orders done, and send a confirmation by SMS from their phone (9.2).
  • Bookings (a hairdresser, lessons, a gîte): show free slots with inbox.taken(keys); one key per slot; rejecting a request frees the slot. Offer the visitor a .ics file of their booking (9.3).
  • Sign-ups and votes (an association, a school event): one key per person or per option, e.g. unique: 'email:' + email.toLowerCase().
  • Printing the link: the Public link panel makes a QR code to put on a flyer, a counter or a door.
  • Live: with window.leavenit.onChange, the members' list shows a new order within a few seconds, and the visitors' page greys out a slot as soon as someone takes it (chapter 5.4).

9.11 A menu, opening hours or free slots, readable by anyone

The members' screen edits the real data; each time it changes, the tool publishes what the public needs (chapter 5.4):

async function saveMenu(menu) {
  await window.leavenit.set('menu', menu, { scope: 'shared' });            // the private, complete version
  await window.leavenit.public.set('menu', menu.items.map(({ name, price }) => ({ name, price })));   // only what visitors see
}

Visitors (context.type === 'visitor') read it with window.leavenit.public.get('menu'). With the inbox, the same page can show the menu and take the order. To update the page while visitors have it open (a dish sold out, the waiting time), read it again when window.leavenit.onChange says public.

9.12 Comparing your figures with the whole organisation (a summary table)

A sales rep sees only the sales of their region (a table with a rule, chapter 3.9), yet wants to compare their growth with the whole of France, filtered by type of client, period… They must not receive the other regions' sales. The answer is a summary table: totals by criterion, computed every night from all the rows by an admin's flow, readable by everyone. No row is copied.

1. The flow (made by an admin). A block or a flow reads a table with a rule whole only when an admin runs it (for anyone else, it is refused). Ask your AI for an SQL block like this one (its inputs: the tables ventes and clients, called by those names in the SQL), in a flow of the organisation, then Schedule it every night on your Runner (or a device that is on):

-- one row per type of client and month; sums and counts only; groups of fewer than 5 clients left out
create table result as
select c.type as client_type,
       substr(v.date, 1, 7) as month,
       sum(v.amount) as amount,
       count(*) as sales,
       count(distinct v.client_id) as clients
from ventes v join clients c on c.id = v.client_id
group by c.type, substr(v.date, 1, 7)
having count(distinct v.client_id) >= 5;

Publish its result as summary_sales in a folder everyone can read (the organisation's main folder). If someone changes the block's SQL, its nightly run pauses until an admin approves it: nobody can make it copy rows without an admin seeing it.

2. The rules that keep it right and safe.

  • Only totals that add up: sums and numbers of rows. A tool can then filter and regroup them freely and work out rates itself. Never store a rate (growth, average, share): rates don't add up. A number of distinct clients doesn't add up across groups either: show it as it is, don't add it.
  • Leave out small groups (having count(distinct client) >= 5): otherwise "pharmacies, East, March" can be a single client, and their figures would show. Choose the threshold with the people concerned; 5 is a usual minimum.
  • The grain is a company choice: with the region among the criteria, everyone sees the other regions' totals (a ranking); without it, only the whole. Fewer, broader criteria hide more.
  • Comparing my region with everything can reveal the others' total (everything minus mine): this is usual and accepted for internal figures; leaving out small groups and keeping the grain broad keep it so.

3. In the tool. Compute the person's figures from their own rows and the organisation's from the summary, with the same filters, then the growth from the sums (this year ÷ last year − 1):

const sql = window.leavenit.sql;
const type = 'Pharmacy';
const byMonth = (r) => new Map(r.rows.map(([month, amount]) => [month, amount]));   // rows are arrays, in the order of the select
// the person's figures: their rows of ventes (the rule gives them only those)
const mine = byMonth(await sql.query('ventes', 'select substr(date, 1, 7), sum(amount) from data where client_type = ? group by 1', [type]));
// the organisation's: the summary, filtered the same way
const all = byMonth(await sql.query('summary_sales', 'select month, sum(amount) from data where client_type = ? group by month', [type]));
const growth = (m, now, before) => (m.get(before) ? m.get(now) / m.get(before) - 1 : null);   // null: nothing to compare with
const west = growth(mine, '2026-10', '2025-10'), france = growth(all, '2026-10', '2025-10');

A query reads one table: if the type of client is in clients rather than on each sale, read the person's clients too and match them in the page (or let the flow copy the type onto each sale).

Say on screen which figures are the person's and which are the organisation's, and that groups too small are left out of the organisation's totals.