Commit 01ed23c5 authored by Marco Mariani's avatar Marco Mariani

docs: typos, small fixes

parent 22d6a875
...@@ -5,16 +5,17 @@ ...@@ -5,16 +5,17 @@
.. _list-of-available-storages: .. _list-of-available-storages:
List of Available Storages List of Available Storages
========================== ==========================
JIO save his job queue in a workspace which is localStorage by default. JIO saves his job queue in a workspace which is localStorage by default.
Provided storage descirption are also stored, and it can be dangerous if we Provided storage descriptions are also stored, and it can be dangerous to
store passwords. store passwords.
The best way to create a storage description is to use the (often) provided The best way to create a storage description is to use the (often) provided
tool given by the storage library. The returned description is secured to avoid tool given by the storage library. The returned description is secured to avoid
clear readable password. (enciphered password for instance) clear readable password. (encrypted password for instance)
When building storage trees, there is no limit on the number of storages you When building storage trees, there is no limit on the number of storages you
can use. The only thing you have to be aware of is compatability of simple and can use. The only thing you have to be aware of is compatability of simple and
...@@ -59,6 +60,8 @@ The tool dav_storage.createDescription generates a dav storage description for ...@@ -59,6 +60,8 @@ The tool dav_storage.createDescription generates a dav storage description for
All parameters are strings. All parameters are strings.
.. XXX simplify here
Only ``url`` and ``auth_type`` are required. If ``auth_type`` is equal to "none", Only ``url`` and ``auth_type`` are required. If ``auth_type`` is equal to "none",
then ``realm``, ``username`` and ``password`` are useless. ``username`` and ``password`` become then ``realm``, ``username`` and ``password`` are useless. ``username`` and ``password`` become
required if ``auth_type`` is equal to "basic". And ``realm`` also becomes required if required if ``auth_type`` is equal to "basic". And ``realm`` also becomes required if
...@@ -139,7 +142,7 @@ Revision Based Handlers ...@@ -139,7 +142,7 @@ Revision Based Handlers
----------------------- -----------------------
A revision based handler is a storage which is able to do some document A revision based handler is a storage which is able to do some document
versionning using simple storages listed above. versioning using simple storages listed above.
On JIO command parameter, ``_id`` is still used to identify a document, but On JIO command parameter, ``_id`` is still used to identify a document, but
another id ``_rev`` must be defined to use a specific revision of this document. another id ``_rev`` must be defined to use a specific revision of this document.
...@@ -148,8 +151,8 @@ On command responses, you will find another field ``rev`` which will represent t ...@@ -148,8 +151,8 @@ On command responses, you will find another field ``rev`` which will represent t
new revision produced by your action. All the document history is kept unless new revision produced by your action. All the document history is kept unless
you decide to delete older revisions. you decide to delete older revisions.
Another fields ``conflicts``, ``revisions`` and ``revs_info`` can be returned if the Other fields ``conflicts``, ``revisions`` and ``revs_info`` can be returned if the
options **conflicts: true**, **revs: true** and **revs_info: true** are set. options **conflicts: true**, **revs: true** or **revs_info: true** are set.
Revision Storage Revision Storage
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
...@@ -162,4 +165,3 @@ Replicate Revision Storage ...@@ -162,4 +165,3 @@ Replicate Revision Storage
Updating to v2.0 Updating to v2.0
...@@ -11,7 +11,7 @@ allDocs method can use complex queries. ...@@ -11,7 +11,7 @@ allDocs method can use complex queries.
A query can either be a string (using a specific language useful for writing A query can either be a string (using a specific language useful for writing
queries), or it can be a tree of objects (useful to browse queries). To handle queries), or it can be a tree of objects (useful to browse queries). To handle
complex queries, jIO uses a parsed grammar file which is complied using `JSCC <http://jscc.phorward-software.com/>`_. complex queries, jIO uses a parsed grammar file which is compiled using `JSCC <http://jscc.phorward-software.com/>`_.
Why use Complex Queries? Why use Complex Queries?
------------------------ ------------------------
...@@ -20,7 +20,7 @@ Complex queries can be used similar to database queries. So they are useful to: ...@@ -20,7 +20,7 @@ Complex queries can be used similar to database queries. So they are useful to:
* search a specific document * search a specific document
* sort a list of documents in a certain order * sort a list of documents in a certain order
* avoid retreiving a list of ten thousand documents * avoid retrieving a list of ten thousand documents
* limit the list to show only xy documents by page * limit the list to show only xy documents by page
For some storages (like localStorage), complex queries can be a powerful tool For some storages (like localStorage), complex queries can be a powerful tool
...@@ -74,6 +74,8 @@ Complex queries can be triggered by including the option named query in the allD ...@@ -74,6 +74,8 @@ Complex queries can be triggered by including the option named query in the allD
How to use Complex Queries outside jIO? How to use Complex Queries outside jIO?
--------------------------------------- ---------------------------------------
.. XXX 404 on complex_example.html
Complex Queries provides an API - which namespace is complex_queries. Please Complex Queries provides an API - which namespace is complex_queries. Please
also refer to the `Complex Queries sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/complex_example.html?js=1>`_ also refer to the `Complex Queries sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/complex_example.html?js=1>`_
on how to use these methods in- and outside jIO. The module provides: on how to use these methods in- and outside jIO. The module provides:
...@@ -140,13 +142,13 @@ Complex Queries in storage connectors ...@@ -140,13 +142,13 @@ Complex Queries in storage connectors
The query exec method must only be used if the server is not able to pre-select The query exec method must only be used if the server is not able to pre-select
documents. As mentioned before, you could use an indexStorage to maintain documents. As mentioned before, you could use an indexStorage to maintain
indices with key information on all documents in a storage. This index file indices with key information on all documents in a storage. This index file
will then be used to run queries on if all fields, required in the query answer will then be used to run queries, if all of the fields required in the query answer
are available in the index. are available in the index.
Matching properties Matching properties
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Complex Queries select items which exactly match with the value given in the Complex Queries select items which exactly match the value given in the
query. You can use wildcards ('%' is the default wildcard character), and you query. You can use wildcards ('%' is the default wildcard character), and you
can change the wildcard character in the query options object. If you don't can change the wildcard character in the query options object. If you don't
want to use a wildcard, just set the wildcard character to an empty string. want to use a wildcard, just set the wildcard character to an empty string.
...@@ -171,7 +173,7 @@ have their own default properties to keep their own behavior. ...@@ -171,7 +173,7 @@ have their own default properties to keep their own behavior.
Convert Complex Queries into another type Convert Complex Queries into another type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Example, convert Query object into human readable string: Example, convert Query object into a human readable string:
.. code-block:: javascript .. code-block:: javascript
...@@ -220,7 +222,7 @@ Example, convert Query object into human readable string: ...@@ -220,7 +222,7 @@ Example, convert Query object into human readable string:
JSON Schemas and Grammar JSON Schemas and Grammar
------------------------ ------------------------
Below you can find schemas for constructing complex queries Below you can find schemas for constructing queries.
* Complex Queries JSON Schema: * Complex Queries JSON Schema:
...@@ -330,4 +332,3 @@ Below you can find schemas for constructing complex queries ...@@ -330,4 +332,3 @@ Below you can find schemas for constructing complex queries
ignore: " " ignore: " "
...@@ -4,9 +4,9 @@ For developers ...@@ -4,9 +4,9 @@ For developers
Quick start Quick start
----------- -----------
To get started with jIO, clone one of the repositories link in :ref:`Download & Fork <download-fork>` tab. To get started with jIO, clone one of the repositories linked in :ref:`Download & Fork <download-fork>`.
To build your library you have to: To build the library you have to:
* Install `NodeJS <http://nodejs.org/>`_ (including NPM) * Install `NodeJS <http://nodejs.org/>`_ (including NPM)
* Install Grunt command line with npm. * Install Grunt command line with npm.
...@@ -19,9 +19,9 @@ To build your library you have to: ...@@ -19,9 +19,9 @@ To build your library you have to:
* Compile JS/CC parser. * Compile JS/CC parser.
``$ make`` (until we found how to compile it with grunt) ``$ make`` (until we find how to compile it with grunt)
* And run build. * Run build.
``$ grunt`` ``$ grunt``
...@@ -32,7 +32,7 @@ plus the storages and dependencies you need and you will be good to go. ...@@ -32,7 +32,7 @@ plus the storages and dependencies you need and you will be good to go.
Naming Conventions Naming Conventions
------------------ ------------------
All the code follows this :ref:`Javascript Naming Conventions <naming-conventions>`. All the code follows these :ref:`JavaScript Naming Conventions <naming-conventions>`.
How to design your own jIO Storage Library How to design your own jIO Storage Library
------------------------------------------ ------------------------------------------
...@@ -74,7 +74,7 @@ Create 10 methods: ``post``, ``put``, ``putAttachment``, ``get``, ``getAttachmen ...@@ -74,7 +74,7 @@ Create 10 methods: ``post``, ``put``, ``putAttachment``, ``get``, ``getAttachmen
(To help you to design your methods, some tools are provided by jIO.util.) (To help you design your methods, some tools are provided by jIO.util.)
The first parameter command provides some methods to act on the JIO job: The first parameter command provides some methods to act on the JIO job:
...@@ -90,14 +90,14 @@ The first parameter command provides some methods to act on the JIO job: ...@@ -90,14 +90,14 @@ The first parameter command provides some methods to act on the JIO job:
* ``retry``, to tell JIO that the job cannot be done now, but can be retried later. (same API than error) * ``retry``, to tell JIO that the job cannot be done now, but can be retried later. (same API than error)
* ``reject``, to tell JIO that the job cannot be done, let JIO to decide to retry or not. (same API than error) * ``reject``, to tell JIO that the job cannot be done, let JIO to decide whether to retry or not. (same API than error)
The second parameter ``metadata`` or ``param`` is the first parameter given by the JIO user. The second parameter ``metadata`` or ``param`` is the first parameter provided by the JIO user.
The third parameter ``option`` is the option parameter given by the JIO user. The third parameter ``option`` is the option parameter provided by the JIO user.
Detail of what should return a method: Methods should return the following objects:
* post --> success("created", {"id": new_generated_id}) * post --> success("created", {"id": new_generated_id})
...@@ -123,7 +123,7 @@ Detail of what should return a method: ...@@ -123,7 +123,7 @@ Detail of what should return a method:
// or // or
error("conflict", "corrupted", "incoherent document or storage") error("conflict", "corrupted", "incoherent document or storage")
repair --> * repair -->
.. code-block:: javascript .. code-block:: javascript
...@@ -134,9 +134,9 @@ Detail of what should return a method: ...@@ -134,9 +134,9 @@ Detail of what should return a method:
error("conflict", "corrupted", "impossible to repair document or storage") error("conflict", "corrupted", "impossible to repair document or storage")
// DON'T DESIGN STORAGES IF THEIR IS NO WAY TO REPAIR INCOHERENT STATES // DON'T DESIGN STORAGES IF THEIR IS NO WAY TO REPAIR INCOHERENT STATES
After setting up all methods, your storage must be added to jIO. This is done After creating all methods, your storage must be added to jIO. This is done
using the ``jIO.addStorage()`` method, which requires two parameters: the storage with the ``jIO.addStorage()`` method, which requires two parameters: the storage
type (string) add a constructor (function). It is called like this: type (string) and a constructor (function). It is called like this:
.. code-block:: javascript .. code-block:: javascript
...@@ -145,18 +145,19 @@ type (string) add a constructor (function). It is called like this: ...@@ -145,18 +145,19 @@ type (string) add a constructor (function). It is called like this:
Please refer to *localstorage.js* implementation for a good example on how to Please refer to *localstorage.js* implementation for a good example on how to
setup a storage and what methods are required. Also keep in mind, that jIO is a setup a storage and what methods are required.
job-based library, so whenever you trigger a method, a job is created, which
after being processed returns a response. Also keep in mind that jIO is a job-based library: whenever you trigger a method,
a job is created, which will later return a response, after being processed.
Job rules Job rules
--------- ---------
jIO job manager will follow several rules set at the creation of a new jIO The jIO job manager follows several rules set at the creation of a new jIO
instance. When you try to call a method, jIO will create a job and will make instance. When you try to call a method, jIO will create a job and will make
sure the job is really necessary and will be executed. Thanks to these job sure the job is really necessary and will be executed. Thanks to these job
rules, jIO knows what to do with the new job before adding it to the queue. You rules, jIO knows what to do with the new job before adding it to the queue. You
can add your own rules like this: can also add your own rules, as we're going to see now.
These are the jIO **default rules**: These are the jIO **default rules**:
...@@ -212,14 +213,14 @@ The following condition function can be used: ...@@ -212,14 +213,14 @@ The following condition function can be used:
* ``useMetadataOnly`` - check if the commands are ``post``, ``put``, ``get``, ``remove`` or ``allDocs``. * ``useMetadataOnly`` - check if the commands are ``post``, ``put``, ``get``, ``remove`` or ``allDocs``.
* ``sameMethod`` - check if the commands are equal. * ``sameMethod`` - check if the commands are equal.
* ``sameDocumentId`` - check if the document ids are equal. * ``sameDocumentId`` - check if the document ids are equal.
* ``sameParameters`` - check if the metadata or param are equal in deep. * ``sameParameters`` - check if the metadata or param are equal (deep comparison).
* ``sameOptions`` - check if the command options are equal. * ``sameOptions`` - check if the command options are equal.
* ``haveDocumentIds`` - test if the two commands contain document ids * ``haveDocumentIds`` - test if the two commands contain document ids.
Create Job Condition Create Job Condition
-------------------- --------------------
You can create 2 types of function: job condition, and job comparison. You can create two types of function: job condition, and job comparison.
.. code-block:: javascript .. code-block:: javascript
...@@ -267,7 +268,7 @@ You just have to define job rules in the jIO options: ...@@ -267,7 +268,7 @@ You just have to define job rules in the jIO options:
Clear/Replace default job rules Clear/Replace default job rules
------------------------------- -------------------------------
If a job which code_name is equal to readers update, then add this rule will replace it: If a job's ``code_name`` is equal to ``readers update``, then adding this rule will replace it:
.. code-block:: javascript .. code-block:: javascript
...@@ -286,7 +287,7 @@ If a job which code_name is equal to readers update, then add this rule will rep ...@@ -286,7 +287,7 @@ If a job which code_name is equal to readers update, then add this rule will rep
}] }]
}); });
Or you can just clear all rules before adding other ones: Or you can just clear all rules before adding new ones:
.. code-block:: javascript .. code-block:: javascript
......
...@@ -43,6 +43,8 @@ Revision based storage handlers: ...@@ -43,6 +43,8 @@ Revision based storage handlers:
Minified version Minified version
---------------- ----------------
.. XXX this sounds harsh. Can we provide it or at least be more explicit?
To get the minified version of the jIO library, you have to build it yourself. See documentation. To get the minified version of the jIO library, you have to build it yourself. See documentation.
Fork Fork
......
...@@ -9,19 +9,19 @@ A storage to enable interoperability between all kind of storages. ...@@ -9,19 +9,19 @@ A storage to enable interoperability between all kind of storages.
A global ID (GID) is a document id which represents a unique document. This ID A global ID (GID) is a document id which represents a unique document. This ID
will be used to find this unique document on all kind of backends. will be used to find this unique document on all kind of backends.
This storage used sub storage allDocs and complex queries to find unique documents, and convert their ids to gids. This storage uses sub storage allDocs and complex queries to find unique documents, and converts their ids to gids.
Cases where it can be used Where it can be used
-------------------------- --------------------
When you want to duplicate/synchronize/split/edit data in different kind of storages (ERP5 + XWiki + Dav + ...). When you want to duplicate / synchronize / split / edit data in different kind of storages (ERP5 + XWiki + Dav + ...).
Storage Description Storage Description
------------------- -------------------
* ``type`` - ``"gid"`` * ``type`` - ``"gid"``
* ``sub_storage`` - the sub storage description. * ``sub_storage`` - the sub storage description.
* ``constraints`` - the constraints to use to generate a gid by define metadata types for some kind of document. * ``constraints`` - the constraints to use to generate a gid by defining metadata types for some kind of document.
Example: Example:
...@@ -155,5 +155,3 @@ Offline Application Usage:: ...@@ -155,5 +155,3 @@ Offline Application Usage::
**CAUTION: All gid storage must have the same description!** **CAUTION: All gid storage must have the same description!**
...@@ -17,13 +17,15 @@ retrieve documents and specific information across storage trees. ...@@ -17,13 +17,15 @@ retrieve documents and specific information across storage trees.
How does it work? How does it work?
----------------- -----------------
.. XXX three parts?
JIO is separated into three parts - jIO core and storage library(ies). The core JIO is separated into three parts - jIO core and storage library(ies). The core
is using storage libraries (connectors) to interact with the accociated remote is using storage libraries (connectors) to interact with the associated remote
storage servers. Some queries can be used on top of the jIO allDocs method to storage servers. Some queries can be used on top of the jIO allDocs method to
query documents based on defined criteria. query documents based on defined criteria.
JIO uses a job management system, so every method called adds a job into a JIO uses a job management system, so every method called adds a job into a
queue. The queue is copied in the browsers local storage (by default), so it queue. The queue is copied in the browser's local storage (by default), so it
can be restored in case of a browser crash. Jobs are being invoked can be restored in case of a browser crash. Jobs are being invoked
asynchronously with ongoing jobs not being able to re-trigger to prevent asynchronously with ongoing jobs not being able to re-trigger to prevent
conflicts. conflicts.
...@@ -87,6 +89,8 @@ This walkthrough is designed to get you started using a basic jIO instance. ...@@ -87,6 +89,8 @@ This walkthrough is designed to get you started using a basic jIO instance.
// create your jio instance // create your jio instance
var my_jio = jIO.createJIO(storage_description); var my_jio = jIO.createJIO(storage_description);
.. XXX 6 methods or 10?
#. The jIO API provides six main methods to manage documents across the storage(s) specified in your jIO storage tree. #. The jIO API provides six main methods to manage documents across the storage(s) specified in your jIO storage tree.
================== ===================================================== ======================================== ================== ===================================================== ========================================
......
How to manage documents? How to manage documents?
======================== ========================
JIO is mapped after the CouchDB API and extends it to provide unified, scalable JIO is mapped after the CouchDB API and extends them to provide unified, scalable
and high performance access via Javascript to a wide variety of different and high performance access via Javascript to a wide variety of different
storage backends. storage backends.
If you are unfamiliar with Apache `CouchDB <http://couchdb.apache.org/>`_: If you are unfamiliar with `Apache CouchDB <http://couchdb.apache.org/>`_:
it is a scalable, fault-tolerant, and schema-free document-oriented database. it is a scalable, fault-tolerant, and schema-free document-oriented database.
It's used in large and small organizations for a variety of applications where It is used in large and small organizations for a variety of applications where
traditional SQL databases aren't the best solution for the problem at hand. traditional SQL databases are not the best solution for the problem at hand.
CouchDB provides a RESTful HTTP/JSON API accessible from many programming CouchDB provides a RESTful HTTP/JSON API accessible by many programming
libraries and tools (like 'curl' or 'Pouchdb') and has it's own conflict management system. libraries and tools (like `curl <http://curl.haxx.se/>`_ or `Pouchdb <http://pouchdb.com/>`_)
and has its own conflict management system.
What is a document? What is a document?
------------------- -------------------
A document an association with metadata and attachment(s). The metadata are the A document is an association of metadata and attachment(s). The metadata is the
properties of the document and the attachments are the binaries of the content set of properties of the document and the attachments are the binaries of the content
of the document. of the document.
In jIO, metadata are just a dictionnary with keys and values (JSON object), and In jIO, metadata is just a dictionnary with keys and values (JSON object), and
attachments are just simple strings. attachments are just simple strings.
.. code-block:: javascript .. code-block:: javascript
...@@ -60,7 +61,7 @@ Basic Methods ...@@ -60,7 +61,7 @@ Basic Methods
Below you can find sample calls of the main jIO methods. All examples are using Below you can find sample calls of the main jIO methods. All examples are using
revisions (as in revision storage or replicate revision storage), so you can revisions (as in revision storage or replicate revision storage), so you can
see, how method calls should be made with either of these storages. see how method calls should be made with either of these storages.
.. code-block:: javascript .. code-block:: javascript
:linenos: :linenos:
...@@ -71,20 +72,20 @@ see, how method calls should be made with either of these storages. ...@@ -71,20 +72,20 @@ see, how method calls should be made with either of these storages.
// create and store new document // create and store new document
jio_instance.post({"title": "some title"}). jio_instance.post({"title": "some title"}).
then(function (response) { then(function (response) {
// console.log(response): // console.log(response);
}); });
// create or update an existing document // create or update an existing document
jio_instance.put({"_id": "my_document", "title": "New Title"}). jio_instance.put({"_id": "my_document", "title": "New Title"}).
then(function (response) { then(function (response) {
// console.log(response): // console.log(response);
}); });
// add an attachement to a document // add an attachment to a document
jio_instance.putAttachment({"_id": "my_document", "_attachment": "its_attachment", jio_instance.putAttachment({"_id": "my_document", "_attachment": "its_attachment",
"_data": "abc", "_mimetype": "text/plain"}). "_data": "abc", "_mimetype": "text/plain"}).
then(function (response) { then(function (response) {
// console.log(response): // console.log(response);
}); });
// read a document // read a document
...@@ -93,7 +94,7 @@ see, how method calls should be made with either of these storages. ...@@ -93,7 +94,7 @@ see, how method calls should be made with either of these storages.
// console.log(response); // console.log(response);
}); });
// read an attachement // read an attachment
jio_instance.getAttachment({"_id": "my_document", "_attachment": "its_attachment"}). jio_instance.getAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
then(function (response) { then(function (response) {
// console.log(response); // console.log(response);
...@@ -105,7 +106,7 @@ see, how method calls should be made with either of these storages. ...@@ -105,7 +106,7 @@ see, how method calls should be made with either of these storages.
// console.log(response): // console.log(response):
}); });
// delete an attachement // delete an attachment
jio_instance.removeAttachment({"_id": "my_document", "_attachment": "its_attachment"}). jio_instance.removeAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
then(function (response) { then(function (response) {
// console.log(response): // console.log(response):
...@@ -120,7 +121,7 @@ see, how method calls should be made with either of these storages. ...@@ -120,7 +121,7 @@ see, how method calls should be made with either of these storages.
Promises Promises
-------- --------
Each JIO methods return a Promise object, which allows us to get responses into Each JIO methods returns a Promise object, which allows us to get responses into
callback parameters and to chain callbacks with other returned values. callback parameters and to chain callbacks with other returned values.
JIO uses a custom version of `RSVP.js <https://github.com/tildeio/rsvp.js>`_, adding canceler and progression features. JIO uses a custom version of `RSVP.js <https://github.com/tildeio/rsvp.js>`_, adding canceler and progression features.
...@@ -132,13 +133,10 @@ You can read more about promises: ...@@ -132,13 +133,10 @@ You can read more about promises:
* `CommonJS Promises <http://wiki.commonjs.org/wiki/Promises>`_ * `CommonJS Promises <http://wiki.commonjs.org/wiki/Promises>`_
Method Options and Callback Responses Method Options and Callback Responses
------------------------------------- -------------------------------------
To retrieve JIO responses, you have to give callbacks like this: To retrieve JIO responses, you have to provide callbacks like this:
.. code-block:: javascript .. code-block:: javascript
...@@ -337,6 +335,3 @@ localStorage contents: ...@@ -337,6 +335,3 @@ localStorage contents:
"jio/local/usr/app/myVideo/video": "..." "jio/local/usr/app/myVideo/video": "..."
} }
...@@ -60,7 +60,7 @@ List of metadata to use ...@@ -60,7 +60,7 @@ List of metadata to use
Identification Identification
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
* **"_id"**, a specific JIO metadata which helps the storage to find a documents * **"_id"**, a specific JIO metadata which helps the storage to find a document
(can be a real path name, a dc:identifier, a uuid, ...). **String Only** (can be a real path name, a dc:identifier, a uuid, ...). **String Only**
* **"identifer"**, :js:`{"identifier": "http://domain/jio_home_page"}, {"identifier": "urn:ISBN:978-1-2345-6789-X"}, * **"identifer"**, :js:`{"identifier": "http://domain/jio_home_page"}, {"identifier": "urn:ISBN:978-1-2345-6789-X"},
...@@ -101,7 +101,7 @@ Intellectual property ...@@ -101,7 +101,7 @@ Intellectual property
* **"creator"**, :js:`{"creator": "Tristan Cavelier"}, {"creator": ["Tristan Cavelier", "Sven Franck"]}` * **"creator"**, :js:`{"creator": "Tristan Cavelier"}, {"creator": ["Tristan Cavelier", "Sven Franck"]}`
an entity primarily responsible for making the content of the resource. an entity primarily responsible for creating the content of the resource.
Examples of a Creator include a person, an organization, or a service. Examples of a Creator include a person, an organization, or a service.
Typically the name of the Creator should be used to indicate the entity. Typically the name of the Creator should be used to indicate the entity.
...@@ -150,7 +150,7 @@ Content ...@@ -150,7 +150,7 @@ Content
* **"language"**, :js:`{"language": "en"}` * **"language"**, :js:`{"language": "en"}`
a language of the intellectual content of the resource. Recommended best the language of the intellectual content of the resource. Recommended best
practice for the values of the Language element is defined by `RFC 3066 <http://www.ietf.org/rfc/rfc3066.txt>`_ practice for the values of the Language element is defined by `RFC 3066 <http://www.ietf.org/rfc/rfc3066.txt>`_
which, in conjunction with `ISO 639 <http://www.oasis-open.org/cover/iso639a.html>`_, defines two- and which, in conjunction with `ISO 639 <http://www.oasis-open.org/cover/iso639a.html>`_, defines two- and
three-letter primary language tags with optional subtags. Examples include "en" three-letter primary language tags with optional subtags. Examples include "en"
...@@ -193,6 +193,8 @@ Content ...@@ -193,6 +193,8 @@ Content
* **custom**, :js:`{custom1: value1, custom2: value2, ...}` * **custom**, :js:`{custom1: value1, custom2: value2, ...}`
.. XXX short description here
Examples Examples
-------- --------
...@@ -427,8 +429,3 @@ Sources ...@@ -427,8 +429,3 @@ Sources
* https://en.wikipedia.org/wiki/Internet_media_type * https://en.wikipedia.org/wiki/Internet_media_type
* https://www.iana.org/assignments/media-types * https://www.iana.org/assignments/media-types
...@@ -12,16 +12,18 @@ This document defines JavaScript naming conventions, which are split into essent ...@@ -12,16 +12,18 @@ This document defines JavaScript naming conventions, which are split into essent
Essential Conventions Essential Conventions
--------------------- ---------------------
Essential conventions include generic patterns that should be adhered in order to write *readable*, *consistent* and *maintainable* code. Essential conventions include generic patterns that should be adhered to in order to write *readable*, *consistent* and *maintainable* code.
Minimizing Globals Minimizing Globals
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
Variable declarations should always be made using *var* to not declare them as Variable declarations should always be done using *var* to not declare them as
global variables. This avoids conflicts from using a variable name across global variables. This avoids conflicts from using a variable name across
different functions as well as conflicts with global variables declared by 3rd different functions as well as conflicts with global variables declared by third
party plugins. party plugins.
.. XXX always pub good+bad or bad+good examples in the same order
Good Example Good Example
.. code-block:: javascript .. code-block:: javascript
...@@ -52,37 +54,37 @@ writing code. ...@@ -52,37 +54,37 @@ writing code.
Before validating your code in JSLint, you should use a code Before validating your code in JSLint, you should use a code
beautifier to fix basic syntax errors (like indentation) automatically. There beautifier to fix basic syntax errors (like indentation) automatically. There
are a number of beautifiers available online. The following seem to be the best are a number of beautifiers available online. The following ones seem to work best:
working:
* `JSbeautifier.org <http://jsbeautifier.org/>`_ * `JSbeautifier.org <http://jsbeautifier.org/>`_
* `JS-Beautify <http://alexis.m2osw.com/js-beautify/>`_ * `JS-Beautify <http://alexis.m2osw.com/js-beautify/>`_
Here, javascript sources have to begin with this header: :js:`/*jslint indent: 2, In this project, JavaScript sources have to begin with the header: :js:`/*jslint indent: 2,
maxlen: 80, nomen: true */`, which means it uses two spaces indentation, 80 maxlen: 80, nomen: true */`, which means it uses two spaces indentation, 80
maximum characters by line and allow the use of '_' as first variable name maximum characters per line and the use of '_' as first character in a variable name is allowed.
character. Other JSLint options can be added in sub functions if necessary; Other JSLint options can be added in sub functions if necessary.
Allowed options are:
Some allowed options are:
* ``ass: true`` if assignment should be allowed outside of statement position. * ``ass: true`` if assignment should be allowed outside of statement position.
* ``bitwise: true`` if bitwise operators should be allowed. * ``bitwise: true`` if bitwise operators should be allowed.
* ``continue: true`` if the continue statement should be allowed. * ``continue: true`` if the continue statement should be allowed.
* ``newcap: true`` if Initial Caps with constructor function is optional. * ``newcap: true`` if Initial Caps with constructor function is optional.
* ``regexp: true`` if ``.`` and ``[^...]`` should be allowed in RegExp literals. They match more material than might be expected, allowing attackers to confuse applications. These forms should not be used when validating in secure applications. * ``regexp: true`` if ``.`` and ``[^...]`` should be allowed in RegExp literals. They match more material than might be expected, allowing attackers to confuse applications. These forms should not be used when validating in secure applications.
* ``unparam: true`` if warnings should not be given for unused parameters. * ``unparam: true`` if warnings should be silenced for unused parameters.
Coding Conventions Coding Conventions
------------------ ------------------
Coding conventions include generic patterns that ensure that written code adheres to certain formatting conventions. Coding conventions include generic patterns that ensure that written code follows certain formatting conventions.
Uses two-space indentation Uses two-space indentation
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
Tabs and 2-space indentation are being used equally. Since a lot of errors on Tabs and 2-space indentation are being used equally. Since a lot of errors on
JSLint often result from mixed use of space and tab using 2 spaces throughout JSLint often result from mixed use of space and tab, using 2 spaces throughout
prevents these errors up front. prevents these errors up front.
...@@ -189,7 +191,7 @@ Good Example ...@@ -189,7 +191,7 @@ Good Example
Closing Brace Location Closing Brace Location
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
The closing brace should be on the same indent as the original function call. The closing brace should be on the same indent level as the original function call.
Bad Example Bad Example
...@@ -249,7 +251,7 @@ Naming conventions include generic patterns for setting names and identifiers th ...@@ -249,7 +251,7 @@ Naming conventions include generic patterns for setting names and identifiers th
Constructors Constructors
^^^^^^^^^^^^ ^^^^^^^^^^^^
A constructor function starting with new should always start with a capital letter Constructor functions (called with the ``new`` statement) should always start with a capital letter:
.. code-block:: javascript .. code-block:: javascript
...@@ -299,7 +301,7 @@ Follow the camel case convention, typing the words in lower-case, only capitaliz ...@@ -299,7 +301,7 @@ Follow the camel case convention, typing the words in lower-case, only capitaliz
Variables Variables
^^^^^^^^^ ^^^^^^^^^
Variables with multiple words should always use an underscore between words. Variable names with multiple words should always use an underscore between them.
.. code-block:: javascript .. code-block:: javascript
...@@ -325,7 +327,9 @@ Example ...@@ -325,7 +327,9 @@ Example
var value_list = getObjectOrArray(); var value_list = getObjectOrArray();
// value_list can be an object which can be cast into an array // value_list can be an object which can be cast into an array
To use camelCase, when sometimes it is impossible to declare a function directly, the function variable name should match some patterns which shows that it is a function. To use camelCase, when sometimes it is not possible to declare a function
directly, the function variable name should match some pattern which shows
that it is a function.
.. code-block:: javascript .. code-block:: javascript
...@@ -402,7 +406,7 @@ Bad Example ...@@ -402,7 +406,7 @@ Bad Example
No Abbreviations No Abbreviations
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
Abbreviations should not be used to avoid confusion Abbreviations should not be used to avoid confusion.
Good Example Good Example
...@@ -422,7 +426,7 @@ Bad Example ...@@ -422,7 +426,7 @@ Bad Example
No Plurals No Plurals
^^^^^^^^^^ ^^^^^^^^^^
Plurals should not be used when assigning names Plurals should not be used as variable names.
.. code-block:: javascript .. code-block:: javascript
...@@ -436,7 +440,8 @@ Plurals should not be used when assigning names ...@@ -436,7 +440,8 @@ Plurals should not be used when assigning names
Use Comments Use Comments
^^^^^^^^^^^^ ^^^^^^^^^^^^
Should be used with reason but include enough information so that a reader can get a first grasp of what a part of code is supposed to do. Comments should be used within reason but include enough information so that a
reader can get a first grasp of what a part of code is supposed to do.
Good Example Good Example
...@@ -463,9 +468,9 @@ Bad Example ...@@ -463,9 +468,9 @@ Bad Example
Documentation Documentation
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
You can use `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_ and their custom comment You can use `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_ and its custom comment
tags together with Node.js to generate the documentation from the script file tags together with Node.js to generate the documentation from the script file
itself. Comments will look something like this: itself. Comments should look like this:
Good Example Good Example
...@@ -495,12 +500,10 @@ Bad Example ...@@ -495,12 +500,10 @@ Bad Example
Additional Readings Additional Readings
------------------- -------------------
Resources, additional reading materials and links used Resources, additional reading materials and links:
* `Javascript Patterns <http://shop.oreilly.com/product/9780596806767.do>`_, main ressource used. * `Javascript Patterns <http://shop.oreilly.com/product/9780596806767.do>`_, main ressource used.
* `JSLint <http://www.jslint.com/>`_, code quality. * `JSLint <http://www.jslint.com/>`_, code quality.
* `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_, generate documentation from code. * `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_, generate documentation from code.
...@@ -124,7 +124,9 @@ update is executed. ...@@ -124,7 +124,9 @@ update is executed.
// response.data.email -> "me_again@web.com" // response.data.email -> "me_again@web.com"
}); });
When multiple versions of a document are available, jIO returns the lastest, left-most version on the document tree (2-375... and labels all other versions as conflicting 2-068...). When multiple versions of a document are available, jIO returns the latest,
left-most version on the document tree (2-375... and labels all other
versions as conflicting 2-068...).
#. Retrieve conflicts by setting option #. Retrieve conflicts by setting option
...@@ -156,6 +158,6 @@ update is executed. ...@@ -156,6 +158,6 @@ update is executed.
When deleting the conflicting version of your namecard, jIO removes this When deleting the conflicting version of your namecard, jIO removes this
version from all storages and sets the document tree leaf of this version to version from all storages and sets the document tree leaf of this version to
deleted. All storages now contain just a single version of your namecard deleted. All storages now contain just a single version of your namecard
(2-3753...). Note, that the on the document tree, removing a revison will (2-3753...). Note that, on the document tree, removing a revison will
create a new revision with status set to *deleted*. create a new revision with status set to *deleted*.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment