Sugar Network/API: Difference between revisions
| Line 197: | Line 197: | ||
The reasons to proxy Sugar Network data on users side: | The reasons to proxy Sugar Network data on users side: | ||
* [[#Offline case| | * Seamless support [[#Offline case|offline workflow]]; | ||
* [[#Launching|Reliable launch]] Sugar activities hosted on Sugar Network. | |||
* [[# | |||
Proxying happens by providing the same Sugar Network API (with some extra functionality, see below) from | Proxying happens by providing the same Sugar Network API (with some extra functionality, see below) from | ||
| Line 208: | Line 207: | ||
Being connected to a Sugar Network server, local proxy provides original Sugar Network content. If the connection is lost, the proxy will switch to local Sugar Network storage and continue working. Any content created in offline mode will be uploaded to the server after getting a connection back. | Being connected to a Sugar Network server, local proxy provides original Sugar Network content. If the connection is lost, the proxy will switch to local Sugar Network storage and continue working. Any content created in offline mode will be uploaded to the server after getting a connection back. | ||
Besides, local Sugar Network storage will be reused to keep users preferences, such as: | |||
* '''favorite''' contexts<br>to select preferred ''Context'' resources; these contexts will be marked by {{Code|favorite}} value in the ''Context.layer'' property; | |||
* '''cloned''' contexts<br>to keep most recent context ''Implementation'' in local storage to make it available in offline; note that there is no need in cloning to speedup online lunch, ''Implementations'' are being [[#Launching|cached]] anyway; these contexts will be marked by {{Code|clone}} value in the ''Context.layer'' property. | |||
To control users preferences there are special API commands: | |||
To control | |||
<div id="PUT_favorite"></div> | <div id="PUT_favorite"></div> | ||
'''PUT''' / | '''PUT''' /context/''GUID''?cmd='''favorite''' | ||
Change favorite status. {{Code|PUT}} content should be favorite status. | Change favorite status. {{Code|PUT}} content should be favorite status. | ||
| Line 234: | Line 223: | ||
<div id="PUT_clone"></div> | <div id="PUT_clone"></div> | ||
'''PUT''' / | '''PUT''' /context/''GUID''?cmd='''clone''' | ||
Change cloning status for the specified | Change cloning status for the specified context. {{Code|PUT}} content should be cloning status. If cloned context is a Sugar activity, the command will create a symlink in {{Code||~/Activities}} directory to newly fetched implementation. | ||
=== | === Launching === | ||
Sugar Network ''Contexts'' can be launched as-is. The launching process is implicit and includes selecting most recent (and appropriate for software contexts) ''Implementation'', downloading bundles from the Sugar Network, execution. All downloaded implementations will be cached [with further garbage collecting] to speedup next launching. | |||
Sugar activities (with {{Code|activity}} value in the ''Context.type'' property) will be directly executed after making sure that all [[Sugar_Network/Recipe_Specification#Dependencies|software dependencies]] are installed in the system. Non-software contexts will be opened in the proper application according to its ''Context.mime_type''. | |||
'''GET''' /context/''GUID''?cmd='''launch'''[&args=''ARG''][&activity_id=''ACTIVITY_ID''][&object_id=''OBJECT_ID''][&uri=''URI''][&color=''COLOR''][&no_spawn=''NO_SPAWN''] | '''GET''' /context/''GUID''?cmd='''launch'''[&args=''ARG''][&activity_id=''ACTIVITY_ID''][&object_id=''OBJECT_ID''][&uri=''URI''][&color=''COLOR''][&no_spawn=''NO_SPAWN''] | ||
* {{Code|NO_SPAWN}}, if specified, HTTP connection will not be closed until exiting activity process. | |||
Arguments that make sense only for Sugar activities: | |||
* {{Code|ARG}}, command line argument to pass to launched activities, repeat {{Code|ARG}} for each argument; | * {{Code|ARG}}, command line argument to pass to launched activities, repeat {{Code|ARG}} for each argument; | ||
| Line 249: | Line 244: | ||
* {{Code|URI}}, URL to resume if activity supports this functionality; | * {{Code|URI}}, URL to resume if activity supports this functionality; | ||
* {{Code|COLOR}}, comma separated pair of Sugar colors to assign to activity object; | * {{Code|COLOR}}, comma separated pair of Sugar colors to assign to activity object; | ||
<!-- | |||
=== Access to the Journal === | === Access to the Journal === | ||
| Line 262: | Line 255: | ||
This kind of access might be useful when local applications cannot use DBus sugar-datastore API, e.g., [[wikipedia:Javascript|Javascript]] applications. | This kind of access might be useful when local applications cannot use DBus sugar-datastore API, e.g., [[wikipedia:Javascript|Javascript]] applications. | ||
--> | |||
== Usage == | == Usage == | ||