Move pages to and from the vault
CI / test (push) Successful in 2m12s
Release / release (push) Successful in 3m42s

A page, including a journal day, can be moved into the unlocked vault with its id kept. Links to it elsewhere become [[locked:id]], shown as Locked Page until the vault is unlocked, so its title is kept only in the vault. Move out reverses it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
VeillaxandClaude Sonnet 5.5 committed 2026-11-01 01:58:29 -07:00
1 parent c08a8b8718
commit 994927c704
10 files changed
+443 -14

No files matched your search

+17 -2
View File
@@ -47,14 +47,14 @@ async function boot() {
if (e.status === 401) return showLogin(why);
return $app.replaceChildren(h('div', { class: 'center' }, card('', brand(), h('p', {}, e.message), btn('Try again', 'restore', boot, 'btn'))));
}
await refreshPages().catch(() => { });
await Promise.all([refreshPages().catch(() => { }), refreshVaultNames()]);
S.ready = true;
buildShell();
show();
}
function showLogin(why) {
S.editors.clear(); S.view = null; document.title = 'Sign in · Mako';
S.editors.clear(); S.view = null; S.vaultNames = null; document.title = 'Sign in · Mako';
const next = location.hash.length > 2 ? location.hash : '';
$app.replaceChildren(h('main', { class: 'center' }, card('', brand(),
h('h1', { class: 'login-h' }, 'Your private notebook'),
@@ -233,10 +233,25 @@ function pageView({ id, date, parent = '' }) {
})),
date ? null : btn('Move', 'move', () => have ? movePage(note, async () => { await refreshPages(); note = await api('GET', '/api/notes/' + note.id); drawCrumbs(); }) : toast('Type something first, then you can move the page')),
date ? null : btn('Subpage', 'add', act(async () => { if (!have) return toast('Type something first, then you can add a subpage'); await ed.flush(); location.hash = '#/new/' + note.id; })),
btn('To vault', 'lock', act(toVault), 'ghost'),
btn('Delete', 'trash', act(trashIt), 'ghost danger'));
}
ed = null;
// Moving a page to the vault needs the vault to be unlocked. Links to the page elsewhere read "Locked Page".
async function toVault() {
if (!note || !note.id) return toast('Type something first, then you can move the page to the vault');
await ed.flush();
const v = await api('GET', '/api/vault');
if (!v.unlocked) return toast(v.exists ? 'Unlock your vault first, then move the page.' : 'Make your vault first, then move the page.', false, { label: 'Open vault', fn: () => { location.hash = '#/vault'; } });
const n = note;
if (!await confirmDialog({ title: 'Move this page to the vault?', body: `"${n.daily ? dayLabel(n.daily) : n.name}" will be locked away in your vault. Pages that link to it will show "Locked Page" until you unlock the vault.`, confirm: 'Move to vault', danger: false })) return;
await api('POST', `/api/notes/${n.id}/vault`);
await Promise.all([refreshPages(), refreshVaultNames()]);
toast('Moved to the vault', false, { label: 'Undo', fn: act(async () => { await api('POST', `${VAULT}/notes/${n.id}/out`); await Promise.all([refreshPages(), refreshVaultNames()]); location.hash = hrefOf(n); }) });
location.hash = date ? '#/journal' : n.parent && S.byId.has(n.parent) ? '#/p/' + n.parent : '#/';
}
async function trashIt() {
if (!note) { location.hash = '#/'; return; }
await ed.flush();