mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-19 22:26:18 +00:00
![Jermolene](/assets/img/avatar_default.png)
It was getting a pain to manage the content in separate places, and I suspect confusing for end users. I think the best time to move the dev content out is when we’ve established the community wiki for TW5, which is a much more natural home for it. In the meantime, a feature that I’m interested in exploring is the ability to hide tiddlers from the UI based on tag. Then the tw5.com wiki could disable all tiddlers tagged ‘dev’ until explicitly overridden by the user.
102 lines
3.2 KiB
Plaintext
102 lines
3.2 KiB
Plaintext
created: 201308251621
|
|
creator: JeremyRuston
|
|
modified: 201311011307
|
|
modifier: JeremyRuston
|
|
tags: dev moduletypes
|
|
title: SyncAdaptorModules
|
|
|
|
! Introduction
|
|
|
|
SyncAdaptorModules encapsulate storage mechanisms that can be used by the SyncMechanism. Two examples are:
|
|
|
|
* The TiddlyWebAdaptor interfaces with servers compatible with TiddlyWeb's HTTP API, such as TiddlyWeb itself and TiddlyWiki5's built-in ServerMechanism.
|
|
|
|
* The LocalFileAdaptor interfaces with file systems with an API compatible with Node.js's `fs` module
|
|
|
|
SyncAdaptorModules are represented as JavaScript tiddlers with the field `module-type` set to `syncadaptor`.
|
|
|
|
! Exports
|
|
|
|
The following properties should be exposed via the `exports` object:
|
|
|
|
|!Property |!Description |
|
|
|adaptorClass |The JavaScript class for the adaptor |
|
|
|
|
Nothing should be exported if the adaptor detects that it isn't capable of operating successfully (eg, because it only runs on either the browser or the server, or because a dependency is missing).
|
|
|
|
! Adaptor Module Methods
|
|
|
|
Adaptor modules must handle the following methods.
|
|
|
|
!! `Constructor(syncer)`
|
|
|
|
Initialises a new adaptor instance.
|
|
|
|
|!Parameter |!Description |
|
|
|syncer |Syncer object that is using this adaptor |
|
|
|
|
!! `getTiddlerInfo(tiddler)`
|
|
|
|
Gets the supplemental information that the adaptor needs to keep track of for a particular tiddler. For example, the TiddlyWeb adaptor includes a `bag` field indicating the original bag of the tiddler.
|
|
|
|
|!Parameter |!Description |
|
|
|tiddler |Target tiddler |
|
|
|
|
Returns an object storing any additional information required by the adaptor.
|
|
|
|
!! `getStatus(callback)`
|
|
|
|
Retrieves status information from the server. This method is optional.
|
|
|
|
|!Parameter |!Description |
|
|
|callback |Callback function invoked with parameters `err,isLoggedIn,username` |
|
|
|
|
!! `login(username,password,callback)`
|
|
|
|
Attempts to login to the server with specified credentials. This method is optional.
|
|
|
|
|!Parameter |!Description |
|
|
|username |Username |
|
|
|password |Password |
|
|
|callback |Callback function invoked with parameter `err` |
|
|
|
|
!! `logout(callback)`
|
|
|
|
Attempts to logout of the server. This method is optional.
|
|
|
|
|!Parameter |!Description |
|
|
|callback |Callback function invoked with parameter `err` |
|
|
|
|
!! `getSkinnyTiddlers(callback)`
|
|
|
|
Retrieves a list of skinny tiddlers from the server.
|
|
|
|
This method is optional. If an adaptor doesn't implement it then synchronisation will be unidirectional from the TiddlyWiki store to the adaptor, but not the other way.
|
|
|
|
|!Parameter |!Description |
|
|
|callback |Callback function invoked with parameter `err,tiddlers`, where `tiddlers` is an array of tiddler field objects |
|
|
|
|
!! `saveTiddler(tiddler,callback)`
|
|
|
|
Saves a tiddler to the server.
|
|
|
|
|!Parameter |!Description |
|
|
|tiddler |Tiddler to be saved |
|
|
|callback |Callback function invoked with parameter `err,adaptorInfo,revision` |
|
|
|
|
!! `loadTiddler(title,callback)`
|
|
|
|
Loads a tiddler from the server.
|
|
|
|
|!Parameter |!Description |
|
|
|title |Title of tiddler to be retrieved |
|
|
|callback |Callback function invoked with parameter `err,tiddlerFields` |
|
|
|
|
!! `deleteTiddler(title,callback)`
|
|
|
|
Delete a tiddler from the server.
|
|
|
|
|!Parameter |!Description |
|
|
|title |Title of tiddler to be deleted |
|
|
|callback |Callback function invoked with parameter `err` |
|