Labs/F1/Modularity/WebMod-API
F1 defines the following javascript postMessage/jschannel based APIs.
For simplicity, the functions are described as if they are regular blocking functions (ie, they specify a return value). However, as they are implemented using jschannels, the actual implementation will be that the caller obtains the "return value" via jschannel 'success' callback.
Authentication
Authentication is all performed by the WMF library - see Labs/F1/Modularity#Authentication for details.
Sharing
To be implemented by the app (ie, APIs called by F1)
Get enough metadata about the application so the necessary UI for the service can be dynamically built. This is similar to the current F1 "services" global, and allows F1 to offer "send to wall" for facebook versus "send to my contacts" for linkedin.
The result is an object with the following fields (mostly taken from the current F1 implementation)
- name
- The (localized) name of the service as displayed to the user. If 'serviceUrl' is specified, the name will be rendered as a link to that URL, otherwise it will be rendered as plain text.
- serviceUrl
- The main URL for this service.
- icon
- The favicon to be displayed for this service.
- subject
- Whether the app supports a 'subject' field.
- shareTypes
- A list of ways an item can be shared with this service. If the service supports direct messaging, then this must be reflected in shareTypes. Each element in the list may have fields type (an identifier passed back to the service if this item is selected), label (what is shown to the user) and toLabel (the label for the 'to' field - if not specified, the 'to' field is hidden)
- textLimit
- The maximum number of characters allowed. If specified, a counter will be displayed and the limit will be enforced.
- shorten
- A boolean indicating if links must be shortened. (XXX - is this necessary? Can't we determine whether to shorten links based on the specified textLimit and the amount of text currently entered?)
getAutocompleteEntries(user_info, send_to, to_prefix, callback)
Get all the autocomplete entries for the "to" field based on the current setting of the "send to" field for the specified user. For example, the facebook app might return the list of all groups you are a member of if send_to="group wall", and twitter would send a list of all your followers for send_to="direct".
send(user_info, data)
Send an item as described by "data" - ie, perform the actual share.