I want to add SilverBullet as a “share” target on Android. This would allow me to send it pages I’m looking at, notes from chats, and others. I’ve requested a native PWA implementation in #1090, but in the meantime I found an alternative.
https://http-shortcuts.rmy.ch/ is an Android app that lets you set up a custom share target which sends an HTTP request. My config:
- Basic request is PUT to
https://my.sb.instance/Inbox/{dateSlashTime}.mddateSlashTimeis a global variable (you can define it from the “basic request” dialog) of type Timestamp, with formatyyyy-MM-dd/HH-mm-ss.- Altogether, this makes it compatible with the built-in “quick note” syntax.
- Request headers is
X-Sync-Modeset totrue, a la https://silverbullet.md/HTTP%20API - Request body has
Content-Typeset totext/markdown, and request body set to{quickNoteContents}quickNoteContents is aText inputglobal variable, with Multiline enabled,Allow Receiving Value from Share Dialogueenabled, andData to Receive from Sharingset toText only`.
- Authentication is set to
Bearer Authentication, configured withSB_AUTH_TOKENa la https://silverbullet.md/Install/Configuration#Authentication - Response Handling is set to display a Toast Popup
And that’s basically it! Now I can either go to HTTP shortcut directly from the app, from its shortcut menu (holding the app icon on the homescreen), or I can use the Share button in app to send a quick note to silverbullet.
To make these useful, I also have a bit of space lua; inbox.notes() shows everything from the inbox (I have this on my index page), and because I often just delete these notes directly from my mobile, I also automatically show a Page: Delete bottom on them.
function inbox.notes()
local res = template.each(query[[
from index.tag "page"
where string.startsWith(name, "Inbox/")
]], template.new[==[
**[[${name}|${string.sub(name,7)}]]** - ![[${name}]]
]==])
if some(res) then
return [==[# Inbox notes
]==] .. string.trimEnd(res)
else
return ""
end
end
local inboxBottomTemplate = template.new[==[This is an inbox page
]==]
local function inboxBottomWidget()
if not string.startsWith(editor.getCurrentPage(), "Inbox/") then
return nil
end
return widgets.commandButton("Delete this note", "Page: Delete")
end
event.listen {
name = "hooks:renderBottomWidgets",
run = inboxBottomWidget
}
