App Notes
These are notes/guidelines on how to structure a JS-apps and widgets.
The structure should facilitate:
- bundle and distribute as an app
- embed in websites such as wordpress as widget via a <script>-tag.
- host as standalone webapp / pwa
Expected code structure
The app should contain the following files:
package.json
includes metadata about the apprelease/
the entire app, including all dependencies should be in the release folderrelease/icon.webp
iconrelease/script.js
entry point that should be loadable with <script>-tag as both traditional and esm. The loading tag may have several data-tags, such as:data-elem="id"
id of element to render to (or create a new, if not included).data-screenshot=1
anddata-screenshot=2
loads the app in a state that is suitable for screenshot
Package.json
Additional metadata is added for app distibution:
{...
"description": "...",
"veduz": {
"title": "...",
"theme-color": "...",
"orientation": "landscape | portrait | auto",
}}
From this it should be possible to create index.html
, capacitor app, and embed the app as a widget into exisiting wordpress sites, etc.
Generic REST API
Piggy-back on wordpress login and roles etc.
Data storage is done through PUT
/GET
/DELETE
/MOVE
to a given path of the following node structure:
{
"type": "...type of the data: string/binary/list/symlink/...",
"category": "...determines access rights etc.",
"data": "...actual data",
"children": {"name": node, ...},
"last-modified": "YYYY-MM-DDThh:mm:ss.sssZ",
"modified-by": "username",
}
Where children is a bit like a directory listing. Permissions are checked by though the data in /permissions/$category/$role/$permission
. Get has an optional ?depth=n
parameter, and children nodes will be null
when depth is zero, or maximum response size has been reached.
JS-API
Apps may expect a global veduz
object with the following functions to exist:
veduz.login()
user sign-in, - possibly reloading the pageveduz.username
undefined if not signed inveduz.server.get(path[, depth])
veduz.server.put(path, node)
veduz.server.delete(path)
veduz.server.mv(from, to)
- TODO: api for webrtc-signalling
Users home directory is /home/username