Edge: some upcoming (breaking) configuration changes

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

All this will be documented here: Install/Configuration

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?

No no, generally configuring SB from pages (like SETTINGS) will stay as it is.

There’s only a few things I’d like to move out. For now only indexPage and spaceIgnore, because these two impact server boot behavior.

1 Like

Will SB_SPACE_IGNORE still support ignoring multiple patterns?

Yes, it should if you can somehow encode multiple lines in an env variable?

I guess you can:

$ export TESTENV2="Line1
> Line2
> Line3
> Line4"
$ echo "$TESTENV2"
Line1
Line2
Line3
Line4
$ echo $TESTENV2
Line1 Line2 Line3 Line4

You have to use double quotes with bash though. I can test edge later, but maybe it’ll just work w/ deno

1 Like

Hmm, this isn’t ideal for me, I have

indexPage: "Journal/{{today}}"

in SETTINGS.

How do I set the index page to be derived from today’s date now?

Thanks

Nick

(Edit: although I could just have a link on the new index page.)

I should never have doubted you @zef

- SB_INDEX_PAGE=Journal/{{today}}

in the docker-compose works perfectly :slight_smile:

Case closed

Heh, I was also expecting issues to pop up due to having an emoji in the index page name (:house: 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…

Hmm. I did this as well in my setup and it opened a literal ‘Daily/{{today}}’ page. Wonder what I am doing differently?

In case anyone has switched to v2 and wants the same functionality, I implemented it as part of [v2] [regression?] SB_INDEX_PAGE `{{today}}` no longer works · Issue #1325 · silverbulletmd/silverbullet · GitHub.

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 :slight_smile:

Here’s an alternative solution:

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.

1 Like

That works perfectly for me :slight_smile:

1 Like

I think this might actually be breaking page deletion (on v2) - I can run a page delete command but it never gets deleted.

In the browser console I see TypeError: null is not an object (evaluating 'i.addEventListener') - although I seem to see this anyway.

I removed this Lua, reloaded, and page deletion works again.

Happy to make a GitHub issue from this if preferred.

Edit: Also breaks “Page from Template” (not tested any other commands)

1 Like

I also have this Lua in plance and I also cannot delete any page.

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

Ah wait, you’re doing this on Edge, let me try that.

Nope, also no error there for me…

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):

  1. 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)
  2. The Lua is in a meta-page Library/Personal/IndexHandler (content below)
  3. Create a new quick note (so I don’t delete something I care about) and enter some text
  4. Run Page: Delete on the quick note
  5. 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
}
1 Like

I can confirm this, also using custom index with no way to delete any page.

Ok, I just pushed a fix. Let me know if that works.