Here's a quick documentation of the APIs of TiwyWiki, at various levels: ==== Flash: ==== setValue(category, name, value) getValue(category, name) flush(category) list(category): lists all the names under that category, except those starting with an underscore ('_') ==== Data model: ==== For each wikiword, the Flash storage will hold a number of key/value pairs under the "wiki" category. There is one entry: /"" to mark that the wikiword exists. Other entries are formatted as: __/, where can be "entry" and "dirty". Possible states for an entry: clean, dirty, needsmerge and old clean: version, entry: version is the version that was loaded from the server, and entry is the content. dirty: version, entry, dirty: this entry needs to be saved to the server. needsmerge: version, entry, dirty, remoteversion, mergedentry: this entry has a conflict that needs to be resolved. old: version, entry, old: this entry is clean, but the server has a newer version. ==== Javascript: ==== Server.remoteLoad(wikiword, callback) The callback should expect a single argument, response, containing a status. If the status is "loaded", the response should also have: entry and version. If the status is "loadfailed" or "loadimpossible", the response doesn't have any other field. Server.remoteSave(wikiword, input, callback) The input should contain: entry, version (version that was checked out). The callback should expect a single argument, response, containing a status. If the status is "saved", the response should also have: remoteentry and remoteversion. This allows the server to do some automatic merges. If the status is "savefailed" or "saveimpossible", the response doesn't have any other field. If the status is "conflict", the response should also have: mergedentry and remoteversion. Wiki.localLoad(wikiword): Returns an object containing entry, origentry, version, dirty Wiki.localSave(wikiword, input): Any properties on the input will get saved Wiki.smartLoad(wikiword, callback) The callback should expect a single argument, response, containing a status. The status may be "offlinefailed", "offlineloaded", "remoteloaded", "remotefailed", "loadfailed", "localdirty", "loadimpossible" Wiki.smartSave(wikiword, input, callback) The status may be "localsaved", "remotesaved", "remoteconflict", "remotefailed", "savefailed", "saveimpossible" Wiki.isOnline(): check the mode for the wiki storage Wiki.remoteList(callback): download the latest list of entries, cache them locally (marked as "needsync" if needed) Wiki.dump(): dump the content of the local storage in a text format. FlashHelper.onload(fs): register to this callback to start your app after the Flash object is loaded. ==== Server: ==== getEntry Takes a wikiword and an optional version as an input and returns an entry and a version, if a newer version is available. If the client already has the latest version, then return a special status code. It should also be possible to request a specific version. saveEntry Takes a wikiword, origversion and entry, and returns a status, remoteversion and remoteentry (optional) listEntries Returns a list of wikiwords and versions