In the ongoing move to slowly move away from SETTINGS as a “special” page, and even to be able to move away from space-config in general in the future I’m migrating some SETTINGS into server-side environment variables.
This means that on Edge these particular SETTINGS will stop having effect (and need to be configured via equivalent environment variables):
indexPage is now to be configured using SB_INDEX_PAGE
spaceIgnore is now to be configured using SB_SPACE_IGNORE
The power of doing this on a settings page is that you can easily modify it from the client without restarting the server (just a reload).
The risk is that, even on a read-only space, you leak date (especially with things like space ignore or secret values).
Is everything eventually moving to server side config or will we still be able to configure some things via a page or block?
Heh, I was also expecting issues to pop up due to having an emoji in the index page name ( Home), but that also worked without any extra effort. I guess it shouldn’t be a surprise in 2025 but for some reason I still expect special characters to break somewhere along the process…
To use this, set SB_INDEX_PAGE=Journal/$${os.date('%Y-%m-%d')} ($$ required for docker-compose escaping).
You can either build from my branch or use the Docker image vxnick/silverbullet:1325.
An (untested) side effect is that this should allow any Lua template (i.e. within ${...}) to work if you want something other than the date in your index page name.
If you also want to apply a page template to these pages, you can add a space-lua block somewhere:
event.listen {
name = "editor:pageCreating",
run = function(e)
if not e.data.name:startsWith("Journal/") then
return
end
return {
text = space.readPage("Library/Custom/Daily Journal Template"),
perm = "rw"
}
end
}
I chose to read the page in rather than paste in my Daily Journal Template.
I had to use AI to implement this functionality as I’m wholly unfamiliar with TypeScript, so please, no feature requests! I’m hoping it’ll be merged or otherwise incorporated into v2 at some point
To use use it simply keep SB_INDEX_PAGE set to “index”, and put this script anywhere except that index page (because it will be hard to edit). This will automatically redirect you to a custom page whenever you’re sent to index (e.g. on first page load or when clicking the home button):
```space-lua
local function redirectToCustomIndex()
if editor.getCurrentPage() == "index" then
editor.navigate({kind = "page", page = "Daily/" .. date.today()})
end
end
event.listen {
name = "editor:init",
run = redirectToCustomIndex
}
event.listen {
name = "editor:pageLoaded",
run = redirectToCustomIndex
}
```
You can combine this with @vxnick 's pageLoading suggestion to template that page, or I suppose you could check for the existence of the page and then write a template it if it doesn’t exist before navigating there, whichever you prefer.
Hmm, you’re both on the latest build of v2? For me deleting pages seems to work just fine with this on. I don’t see this error in the JS console. Do note that deleting a page will redirect you to the index page, which will then redirect you to the custom index page, so if it’s this redirected index page you’re trying to delete, you will immediately recreate it (if that makes sense).
Update: Page: From Template also works fine for me still
The error in the console is related to a task listing I’m doing by the looks of the error, so disregard that.
I’ve tried reproducing this (running latest v2):
Create a new page Foo with some text on it and set this as my index page in step 2’s code (to exclude my previous console error from the mix)
The Lua is in a meta-page Library/Personal/IndexHandler (content below)
Create a new quick note (so I don’t delete something I care about) and enter some text
Run Page: Delete on the quick note
I am redirected back to Foo but the quick note is not deleted
The browser console shows two redirects which might be helpful?
Navigating to index page
client.ts:438 Now navigating to {kind: 'page', page: 'index', selection: {…}, scrollTop: 0}
client.ts:438 Now navigating to {kind: 'page', page: 'Foo', selection: {…}, scrollTop: 0}
sync_service.ts:299 Syncing file index.md
sync_service.ts:208 Waiting for ongoing sync to finish...
(3) sync_service.ts:299 Syncing file Foo.md
If I disable the space-lua block, run System: Reload and try deleting the quick note, I see the following in the browser console:
Now navigating to {kind: 'page', page: 'Inbox/2025-04-09/19-03-52', selection: {…}, scrollTop: 0}
sync_service.ts:299 Syncing file Inbox/2025-04-09/19-03-52.md
editor.plug.js:1 Navigating to index page
client.ts:438 Now navigating to {kind: 'page', page: 'index', selection: {…}, scrollTop: 0}
editor.plug.js:1 Deleting page from space
space.ts:79 Deleting page
(2) sync_service.ts:299 Syncing file index.md
#meta
```space-lua
local function redirectToCustomIndex()
if editor.getCurrentPage() == "index" then
editor.navigate({kind = "page", page = "Foo"})
end
end
event.listen {
name = "editor:init",
run = redirectToCustomIndex
}
event.listen {
name = "editor:pageLoaded",
run = redirectToCustomIndex
}