This commit is contained in:
Benoit Schweblin 2013-06-18 15:43:52 -07:00
parent 2bfb307849
commit c564b74c39

View File

@ -20,12 +20,29 @@ StackEdit uses [RequireJS][2] for asynchronous module definition ([AMD][3]).
The `core` module is responsible for: The `core` module is responsible for:
- creating the layout (using [UI Layout][4]) - creating the [UI Layout][4],
- creating the editor (using [PageDown][5]) - creating the [PageDown][5] editor,
- loading/saving the settings - loading/saving the settings,
- running period tasks - running periodic tasks,
- detecting the user activity - detecting the user activity,
- checking the offline status - checking the offline status.
##### Attributes:
- `isOffline`: indicates the offline status of the application.
##### Methods:
- `core.onReady(callback)`: sets a callback to be called when all modules have been loaded and the DOM is ready.
> **NOTE:** This is preferred over [jQuery's `.ready()`][6] because it ensures that all AMD modules are loaded by [RequireJS][2]).
- `runPeriodically(callback)`: sets a callback to be called every second.
> **NOTE:** The callback will not run if the user is inactive or in StackEdit Viewer. User is considered inactive after 5 minutes of inactivity (mouse or keyboard).
- `setOffline()`: can be called by any other modules when a network timeout occurs for instance.
> **NOTE:** the offline status is also set by detecting the window `offline` event. `isOffline` is automatically set to `false` when the network is recovered.
- `initEditor(fileDesc)`: creates or refreshes the [PageDown][7] editor with a given [`FileDescriptor`][8] object.
---------- ----------
@ -45,19 +62,19 @@ The `FileDescriptor` class represents a local file. A `FileDescriptor` object ha
- `fileIndex`: the unique string index of the file in the file system - `fileIndex`: the unique string index of the file in the file system
- `title`: the title of the document - `title`: the title of the document
- `content`: the content of the document - `content`: the content of the document
- `syncLocations`: a map containing all the associated [`syncAttributes`][7] objects with their `syncIndex` as a key - `syncLocations`: a map containing all the associated [`syncAttributes`][9] objects with their `syncIndex` as a key
- `publishLocations`: a map containing all the associated [`publishAttributes`][8] objects with their `publishIndex` as a key - `publishLocations`: a map containing all the associated [`publishAttributes`][10] objects with their `publishIndex` as a key
And the following methods: And the following methods:
- `addSyncLocation(syncAttributes)`: associates a [`syncAttributes`][9] object with the file - `addSyncLocation(syncAttributes)`: associates a [`syncAttributes`][11] object with the file
- `removeSyncLocation(syncAttributes)`: unassociates a [`syncAttributes`][10] object with the file - `removeSyncLocation(syncAttributes)`: unassociates a [`syncAttributes`][12] object with the file
- `addPublishLocation(publishAttributes)`: associates a [`publishAttributes`][11] object with the file - `addPublishLocation(publishAttributes)`: associates a [`publishAttributes`][13] object with the file
- `removePublishLocation(publishAttributes)`: unassociates a [`publishAttributes`][12] object with the file - `removePublishLocation(publishAttributes)`: unassociates a [`publishAttributes`][14] object with the file
#### fileSystem #### fileSystem
The `fileSystem` module is a map containing all the [`FileDescriptor`][6] objects with their `fileIndex` as a key The `fileSystem` module is a map containing all the [`FileDescriptor`][15] objects with their `fileIndex` as a key
---------- ----------
@ -73,7 +90,7 @@ The `synchronizer` module is responsible for:
#### synchronizer's providers #### synchronizer's providers
A [`provider`][13] module can be associated with the `synchronizer` module if it implements the following functions: A [`provider`][16] module can be associated with the `synchronizer` module if it implements the following functions:
- `importFiles()`: downloads one or multiple files and create local files associated with the sync locations - `importFiles()`: downloads one or multiple files and create local files associated with the sync locations
- `exportFile()`: uploads a local file to a new sync location - `exportFile()`: uploads a local file to a new sync location
@ -85,7 +102,7 @@ A [`provider`][13] module can be associated with the `synchronizer` module if it
A `syncAttributes` object is an object that describes a sync location. Attributes differ from one provider to another except for the following: A `syncAttributes` object is an object that describes a sync location. Attributes differ from one provider to another except for the following:
- `syncIndex`: the unique string index of the publish location - `syncIndex`: the unique string index of the publish location
- `provider`: the [`provider`][14] module that handles the sync location - `provider`: the [`provider`][17] module that handles the sync location
---------- ----------
@ -100,9 +117,9 @@ The `publisher` module is responsible for:
#### publisher's providers #### publisher's providers
A [`provider`][15] module can be associated with the `publisher` module if it implements the following functions: A [`provider`][18] module can be associated with the `publisher` module if it implements the following functions:
- `newPublishAttributes()`: returns a new [`publishAttributes`][16] object in order to create a new publish location - `newPublishAttributes()`: returns a new [`publishAttributes`][19] object in order to create a new publish location
- `publish()`: performs publishing of one publish location - `publish()`: performs publishing of one publish location
#### publishAttributes #### publishAttributes
@ -110,7 +127,7 @@ A [`provider`][15] module can be associated with the `publisher` module if it im
A `publishAttributes` object is an object that describes a publish location. Attributes differ from one provider to another except for the following: A `publishAttributes` object is an object that describes a publish location. Attributes differ from one provider to another except for the following:
- `publishIndex`: the unique string index of the publish location - `publishIndex`: the unique string index of the publish location
- `provider`: the [`provider`][17] module that handles the publish location - `provider`: the [`provider`][20] module that handles the publish location
- `format`: the publishing format for the publish location. It can be: - `format`: the publishing format for the publish location. It can be:
- `markdown` for Markdown format - `markdown` for Markdown format
- `html` for HTML format - `html` for HTML format
@ -135,15 +152,18 @@ A `publishAttributes` object is an object that describes a publish location. Att
[3]: http://en.wikipedia.org/wiki/Asynchronous_module_definition "Asynchronous module definition" [3]: http://en.wikipedia.org/wiki/Asynchronous_module_definition "Asynchronous module definition"
[4]: http://layout.jquery-dev.net/ "UI Layout" [4]: http://layout.jquery-dev.net/ "UI Layout"
[5]: https://code.google.com/p/pagedown/ "PageDown" [5]: https://code.google.com/p/pagedown/ "PageDown"
[6]: #filedescriptor [6]: http://api.jquery.com/ready/
[7]: #syncattributes [7]: https://code.google.com/p/pagedown/ "PageDown"
[8]: #publishattributes [8]: #filedescriptor
[9]: #syncattributes [9]: #syncattributes
[10]: #syncattributes [10]: #publishattributes
[11]: #publishattributes [11]: #syncattributes
[12]: #publishattributes [12]: #syncattributes
[13]: #provider [13]: #publishattributes
[14]: #provider [14]: #publishattributes
[15]: #provider [15]: #filedescriptor
[16]: #publishattributes [16]: #provider
[17]: #provider [17]: #provider
[18]: #provider
[19]: #publishattributes
[20]: #provider