Changes

Jump to navigation Jump to search
2,700 bytes added ,  10:25, 30 April 2013
Line 36: Line 36:     
=== Datastore ===
 
=== Datastore ===
This part of the framework should expose Datastore API into JavaScript.
+
This part of the framework should expose Datastore API into JavaScript. In a first step, the JavaScript Datastore API will just call the Sugar Datastore API. Some considerations about how to write a pure HTML5 Datastore are listed below.
 +
 
 +
==== API Use case ====
 +
* Called by an activity to Write/Read its context (most often seen use case)
 +
* Called by Sugar or by an activity to navigate into. Query could be:
 +
** Filtered by title, mime type, date, …
 +
** Ordered by one or more keys
 +
** Limited to some number of results (with an optional starting offset)
 +
==== What is a datastore object ? ====
 +
* A set of properties:
 +
** Some comes from Sugar
 +
** Some are custom properties
 +
** All properties values type are: string, text, int, number, date, binary or external (file)
 +
* A filename (optional)
 +
==== Proposed interface ====
 +
function DataStore.create(properties, filename);  // Return object_id
 +
function DataStore.get_properties(object_id);    // Return set of properties as JSON object
 +
function DataStore.get_filename(object_id);      // Return filename
 +
function DataStore.find(query, properties);      // Return array of object_id
 +
function DataStore_created(object_id);            // Callback interface to object_id created event
 +
function DataStore.addEventListener("created", DataStore_created);
 +
function DataStore_Updated(object_id);            // Callback interface to object_id updated event
 +
function DataStore.addEventListener("updated", DataStore_updated);
 +
function DataStore_Deleted(object_id);            // Callback interface to object_id deleted event
 +
function DataStore.addEventListener("deleted", DataStore_deleted);
 +
 
 +
function write_file(properties, filename);
 +
function Activity.addEventListener("write", write_file);
 +
function read_file(properties, filename);
 +
function Activity.addEventListener("read", read_file);
 +
 
 +
==== HTML5 implementation consideration ====
 +
* DataStore and Activity will be new JavaScript namespace.
 +
* This interface is mostly inherited from the existing sugar.datastore.store API [http://wiki.sugarlabs.org/go/Development_Team/Almanac/sugar.datastore.datastore]. By the way it make sense to reproduce these features because basically the Sugar DataStore can't be something else than a place to store files and metadata related to files.
 +
* Files handling is possible directly in JavaScript - WebKit only - using File API [http://dev.w3.org/2009/dap/file-system/pub/FileSystem/][http://dev.w3.org/2009/dap/file-system/file-writer.html]. Alternatively we could consider than file storage will be handle by the JavaScript to Sugar interface.
 +
* Event registration ("addEventListener") is inspired by the DOM events model thought it's not directly connected to it.
 +
* Activity events should be raised by the JavaScript to Sugar interface.
   −
TODO
      
=== Telepathy ===
 
=== Telepathy ===
Line 49: Line 84:     
Daniel has wrote a first template [http://lists.sugarlabs.org/archive/sugar-devel/2013-April/042710.html].
 
Daniel has wrote a first template [http://lists.sugarlabs.org/archive/sugar-devel/2013-April/042710.html].
      
== HTML Activities ==
 
== HTML Activities ==

Navigation menu