Renamed 'source' to 'import' for Libraries

pull/951/head
Zef Hemel 2024-07-16 15:48:49 +02:00
parent 8662357799
commit 663f1523f1
7 changed files with 21 additions and 12 deletions

View File

@ -1,13 +1,13 @@
export const SETTINGS_TEMPLATE = `#meta export const SETTINGS_TEMPLATE = `#meta
This page contains settings for configuring SilverBullet. A list of built-in settings [[!silverbullet.md/SETTINGS|can be found here]]. This page contains settings for configuring SilverBullet. A list of settings and their documentation [[!silverbullet.md/SETTINGS|can be found here]].
To update \`libraries\` specified here: {[Libraries: Update]} To update the [[!silverbullet.md/Libraries|libraries]] specified below, run {[Libraries: Update]}
\`\`\`yaml \`\`\`yaml
indexPage: index indexPage: index
libraries: libraries:
- source: "[[!silverbullet.md/Library/Core/*]]" - import: "[[!silverbullet.md/Library/Core/*]]"
\`\`\` \`\`\`
`; `;

View File

@ -7,7 +7,11 @@ import { federatedPathToLocalPath, wildcardPathToRegex } from "./util.ts";
import { confirm } from "$sb/syscalls/editor.ts"; import { confirm } from "$sb/syscalls/editor.ts";
type LibraryDef = { type LibraryDef = {
source: string; /**
* @deprecated Use `import` instead
*/
source?: string;
import: string;
exclude?: string[]; exclude?: string[];
}; };
@ -38,11 +42,15 @@ export async function updateLibraries(): Promise<UpdateStats> {
const updateStats: UpdateStats = { libraries: 0, items: 0 }; const updateStats: UpdateStats = { libraries: 0, items: 0 };
const libraries = (await readSetting("libraries", [])) as LibraryDef[]; const libraries = (await readSetting("libraries", [])) as LibraryDef[];
for (const lib of libraries) { for (const lib of libraries) {
if (!lib.source) { // Handle deprecated 'source' field
if (lib.source) {
lib.import = lib.source;
}
if (!lib.import) {
console.warn("Library source not set, skipping", lib); console.warn("Library source not set, skipping", lib);
continue; continue;
} }
const pageUri = parsePageRef(lib.source).page; const pageUri = parsePageRef(lib.import).page;
if (!pageUri.startsWith("!")) { if (!pageUri.startsWith("!")) {
console.warn( console.warn(

View File

@ -8,6 +8,7 @@ _These features are not yet properly released, you need to use [the edge builds]
* [[Page Decorations]] are here (initial implementation by [Deepak Narayan](https://github.com/silverbulletmd/silverbullet/pull/940), later refined by Zef) * [[Page Decorations]] are here (initial implementation by [Deepak Narayan](https://github.com/silverbulletmd/silverbullet/pull/940), later refined by Zef)
* New type of [[Shortcuts|shortcut]]: `slashCommand` * New type of [[Shortcuts|shortcut]]: `slashCommand`
* Naming is hard. Renamed the `source` attribute of [[Libraries]] to `import`. egacy references to `source` will keep working.
* **Fix:** very large spaces would let the server blow up when saving snapshots. This is now fixed. * **Fix:** very large spaces would let the server blow up when saving snapshots. This is now fixed.
* **Fix:** Conflict copies could no longer be edited, whoops (initial fix by [Semyon Novikov](https://github.com/silverbulletmd/silverbullet/pull/939), later refined by Zef) * **Fix:** Conflict copies could no longer be edited, whoops (initial fix by [Semyon Novikov](https://github.com/silverbulletmd/silverbullet/pull/939), later refined by Zef)

View File

@ -14,14 +14,14 @@ When you set up a fresh space, the [[Library/Core]] is automatically configured:
```yaml ```yaml
libraries: libraries:
- source: "[[!silverbullet.md/Library/Core/*]]" - import: "[[!silverbullet.md/Library/Core/*]]"
``` ```
If you would like to _exclude_ specific pages, for instance [[Library/Core/Widget/Table of Contents]], you can do so using the librarys `exclude` attribute If you would like to _exclude_ specific pages, for instance [[Library/Core/Widget/Table of Contents]], you can do so using the librarys `exclude` attribute
```yaml ```yaml
libraries: libraries:
- source: "[[!silverbullet.md/Library/Core/*]]" - import: "[[!silverbullet.md/Library/Core/*]]"
exclude: exclude:
- "[[!silverbullet.md/Library/Core/Widget/Table of Contents]]" - "[[!silverbullet.md/Library/Core/Widget/Table of Contents]]"
``` ```

View File

@ -11,7 +11,7 @@ Some examples:
In your [[SETTINGS]] list the following under `libraries:` In your [[SETTINGS]] list the following under `libraries:`
```yaml ```yaml
libraries: libraries:
- source: "[[!silverbullet.md/Library/Core/*]]" - import: "[[!silverbullet.md/Library/Core/*]]"
``` ```
Then run the {[Libraries: Update]} command to install it. Then run the {[Libraries: Update]} command to install it.

View File

@ -4,7 +4,7 @@ This [[Libraries|library]] contains some useful page templates for journalers. W
In your [[SETTINGS]] list the following under `libraries:` In your [[SETTINGS]] list the following under `libraries:`
```yaml ```yaml
libraries: libraries:
- source: "[[!silverbullet.md/Library/Journal/*]]" - import: "[[!silverbullet.md/Library/Journal/*]]"
``` ```
Then run the {[Libraries: Update]} command to install it. Then run the {[Libraries: Update]} command to install it.

View File

@ -1,5 +1,5 @@
#meta #meta
/ind
This page contains settings for configuring SilverBullet and its Plugs. Changing any of these will go into effect immediately in most cases except `indexPage` which requires a page reload. This page contains settings for configuring SilverBullet and its Plugs. Changing any of these will go into effect immediately in most cases except `indexPage` which requires a page reload.
```yaml ```yaml
@ -7,7 +7,7 @@ This page contains settings for configuring SilverBullet and its Plugs. Changing
indexPage: "[[SilverBullet]]" indexPage: "[[SilverBullet]]"
libraries: libraries:
# The "Core" library is recommended for all users # The "Core" library is recommended for all users
- source: "[[!silverbullet.md/Library/Core/*]]" - import: "[[!silverbullet.md/Library/Core/*]]"
# You can exclude items from the import using exclude (also supports wildcards): # You can exclude items from the import using exclude (also supports wildcards):
# exclude: # exclude:
# - [[!silverbullet.md/Table of Contents]] # - [[!silverbullet.md/Table of Contents]]