1
0

Fix onboarding and cloud pages appearing in queries

This commit is contained in:
Zef Hemel 2023-01-17 09:34:49 +01:00
parent d23846cdbf
commit a53ebbd2e1
8 changed files with 62 additions and 16 deletions

View File

@ -141,8 +141,8 @@ export class Space extends EventEmitter<SpaceEvents>
return this.spacePrimitives.invokeFunction(plug, env, name, args);
}
listPages(): Set<PageMeta> {
return new Set(this.pageMetaCache.values());
listPages(): PageMeta[] {
return [...new Set(this.pageMetaCache.values())];
}
async listPlugs(): Promise<string[]> {
@ -254,7 +254,10 @@ export class Space extends EventEmitter<SpaceEvents>
}
private metaCacher(name: string, meta: PageMeta): PageMeta {
if (meta.lastModified !== 0) {
// Don't cache metadata for pages with a 0 lastModified timestamp (usualy dynamically generated pages)
this.pageMetaCache.set(name, meta);
}
return meta;
}
}

View File

@ -11,7 +11,7 @@ import { FileMeta as PlugFileMeta } from "../../plug-api/plugos-syscall/types.ts
export default (space: Space): SysCallMapping => {
return {
"space.listPages": (): PageMeta[] => {
return [...space.listPages()];
return space.listPages();
},
"space.readPage": async (
_ctx,

View File

@ -65,9 +65,9 @@ export async function ensureAndLoadSettings(
settings.indexPage,
`Hello! And welcome to your brand new SilverBullet space!
<!-- #include [[💭 silverbullet.md/Getting Started]] -->
<!-- #use [[💭 silverbullet.md/Getting Started]] -->
Loading some onboarding content for you (but doing so does require a working internet connection)...
<!-- /include -->`,
<!-- /use -->`,
);
}

View File

@ -350,7 +350,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = Z92J6WM6X8;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = SilverBullet;
@ -376,7 +376,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = Z92J6WM6X8;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = SilverBullet;

View File

@ -7,14 +7,14 @@ import type { FileMeta } from "../../common/types.ts";
import { parseMarkdown } from "$sb/silverbullet-syscall/markdown.ts";
import { base64EncodedDataUrl } from "../../plugos/asset_bundle/base64.ts";
const pagePrefix = "💭 ";
export const cloudPrefix = "💭 ";
export async function readFileCloud(
name: string,
encoding: FileEncoding,
): Promise<{ data: FileData; meta: FileMeta } | undefined> {
const originalUrl = name.substring(
pagePrefix.length,
cloudPrefix.length,
name.length - ".md".length,
);
let url = originalUrl;
@ -29,7 +29,7 @@ export async function readFileCloud(
let text = "";
try {
const r = await fetch(`${url}.md`);
const r = await fetch(`${encodeURI(url)}.md`);
text = await r.text();
if (!r.ok) {
text = `ERROR: ${text}`;
@ -40,7 +40,7 @@ export async function readFileCloud(
}
text = await translateLinksWithPrefix(
text,
`${pagePrefix}${originalUrl.split("/")[0]}/`,
`${cloudPrefix}${originalUrl.split("/")[0]}/`,
);
return {
data: encoding === "utf8" ? text : base64EncodedDataUrl(
@ -65,7 +65,7 @@ async function translateLinksWithPrefix(
replaceNodesMatching(tree, (tree) => {
if (tree.type === "WikiLinkPage") {
// Add the prefix in the link text
if (!tree.children![0].text!.startsWith(pagePrefix)) {
if (!tree.children![0].text!.startsWith(cloudPrefix)) {
// Only for links that aren't already cloud links
tree.children![0].text = prefix + tree.children![0].text;
}

View File

@ -1,6 +1,14 @@
An attempt at documenting the changes/new features introduced in each
release.
---
## 0.2.8
* [[Sync]] should now be usable and is documented
* Windows and Mac [[Desktop]] apps now have proper icons (only Linux left)
* [[Mobile]] app for iOS in TestFlight
* New onboarding index page when you create a new space, pulling content from [[Getting Started]].
* Various bug fixes
---

View File

@ -1,7 +1,42 @@
There is a “native” mobile app under development (the code [lives here](https://github.com/silverbulletmd/silverbullet/tree/main/mobile)). Initially, it will be offered for iOS (and iPadOS), but soon thereafter an Android version is planned.
The SilverBullet mobile app is an (almost) full version of SilverBullet running on your mobile device. It keeps its content (pages, attachments) locally, so you have access to it even without an Internet connection. You can install [[🔌 Plugs]], and they run locally as well.
The mobile app is built using [CapacitorJS](https://capacitorjs.com/) and therefore cross-platform. It essentially wraps the existing web app, and swaps out the server calls to local on-device APIs, such as using the local filesystem to store content (pages and attachments), uses a local SQLite database, and it runs all [[🔌 Plugs]] code on device. It is capable of fully running offline.
The mobile app is still in beta and available via TestFlight, and initially only available for iOS. The [Android version is coming next](https://github.com/silverbulletmd/silverbullet/issues/310).
![](ios-app-screenshot.png)
[**Join the TestFlight iOS SilverBullet beta**](https://testflight.apple.com/join/QqYAVZcr)
## PWA vs “native” app
On mobile you essentially have two ways to run SilverBullet:
1. Run the [[Server]] and access it via your mobile browser
2. Run the [[Mobile]] app and either maintain a separate space there, or use [[Sync]] to synchronize your content with a [[Server]].
There are a few advantages to using the [[Server]] on a mobile browser:
1. No [[Sync]] required. Content is kept in one place (which you can backup separately).
2. You can access one SilverBullet from any browser on any device, so Android too.
3. Any “heavy lifting” (like indexing pages) happens on the server, not the device.
There are also disadvantages:
1. You need a network connection to the [[Server]] at all times.
2. PWAs dont always work fully reliably on all devices (specifically iOS)
The advantages of using the “native” mobile app:
1. Fully offline capable: no need for an Internet connection, except for [[Sync]] or any [[🔌 Plugs]] that require one
2. Faster, local performance
The disadvantages:
1. Likely youll need to use [[Sync]] to synchronize your content with other devices, this comes with any drawbacks of sync: conflicts, forgetting to sync content etc.
## Implementation
The reason were quoting “native” app consistently, is that the mobile app is built using [CapacitorJS](https://capacitorjs.com/). A lightweight wrapper around a WebView exposing various native APIs, such as access to the local file system, SQLite database etc.
The mobile app keeps its files in the sandboxed file system of the SilverBullet app. These files are accessible via iOS file sharing capability (when you plug in your device via USB, you can see all files, copy new ones and remove them), and are included with the regular iOS backups.
In the very likely scenario youd like to synchronize with your space e.g. on [[Desktop]] or a [[Server]], youll need to use [[Sync]].
## Caveats
* Shell commands: on [[Server]] and [[Desktop]] [[🔌 Plugs]] have the ability to run shell commands, the [[🔌 Git]] plug uses this functionality for instance. This does not work on mobile.
* Local file system access (outside the space): on [[Server]] and [[Desktop]], plugs can get access to your local file system _outside_ the location where your space content is stored. This is used, for instance for [[🔌 Markdown]] sharing as well as `file:` URLs in your [[PLUGS]] file. This is not supported on mobile.

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB