arrow_back_ios App Notes menu group

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 app
  • release/ the entire app, including all dependencies should be in the release folder
  • release/icon.webp icon
  • release/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 and data-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 page
  • veduz.username undefined if not signed in
  • veduz.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