Migrate to Deno (#86)

Big bang migration to Deno 🤯
This commit is contained in:
Zef Hemel
2022-10-10 14:50:21 +02:00
committed by GitHub
parent 78f83c70d8
commit 561aa6891f
287 changed files with 4577 additions and 25087 deletions
+4 -4
View File
@@ -4,7 +4,7 @@ An attempt at documenting of the changes/new features introduced in each release
## 0.0.35
* Big refactor of the internal Space API unifying attachment and page handling. This shouldn't affect (most) existing code and plugs (except some more exotic areas), but if stuff breaks, please report it.
* Technical change: Upgrades are now detected on the server-side, and plugs re-loaded and pages indexes upon every upgrade.
* Technical change: Upgrades are now detected on the server-side, and plugs re-loaded and pages indexed upon every upgrade.
* Various bug fixes (e.g. using HTML tags in a page before completely broke syntax highlighting)
* Exposed `fulltext.*` syscalls on the client
@@ -36,13 +36,13 @@ An attempt at documenting of the changes/new features introduced in each release
* Updates to templates:
* For the `Template: Instantiate Page` command, the page meta value `$name` is now used to configure the page name (was `name` before). Also if `$name` is the only page meta defined, it will remove the page meta entirely when instantiating.
* You can now configure a daily note prefix with `dailyNotePrefix` in `SETTINGS` and create a template for your daily note under `template/page/Daily Note` (configurable via the `dailyNoteTemplate` setting).
* You can now a quick note prefix with `quickNotePrefix` in `SETTINGS`.
* You can now set a quick note prefix with `quickNotePrefix` in `SETTINGS`.
* Directives (e.g. `#query`, `#import`, `#use`) changes:
* Renamed `#template` directive to `#use-verbose`
* New `#use` directive will clean all the embedded queries and templates in its scope
* All directives now use the page reference syntax `[[page name]]` instead of `"page name"`, this includes `#use` and `#use-verbose` as well as `#import`.
* The `link` query provider now also returns the `pos` of a link (in addition to the `page`)
* New `$disableDirectives` page meta data attribute can be used to disable directives processing in a page (useful for templates)
* New `$disableDirectives` page metadata attribute can be used to disable directives processing in a page (useful for templates)
* Added a new `/hr` slash command to insert a horizontal rule (`---`) useful for mobile devices (where these are harder to type)
---
@@ -50,7 +50,7 @@ An attempt at documenting of the changes/new features introduced in each release
* Slash commands now only trigger after a non-word character to avoid "false positives" like "hello/world".
* Page auto complete now works with slashes in the name.
* Having a `SETTINGS` page is now mandatory. One is auto generated if none is present.
* Added a `indexPage` setting to set the index page for the space (which by default is `index`). When navigating to this page, the page name will "disappear" from the URL. That is, the index URL will simply be `http://localhost:3000/`.
* Added an `indexPage` setting to set the index page for the space (which by default is `index`). When navigating to this page, the page name will "disappear" from the URL. That is, the index URL will simply be `http://localhost:3000/`.
* This feature is now used in `website` and set to `Silver Bullet` there. To also make the title look nicer when visiting https://silverbullet.md
---
+1 -1
View File
@@ -7,7 +7,7 @@ So, feel free to make some edits in this space. Dont worry, you wont break
Here are some things to try:
* Click on the page title (`index` for this particular one) at the top, or hit `Cmd-k` (Mac) or `Ctrl-k` (Linux and Windows) to open the **page switcher**. Type the a name of a non-existing page to create it (although it wont save in this environment).
* Click on the page title (`index` for this particular one) at the top, or hit `Cmd-k` (Mac) or `Ctrl-k` (Linux and Windows) to open the **page switcher**. Type the name of a nonexistent page to create it (although it wont save in this environment).
* Click on the run button (top right) or hit `Cmd-/` (Mac) or `Ctrl-/` (Linux and Windows) to open the **command palette** (note not all commands will work in this quasi read-only mode).
* Select some text and hit `Alt-m` to ==highlight== it, or `Cmd-b` (Mac) or `Ctrl-b` to make it **bold**.
* Click a link somewhere in this page to navigate there.
+5 -5
View File
@@ -12,7 +12,7 @@ Or [try it in a sandbox demo environment](https://demo.silverbullet.md/Sandbox).
## Extensions
What type of extensions, you ask? Let us demonstrate this in a very meta way: by querying a list of plugs and injecting it into this page!
Heres a list of (non-built in) plugs documented in this space (note the `#query` ... `/query` notation used):
Heres a list of (non-built-in) plugs documented in this space (note the `#query` ... `/query` notation used):
<!-- #query page where type = "plug" order by name render [[template/plug]] -->
* [[🔌 Backlinks]] by **Guillermo Vayá** ([repo](https://github.com/Willyfrog/silverbullet-backlinks))
@@ -25,7 +25,7 @@ Heres a list of (non-built in) plugs documented in this space (note the `#que
* [[🔌 Query]] by **Silver Bullet Authors** ([repo](https://github.com/silverbulletmd/silverbullet))
<!-- /query -->.
In a regular SB installation, the body of this query 👆 (in between the placeholders) would automatically be kept up to date as new pages are added to the space that match the query. 🤯 Have a look at the [[template/plug]] _template_ (referenced in the `render` clause) to see how the results are rendered using handlebars syntax, and have a look at one of the linked pages to see how the _meta data_ is specified, which is subsequently used to query and render in this page. And to learn about the specific plug, of course.
In a regular SB installation, the body of this query 👆 (in between the placeholders) would automatically be kept up to date as new pages are added to the space that match the query. 🤯 Have a look at the [[template/plug]] _template_ (referenced in the `render` clause) to see how the results are rendered using handlebars syntax and have a look at one of the linked pages to see how the _metadata_ is specified, which is subsequently used to query and render in this page. And to learn about the specific plug, of course.
## Explore more
Click on the links below to explore various aspects of Silver Bullet more in-depth:
@@ -36,7 +36,7 @@ Click on the links below to explore various aspects of Silver Bullet more in-dep
* [[🔌 Plugs]]
* [[🔨 Development]]
More of a video person? Heres two to get you started:
More of a video person? Here are two to get you started:
* [A Tour of Silver Bullets features](https://youtu.be/RYdc3UF9gok) — spoiler alert: its cool.
* [A look the SilverBullet architecture](https://youtu.be/mXCGau05p5o) — spoiler alert: its plugs all the way down.
@@ -46,7 +46,7 @@ Some core principles that underly Silver Bullets philosophy:
* **Free and open source**. Silver Bullet is MIT licensed.
* **The truth is in the markdown.** Markdown is simply text files, stored on disk. Nothing fancy. No proprietary formats or lock in. While SB uses a database for indexing and caching some data, all of that can be rebuilt from its markdown source at any time. If SB would ever go away, you can still read your pages with any text editor.
* **Single, distraction free mode.** SB doesnt have a separate view and edit mode. It doesnt have a “focus mode.” Youre always in focused edit mode, why wouldnt you?
* **Single, distraction-free mode.** SB doesnt have a separate view and edit mode. It doesnt have a “focus mode.” Youre always in focused edit mode, why wouldnt you?
* **Keyboard oriented**. You can use SB fully using the keyboard, typin the keys.
* **Extend it your way**. SB is highly extensible with [[🔌 Plugs]], and you can customize it to your liking and your workflows.
@@ -57,7 +57,7 @@ To install and run SB, create a folder for your pages (it can be empty, or be an
npx @silverbulletmd/server <path-to-folder>
Optionally you can use the `--port` argument to specify a HTTP port (defaults to `3000`) and you can pass a `--password` flag to require a password to access. Note this is a rather weak security mechanism, so its recommended to add additional layers of security on top of this if you run this on a public server somewhere (at least add TLS). Personally I run it on a tiny Linux VM on my server at home, and use a VPN (Tailscale) to access it from outside my home.
Optionally you can use the `--port` argument to specify a HTTP port (defaults to `3000`) and you can pass a `--password` flag to require a password to access. Note this is a rather weak security mechanism, so its recommended to add additional layers of security on top of this if you run this on a public server somewhere (at least add TLS). Personally, I run it on a tiny Linux VM on my server at home and use a VPN (Tailscale) to access it from outside my home.
Once downloaded and booted, you will be provided with a URL to open SB in your browser (spoiler alert: by default this will be http://localhost:3000 ).
+1 -1
View File
@@ -1,3 +1,3 @@
Inspiration for Silver Bullet comes primarily from [Obsidian](https://obsidian.md/) and its vast plug-in ecosystem (the work-in-progress plugs around querying and tasks are inspired by Obsidians tasks and dataview plugins), but also [Roam Research](https://roamresearch.com/) was an inspiration.
The way plugs are implemented, is a further iteration on how this was done in a previous project of mine (now defunct) called [Zed](https://github.com/zedapp/zed) as well as [Matterless](https://github.com/zefhemel/matterless).
The way plugs are implemented is a further iteration on how this was done in a previous project of mine (now defunct) called [Zed](https://github.com/zedapp/zed) as well as [Matterless](https://github.com/zefhemel/matterless).
+5 -5
View File
@@ -14,11 +14,11 @@ The core plug implements a few templating mechanisms.
### Page Templates
The {[Template: Instantiate Page]} command enables you to create a new page based on a page template.
Page templates, by default, are looked for in the `template/page/` prefix. So creating e.g. a `template/page/Meeting Notes` page, will create a “Meeting Notes” template. You can override this prefix by setting the `pageTemplatePrefix` in `SETTINGS`.
Page templates, by default, are looked for in the `template/page/` prefix. So creating e.g. a `template/page/Meeting Notes` page will create a “Meeting Notes” template. You can override this prefix by setting the `pageTemplatePrefix` in `SETTINGS`.
Page template have one “magic” type of page meta data that is used during instantiation:
Page templates have one “magic” type of page metadata that is used during instantiation:
* `$name` is used as a default value for a new page based on this template
* `$name` is used as the default value for a new page based on this template
In addition, any standard template placeholders are available (see below)
@@ -85,10 +85,10 @@ You can reference and instantiate as follows:
If a template contains any dynamic sections with directives, these will all be removed before injecting the content into the page. This makes things look cleaner. If you want to preserve them, use `#use-verbose` instead of `#use`.
### Daily Note
The {[Open Daily Note]} command navigates (or creates) a daily note prefixed with a 📅 emoji by default, but this is configurable via the `dailyNotePrefix` setting in `SETTINGS`. If you have a page template (see above) named `Daily Note` it will use this as a template, otherwise the page will just be empty.
The {[Open Daily Note]} command navigates (or creates) a daily note prefixed with a 📅 emoji by default, but this is configurable via the `dailyNotePrefix` setting in `SETTINGS`. If you have a page template (see above) named `Daily Note` it will use this as a template, otherwise, the page will just be empty.
### Quick Note
The {[Quick Note]} command will navigate to an empty page named with the current date and time prefixed with a 📥 emoji, but this is configurable via the `quickNotePrefix` in `SETTINGS`. The use case is to take a quick note outside of you current context.
The {[Quick Note]} command will navigate to an empty page named with the current date and time prefixed with a 📥 emoji, but this is configurable via the `quickNotePrefix` in `SETTINGS`. The use case is to take a quick note outside of your current context.
### Template placeholders
Currently supported (hardcoded in the code):
+1 -1
View File
@@ -7,7 +7,7 @@ author: Zef Hemel
<!-- #include "https://raw.githubusercontent.com/silverbulletmd/silverbullet-ghost/main/README.md" -->
# Ghost plug for Silver Bullet
Note: Still very basic, to use:
Note: Still very basic. To use:
In your `SETTINGS` specify the following settings:
+1 -1
View File
@@ -6,7 +6,7 @@ author: Zef Hemel
```
<!-- #include "https://raw.githubusercontent.com/silverbulletmd/silverbullet-mattermost/main/README.md" -->
# Mattermost plug for Silver Bullet
Provides a `mm-saved` query provider (and maybe more in the future). Please follow the installation, configuration sections, and have a look at the example.
Provides an `mm-saved` query provider (and maybe more in the future). Please follow the installation, configuration sections, and have a look at the example.
## Installation
Open your `PLUGS` note in SilverBullet and add this plug to the list:
+19 -19
View File
@@ -6,13 +6,13 @@ author: Silver Bullet Authors
```
### 1. What?
The query plug is a built-in plug implementing the `<!-- #query -->` mechanism. You can use query plug to automatically receive information from your pages.
The query plug is a built-in plug implementing the `<!-- #query -->` mechanism. You can use the query plug to automatically receive information from your pages.
### 2. Syntax
1. _start with_: `<!-- #query [QUERY GOES HERE] -->`
2. _end with_: `<!-- /query -->`
3. _write your query_: replace `[QUERY GOES HERE]` with any query you want using options below
4. _available query options_: Usage of options is similar to SQL except special `render` option. Render option is to use display the data in a format that you created in a separate template.
3. _write your query_: replace `[QUERY GOES HERE]` with any query you want using the options below
4. _available query options_: Usage of options is similar to SQL except for the special `render` option. The `render` option is used to display the data in a format that you created in a separate template.
* `where`
* `order by`
* `limit`
@@ -38,7 +38,7 @@ Further, you can combine multiple of these with `and`. Example `prop =~ /somethi
After writing the query, there are three options:
* Open the **command palette** and run **Materialized Queries: Update**
* Use shortcut: hit **Alt-q** (Windows, Linux) or **Option-q** (Mac)
* Go to another page and come back to the page where query is located
* Go to another page and come back to the page where the query is located
After using one of the options, the “body” of the query is replaced with the new results of the query data will be displayed.
@@ -48,7 +48,7 @@ Available data sources can be categorized as:
2. Data that can be inserted by users
3. Plugs data sources
Best part about data sources: there is an auto completion. 🎉
The best part about data sources: there is auto-completion. 🎉
Start writing `<!— #query ` or simply use `/query` slash command, it will show you all available data sources. 🤯
@@ -59,7 +59,7 @@ Start writing `<!— #query ` or simply use `/query` slash command, it will show
* `item`: list of ordered and unordered items such as bulleted lists ⏺️
* `tags`: list of all hashtags used in all pages ⚡
* `link`: list of all pages giving a link to the page where query is written 🔗
* `data`: You can insert a data using the syntax below 🖥️. You can query the data using `data` option.
* `data`: You can insert data using the syntax below 🖥️. You can query the data using `data` option.
```data
name: John
age: 50
@@ -84,7 +84,7 @@ country: Germany
<!-- /query -->
#### 4.2 Plugs data sources
Certain plugs can also provide special data sources to query a certain data. Some examples are:
Certain plugs can also provide special data sources to query specific data. Some examples are:
* [[🔌 Github]] provides `gh-pull` to query PRs for selected repo
* [[🔌 Mattermost]] provides `mm-saved` to fetch (by default 15) saved posts in Mattermost
@@ -97,7 +97,7 @@ Templates are predefined formats to render the body of the query.
It is pretty easy. You just need to create a new page. However, it is recommended to create your templates using `template/[TEMPLATE_NAME]` convention. For this guide, we will create `template/plug` to display list of Plugs available in Silver Bullet. We will use this template in the Examples section below.
#### 5.2 What is the syntax?
We are using Handlebars which is a simple templating language. It is using double curly braces and name of parameter to be injected. For our `template/plug`, we are using simple template like below.
We are using Handlebars which is a simple templating language. It is using double curly braces and the name of the parameter to be injected. For our `template/plug`, we are using simple template like below.
`* [[{{name}}]] by **{{author}}** ([repo]({{repo}}))`
@@ -105,28 +105,28 @@ Let me break it down for you
* `* ` is creating a bullet point for each item in Silver Bullet
* `[[{{name}}]]` is injecting the name of Plug and creating an internal link to the page of the Plug
* `**{{author}}**` is injecting the author of the Plug and making it bold
* `([repo]({{repo}}))` is injecting the name of the Plug and creating an external link to GitHub page of the Plug
* `([repo]({{repo}}))` is injecting the name of the Plug and creating an external link to the GitHub page of the Plug
For more information on the Handlebars syntax, you can read the [official documentation](https://handlebarsjs.com/).
#### 5.3 How to use the template?
You just need to add `render` keyword followed by the link of the template to the query like below:
You just need to add the `render` keyword followed by the link of the template to the query like below:
`#query page where type = "plug" render [[template/plug]]`
You can see the usage of our template in the example 6.4 below.
You can see the usage of our template in example 6.4 below.
### 6. Examples
We will walk you through a set of examples starting from very basic one until to format the data using templates.
We will walk you through a set of examples starting from a very basic one through one formatting the data using templates.
Our goal in this exercise is to (i) get all plug pages (ii) ordered by last modified time and (iii) display in a nice format.
For the sake of simplicity, we will use `page` data source and limit the results not to spoil the page.
For the sake of simplicity, we will use the `page` data source and limit the results not to spoil the page.
#### 6.1 Simple query without any condition
**Goal:** We would like to get the list of all pages.
**Result:** Look at the data. This is more than we need. The query even gives us template pages. Lets try to limit it in the next step.
**Result:** Look at the data. This is more than we need. The query even gives us template pages. Let's try to limit it in the next step.
<!-- #query page limit 10 -->
|name |lastModified |perm|tags |type|uri |repo |author |
|--|--|--|--|--|--|--|--|
@@ -143,9 +143,9 @@ For the sake of simplicity, we will use `page` data source and limit the results
<!-- /query -->
#### 6.2 Simple query with a condition
**Goal:** We would like to get all plug pages and sorted by last modified time.
**Goal:** We would like to get all plug pages sorted by last modified time.
**Result:** Okay, this what we wanted but there are also information such as perm, type and lastModified that we don't need.
**Result:** Okay, this is what we wanted but there is also information such as perm, type and lastModified that we don't need.
<!-- #query page where type = "plug" order by lastModified desc limit 5 -->
|name |lastModified |perm|type|uri |repo |author |
@@ -159,7 +159,7 @@ For the sake of simplicity, we will use `page` data source and limit the results
#### 6.3 Query to select only certain fields
**Goal:** We would like to get all plug pages, select only `name`, `author` and `repo` columns and sort by last modified time.
**Goal:** We would like to get all plug pages, selecting only `name`, `author` and `repo` columns and then sort by last modified time.
**Result:** Okay, this is much better. However, I believe this needs a touch from a visual perspective.
@@ -175,7 +175,7 @@ For the sake of simplicity, we will use `page` data source and limit the results
#### 6.4 Display the data in a format defined by a template
**Goal:** We would like to display the data from step 5.3 in a nice format using bullet points with links to Plug pages, with author name and link to their GitHub repo.
**Goal:** We would like to display the data from step 5.3 in a nice format using bullet points with links to Plug pages, with the author name and a link to their GitHub repo.
**Result:** Here you go. This is the result we would like to achieve 🎉. Did you see how I used `render` and `template/plug` in a query? 🚀
@@ -188,7 +188,7 @@ For the sake of simplicity, we will use `page` data source and limit the results
<!-- /query -->
PS: You don't need to select only certain fields to use templates. Templates are smart enough to get only the information needed to render the data.
Therefore, following queries are same in terms of end result when using the templates.
Therefore, the following queries are the same in terms of end result when using the templates.
```yaml
<!-- #query page select name author repo uri where type = "plug" order by lastModified desc limit 5 render [[template/plug]] -->
+1 -1
View File
@@ -21,7 +21,7 @@ npm run build-plugs
npm run server -- <PATH-TO-YOUR-SPACE>
```
This `<PATH-TO-YOUR-SPACE>` can be any folder with markdown files, upon first boot SB will ensure there is an `index.md` file (root page) and `PLUGS.md` file (with default list of plugs to load). SB will also create a SQLite `data.db` file with various data caches and indices (you can delete this file at any time and use the `Space: Reindex` command to reindex everything).
This `<PATH-TO-YOUR-SPACE>` can be any folder with markdown files, upon first boot SB will ensure there is an `index.md` file (root page) and `PLUGS.md` file (with the default list of plugs to load). SB will also create an SQLite `data.db` file with various data caches and indices (you can delete this file at any time and use the `Space: Reindex` command to reindex everything).
Open SB at http://localhost:3000 If you're using a browser supporting PWAs, you can install this page as a PWA. This also works on iOS (use the "Add to homescreen" option in the share menu).
+2 -2
View File
@@ -1,6 +1,6 @@
* **Powerful Markdown editor** at its core (powered by [CodeMirror](https://codemirror.net))
* **Distraction free** UI with [What You See is What You Mean](https://en.wikipedia.org/wiki/WYSIWYM) Markdown editing.
* **Future proof**: stores all notes in a regular folder with markdown files, no proprietary file formats. While SB uses a SQLite database for indexes, this database can be wiped and rebuilt based on your pages at any time. Your Markdown files are the single source of truth.
* **Distraction-free** UI with [What You See is What You Mean](https://en.wikipedia.org/wiki/WYSIWYM) Markdown editing.
* **Future proof**: stores all notes in a regular folder with markdown files, no proprietary file formats. While SB uses an SQLite database for indexes, this database can be wiped and rebuilt based on your pages at any time. Your Markdown files are the single source of truth.
* **Run anywhere**: run it on your local machine, or install it on a server. You access it via your web browser (desktop or mobile), or install it as a PWA (giving it its own window frame and dock/launcher/dock icon).
* **Keyboard oriented:** you can fully operate SB via the keyboard (on laptop/desktop machines as well as iPads with a keyboard).
* **Extensible** through [[🔌 Plugs]]