This commit is contained in:
Benoit Schweblin 2013-10-17 13:54:33 -07:00
parent adaee230ec
commit 458d849566

View File

@ -21,34 +21,27 @@ Getting started
bower install bower install
- To serve **StackEdit** in http://localhost/stackedit, add something like this in `httpd.conf`: - Serve **StackEdit** at `http://localhost/`:
Alias /stackedit /Users/benweet/workspace/stackedit (PORT=80 && node server.js)
<Directory /Users/benweet/workspace/stackedit> - Run Chrome without application cache:
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
- Open Chrome without application cache:
chrome --disable-application-cache chrome --disable-application-cache
- Run **StackEdit** in debug mode (serve original files instead of minified): - Run **StackEdit** in debug mode (serve original files instead of minified):
http://localhost/stackedit/?debug http://localhost/?debug
#### Add new dependencies #### Add new dependencies
**NOTE:** StackEdit uses [RequireJS][6] for asynchronous module definition ([AMD][7]). **NOTE:** StackEdit uses [RequireJS][5] for asynchronous module definition ([AMD][6]).
- Install new dependencies using [Bower][4]: - Install new dependencies using [Bower][7]:
bower install <library> --save bower install <library> --save
- Add the new dependency to [RequireJS][6] configuration file (`main.js`): - Add the new dependency to [RequireJS][8] configuration file (`main.js`):
grunt bower grunt bower
@ -60,7 +53,7 @@ Getting started
Architecture Architecture
------------ ------------
![Architecture diagram][5] ![Architecture diagram][9]
---------- ----------
@ -70,8 +63,7 @@ Architecture
The `core` module is responsible for: The `core` module is responsible for:
- creating the [UI Layout][10], - creating the [UI Layout][10], the [ACE][11] editor and the [PageDown][12] editor,
- creating the [PageDown][11] editor,
- loading/saving the settings, - loading/saving the settings,
- running periodic tasks, - running periodic tasks,
- detecting the user activity, - detecting the user activity,
@ -84,7 +76,7 @@ The `core` module is responsible for:
**Methods:** **Methods:**
- `onReady(callback)`: sets a callback to be called when all modules have been loaded and the DOM is ready. - `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()`][12] because it ensures that all AMD modules are loaded by [RequireJS][13]). > **NOTE:** This is preferred over [jQuery's `.ready()`][13] because it ensures that all AMD modules are loaded by [RequireJS][14]).
- `runPeriodically(callback)`: sets a callback to be called every second. - `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). > **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).
@ -92,7 +84,7 @@ The `core` module is responsible for:
- `setOffline()`: can be called by any other modules when a network timeout occurs for instance. - `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. `core.isOffline` is automatically set to `false` when the network is recovered. > **NOTE:** the offline status is also set by detecting the window `offline` event. `core.isOffline` is automatically set to `false` when the network is recovered.
- `initEditor(fileDesc)`: creates or refreshes the [PageDown][14] editor with a given [`FileDescriptor`][15] object. - `initEditor(fileDesc)`: creates or refreshes the [PageDown][15] editor with a given [`FileDescriptor`][16] object.
---------- ----------
@ -107,13 +99,13 @@ The `fileMgr` module is responsible for:
**Attributes:** **Attributes:**
- `currentFile`: the [`FileDescriptor`][16] object that is currently edited. - `currentFile`: the [`FileDescriptor`][17] object that is currently edited.
**Methods:** **Methods:**
- `createFile(title, content)`: creates a [`FileDescriptor`][17] object, add it in the [`fileSystem`][18] map and returns it. - `createFile(title, content)`: creates a [`FileDescriptor`][18] object, add it in the [`fileSystem`][19] map and returns it.
- `deleteFile(fileDesc)`: deletes a [`FileDescriptor`][19] object from the [`fileSystem`][20] map. - `deleteFile(fileDesc)`: deletes a [`FileDescriptor`][20] object from the [`fileSystem`][21] map.
- `selectFile(fileDesc)`: selects a [`FileDescriptor`][21] object for editing. - `selectFile(fileDesc)`: selects a [`FileDescriptor`][22] object for editing.
#### FileDescriptor #### FileDescriptor
@ -123,19 +115,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`][22] objects with their `syncIndex` as a key - `syncLocations`: a map containing all the associated [`syncAttributes`][23] objects with their `syncIndex` as a key
- `publishLocations`: a map containing all the associated [`publishAttributes`][23] objects with their `publishIndex` as a key - `publishLocations`: a map containing all the associated [`publishAttributes`][24] objects with their `publishIndex` as a key
And the following methods: And the following methods:
- `addSyncLocation(syncAttributes)`: associates a [`syncAttributes`][24] object with the file - `addSyncLocation(syncAttributes)`: associates a [`syncAttributes`][25] object with the file
- `removeSyncLocation(syncAttributes)`: unassociates a [`syncAttributes`][25] object with the file - `removeSyncLocation(syncAttributes)`: unassociates a [`syncAttributes`][26] object with the file
- `addPublishLocation(publishAttributes)`: associates a [`publishAttributes`][26] object with the file - `addPublishLocation(publishAttributes)`: associates a [`publishAttributes`][27] object with the file
- `removePublishLocation(publishAttributes)`: unassociates a [`publishAttributes`][27] object with the file - `removePublishLocation(publishAttributes)`: unassociates a [`publishAttributes`][28] object with the file
#### fileSystem #### fileSystem
The `fileSystem` module is a map containing all the [`FileDescriptor`][28] objects with their `fileIndex` as a key. The `fileSystem` module is a map containing all the [`FileDescriptor`][29] objects with their `fileIndex` as a key.
---------- ----------
@ -151,7 +143,7 @@ The `synchronizer` module is responsible for:
#### synchronizer's providers #### synchronizer's providers
A [`provider`][29] module can be associated with the `synchronizer` module if it implements the following functions: A [`provider`][30] 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
@ -163,7 +155,7 @@ A [`provider`][29] 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`][30] module that handles the sync location - `provider`: the [`provider`][31] module that handles the sync location
---------- ----------
@ -178,9 +170,9 @@ The `publisher` module is responsible for:
#### publisher's providers #### publisher's providers
A [`provider`][31] module can be associated with the `publisher` module if it implements the following functions: A [`provider`][32] module can be associated with the `publisher` module if it implements the following functions:
- `newPublishAttributes()`: returns a new [`publishAttributes`][32] object in order to create a new publish location - `newPublishAttributes()`: returns a new [`publishAttributes`][33] 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
@ -188,7 +180,7 @@ A [`provider`][31] 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`][33] module that handles the publish location - `provider`: the [`provider`][34] 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
@ -198,46 +190,47 @@ A `publishAttributes` object is an object that describes a publish location. Att
---------- ----------
### provider ### eventMgr
The `eventMgr` module is responsible for receiving and dispatching events in **StackEdit**.
> Written with [StackEdit](https://stackedit.io/).
> Written with [StackEdit](http://benweet.github.io/stackedit/).
[1]: http://git-scm.com/ [1]: http://git-scm.com/
[2]: http://nodejs.org/ [2]: http://nodejs.org/
[3]: http://gruntjs.com/ [3]: http://gruntjs.com/
[4]: http://bower.io/ [4]: http://bower.io/
[5]: http://benweet.github.io/stackedit/doc/img/architecture.png "Architecture diagram" [5]: http://requirejs.org/ "RequireJS"
[6]: http://requirejs.org/ "RequireJS" [6]: http://en.wikipedia.org/wiki/Asynchronous_module_definition "Asynchronous module definition"
[7]: http://en.wikipedia.org/wiki/Asynchronous_module_definition "Asynchronous module definition" [7]: http://bower.io/
[8]: http://jquery.com/ [8]: http://requirejs.org/ "RequireJS"
[9]: http://underscorejs.org/ [9]: http://benweet.github.io/stackedit/doc/img/architecture.png "Architecture diagram"
[10]: http://layout.jquery-dev.net/ "UI Layout" [10]: http://layout.jquery-dev.net/ "UI Layout"
[11]: https://code.google.com/p/pagedown/ "PageDown" [11]: http://ace.c9.io
[12]: http://api.jquery.com/ready/ [12]: https://code.google.com/p/pagedown/ "PageDown"
[13]: http://requirejs.org/ "RequireJS" [13]: http://api.jquery.com/ready/
[14]: https://code.google.com/p/pagedown/ "PageDown" [14]: http://requirejs.org/ "RequireJS"
[15]: #filedescriptor [15]: https://code.google.com/p/pagedown/ "PageDown"
[16]: #filedescriptor [16]: #filedescriptor
[17]: #filedescriptor [17]: #filedescriptor
[18]: #filesystem [18]: #filedescriptor
[19]: #filedescriptor [19]: #filesystem
[20]: #filesystem [20]: #filedescriptor
[21]: #filedescriptor [21]: #filesystem
[22]: #syncattributes [22]: #filedescriptor
[23]: #publishattributes [23]: #syncattributes
[24]: #syncattributes [24]: #publishattributes
[25]: #syncattributes [25]: #syncattributes
[26]: #publishattributes [26]: #syncattributes
[27]: #publishattributes [27]: #publishattributes
[28]: #filedescriptor [28]: #publishattributes
[29]: #provider [29]: #filedescriptor
[30]: #provider [30]: #provider
[31]: #provider [31]: #provider
[32]: #publishattributes [32]: #provider
[33]: #provider [33]: #publishattributes
[34]: #provider