forked from cory/tildefriends
2.2 KiB
2.2 KiB
Tilde Friends Cheat Sheet
Making apps for the impatient tilde friend.
Prerequisites
- either run your own instance or use tildefriends.net
- register and login
- [optional] use the
ssb
app to create yourself an SSB identity
Development Process
- hit the
edit
link from any app or new app URL - make sure the path in the text box is under your username:
/~username/app/
- write server-side code in
app.js
- click the
save
button or press the save hotkey (Alt+S or [browser-specific modifiers]+S) - see the app reload on the right side
Output
app.setDocument(html)
- send HTML to the browserprint(...)
- send values to the browser's developer console
Persistence
app.localStorageGet(key)
->value
app.localStorageSet(key, value)
database()
,shared_database(key)
,my_shared_database(package, key)
db.get(key)
->value
db.set(key, value)
db.exchange(key, expected, value)
->exchanged
db.remove(key)
db.getAll()
->[key1, ...]
db.getLike(pattern)
->{key1: value1, ...}
SSB
ssb.createIdentity()
->id
ssb.getIdentities()
->[id1, ...]
ssb.appendMessageWithIdentity(id, content)
->message_id
ssb.blobStore(blob)
->blob_id
ssb.blobGet(id)
->blob
ssb.sqlAsync(query, args, row_callback)
TF-RPC
Stock helper code for calling functions across the web server and browser boundary.
- on the server:
import * as tfrpc from '/tfrpc.js';
- in the browser:
import * as tfrpc from '/static/tfrpc.js';
- either direction:
- register a function:
tfrpc.register(function my_function() {});
- call a remote function:
let promise = tfrpc.rpc.my_function();
- register a function:
Share
- give out web links: https://www.tildefriends.net/~cory/screwble/
- use the
Attach App
button when composing a post in the SSB app