Fixes #1560
* Adds back auto creation of index page and CONFIG page if they don't exist. * Remove observe argument on backend
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -165,9 +167,39 @@ func buildConfig(bundledFiles fs.FS, args []string) *server.ServerConfig {
|
||||
rootSpaceConfig.ShellBackend = server.NewNotSupportedShell()
|
||||
}
|
||||
|
||||
// Ensure at least the index page and config page exist
|
||||
ensureIndexAndConfig(rootSpaceConfig)
|
||||
|
||||
return serverConfig
|
||||
}
|
||||
|
||||
//go:embed space_template/index.md
|
||||
var indexPageContent []byte
|
||||
|
||||
//go:embed space_template/CONFIG.md
|
||||
var configPageContent []byte
|
||||
|
||||
func ensureIndexAndConfig(rootSpaceConfig *server.SpaceConfig) {
|
||||
// Index page first
|
||||
indexPagePath := fmt.Sprintf("%s.md", rootSpaceConfig.IndexPage)
|
||||
_, err := rootSpaceConfig.SpacePrimitives.GetFileMeta(indexPagePath)
|
||||
if err == server.ErrNotFound {
|
||||
log.Printf("Index page %s does not yet exist, creating...", indexPagePath)
|
||||
if _, err := rootSpaceConfig.SpacePrimitives.WriteFile(indexPagePath, indexPageContent, nil); err != nil {
|
||||
log.Fatalf("Could not write index page %s: %v", indexPagePath, err)
|
||||
}
|
||||
}
|
||||
// Now let's check for a CONFIG.md
|
||||
configPagePath := "CONFIG.md"
|
||||
_, err = rootSpaceConfig.SpacePrimitives.GetFileMeta(configPagePath)
|
||||
if err == server.ErrNotFound {
|
||||
log.Printf("Config page %s does not yet exist, creating...", configPagePath)
|
||||
if _, err := rootSpaceConfig.SpacePrimitives.WriteFile(configPagePath, configPageContent, nil); err != nil {
|
||||
log.Fatalf("Could not write config page %s: %v", configPagePath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ServerCommand(bundledFiles fs.FS) *cobra.Command {
|
||||
var hostname string
|
||||
var port int
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
This is where you configure SilverBullet to your liking. See [[^Library/Std/Config]] for a full list of configuration options.
|
||||
|
||||
```space-lua
|
||||
config.set {
|
||||
plugs = {
|
||||
-- Add your plugs here (https://silverbullet.md/Plugs)
|
||||
-- Then run the `Plugs: Update` command to update them
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
# Hello 👋
|
||||
Welcome to the wondrous world of SilverBullet. A world that once you discover and appreciate, you’ll never want to leave.
|
||||
|
||||
_One of us!_
|
||||
|
||||
You can go ahead and delete this placeholder content in a second, but before you do, let me quickly show you around.
|
||||
|
||||
We’ll do this through a list of **silver bullets**.
|
||||
|
||||
_Ah, so that explains the name!_
|
||||
|
||||
* Click on the page picker (book icon) icon at the top right, or hit `Cmd-k` (Mac) or `Ctrl-k` (Linux and Windows) to open the **page picker**.
|
||||
* Type the name of a non-existent page to create it.
|
||||
* Folders are implicitly created by putting slashes (`/`) in the name (even on Windows), e.g. `My Folder/My Page`. Don’t worry about folders existing, SilverBullet will automatically create them if they don’t.
|
||||
* Click on the terminal icon (top right), or hit `Cmd-/` (Mac) or `Ctrl-/` (Linux and Windows) to open the **command palette**. From here you can run various useful and perhaps less useful commands.
|
||||
* Select some text and hit `Cmd-b` (Mac) or `Ctrl-b` (Windows/Linux) to make it **bold**, or `Cmd-i` (Mac) or `Ctrl-i` (Windows/Linux) to make it _italic_.
|
||||
* You can create links to pages using the `[[other page]]` syntax, for instance: `[[aspiring page]]`. When you link to a non-existent page it will initially show up in orange (to indicate it does not yet exist), but once you click it — you will create the page automatically (only for real when you actually enter some text).
|
||||
* Start typing `:party` to trigger the emoji picker 🎉
|
||||
* Type `/` somewhere in the text to invoke a **slash command**.
|
||||
* If this matches your personality type, there is also an `Editor: Toggle Vim Mode` command to switch to Vim mode. If you cannot figure out how to exit it (classic vim issue), just run that same command again. _Phew!_
|
||||
* As you may have noticed, while SilverBullet uses [markdown](https://www.markdownguide.org/) underneath, it also “live previews” it to give a bit more of a WYSIWYG feel. You can always move your cursor “into” the underlying code by `Alt-clicking` it (even links and widgets, which we’ll get to later).
|
||||
|
||||
While SilverBullet implements (most) of [CommonMark](https://commonmark.org/), it also adds a few extensions that are SilverBullet-specific. Most notably, it adds the `${Lua expression}` syntax to render Lua expressions inline.
|
||||
|
||||
Using SilverBullet’s Lua APIs, you can do all kinds of cool stuff. For instance, query your space for the last 3 modified pages. _Exciting!_
|
||||
|
||||
${query[[from index.tag "page" order by lastModified desc limit 3]]}
|
||||
|
||||
There’s a whole world out there to explore, but let’s not get ahead of ourselves. First, have some fun and add some content to your fresh space.
|
||||
|
||||
Then we’ll talk.
|
||||
|
||||
# What next?
|
||||
You can find more information on SilverBullet’s feature set on its [official website](https://v2.silverbullet.md/). Also, be sure to join the [SilverBullet community](https://community.silverbullet.md/) to interact with fellow SilverBullet explorers.
|
||||
Reference in New Issue
Block a user