MojoPad

Scripting: Event Pages

Event pages are plugins that run themselves. Name a page Event: Name and its script fires when that thing happens — the page is the handler.

Page nameFiresmojo.event contains
Event: Openwhen the document openstype
Event: Page Viewafter navigating to any pagetype, page
Event: Exportbefore any document exporttype, destination
Event: Publishbefore Static Publishing writes the sitetype, destination (the folder)
Event: Daily Notewhen a daily note is createdtype, page, date

Inside, the full mojo API is available, plus mojo.event with the details above. A tiny example — keep a visit log. Create Event: Page View containing:

if (!mojo.exists('Log')) await mojo.create('Log')
mojo.append('Log', mojo.today() + ' — ' + mojo.event.page)

Event scripts won't trigger themselves recursively, and errors flash in the status bar instead of interrupting you.

Only pages you wrote will run

A page that arrived never runs its own code, whatever it is called. That means anything brought in by following a folder, clipping from the web, importing, opening a link, or an AI agent writing into your wiki: those pages can be read, searched, edited and copied like any other, but naming one Event: Open does not make it run when you open the document, and a scriptlet inside one is shown rather than carried out.

This matters because trusting a document is a decision you make once, about the pages in front of you at the time. A followed folder can gain a file next week, and whoever can write into that folder — a sync service, a shared drive, somebody else's computer — would otherwise be writing code that runs on yours under a permission you gave for your own notes. So the answer is per page as well as per document: what you wrote runs, what turned up doesn't.

If you do want an arrived page to run, copy what it says into a page you make yourself. That is one extra step, and it is the step where you read what you are about to run.