Commit 68c28702 authored by Marco Mariani's avatar Marco Mariani

sphinx theme courtesy by Armin Ronacher; content rearranged; removed

build directory from repository
parent 84e37a56
_build/*
env
......@@ -3,23 +3,22 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = /home/marco/src/jio/docs/bin/sphinx-build
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = /home/marco/src/jio/docs/sphinx/build
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) /home/marco/src/jio/docs/sphinx/source
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) /home/marco/src/jio/docs/sphinx/source
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " warnings-html to make standalone HTML files (warnings become errors)"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
......@@ -47,11 +46,6 @@ html:
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
warnings-html:
$(SPHINXBUILD) -W -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
......@@ -83,17 +77,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sphinx.qhcp"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/JIO.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sphinx.qhc"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/JIO.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/sphinx"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sphinx"
@echo "# mkdir -p $$HOME/.local/share/devhelp/JIO"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/JIO"
@echo "# devhelp"
epub:
......
{%- extends "basic/layout.html" %}
{%- block extrahead %}
{{ super() }}
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
{% endif %}
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
{% endblock %}
{%- block relbar2 %}{% endblock %}
{%- block footer %}
<div class="footer">
&copy; Copyright {{ copyright }}.
<a href="https://github.com/nexedi/jio" class="github">
<img style="position: absolute; top: 0; right: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"
alt="Fork me on GitHub">
</a>
{%- endblock %}
<h3>Stay Informed</h3>
You can follow our <a href="http://www.j-io.org/blog">blog</a> to get notified about new releases.
<h3>Support</h3>
<p>
We have a <a href="http://www.j-io.org/forum">forum</a> and an <a href="https://github.com/nexedi/jio/issues">issue tracker</a>
on GitHub.
</p>
<p>
<iframe src="http://ghbtns.com/github-btn.html?user=nexedi&repo=jio&type=watch&count=true&size=large"
allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>
</p>
*.pyc
*.pyo
.DS_Store
Modifications:
Copyright (c) 2010 Kenneth Reitz.
Original Project:
Copyright (c) 2010 by Armin Ronacher.
Some rights reserved.
Redistribution and use in source and binary forms of the theme, with or
without modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
We kindly ask you to only use these themes in an unmodified manner just
for Flask and Flask-related products, not for unrelated projects. If you
like the visual style and want to use it for your own projects, please
consider making some larger changes to the themes (such as changing
font faces, sizes, colors or margins).
THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
class FlaskyStyle(Style):
background_color = "#f8f8f8"
default_style = ""
styles = {
# No corresponding class for the following:
#Text: "", # class: ''
Whitespace: "underline #f8f8f8", # class: 'w'
Error: "#a40000 border:#ef2929", # class: 'err'
Other: "#000000", # class 'x'
Comment: "italic #8f5902", # class: 'c'
Comment.Preproc: "noitalic", # class: 'cp'
Keyword: "bold #004461", # class: 'k'
Keyword.Constant: "bold #004461", # class: 'kc'
Keyword.Declaration: "bold #004461", # class: 'kd'
Keyword.Namespace: "bold #004461", # class: 'kn'
Keyword.Pseudo: "bold #004461", # class: 'kp'
Keyword.Reserved: "bold #004461", # class: 'kr'
Keyword.Type: "bold #004461", # class: 'kt'
Operator: "#582800", # class: 'o'
Operator.Word: "bold #004461", # class: 'ow' - like keywords
Punctuation: "bold #000000", # class: 'p'
# because special names such as Name.Class, Name.Function, etc.
# are not recognized as such later in the parsing, we choose them
# to look the same as ordinary variables.
Name: "#000000", # class: 'n'
Name.Attribute: "#c4a000", # class: 'na' - to be revised
Name.Builtin: "#004461", # class: 'nb'
Name.Builtin.Pseudo: "#3465a4", # class: 'bp'
Name.Class: "#000000", # class: 'nc' - to be revised
Name.Constant: "#000000", # class: 'no' - to be revised
Name.Decorator: "#888", # class: 'nd' - to be revised
Name.Entity: "#ce5c00", # class: 'ni'
Name.Exception: "bold #cc0000", # class: 'ne'
Name.Function: "#000000", # class: 'nf'
Name.Property: "#000000", # class: 'py'
Name.Label: "#f57900", # class: 'nl'
Name.Namespace: "#000000", # class: 'nn' - to be revised
Name.Other: "#000000", # class: 'nx'
Name.Tag: "bold #004461", # class: 'nt' - like a keyword
Name.Variable: "#000000", # class: 'nv' - to be revised
Name.Variable.Class: "#000000", # class: 'vc' - to be revised
Name.Variable.Global: "#000000", # class: 'vg' - to be revised
Name.Variable.Instance: "#000000", # class: 'vi' - to be revised
Number: "#990000", # class: 'm'
Literal: "#000000", # class: 'l'
Literal.Date: "#000000", # class: 'ld'
String: "#4e9a06", # class: 's'
String.Backtick: "#4e9a06", # class: 'sb'
String.Char: "#4e9a06", # class: 'sc'
String.Doc: "italic #8f5902", # class: 'sd' - like a comment
String.Double: "#4e9a06", # class: 's2'
String.Escape: "#4e9a06", # class: 'se'
String.Heredoc: "#4e9a06", # class: 'sh'
String.Interpol: "#4e9a06", # class: 'si'
String.Other: "#4e9a06", # class: 'sx'
String.Regex: "#4e9a06", # class: 'sr'
String.Single: "#4e9a06", # class: 's1'
String.Symbol: "#4e9a06", # class: 'ss'
Generic: "#000000", # class: 'g'
Generic.Deleted: "#a40000", # class: 'gd'
Generic.Emph: "italic #000000", # class: 'ge'
Generic.Error: "#ef2929", # class: 'gr'
Generic.Heading: "bold #000080", # class: 'gh'
Generic.Inserted: "#00A000", # class: 'gi'
Generic.Output: "#888", # class: 'go'
Generic.Prompt: "#745334", # class: 'gp'
Generic.Strong: "bold #000000", # class: 'gs'
Generic.Subheading: "bold #800080", # class: 'gu'
Generic.Traceback: "bold #a40000", # class: 'gt'
}
{%- extends "basic/layout.html" %}
{%- block extrahead %}
{{ super() }}
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
{% endif %}
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
{% endblock %}
{%- block relbar2 %}{% endblock %}
{%- block footer %}
<div class="footer">
&copy; Copyright {{ copyright }}.
</div>
<a href="https://github.com/myusuf3/delorean" class="github">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
</a>
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '50f10bd6613f5d3e2c00000e');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
{%- endblock %}
<h3>Related Topics</h3>
<ul>
<li><a href="{{ pathto(master_doc) }}">Documentation overview</a><ul>
{%- for parent in parents %}
<li><a href="{{ parent.link|e }}">{{ parent.title }}</a><ul>
{%- endfor %}
{%- if prev %}
<li>Previous: <a href="{{ prev.link|e }}" title="{{ _('previous chapter')
}}">{{ prev.title }}</a></li>
{%- endif %}
{%- if next %}
<li>Next: <a href="{{ next.link|e }}" title="{{ _('next chapter')
}}">{{ next.title }}</a></li>
{%- endif %}
{%- for parent in parents %}
</ul></li>
{%- endfor %}
</ul></li>
</ul>
/*
* flasky.css_t
* ~~~~~~~~~~~~
*
* :copyright: Copyright 2010 by Armin Ronacher. Modifications by Kenneth Reitz.
* :license: Flask Design License, see LICENSE for details.
*/
{% set page_width = '940px' %}
{% set sidebar_width = '220px' %}
@import url("basic.css");
/* -- page layout ----------------------------------------------------------- */
body {
font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro';
font-size: 17px;
background-color: white;
color: #000;
margin: 0;
padding: 0;
}
div.document {
width: {{ page_width }};
margin: 30px auto 0 auto;
}
div.documentwrapper {
float: left;
width: 100%;
}
div.bodywrapper {
margin: 0 0 0 {{ sidebar_width }};
}
div.sphinxsidebar {
width: {{ sidebar_width }};
}
hr {
border: 1px solid #B1B4B6;
}
div.body {
background-color: #ffffff;
color: #3E4349;
padding: 0 30px 0 30px;
}
img.floatingflask {
padding: 0 0 10px 10px;
float: right;
}
div.footer {
width: {{ page_width }};
margin: 20px auto 30px auto;
font-size: 14px;
color: #888;
text-align: right;
}
div.footer a {
color: #888;
}
div.related {
display: none;
}
div.sphinxsidebar a {
color: #444;
text-decoration: none;
border-bottom: 1px dotted #999;
}
div.sphinxsidebar a:hover {
border-bottom: 1px solid #999;
}
div.sphinxsidebar {
font-size: 14px;
line-height: 1.5;
}
div.sphinxsidebarwrapper {
padding: 18px 10px;
}
div.sphinxsidebarwrapper p.logo {
padding: 0;
margin: -10px 0 0 -20px;
text-align: center;
}
div.sphinxsidebarwrapper h1 {
font-size: 25px;
}
div.sphinxsidebar h3,
div.sphinxsidebar h4 {
font-family: 'Garamond', 'Georgia', serif;
color: #444;
font-size: 24px;
font-weight: normal;
margin: 0 0 5px 0;
padding: 0;
}
div.sphinxsidebar h4 {
font-size: 20px;
}
div.sphinxsidebar h3 a {
color: #444;
}
div.sphinxsidebar p.logo a,
div.sphinxsidebar h3 a,
div.sphinxsidebar p.logo a:hover,
div.sphinxsidebar h3 a:hover {
border: none;
}
div.sphinxsidebar p {
color: #555;
margin: 10px 0;
}
div.sphinxsidebar ul {
margin: 10px 0;
padding: 0;
color: #000;
}
div.sphinxsidebar input {
border: 1px solid #ccc;
font-family: 'Georgia', serif;
font-size: 1em;
}
/* -- body styles ----------------------------------------------------------- */
a {
color: #004B6B;
text-decoration: underline;
}
a:hover {
color: #6D4100;
text-decoration: underline;
}
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: 'Garamond', 'Georgia', serif;
font-weight: normal;
margin: 30px 0px 10px 0px;
padding: 0;
}
div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
div.body h2 { font-size: 180%; }
div.body h3 { font-size: 150%; }
div.body h4 { font-size: 130%; }
div.body h5 { font-size: 100%; }
div.body h6 { font-size: 100%; }
a.headerlink {
color: #ddd;
padding: 0 4px;
text-decoration: none;
}
a.headerlink:hover {
color: #444;
background: #eaeaea;
}
div.body p, div.body dd, div.body li {
line-height: 1.4em;
}
div.admonition {
background: #fafafa;
margin: 20px -30px;
padding: 10px 30px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
div.admonition tt.xref, div.admonition a tt {
border-bottom: 1px solid #fafafa;
}
dd div.admonition {
margin-left: -60px;
padding-left: 60px;
}
div.admonition p.admonition-title {
font-family: 'Garamond', 'Georgia', serif;
font-weight: normal;
font-size: 24px;
margin: 0 0 10px 0;
padding: 0;
line-height: 1;
}
div.admonition p.last {
margin-bottom: 0;
}
div.highlight {
background-color: white;
}
dt:target, .highlight {
background: #FAF3E8;
}
div.note {
background-color: #eee;
border: 1px solid #ccc;
}
div.seealso {
background-color: #ffc;
border: 1px solid #ff6;
}
div.topic {
background-color: #eee;
}
p.admonition-title {
display: inline;
}
p.admonition-title:after {
content: ":";
}
pre, tt {
font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
font-size: 0.9em;
}
img.screenshot {
}
tt.descname, tt.descclassname {
font-size: 0.95em;
}
tt.descname {
padding-right: 0.08em;
}
img.screenshot {
-moz-box-shadow: 2px 2px 4px #eee;
-webkit-box-shadow: 2px 2px 4px #eee;
box-shadow: 2px 2px 4px #eee;
}
table.docutils {
border: 1px solid #888;
-moz-box-shadow: 2px 2px 4px #eee;
-webkit-box-shadow: 2px 2px 4px #eee;
box-shadow: 2px 2px 4px #eee;
}
table.docutils td, table.docutils th {
border: 1px solid #888;
padding: 0.25em 0.7em;
}
table.field-list, table.footnote {
border: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
table.footnote {
margin: 15px 0;
width: 100%;
border: 1px solid #eee;
background: #fdfdfd;
font-size: 0.9em;
}
table.footnote + table.footnote {
margin-top: -15px;
border-top: none;
}
table.field-list th {
padding: 0 0.8em 0 0;
}
table.field-list td {
padding: 0;
}
table.footnote td.label {
width: 0px;
padding: 0.3em 0 0.3em 0.5em;
}
table.footnote td {
padding: 0.3em 0.5em;
}
dl {
margin: 0;
padding: 0;
}
dl dd {
margin-left: 30px;
}
blockquote {
margin: 0 0 0 30px;
padding: 0;
}
ul, ol {
margin: 10px 0 10px 30px;
padding: 0;
}
pre {
background: #eee;
padding: 7px 30px;
line-height: 1.3em;
}
dl pre, blockquote pre, li pre {
margin-left: -60px;
padding-left: 60px;
}
dl dl pre {
margin-left: -90px;
padding-left: 90px;
}
tt {
background-color: #ecf0f3;
color: #222;
/* padding: 1px 2px; */
}
tt.xref, a tt {
background-color: #FBFBFB;
border-bottom: 1px solid white;
}
a.reference {
text-decoration: none;
border-bottom: 1px dotted #004B6B;
}
a.reference:hover {
border-bottom: 1px solid #6D4100;
}
a.footnote-reference {
text-decoration: none;
font-size: 0.7em;
vertical-align: top;
border-bottom: 1px dotted #004B6B;
}
a.footnote-reference:hover {
border-bottom: 1px solid #6D4100;
}
a:hover tt {
background: #EEE;
}
@media screen and (max-width: 870px) {
div.sphinxsidebar {
display: none;
}
div.document {
width: 100%;
}
div.documentwrapper {
margin-left: 0;
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
}
div.bodywrapper {
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
margin-left: 0;
}
ul {
margin-left: 0;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.bodywrapper {
margin: 0;
}
.footer {
width: auto;
}
.github {
display: none;
}
}
@media screen and (max-width: 875px) {
body {
margin: 0;
padding: 20px 30px;
}
div.documentwrapper {
float: none;
background: white;
}
div.sphinxsidebar {
display: block;
float: none;
width: 102.5%;
margin: 50px -30px -20px -30px;
padding: 10px 20px;
background: #333;
color: white;
}
div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p,
div.sphinxsidebar h3 a {
color: white;
}
div.sphinxsidebar a {
color: #aaa;
}
div.sphinxsidebar p.logo {
display: none;
}
div.document {
width: 100%;
margin: 0;
}
div.related {
display: block;
margin: 0;
padding: 10px 0 20px 0;
}
div.related ul,
div.related ul li {
margin: 0;
padding: 0;
}
div.footer {
display: none;
}
div.bodywrapper {
margin: 0;
}
div.body {
min-height: 0;
padding: 0;
}
.rtd_doc_footer {
display: none;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.footer {
width: auto;
}
.github {
display: none;
}
}
/* misc. */
.revsys-inline {
display: none!important;
}
/*
* small_flask.css_t
* ~~~~~~~~~~~~~~~~~
*
* :copyright: Copyright 2010 by Armin Ronacher.
* :license: Flask Design License, see LICENSE for details.
*/
body {
margin: 0;
padding: 20px 30px;
}
div.documentwrapper {
float: none;
background: white;
}
div.sphinxsidebar {
display: block;
float: none;
width: 102.5%;
margin: 50px -30px -20px -30px;
padding: 10px 20px;
background: #333;
color: white;
}
div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p,
div.sphinxsidebar h3 a {
color: white;
}
div.sphinxsidebar a {
color: #aaa;
}
div.sphinxsidebar p.logo {
display: none;
}
div.document {
width: 100%;
margin: 0;
}
div.related {
display: block;
margin: 0;
padding: 10px 0 20px 0;
}
div.related ul,
div.related ul li {
margin: 0;
padding: 0;
}
div.footer {
display: none;
}
div.bodywrapper {
margin: 0;
}
div.body {
min-height: 0;
padding: 0;
}
[theme]
inherit = basic
stylesheet = flasky.css
pygments_style = flask_theme_support.FlaskyStyle
[options]
touch_icon =
{% extends "basic/layout.html" %}
{% block header %}
{{ super() }}
{% if pagename == 'index' %}
<div class=indexwrapper>
{% endif %}
{% endblock %}
{% block footer %}
{% if pagename == 'index' %}
</div>
{% endif %}
{% endblock %}
{# do not display relbars #}
{% block relbar1 %}{% endblock %}
{% block relbar2 %}
{% if theme_github_fork %}
<a href="http://github.com/{{ theme_github_fork }}"><img style="position: fixed; top: 0; right: 0; border: 0;"
src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
{% endif %}
{% endblock %}
{% block sidebar1 %}{% endblock %}
{% block sidebar2 %}{% endblock %}
/*
* default.css_t
* ~~~~~~~~~~~~~
* flasky.css_t
* ~~~~~~~~~~~~
*
* Sphinx stylesheet -- default theme.
* Sphinx stylesheet -- flasky theme based on nature theme.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@import url("basic.css");
/* -- page layout ----------------------------------------------------------- */
body {
font-family: sans-serif;
font-size: 100%;
background-color: #11303d;
font-family: 'Georgia', serif;
font-size: 17px;
color: #000;
background: white;
margin: 0;
padding: 0;
}
div.document {
background-color: #1c4e63;
}
div.documentwrapper {
float: left;
width: 100%;
}
div.bodywrapper {
margin: 0 0 0 230px;
margin: 40px auto 0 auto;
width: 700px;
}
hr {
border: 1px solid #B1B4B6;
}
div.body {
background-color: #ffffff;
color: #000000;
padding: 0 20px 30px 20px;
color: #3E4349;
padding: 0 30px 30px 30px;
}
div.footer {
color: #ffffff;
width: 100%;
padding: 9px 0 9px 0;
text-align: center;
font-size: 75%;
img.floatingflask {
padding: 0 0 10px 10px;
float: right;
}
div.footer {
text-align: right;
color: #888;
padding: 10px;
font-size: 14px;
width: 650px;
margin: 0 auto 40px auto;
}
div.footer a {
color: #ffffff;
color: #888;
text-decoration: underline;
}
div.related {
background-color: #133f52;
line-height: 30px;
color: #ffffff;
}
div.related a {
color: #ffffff;
}
div.sphinxsidebar {
}
div.sphinxsidebar h3 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.4em;
font-weight: normal;
margin: 0;
padding: 0;
}
div.sphinxsidebar h3 a {
color: #ffffff;
}
div.sphinxsidebar h4 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.3em;
font-weight: normal;
margin: 5px 0 0 0;
padding: 0;
line-height: 32px;
color: #888;
}
div.sphinxsidebar p {
color: #ffffff;
div.related ul {
padding: 0 0 0 10px;
}
div.sphinxsidebar p.topless {
margin: 5px 10px 10px 10px;
}
div.sphinxsidebar ul {
margin: 10px;
padding: 0;
color: #ffffff;
}
div.sphinxsidebar a {
color: #98dbcc;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
div.related a {
color: #444;
}
/* -- hyperlink styles ------------------------------------------------------ */
/* -- body styles ----------------------------------------------------------- */
a {
color: #355f7c;
text-decoration: none;
}
a:visited {
color: #355f7c;
text-decoration: none;
color: #004B6B;
text-decoration: underline;
}
a:hover {
color: #6D4100;
text-decoration: underline;
}
/* -- body styles ----------------------------------------------------------- */
div.body {
padding-bottom: 40px; /* saved for footer */
}
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: 'Trebuchet MS', sans-serif;
background-color: #f2f2f2;
font-family: 'Garamond', 'Georgia', serif;
font-weight: normal;
color: #20435c;
border-bottom: 1px solid #ccc;
margin: 20px -20px 10px -20px;
padding: 3px 0 3px 10px;
margin: 30px 0px 10px 0px;
padding: 0;
}
div.body h1 { margin-top: 0; font-size: 200%; }
div.body h2 { font-size: 160%; }
div.body h3 { font-size: 140%; }
div.body h4 { font-size: 120%; }
div.body h5 { font-size: 110%; }
{% if theme_index_logo %}
div.indexwrapper h1 {
text-indent: -999999px;
background: url({{ theme_index_logo }}) no-repeat center center;
height: {{ theme_index_logo_height }};
}
{% endif %}
div.body h2 { font-size: 180%; }
div.body h3 { font-size: 150%; }
div.body h4 { font-size: 130%; }
div.body h5 { font-size: 100%; }
div.body h6 { font-size: 100%; }
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
color: white;
padding: 0 4px;
text-decoration: none;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
color: #444;
background: #eaeaea;
}
div.body p, div.body dd, div.body li {
text-align: justify;
line-height: 130%;
line-height: 1.4em;
}
div.admonition p.admonition-title + p {
display: inline;
div.admonition {
background: #fafafa;
margin: 20px -30px;
padding: 10px 30px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
div.admonition p {
margin-bottom: 5px;
div.admonition p.admonition-title {
font-family: 'Garamond', 'Georgia', serif;
font-weight: normal;
font-size: 24px;
margin: 0 0 10px 0;
padding: 0;
line-height: 1;
}
div.admonition pre {
margin-bottom: 5px;
div.admonition p.last {
margin-bottom: 0;
}
div.admonition ul, div.admonition ol {
margin-bottom: 5px;
div.highlight{
background-color: white;
}
dt:target, .highlight {
background: #FAF3E8;
}
div.note {
background-color: #eee;
border: 1px solid #ccc;
}
div.seealso {
background-color: #ffc;
border: 1px solid #ff6;
}
div.topic {
background-color: #eee;
}
div.warning {
background-color: #ffe4e4;
border: 1px solid #f66;
}
p.admonition-title {
display: inline;
}
p.admonition-title:after {
content: ":";
}
pre {
padding: 5px;
background-color: #eeffcc;
color: #333333;
line-height: 120%;
border: 1px solid #ac9;
border-left: none;
border-right: none;
pre, tt {
font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
font-size: 0.85em;
}
tt {
background-color: #ecf0f3;
padding: 0 1px 0 1px;
img.screenshot {
}
tt.descname, tt.descclassname {
font-size: 0.95em;
}
th {
background-color: #ede;
tt.descname {
padding-right: 0.08em;
}
img.screenshot {
-moz-box-shadow: 2px 2px 4px #eee;
-webkit-box-shadow: 2px 2px 4px #eee;
box-shadow: 2px 2px 4px #eee;
}
.warning tt {
background: #efc2c2;
table.docutils {
border: 1px solid #888;
-moz-box-shadow: 2px 2px 4px #eee;
-webkit-box-shadow: 2px 2px 4px #eee;
box-shadow: 2px 2px 4px #eee;
}
.note tt {
background: #d6d6d6;
table.docutils td, table.docutils th {
border: 1px solid #888;
padding: 0.25em 0.7em;
}
.viewcode-back {
font-family: sans-serif;
table.field-list, table.footnote {
border: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
div.viewcode-block:target {
background-color: #f4debf;
border-top: 1px solid #ac9;
border-bottom: 1px solid #ac9;
}
\ No newline at end of file
table.footnote {
margin: 15px 0;
width: 100%;
border: 1px solid #eee;
}
table.field-list th {
padding: 0 0.8em 0 0;
}
table.field-list td {
padding: 0;
}
table.footnote td {
padding: 0.5em;
}
dl {
margin: 0;
padding: 0;
}
dl dd {
margin-left: 30px;
}
pre {
padding: 0;
margin: 15px -30px;
padding: 8px;
line-height: 1.3em;
padding: 7px 30px;
background: #eee;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
dl pre {
margin-left: -60px;
padding-left: 60px;
}
tt {
background-color: #ecf0f3;
color: #222;
/* padding: 1px 2px; */
}
tt.xref, a tt {
background-color: #FBFBFB;
}
a:hover tt {
background: #EEE;
}
[theme]
inherit = basic
stylesheet = flasky.css
nosidebar = true
pygments_style = flask_theme_support.FlaskyStyle
[options]
index_logo = ''
index_logo_height = 120px
github_fork = ''
......@@ -66,7 +66,7 @@ release = '2.0.0'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
......@@ -83,8 +83,7 @@ exclude_patterns = []
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
#pygments_style = 'sphinx'
pygments_style = 'manni'
pygments_style = 'default'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
......@@ -134,7 +133,11 @@ html_static_path = ['_static']
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
html_sidebars = {
'index': ['side-top.html', 'side-support.html', 'side-informed.html', 'searchbox.html'],
'**': ['side-top.html', 'localtoc.html', 'relations.html', 'searchbox.html']
}
# Additional templates that should be rendered to pages, maps page names to
# template names.
......@@ -231,7 +234,7 @@ man_pages = [
# dir menu entry, description, category)
texinfo_documents = [
('index', 'jIO', u'jIO Documentation',
u'Nexedi', 'jIO', 'One line description of project.',
u'Nexedi', 'jIO', 'A JavaScript library to manage documents across multiple storages.',
'Miscellaneous'),
]
......@@ -243,3 +246,8 @@ texinfo_documents = [
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
sys.path.append(os.path.abspath('_themes'))
html_theme_path = ['_themes']
html_theme = 'kr'
.. role:: js(code)
:language: javascript
Getting started
===============
This walkthrough is designed to get you started using a basic jIO instance.
#. Download jIO core, the storages you want to use as well as the
complex-queries scripts and the dependencies required for the storages
you intend to use. :ref:`[Download & Fork] <download-fork>`
#. Add the scripts to your HTML page in the following order:
.. code-block:: html
<!-- jio core + dependency -->
<script src="sha256.amd.js"></script>
<script src="rsvp-custom.js"></script>
<script src="jio.js"></script>
<!-- storages + dependencies -->
<script src="complex_queries.js"></script>
<script src="localstorage.js"></script>
<script src="davstorage.js"></script>
<script ...>
With `RequireJS <http://requirejs.org/>`_, the main.js will look like:
.. code-block:: javascript
require.config({
"paths": {
// jio core + dependency
// the AMD compatible version of sha256.js,
// see Download and Fork
"sha256": "sha256.amd",
"rsvp": "rsvp-custom",
"jio": "jio",
// storages + dependencies
"complex_queries": "complex_queries",
"localstorage": "localstorage",
"davstorage": "davstorage"
}
});
#. jIO connects to a number of storages and allows adding handlers (or
functions) to specifc storages.
You can use both handlers and available storages to build a storage
tree across which all documents will be maintained and managed by jIO.
See :ref:`List of Available Storages <list-of-available-storages>`.
.. code-block:: javascript
// create your jio instance
var my_jio = jIO.createJIO(storage_description);
#. The jIO API provides ten main methods to manage documents across the storage(s) specified in your jIO storage tree.
====================== ===================================================== ========================================
Method Example call Description
====================== ===================================================== ========================================
``post()`` :js:`my_jio.post(document, [options]);` Creates a new document
``put()`` :js:`my_jio.put(document, [options]);` Creates/Updates a document
``putAttachment()`` :js:`my_jio.putAttachement(attachment, [options]);` Updates/Adds an attachment to a document
``get()`` :js:`my_jio.get(document, [options]);` Reads a document
``getAttachment()`` :js:`my_jio.getAttachment(attachment, [options]);` Reads a document attachment
``remove()`` :js:`my_jio.remove(document, [options]);` Deletes a document and its attachments
``removeAttachment()`` :js:`my_jio.removeAttachment(attachment, [options]);` Deletes a document attachment
``allDocs()`` :js:`my_jio.allDocs([options]);` Retrieves a list of existing documents
``check()`` :js:`my_jio.check(document, [options]);` Check the document state
``repair()`` :js:`my_jio.repair(document, [options]);` Repair the document
====================== ===================================================== ========================================
.. _download-fork:
Downloads
=========
Download & Fork
---------------
Core
^^^^
......@@ -54,14 +135,20 @@ Minified version
To get the minified version of the jIO library, you have to build it yourself. See documentation.
Fork
^^^^
Unit tests
^^^^^^^^^^
We monitor code quality with a `test agent <http://www.j-io.org/quality/unit_test>`_ that runs
the test suite with each release.
Fork jIO
^^^^^^^^
jIO source code
The same source code is kept in three synchronized repositories.
Feel free to use any of them.
=============================================== ============================================= ========================================== =======================================
Clone (read only) Git Erp5 Gitorious Github
``git clone http://git.erp5.org/repos/jio.git`` `View <http://git.erp5.org/gitweb/jio.git>`_ `View <https://gitorious.org/nexedi/jio>`_ `View <https://github.com/nexedi/jio>`_
=============================================== ============================================= ========================================== =======================================
* `GitHub <https://github.com/nexedi/jio>`_: ``git clone https://github.com/nexedi/jio.git``
* `Gitorius <https://gitorious.org/nexedi/jio>`_: ``git clone https://git.gitorious.org/nexedi/jio.git``
* `Git Erp5 <http://git.erp5.org/gitweb/jio.git>`_ (read only): ``git clone http://git.erp5.org/repos/jio.git``
.. jIO documentation master file, created by
sphinx-quickstart on Fri Nov 15 11:55:08 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to jIO
==============
jIO is a JavaScript library that allows to manage JSON documents on local or
remote storages in asynchronous fashion. jIO is an abstracted API mapped after
CouchDB, that offers connectors to multiple storages, special handlers to
enhance functionality (replication, revisions, indexing) and a query module to
retrieve documents and specific information across storage trees.
How does it work?
-----------------
jIO is composed of two parts - jIO core and storage library(ies). The core
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
query documents based on defined criteria.
jIO uses a job management system, so each method call adds a job into a
queue. The queue is copied in the browser's local storage (by default), so it
can be restored in case of browser crash. Jobs are invoked
asynchronously and ongoing jobs are not able to re-trigger to prevent
conflicts.
Copyright and license
---------------------
jIO is open source and is licensed under the `LGPL <http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License>`_ license.
jIO documentation
-----------------
.. toctree::
:maxdepth: 2
getting_started
manage_documents
revision_storages
available_storages
gid_storage
complex_queries
metadata
developers
naming_conventions
authors
......@@ -24,7 +24,6 @@ In jIO, metadata is just a dictionary with keys and values (JSON object), and
attachments are just simple strings.
.. code-block:: javascript
:linenos:
{
// document metadata
......@@ -36,7 +35,6 @@ attachments are just simple strings.
You can also retrieve document attachment metadata in this object.
.. code-block:: javascript
:linenos:
{
// document metadata
......@@ -64,7 +62,6 @@ revisions (as in revision storage or replicate revision storage), so you can
see how method calls should be made with either of these storages.
.. code-block:: javascript
:linenos:
// Create a new jIO instance
var jio_instance = jIO.newJio(storage tree description);
......
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: b5eff715ffe3e787813e3b29d0dd7b1f
tags: fbb0d17656682115ca4d033fb2f83ba1
Authors
=======
* Francois Billioud
* Tristan Cavelier
* Sven Franck
.. role:: js(code)
:language: javascript
.. _list-of-available-storages:
List of Available Storages
==========================
jIO saves his job queue in a workspace which is localStorage by default.
Provided storage descriptions are also stored, and it can be dangerous to
store passwords.
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
cleartext, readable passwords (as opposed to encrypted passwords for instance).
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 compatibility of simple and
revision based storages.
Connectors
----------
LocalStorage
^^^^^^^^^^^^
Three methods are provided:
* :js:`createDescription(username, [application_name], [mode="localStorage"])`
* :js:`createLocalDescription(username, [application_name])`
* :js:`createMemoryDescription(username, [application_name])`
All parameters are strings.
Examples:
.. code-block:: javascript
// to work on browser localStorage
var jio = jIO.createJIO(local_storage.createDescription("me"));
// to work on browser memory
var jio = jIO.createJIO(local_storage.createMemoryDescription("me"));
DavStorage
^^^^^^^^^^
The method ``dav_storage.createDescription()`` generates a DAV storage description for
*none*, *basic* or *digest* authentication.
NB: digest **is not implemented yet**.
.. code-block:: javascript
dav_storage.createDescription(url, auth_type, [realm], [username], [password]);
All parameters are strings.
============= ========================
parameter required?
============= ========================
``url`` yes
``auth_type`` yes
``realm`` if auth_type == 'digest'
``username`` if auth_type != 'none'
``password`` if auth-type != 'none'
============= ========================
If ``auth_type`` is "none", then ``realm``, ``username`` and ``password`` are never used.
**Be careful**: The generated description never contains a readable password, but
for basic authentication, the password will just be base64 encoded.
S3Storage
^^^^^^^^^
Updating to v2.0
XWikiStorage
^^^^^^^^^^^^
Updating to v2.0
Handlers
--------
IndexStorage
^^^^^^^^^^^^
This handler indexes documents metadata into a database (which is a simple
document) to increase the speed of ``allDocs()`` requests. However, it is not able to
manage the ``include_docs`` option.
The sub storages have to manage ``query`` and ``include_docs`` options.
Here is the description:
.. code-block:: javascript
{
"type": "index",
"indices": [{
"id": "index_title_subject.json", // doc id where to store indices
"index": ["title", "subject"], // metadata to index
"attachment": "db.json", // default "body"
"metadata": { // additional metadata to add to database, default undefined
"type": "Dataset",
"format": "application/json",
"title": "My index database",
"creator": "Me"
},
"sub_storage": <sub storage where to store index>
// default equal to parent sub_storage field
}, {
"id": "index_year.json",
"index": "year"
...
}],
"sub_storage": <sub storage description>
}
GIDStorage
^^^^^^^^^^
:ref:`Full description here <gid-storage>`.
Updating to v2.0
SplitStorage
^^^^^^^^^^^^
Updating to v2.0
Replicate Storage
^^^^^^^^^^^^^^^^^
Comming soon
Revision Based Handlers
-----------------------
A revision based handler is a storage which is able to do some document
versioning using simple storages listed above.
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 that document.
On command responses, you will find another field ``rev`` which will represent the
new revision produced by your action. All the document history is kept unless
you decide to delete older revisions.
Other fields ``conflicts``, ``revisions`` and ``revs_info`` can be returned if the
options **conflicts: true**, **revs: true** or **revs_info: true** are set.
Revision Storage
^^^^^^^^^^^^^^^^
Updating to v2.0
Replicate Revision Storage
^^^^^^^^^^^^^^^^^^^^^^^^^^
Updating to v2.0
jIO Complex Queries
===================
What are Complex Queries?
-------------------------
In jIO, a complex query can ask a storage server to select, filter, sort, or
limit a document list before sending it back. If the server is not able to do
so, the complex query tool can act on the retreived list by itself. Only the
``allDocs()`` method can use complex queries.
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
complex queries, jIO uses a parsed grammar file which is compiled using `JSCC <http://jscc.phorward-software.com/>`_.
Why use Complex Queries?
------------------------
Complex queries can be used like database queries, for tasks such as:
* search a specific document
* sort a list of documents in a certain order
* avoid retrieving a list of ten thousand documents
* limit the list to show only N documents per page
For some storages (like localStorage), complex queries can be a powerful tool
to query accessible documents. When querying documents on a distant storage,
some server-side logic should be run to avoid having to request large amount of
documents to run a query on the client. If distant storages are static, an
alternative would be to use an indexStorage with appropriate indices as complex
queries will always try to run the query on the index before querying documents
itself.
How to use Complex Queries with jIO?
------------------------------------
Complex queries can be triggered by including the option named query in the ``allDocs()`` method call.
Example:
.. code-block:: javascript
var options = {};
// search text query
options['query'] = '(creator:"John Doe") AND (format:"pdf")';
// OR query tree
options['query'] = {
type:'complex',
operator:'AND',
query_list: [{
"type": "simple",
"key": "creator",
"value": "John Doe"
}, {
"type": "simple",
"key": "format",
"value": "pdf"
}]
};
// FULL example using filtering criteria
options = {
query: '(creator:"% Doe") AND (format:"pdf")',
limit: [0, 100],
sort_on: [['last_modified', 'descending'], ['creation_date', 'descending']],
select_list: ['title'],
wildcard_character: '%'
};
// execution
jio_instance.allDocs(options, callback);
How to use Complex Queries outside jIO?
---------------------------------------
.. XXX 404 page missing on complex_example.html
Complex Queries provides an API - which namespace is complex_queries.
Refer to the `Complex Queries sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/complex_example.html?js=1>`_
for how to use these methods, in and outside jIO. The module provides:
.. code-block:: javascript
{
parseStringToObject: [Function: parseStringToObject],
stringEscapeRegexpCharacters: [Function: stringEscapeRegexpCharacters],
select: [Function: select],
sortOn: [Function: sortOn],
limit: [Function: limit],
convertStringToRegExp: [Function: convertStringToRegExp],
QueryFactory: { [Function: QueryFactory] create: [Function] },
Query: [Function: Query],
SimpleQuery: { [Function: SimpleQuery] super_: [Function: Query] },
ComplexQuery: { [Function: ComplexQuery] super_: [Function: Query] }
}
(Reference API coming soon.)
Basic example:
.. code-block:: javascript
// object list (generated from documents in storage or index)
var object_list = [
{"title": "Document number 1", "creator": "John Doe"},
{"title": "Document number 2", "creator": "James Bond"}
];
// the query to run
var query = 'title: "Document number 1"';
// running the query
var result = complex_queries.QueryFactory.create(query).exec(object_list);
// console.log(result);
// [ { "title": "Document number 1", "creator": "John Doe"} ]
Other example:
.. code-block:: javascript
var result = complex_queries.QueryFactory.create(query).exec(
object_list,
{
"select": ['title', 'year'],
"limit": [20, 20], // from 20th to 40th document
"sort_on": [['title', 'ascending'], ['year', 'descending']],
"other_keys_and_values": "are_ignored"
}
);
// this case is equal to:
var result = complex_queries.QueryFactory.create(query).exec(object_list);
complex_queries.sortOn([['title', 'ascending'], ['year', 'descending']], result);
complex_queries.limit([20, 20], result);
complex_queries.select(['title', 'year'], result);
Complex Queries in storage connectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
indices with key information on all documents in a storage. This index file
will then be used to run queries, if all of the fields required in the query answer
are available in the index.
Matching properties
^^^^^^^^^^^^^^^^^^^
Complex Queries select items which exactly match the value given in the
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
want to use a wildcard, just set the wildcard character to an empty string.
.. code-block:: javascript
var query = {
"query": 'creator:"* Doe"',
"wildcard_character": "*"
};
Should default search types be defined in jIO or in user interface components?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Default search types should be defined in the application's user interface
components because criteria like filters will be changed frequently by the
component (change ``limit: [0, 10]`` to ``limit: [10, 10]`` or ``sort_on: [['title',
'ascending']]`` to ``sort_on: [['creator', 'ascending']]``) and each component must
have its own default properties to keep their own behavior.
Convert Complex Queries into another type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Example, convert Query object into a human readable string:
.. code-block:: javascript
var query = complex_queries.QueryFactory.create('year: < 2000 OR title: "*a"'),
option = {
"wildcard_character": "*",
"limit": [0, 10]
},
human_read = {
"<": "is lower than ",
"<=": "is lower or equal than ",
">": "is greater than ",
">=": "is greater or equal than ",
"=": "matches ",
"!=": "doesn't match "
};
query.onParseStart = function (object, option) {
object.start = "The wildcard character is '" +
(option.wildcard_character || "%") +
"' and we need only the " + option.limit[1] + " elements from the numero " +
option.limit[0] + ". ";
};
query.onParseSimpleQuery = function (object, option) {
object.parsed = object.parsed.key + " " + human_read[object.parsed.operator] +
object.parsed.value;
};
query.onParseComplexQuery = function (object, option) {
object.parsed = "I want all document where " +
object.parsed.query_list.join(" " + object.parsed.operator.toLowerCase() +
" ") + ". ";
};
query.onParseEnd = function (object, option) {
object.parsed = object.start + object.parsed + "Thank you!";
};
console.log(query.parse(option));
// logged: "The wildcard character is '*' and we need only the 10 elements
// from the numero 0. I want all document where year is lower than 2000 or title
// matches *a. Thank you!"
JSON Schemas and Grammar
------------------------
Below you can find schemas for constructing queries.
* Complex Queries JSON Schema:
.. code-block:: javascript
{
"id": "ComplexQuery",
"properties": {
"type": {
"type": "string",
"format": "complex",
"default": "complex",
"description": "The type is used to recognize the query type."
},
"operator": {
"type": "string",
"format": "(AND|OR|NOT)",
"required": true,
"description": "Can be 'AND', 'OR' or 'NOT'."
},
"query_list": {
"type": "array",
"items": {
"type": "object"
},
"required": true,
"default": [],
"description": "query_list is a list of queries which can be in serialized format of in object format."
}
}
}
* Simple Queries JSON Schema:
.. code-block:: javascript
{
"id": "SimpleQuery",
"properties": {
"type": {
"type": "string",
"format": "simple",
"default": "simple",
"description": "The type is used to recognize the query type."
},
"operator": {
"type": "string",
"default": "=",
"format": "(>=?|<=?|!?=)",
"description": "The operator used to compare."
},
"id": {
"type": "string",
"default": "",
"description": "The column id."
},
"value": {
"type": "string",
"default": "",
"description": "The value we want to search."
}
}
}
* Complex Queries Grammar::
search_text
: and_expression
| and_expression search_text
| and_expression OR search_text
and_expression
: boolean_expression
| boolean_expression AND and_expression
boolean_expression
: NOT expression
| expression
expression
: ( search_text )
| COLUMN expression
| value
value
: OPERATOR string
| string
string
: WORD
| STRING
terminal:
OR -> /OR[ ]/
AND -> /AND[ ]/
NOT -> /NOT[ ]/
COLUMN -> /[^><= :\(\)"][^ :\(\)"]*:/
STRING -> /"(\\.|[^\\"])*"/
WORD -> /[^><= :\(\)"][^ :\(\)"]*/
OPERATOR -> /(>=?|<=?|!?=)/
LEFT_PARENTHESE -> /\(/
RIGHT_PARENTHESE -> /\)/
ignore: " "
For developers
==============
Quick start
-----------
To get started with jIO, clone one of the repositories linked in :ref:`Download & Fork <download-fork>`.
To build the library you have to:
* Install `NodeJS <http://nodejs.org/>`_ (including NPM)
* Install Grunt command line with npm.
``# npm -g install grunt-cli``
* Install dev dependencies.
``$ npm install``
* Compile JS/CC parser.
``$ make`` (until we find how to compile it with grunt)
* Run build.
``$ grunt``
The repository also includes the built ready-to-use files, so in case you do
not want to build jIO yourself, just use *jio.js* as well as *complex_queries.js*
plus the storages and dependencies you need and you will be good to go.
Naming Conventions
------------------
All the code follows these :ref:`JavaScript Naming Conventions <naming-conventions>`.
How to design your own jIO Storage Library
------------------------------------------
Create a constructor:
.. code-block:: javascript
function MyStorage(storage_description) {
this._value = storage_description.value;
if (typeof this._value !== 'string') {
throw new TypeError("'value' description property is not a string");
}
}
Create 10 methods: ``post``, ``put``, ``putAttachment``, ``get``, ``getAttachment``,
``remove``, ``removeAttachment``, ``allDocs``, ``check`` and ``repair``.
.. code-block:: javascript
MyStorage.prototype.post = function (command, metadata, option) {
var document_id = metadata._id;
// [...]
};
MyStorage.prototype.get = function (command, param, option) {
var document_id = param._id;
// [...]
};
MyStorage.prototype.putAttachment = function (command, param, option) {
var document_id = param._id;
var attachment_id = param._attachment;
var attachment_data = param._blob;
// [...]
};
// [...]
(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:
* ``success``, to tell jIO that the job is successfully terminated
``command.success(status[Text], [{custom key to add to the response}]);``
* ``resolve``, is equal to success
* ``error``, to tell jIO that the job cannot be done
``command.error(status[Text], [reason], [message], [{custom key to add to the response}])``
* ``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 whether to retry or not. (same API than error)
The second parameter ``metadata`` or ``param`` is the first parameter provided by the jIO user.
The third parameter ``option`` is the option parameter provided by the jIO user.
Methods should return the following objects:
* post --> success("created", {"id": new_generated_id})
* put, remove, putAttachment or removeAttachment --> success(204)
* get --> success("ok", {"data": document_metadata})
* getAttachment -->
success("ok", {"data": binary_string, "content_type": content_type})
// or
success("ok", {"data": new Blob([data], {"type": content_type})})
* allDocs --> success("ok", {"data": row_object})
* check -->
.. code-block:: javascript
// if metadata provides "_id" -> check document state
// if metadata doesn't promides "_id" -> check storage state
success("no_content")
// or
error("conflict", "corrupted", "incoherent document or storage")
* repair -->
.. code-block:: javascript
// if metadata provides "_id" -> repair document state
// if metadata doesn't promides "_id" -> repair storage state
success("no_content")
// or
error("conflict", "corrupted", "impossible to repair document or storage")
// DON'T DESIGN STORAGES IF THEIR IS NO WAY TO REPAIR INCOHERENT STATES
After creating all methods, your storage must be added to jIO. This is done
with the ``jIO.addStorage()`` method, which requires two parameters: the storage
type (string) and a constructor (function). It is called like this:
.. code-block:: javascript
// add custom storage to jIO
jIO.addStorage('mystoragetype', MyStorage);
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 job-based library: whenever you trigger a method,
a job is created, which will later return a response, after being processed.
Job rules
---------
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
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
can also add your own rules, as we're going to see now.
These are the jIO **default rules**:
.. code-block:: javascript
var jio_instance = jIO.createJIO(storage_description, {
"job_rules": [{
"code_name": "readers update",
"conditions": [
"sameStorageDescription",
"areReaders",
"sameMethod",
"sameParameters",
"sameOptions"
],
"action": "update"
}, {
"code_name": "metadata writers update",
"conditions": [
"sameStorageDescription",
"areWriters",
"useMetadataOnly",
"sameMethod",
"haveDocumentIds",
"sameParameters"
],
"action": "update"
}, {
"code_name": "writers wait",
"conditions": [
"sameStorageDescription",
"areWriters",
"haveDocumentIds",
"sameDocumentId"
],
"action": "wait"
}]
});
The following actions can be used:
* ``ok`` - accept the job
* ``wait`` - wait until the end of the selected job
* ``update`` - bind the selected job to this one
* ``deny`` - reject the job
The following condition function can be used:
* ``sameStorageDescription`` - check if the storage descriptions are different.
* ``areWriters`` - check if the commands are ``post``, ``put``, ``putAttachment``, ``remove``, ``removeAttachment``, or ``repair``.
* ``areReaders`` - check if the commands are ``get``, ``getAttachment``, ``allDocs`` or ``check``.
* ``useMetadataOnly`` - check if the commands are ``post``, ``put``, ``get``, ``remove`` or ``allDocs``.
* ``sameMethod`` - check if the commands are equal.
* ``sameDocumentId`` - check if the document ids are equal.
* ``sameParameters`` - check if the metadata or param are equal (deep comparison).
* ``sameOptions`` - check if the command options are equal.
* ``haveDocumentIds`` - test if the two commands contain document ids.
Create Job Condition
--------------------
You can create two types of function: job condition, and job comparison.
.. code-block:: javascript
// Job Condition
// Check if the job is a get command
jIO.addJobRuleCondition("isGetMethod", function (job) {
return job.method === 'get';
});
// Job Comparison
// Check if the jobs have the same 'title' property only if they are strings
jIO.addJobRuleCondition("sameTitleIfString", function (job, selected_job) {
if (typeof job.kwargs.title === 'string' &&
typeof selected_job.kwargs.title === 'string') {
return job.kwargs.title === selected_job.kwargs.title;
}
return false;
});
Add job rules
-------------
You just have to define job rules in the jIO options:
.. code-block:: javascript
// Do not accept to post or put a document which title is equal to another
// already running post or put document title
var jio_instance = jIO.createJIO(storage_description, {
"job_rules": [{
"code_name": "avoid similar title",
"conditions": [
"sameStorageDescription",
"areWriters",
"sameTitleIfString"
],
"action": "deny",
"before": "writers update" // optional
// "after": also exists
}]
});
Clear/Replace default job rules
-------------------------------
If a job's ``code_name`` is equal to ``readers update``, then adding this rule will replace it:
.. code-block:: javascript
var jio_instance = jIO.createJIO(storage_description, {
"job_rules": [{
"code_name": "readers update",
"conditions": [
"sameStorageDescription",
"areReaders",
"sameMethod",
"haveDocumentIds"
"sameParameters"
// sameOptions is removed
],
"action": "update"
}]
});
Or you can just clear all rules before adding new ones:
.. code-block:: javascript
var jio_instance = jIO.createJIO(storage_description, {
"clear_job_rules": true,
"job_rules": [{
// ...
}]
});
.. _gid-storage:
jIO GIDStorage
==============
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
is then used to find this unique document on all types of backends.
This storage uses sub storage allDocs and complex queries to find unique documents, and converts their ids to gids.
Where it can be used
--------------------
When you want to duplicate / synchronize / split / edit data in different kind of storages (ERP5 + XWiki + Dav + ...).
Storage Description
-------------------
* ``type`` - ``"gid"``
* ``sub_storage`` - the sub storage description.
* ``constraints`` - the constraints to use to generate a gid by defining metadata types for some kind of document.
Example:
.. code-block:: javascript
{
"type": "gid",
"sub_storage": {<storage description>},
"constraints": {
"default": { // constraints for all kind of documents
// "document metadata": "type of metadata"
"type": "list"
"title": "string"
},
"Text": { // document of type 'Text' additional constraints
"language": "string"
}
}
}
This description tells the *GIDStorage* to use 2 metadata attributes (``type``, ``title``) to define a
document as unique in the default case. If the document is of type ``Text``, then
the handler will use 3 metadata (``type``, ``title``, ``language``).
If these constraints are not respected, then the storage returns an error telling us to
review the document metadata. Here are samples of document respecting the above
constraints:
.. code-block:: javascript
{
"type": "Text",
"title": "Hello World!",
"language": "en"
}
{
"type": ["Text", "Web Page"],
"title": "My Web Page Title",
"language": "en-US",
"format": "text/html"
}
{
"type": "Image",
"title": "My Image Title"
}
Available metadata types are:
* ``"json"`` - The json value of the metadata.
* ``"string"`` - The value as string if it is not a list.
* ``"list"`` - The value as list.
* ``"date"`` - The value if it can be converted to a date (as string).
* ``"DCMIType"`` - A value matching one of the DCMIType Vocabulary (as string).
* ``"contentType"`` - A value which is a content type (as string).
* ``["DCMIType", "list"]`` - The value which contains a DCMIType (as list).
* ``[...]`` - make your own combination.
Document Requirements
---------------------
A metadata value must be a string. This string can be placed in an attribute within
a ``"content"`` key. The object can contains custom keys with string values. A
metadata object can contain several values. Example:
.. code-block:: javascript
{
"key": "value",
// or
"key": ["value1", "value2"],
// or
"key": {"attribute name": "attribute value", "content": "value"},
// or
"key": [
{"scheme": "DCTERMS.URI", "content": "http://foo.com/bar"},
"value2",
"value3",
...
],
...
}
Metadata attributes which names begin with an underscore can contain anything.
.. code-block:: javascript
{
"_key": {"whatever": ["blue", []], "a": null}
}
Storage Requirements
--------------------
* This storage is not compatible with *RevisionStorage* and *ReplicateRevisionStorage*.
* Sub storages have to support options for ``complex queries`` and ``include_docs``.
Dependencies
------------
No dependency.
Suggested storage tree
----------------------
Replication between storages::
Replicate Storage
+-- GID Storage
| `-- Local Storage
+-- GID Storage
| `-- Remote Storage 1
`-- GID Storage
`-- Remote Storage 2
**CAUTION: All gid storage must have the same description!**
Offline application usage::
Replicate Storage
+-- Index Storage with DB in Local Storage
| `-- GID Storage
| `-- ERP5 Storage
`-- GID Storage
`-- Local Storage
**CAUTION: All gid storage must have the same description!**
.. jIO documentation master file, created by
sphinx-quickstart on Fri Nov 15 11:55:08 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to jIO's documentation!
===============================
Contents:
.. toctree::
:maxdepth: 2
introduction
download
manage_documents
revision_storages
available_storages
gid_storage
complex_queries
metadata
developers
naming_conventions
authors
license
* :ref:`search`
.. role:: js(code)
:language: javascript
Introduction
============
What is jIO?
------------
jIO is a JavaScript library that allows to manage JSON documents on local or
remote storages in asynchronous fashion. jIO is an abstracted API mapped after
CouchDB, that offers connectors to multiple storages, special handlers to
enhance functionality (replication, revisions, indexing) and a query module to
retrieve documents and specific information across storage trees.
How does it work?
-----------------
jIO is composed of two parts - jIO core and storage library(ies). The core
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
query documents based on defined criteria.
jIO uses a job management system, so every method call adds a job into a
queue. The queue is copied in the browser's local storage (by default), so it
can be restored in case of browser crash. Jobs are invoked
asynchronously and ongoing jobs are not able to re-trigger to prevent
conflicts.
Getting started
---------------
This walkthrough is designed to get you started using a basic jIO instance.
#. Download jIO core, the storages you want to use as well as the
complex-queries scripts and the dependencies required for the storages
you intend to use. :ref:`[Download & Fork] <download-fork>`
#. Add the scripts to your HTML page in the following order:
.. code-block:: html
<!-- jio core + dependency -->
<script src="sha256.amd.js"></script>
<script src="rsvp-custom.js"></script>
<script src="jio.js"></script>
<!-- storages + dependencies -->
<script src="complex_queries.js"></script>
<script src="localstorage.js"></script>
<script src="davstorage.js"></script>
<script ...>
With `RequireJS <http://requirejs.org/>`_, the main.js will look like:
.. code-block:: javascript
:linenos:
require.config({
"paths": {
// jio core + dependency
// the AMD compatible version of sha256.js -> see Download and Fork
"sha256": "sha256.amd",
"rsvp": "rsvp-custom",
"jio": "jio",
// storages + dependencies
"complex_queries": "complex_queries",
"localstorage": "localstorage",
"davstorage": "davstorage"
}
});
#. jIO connects to a number of storages and allows adding handlers (or
functions) to specifc storages.
You can use both handlers and available storages to build a storage
tree across which all documents will be maintained and managed by jIO.
See :ref:`List of Available Storages <list-of-available-storages>`.
.. code-block:: javascript
// create your jio instance
var my_jio = jIO.createJIO(storage_description);
#. The jIO API provides ten main methods to manage documents across the storage(s) specified in your jIO storage tree.
====================== ===================================================== ========================================
Method Example call Description
====================== ===================================================== ========================================
``post()`` :js:`my_jio.post(document, [options]);` Creates a new document
``put()`` :js:`my_jio.put(document, [options]);` Creates/Updates a document
``putAttachment()`` :js:`my_jio.putAttachement(attachment, [options]);` Updates/Adds an attachment to a document
``get()`` :js:`my_jio.get(document, [options]);` Reads a document
``getAttachment()`` :js:`my_jio.getAttachment(attachment, [options]);` Reads a document attachment
``remove()`` :js:`my_jio.remove(document, [options]);` Deletes a document and its attachments
``removeAttachment()`` :js:`my_jio.removeAttachment(attachment, [options]);` Deletes a document attachment
``allDocs()`` :js:`my_jio.allDocs([options]);` Retrieves a list of existing documents
``check()`` :js:`my_jio.check(document, [options]);` Check the document state
``repair()`` :js:`my_jio.repair(document, [options]);` Repair the document
====================== ===================================================== ========================================
Copyright and license
=====================
jIO is an open-source library and is licensed under the LGPL license. More
information on LGPL can be found `here <http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License>`_
How to manage documents?
========================
jIO is mapped after the CouchDB APIs and extends them to provide unified, scalable
and high performance access via JavaScript to a wide variety of different
storage backends.
If you are not familiar with `Apache CouchDB <http://couchdb.apache.org/>`_:
it is a scalable, fault-tolerant, and schema-free document-oriented database.
It is used in large and small organizations for a variety of applications where
traditional SQL databases are not the best solution for the problem at hand.
CouchDB provides a RESTful HTTP/JSON API accessible by many programming
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?
-------------------
A document is an association of metadata and attachment(s). The metadata is the
set of properties of the document and the attachments are the binaries of the content
of the document.
In jIO, metadata is just a dictionary with keys and values (JSON object), and
attachments are just simple strings.
.. code-block:: javascript
:linenos:
{
// document metadata
"_id" : "Identifier",
"title" : "A Title!",
"creator": "Mr.Author"
}
You can also retrieve document attachment metadata in this object.
.. code-block:: javascript
:linenos:
{
// document metadata
"_id" : "Identifier",
"title" : "A Title!",
"creator": "Mr.Author",
"_attachments": {
// attachment metadata
"body.html": {
"length": 12893,
"digest": "sha256-XXXX...",
"content_type": "text/html"
}
}
}
:ref:`Here <metadata-head>` is a draft about metadata to use with jIO.
Basic Methods
-------------
Below you can see examples of the main jIO methods. All examples are using
revisions (as in revision storage or replicate revision storage), so you can
see how method calls should be made with either of these storages.
.. code-block:: javascript
:linenos:
// Create a new jIO instance
var jio_instance = jIO.newJio(storage tree description);
// create and store new document
jio_instance.post({"title": "some title"}).
then(function (response) {
// console.log(response);
});
// create or update an existing document
jio_instance.put({"_id": "my_document", "title": "New Title"}).
then(function (response) {
// console.log(response);
});
// add an attachment to a document
jio_instance.putAttachment({"_id": "my_document", "_attachment": "its_attachment",
"_data": "abc", "_mimetype": "text/plain"}).
then(function (response) {
// console.log(response);
});
// read a document
jio_instance.get({"_id": "my_document"}).
then(function (response) {
// console.log(response);
});
// read an attachment
jio_instance.getAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
then(function (response) {
// console.log(response);
});
// delete a document and its attachment(s)
jio_instance.remove({"_id": "my_document"}).
then(function (response) {
// console.log(response);
});
// delete an attachment
jio_instance.removeAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
then(function (response) {
// console.log(response);
});
// get all documents
jio_instance.allDocs().then(function (response) {
// console.log(response);
});
Promises
--------
Each jIO method returns a Promise object, which allows us to get responses into
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.
You can read more about promises:
* `RSVP.js <https://github.com/tildeio/rsvp.js#rsvpjs-->`_ on GitHub
* `Promises/A+ <http://promisesaplus.com/>`_
* `CommonJS Promises <http://wiki.commonjs.org/wiki/Promises>`_
Method Options and Callback Responses
-------------------------------------
To retrieve jIO responses, you have to provide callbacks like this:
.. code-block:: javascript
jio_instance.post(metadata, [options]).
then([responseCallback], [errorCallback], [progressionCallback]);
* On command success, ``responseCallback`` will be called with the jIO response as first parameter.
* On command error, ``errorCallback`` will be called with the jIO error as first parameter.
* On command notification, ``progressionCallback`` will be called with the storage notification.
Here is a list of responses returned by jIO according to methods and options:
================== =========================================== ===============================================
Option Available for Response (Callback first parameter)
================== =========================================== ===============================================
No options ``post()``, ``put()``, ``remove()`` .. code-block:: javascript
{
"result": "success",
"method": "post",
// or put or remove
"id": "my_doc_id",
"status": 204,
"statusText": "No Content"
}
No options ``putAttachment()``, ``removeAttachment()`` .. code-block:: javascript
{
"result": "success",
"method": "putAttachment",
// or removeAttachment
"id": "my_doc_id",
"attachment": "my_attachment_id",
"status": 204,
"statusText": "No Content"
}
No options ``get()`` .. code-block:: javascript
{
"result": "success",
"method": "get",
"id": "my_doc_id",
"status": 200,
"statusText": "Ok",
"data": {
// Here, the document metadata
}
}
No options ``getAttachment()`` .. code-block:: javascript
{
"result": "success",
"method": "getAttachment",
"id": "my_doc_id",
"attachment": "my_attachment_id",
"status": 200,
"statusText": "Ok",
"data": Blob // Here, the attachment content
}
No option ``allDocs()`` .. code-block:: javascript
{
"result": "success",
"method": "allDocs",
"id": "my_doc_id",
"status": 200,
"statusText": "Ok",
"data": {
"total_rows": 1,
"rows": [{
"id": "mydoc",
"key": "mydoc", // optional
"value": {},
}]
}
}
include_docs: true ``allDocs()`` .. code-block:: javascript
{
"result": "success",
"method": "allDocs",
"id": "my_doc_id",
"status": 200,
"statusText": "Ok",
"data": {
"total_rows": 1,
"rows": [{
"id": "mydoc",
"key": "mydoc", // optional
"value": {},
"doc": {
// Here, "mydoc" metadata
}
}]
}
}
================== =========================================== ===============================================
In case of error, the ``errorCallback`` first parameter will look like:
.. code-block:: javascript
{
"result": "error",
"method": "get",
"status": 404,
"statusText": "Not Found",
"error": "not_found",
"reason": "document missing",
"message": "Unable to get the requseted document"
}
Example: How to store a video on localStorage
---------------------------------------------
The following shows how to create a new jIO in localStorage and then post a document with two attachments.
.. code-block:: javascript
// create a new jIO
var jio_instance = jIO.newJio({
"type": "local",
"username": "usr",
"application_name":"app"
});
// post the document "metadata"
jio_instance.post({
"title" : "My Video",
"type" : "MovingImage",
"format" : "video/ogg",
"description" : "Images Compilation"
}, function (err, response) {
var id;
if (err) {
return alert('Error posting the document meta');
}
id = response.id;
// post a thumbnail attachment
jio_instance.putAttachment({
"_id": id,
"_attachment": "thumbnail",
"_data": my_image,
"_mimetype": "image/jpeg"
}, function (err, response) {
if (err) {
return alert('Error attaching thumbnail');
}
// post video attachment
jio_instance.putAttachment({
"_id": id,
"_attachment": "video",
"_data": my_video,
"_mimetype":"video/ogg"
}, function (err, response) {
if (err) {
return alert('Error attaching the video');
}
alert('Video Stored');
});
});
});
localStorage contents:
.. code-block:: javascript
{
"jio/local/usr/app/12345678-1234-1234-1234-123456789012": {
"_id": "12345678-1234-1234-1234-123456789012",
"title": "My Video",
"type": "MovingImage",
"format": "video/ogg",
"description": "Images Compilation",
"_attachments":{
"thumbnail":{
"digest": "md5-3ue...",
"content_type": "image/jpeg",
"length": 17863
},
"video":{
"digest": "md5-0oe...",
"content_type": "video/ogg",
"length": 2840824
}
}
},
"jio/local/usr/app/myVideo/thumbnail": "/9j/4AAQSkZ...",
"jio/local/usr/app/myVideo/video": "..."
}
.. role:: js(code)
:language: javascript
.. _metadata-head:
Metadata
========
What is metadata?
-----------------
The word "metadata" means "data about data". Metadata articulates a context for
objects of interest -- "resources" such as MP3 files, library books, or
satellite images -- in the form of "resource descriptions". As a tradition,
resource description dates back to the earliest archives and library catalogs.
During the Web revolution of the mid-1990s, `Dublic Core <http://dublincore.org/metadata-basics/>`_
has emerged as one of the prominent metadata standards.
Why use metadata?
-----------------
Uploading a document to several servers can be very tricky, because the
document has to be saved in a place where it can be easily found with basic
searches in all storages (For instance: ERP5, XWiki and Mioga2 have their own
way to save documents and to get them). So we must use metadata for
*interoperability reasons*. Interoperability is the ability of diverse systems
and organizations to work together.
How to format metadata with jIO
-------------------------------
See below XML and its JSON equivalent:
+--------------------------------------------+---------------------------------------+
| XML | JSON |
+============================================+=======================================+
| .. code-block:: xml | .. code-block:: javascript |
| | |
| <dc:title>My Title</dc:title> | {"title":"My Title"} |
+--------------------------------------------+---------------------------------------+
| .. code-block:: xml | .. code-block:: javascript |
| | |
| <dc:contributor>Me</dc:contributor> | {"contributor":["Me", "And You"]} |
| <dc:contributor>And You</dc:contributor> | |
+--------------------------------------------+---------------------------------------+
| .. code-block:: xml | .. code-block:: javascript |
| | |
| <dc:identifier scheme="DCTERMS.URI"> | {"identifier": [ |
| http://my/resource | { |
| </dc:identifier> | "scheme": "DCTERMS.URI", |
| <dc:identifier> | "content": "http://my/resource" |
| Xaoe41PAPNIWz | }, |
| </dc:identifier> | "Xaoe41PAPNIWz"]} |
+--------------------------------------------+---------------------------------------+
List of metadata to use
-----------------------
Identification
^^^^^^^^^^^^^^
* **_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**
* **identifer**, :js:`{"identifier": "http://domain/jio_home_page"}, {"identifier": "urn:ISBN:978-1-2345-6789-X"},
{"identifier": [{"scheme": "DCTERMS.URI", "content": "http://domain/jio_home_page"}]}`
an unambiguous reference to the resource within a given context. Recommended
best practice is to identify the resource by means of a string or number
conforming to a formal identification system. Examples of formal identification
systems include the Uniform Resource Identifier (URI) (including the Uniform
Resource Locator (URL), the Digital Object Identifier (DOI) and the
International Standard Book Number (ISBN).
* **format**, :js:`{"format": ["text/html", "52 kB"]}, {"format": ["image/jpeg", "100 x 100 pixels", "13.2 KiB"]}`
the physical or digital manifestation of the resource. Typically, Format may
include the media-type or dimensions of the resource. Examples of dimensions
include size and duration. Format may be used to determine the software,
hardware or other equipment needed to display or operate the resource.
* **date**, :js:`{"date": "2011-12-13T14:15:16Z"}, {"date": {"scheme": "DCTERMS.W3CDTF", "content": "2011-12-13"}}`
a date associated with an event in the life cycle of the resource. Typically,
Date will be associated with the creation or availability of the resource.
Recommended best practice for encoding the date value is defined in a profile
of ISO 8601 `Date and Time Formats, W3C Note <http://www.w3.org/TR/NOTE-datetime>`_
and follows the YYYY-MM-DD format.
* **type**, :js:`{"type": "Text"}, {"type": "Image"}, {"type": "Dataset"}`
the nature or genre of the content of the resource. Type includes terms describing
general categories, functions, genres, or aggregation levels for content.
Recommended best practice is to select a value from a controlled vocabulary.
**The type is not a MIME Type!**
Intellectual property
^^^^^^^^^^^^^^^^^^^^^
* **creator**, :js:`{"creator": "Tristan Cavelier"}, {"creator": ["Tristan Cavelier", "Sven Franck"]}`
an entity primarily responsible for creating the content of the resource.
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.
* **publisher**, :js:`{"publisher": "Nexedi"}`
the entity responsible for making the resource available. Examples of a
Publisher include a person, an organization, or a service. Typically, the name
of a Publisher should be used to indicate the entity.
* **contributor**, :js:`{"contributor": ["Full Name", "Full Name", ...]}`
an entity responsible for making contributions to the content of the
resource. Examples of a Contributor include a person, an organization or a
service. Typically, the name of a Contributor should be used to indicate the
entity.
* **rights**, :js:`{"rights": "Access limited to members"}, {"rights": "https://www.j-io.org/documentation/jio-documentation/#copyright-and-license"}`
information about rights held in and over the resource. Typically a Rights
element will contain a rights management statement for the resource, or
reference a service providing such information. Rights information often
encompasses Intellectual Property Rights (IPR), Copyright, and various Property
Rights. If the rights element is absent, no assumptions can be made about the
status of these and other rights with respect to the resource.
Content
^^^^^^^
* **title**, :js:`{"title": "jIO Home Page"}`
the name given to the resource. Typically, a Title will be a name by which the resource is formally known.
* **subject**, :js:`{"subject": "jIO"}, {"subject": ["jIO", "basics"]}`
the topic of the content of the resource. Typically, a Subject will be
expressed as keywords or key phrases or classification codes that describe the
topic of the resource. Recommended best practice is to select a value from a
controlled vocabulary or formal classification scheme.
* **description**, :js:`{"description": "Simple guide to show the basics of jIO"}, {"description": {"lang": "fr", "content": "Ma description"}}`
an account of the content of the resource. Description may include but is not
limited to: an abstract, table of contents, reference to a graphical
representation of content or a free-text account of the content.
* **language**, :js:`{"language": "en"}`
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>`_
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"
or "eng" for English, "akk" for Akkadian, and "en-GB" for English used in the
United Kingdom.
* **source**, :js:`{"source": ["Image taken from a drawing by Mr. Artist", "<phone number>"]}`,
a Reference to a resource from which the present resource is derived. The
present resource may be derived from the Source resource in whole or part.
Recommended best practice is to reference the resource by means of a string or
number conforming to a formal identification system.
* **relation**, :js:`{"relation": "Resilience project"}`
a reference to a related resource. Recommended best practice is to reference
the resource by means of a string or number conforming to a formal
identification system.
* **coverage**, :js:`{"coverage": "France"}`
the extent or scope of the content of the resource. Coverage will typically
include spatial location (a place name or geographic co-ordinates), temporal
period (a period label, date, or date range) or jurisdiction (such as a named
administrative entity). Recommended best practice is to select a value from a
controlled vocabulary (for example, the `Getty Thesaurus of Geographic Names
<http://www.getty.edu/research/tools/vocabulary/tgn/>`_. Where appropriate, named
places or time periods should be used in preference to numeric identifiers such
as sets of co-ordinates or date ranges.
* **category**, :js:`{"category": ["parent/26323", "resilience/javascript", "javascript/library/io"]}`
the category the resource is associated with. The categories may look like
navigational facets, they correspond to the properties of the resource which
can be generated with metadata or some other information (see `faceted search <https://en.wikipedia.org/wiki/Faceted_search>`_).
* **product**, :js:`{"product": "..."}`
for e-commerce use.
* **custom**, :js:`{custom1: value1, custom2: value2, ...}`
.. XXX short description here
Examples
--------
Posting a webpage for jIO
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: javascript
jio.put({
"_id" : "...",
"identifier" : "http://domain/jio_home_page",
"format" : ["text/html", "52 kB"],
"date" : new Date(),
"type" : "Text",
"creator" : ["Nexedi", "Tristan Cavelier", "Sven Franck"],
"title" : "jIO Home Page",
"subject" : ["jIO", "basics"],
"description" : "Simple guide to show the basics of jIO",
"category" : ["resilience/jio", "webpage"],
"language" : "en"
}, callbacks); // send content as attachment
Posting jIO library
^^^^^^^^^^^^^^^^^^^
.. code-block:: javascript
jio.put({
"_id" : "...",
"identifier" : "jio.js",
"date" : "2013-02-15",
"format" : "application/javascript",
"type" : "Software",
"creator" : ["Tristan Cavelier", "Sven Franck"],
"publisher" : "Nexedi",
"rights" :
"https://www.j-io.org/documentation/jio-documentation/#copyright-and-license",
"title" : "Javascript Input/Output",
"subject" : "jIO",
"category" : ["resilience/javascript", "javascript/library/io"]
"description" : "jIO is a client-side JavaScript library to manage " +
"documents across multiple storages."
}, callbacks); // send content as attachment
Posting a webpage for interoperability levels
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: javascript
jio.put({
"_id" : "...",
"identifier" : "http://dublincore.org/documents/interoperability-levels/",
"date" : "2009-05-01",
"format" : "text/html",
"type" : "Text",
"creator" : ["Mikael Nilsson", "Thomas Baker", "Pete Johnston"],
"publisher" : "Dublin Core Metadata Initiative",
"title" : "Interoperability Levels for Dublin Core Metadata",
"description" : "This document discusses the design choices involved " +
"in designing applications for different types of " +
"interoperability. [...]",
"language" : "en"
}, callbacks); // send content as attachment
Posting an image
^^^^^^^^^^^^^^^^
.. code-block:: javascript
jio.put({
"_id" : "...",
"identifier" : "new_york_city_at_night",
"format" : ["image/jpeg", "7.2 MB", "8192 x 4096 pixels"],
"date" : "1999",
"type" : "Image",
"creator" : "Mr. Someone",
"title" : "New York City at Night",
"subject" : ["New York"],
"description" : "A photo of New York City taken just after midnight",
"coverage" : ["New York", "1996-1997"]
}, callbacks); // send content as attachment
Posting a book
^^^^^^^^^^^^^^
.. code-block:: javascript
jio.put({
"_id" : "...",
"identifier" : {"scheme": "DCTERMS.URI", "content": "urn:ISBN:0385424728"},
"format" : "application/pdf",
"date" : {"scheme": "DCTERMS.W3CDTF", "content": getW3CDate()}, // see tools below
"creator" : "Original Author(s)",
"publisher" : "Me",
"title" : {"lang": "en", "content": "..."},
"description" : {"lang": "en", "Summary: ..."},
"language" : {"scheme": "DCTERMS.RFC4646", "content": "en-GB"}
}, callbakcs); // send content as attachment
Posting a video
^^^^^^^^^^^^^^^
.. code-block:: javascript
jio.put({
"_id" : "...",
"identifier" : "my_video",
"format" : ["video/ogg", "130 MB", "1080p", "20 seconds"],
"date" : getW3CDate(), // see tools below
"type" : "Video",
"creator" : "Me",
"title" : "My life",
"description" : "A video about my life"
}, callbacks); // send content as attachment
Posting a job announcement
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: javascript
jio.post({
"format" : "text/html",
"date" : "2013-02-14T14:44Z",
"type" : "Text",
"creator" : "James Douglas",
"publisher" : "Morgan Healey Ltd",
"title" : "E-Commerce Product Manager",
"subject" : "Job Announcement",
"description" : "...",
"language" : "en-GB",
"source" : "James@morganhealey.com",
"relation" : ["Totaljobs"],
"coverage" : "London, South East",
"job_type" : "Permanent",
"salary" : "£45,000 per annum"
}, callbacks); // send content as attachment
// result: http://www.totaljobs.com/JobSeeking/E-Commerce-Product-Manager_job55787655
Getting a list of document created by someone
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With complex query:
.. code-block:: javascript
jio.allDocs({"query": "creator: \"someone\""}, callbacks);
Getting all documents about jIO in the resilience project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With complex query:
.. code-block:: javascript
jio.allDocs({"query": "subject: \"jIO\" AND category: \"resilience\""}, callbacks);
Tools
-----
W3C Date function
^^^^^^^^^^^^^^^^^
.. code-block:: javascript
/**
* Tool to get the date in W3C date format
* - "2011-12-13T14:15:16+01:00" with use_utc = false (by default)
* - "2011-12-13T13:15:16Z" with use_utc = true
*
* @param {Boolean} use_utc Use UTC format
* @return {String} The date in W3C date format
*/
function getW3CDate(use_utc) {
var d = new Date(), offset;
if (use_utc === true) {
return d.toISOString();
}
offset = - d.getTimezoneOffset();
return (
d.getFullYear() + "-" +
(d.getMonth() + 1) + "-" +
d.getDate() + "T" +
d.getHours() + ":" +
d.getMinutes() + ":" +
d.getSeconds() + "." +
d.getMilliseconds() +
(offset < 0 ? "-" : "+") +
(offset / 60) + ":" +
(offset % 60)
).replace(/[0-9]+/g, function (found) {
if (found.length < 2) {
return '0' + found;
}
return found;
});
}
Sources
-------
* `Interoperability definition <https://en.wikipedia.org/wiki/Interoperability>`_
* `Faceted search <https://en.wikipedia.org/wiki/Faceted_search>`_
* `DublinCore <http://dublincore.org/>`_
* `Interoperability levels <http://dublincore.org/documents/interoperability-levels/>`_
* `Metadata elements <http://dublincore.org/documents/usageguide/elements.shtml>`_
* http://www.chu-rouen.fr/documed/eahilsantander.html
* http://openweb.eu.org/articles/dublin_core (French)
* `CouchDB <https://couchdb.apache.org/>`_
* `Resource Description Framework (RDF) <http://www.w3.org/RDF/>`_
* `Five Ws <https://en.wikipedia.org/wiki/Five_Ws>`_
* `Metadata <https://en.wikipedia.org/wiki/Metadata>`_
* MIME Types
* https://en.wikipedia.org/wiki/Internet_media_type
* https://www.iana.org/assignments/media-types
.. role:: js(code)
:language: javascript
.. _naming-conventions:
JavaScript Naming Conventions
=============================
This document defines JavaScript naming conventions, which are split into essential, coding and naming conventions.
Essential Conventions
---------------------
Essential conventions include generic patterns that should be adhered to in order to write *readable*, *consistent* and *maintainable* code.
Minimizing Globals
^^^^^^^^^^^^^^^^^^
Variable declarations should always be done using *var* to not declare them as
global variables. This avoids conflicts from using a variable name across
different functions as well as conflicts with global variables declared by third
party plugins.
.. XXX always pub good+bad or bad+good examples in the same order
Good Example
.. code-block:: javascript
function sum(x, y) {
var result = x + y;
return result;
}
Bad Example
.. code-block:: javascript
function sum(x, y) {
// missing var declaration, implied global
result = x + y;
return result;
}
Use JSLint
^^^^^^^^^^
`JSLint <http://www.jslint.com/>`_ is a quality tool that inspects code and warns
about potential problems. It is available online and can also be integrated
into several development environments, so errors will be highlighted when
writing code.
Before validating your code in JSLint, you should use a code
beautifier to fix basic syntax errors (like indentation) automatically. There
are a number of beautifiers available online. The following ones seem to work best:
* `JSbeautifier.org <http://jsbeautifier.org/>`_
* `JS-Beautify <http://alexis.m2osw.com/js-beautify/>`_
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
maximum characters per line and the use of '_' as first character in a variable name is allowed.
Other JSLint options can be added in sub functions if necessary.
Some allowed options are:
* ``ass: true`` if assignment should be allowed outside of statement position.
* ``bitwise: true`` if bitwise operators should be allowed.
* ``continue: true`` if the continue statement should be allowed.
* ``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.
* ``unparam: true`` if warnings should be silenced for unused parameters.
Coding Conventions
------------------
Coding conventions include generic patterns that ensure that written code follows certain formatting conventions.
Uses two-space indentation
^^^^^^^^^^^^^^^^^^^^^^^^^^
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
prevents these errors up front.
Good Example
.. code-block:: javascript
function outer(a, b) {
var c = 1,
d = 2,
inner;
if (a > b) {
inner = function () {
return {
"r": c - d
};
};
} else {
inner = function () {
return {
"r": c + d
};
};
}
return inner;
}
Bad Example
.. code-block:: javascript
function outer(a, b) {
var c = 1,
d = 2,
inner;
if (a > b) {
inner = function () {
return {
r: c - d
}}}};
Using shorthand for conditional statements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
An alternative for using braces is the shorthand notation for conditional
statements. When using multiple conditions, the conditional statement can be
split on multiple lines.
Good Example
.. code-block:: javascript
// single line
var results = test === true ? alert(1) : alert(2);
// multiple lines
var results = (test === true && number === undefined ?
alert(1) : alert(2));
var results = (test === true ?
alert(1) : number === undefined ?
alert(2) : alert(3));
Bad Example
.. code-block:: javascript
// multiple conditions
var results = (test === true && number === undefined) ?
alert(1) :
alert(2);
Opening Brace Location
^^^^^^^^^^^^^^^^^^^^^^
Always put the opening brace on the same line as the previous statement.
Bad Example
.. code-block:: javascript
function func()
{
return
{
"name": "Batman"
};
}
Good Example
.. code-block:: javascript
function func() {
return {
"name": "Batman"
};
}
Closing Brace Location
^^^^^^^^^^^^^^^^^^^^^^
The closing brace should be on the same indent level as the original function call.
Bad Example
.. code-block:: javascript
function func() {
return {
"name": "Batman"
};
}
Good Example
.. code-block:: javascript
function func() {
return {
"name": "Batman"
};
}
Function Declaration Location
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Non anonymous functions should be declared before use.
Bad Example
.. code-block:: javascript
// [...]
return {
"namedFunction": function namedFunction() {
return;
}
};
Good Example
.. code-block:: javascript
// [...]
function namedFunction() {
return;
}
return {
"namedFunction": namedFunction
};
Naming Conventions
------------------
Naming conventions include generic patterns for setting names and identifiers throughout a script.
Constructors
^^^^^^^^^^^^
Constructor functions (called with the ``new`` statement) should always start with a capital letter:
.. code-block:: javascript
// bad example
var test = new application();
// good example
var test = new Application();
Methods/Functions
^^^^^^^^^^^^^^^^^
A method/function should always start with a small letter.
.. code-block:: javascript
// bad example
function MyFunction() {...}
// good example
function myFunction() {...}
TitleCase, camelCase
^^^^^^^^^^^^^^^^^^^^
Follow the camel case convention, typing the words in lower-case, only capitalizing the first letter in each word.
.. code-block:: javascript
// Good example constructor = TitleCase
var test = new PrototypeApplication();
// Bad example constructor
var test = new PROTOTYPEAPPLICATION();
// Good example functions/methods = camelCase
myFunction();
calculateArea();
// Bad example functions/methods
MyFunction();
CalculateArea();
Variables
^^^^^^^^^
Variable names with multiple words should always use an underscore between them.
.. code-block:: javascript
// bad example
var deliveryNote = 1;
// good example
var delivery_note = 1;
Confusing variable names should end with the variable type.
Example
.. code-block:: javascript
// implicit type
var my_callback = doSomething();
var Person = require("./person");
// confusing names + var type
var do_something_function = doSomething.bind(context);
var value_list = getObjectOrArray();
// value_list can be an object which can be cast into an array
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
// good example
var doSomethingFunction = function () { ... };
// or
var tool = {"doSomething": function () { ... }};
// bad example
var doSomething = function () { ... };
Element Classes and IDs
^^^^^^^^^^^^^^^^^^^^^^^
JavaScript can access elements by their ID attribute and class names. When
assigning IDs and class names with multiple words, these should also be
separated by an underscore (same as variables).
Example
.. code-block:: javascript
// bad example
test.setAttribute("id", "uniqueIdentifier");
// good example
test.setAttribute("id", "unique_identifier");
Discuss - checked with jQuery UI/jQuery Mobile, they don't use written name conventions, only
* events names should fit their purpose (pageChange for changing a page)
* element classes use “-” like in ui-shadow
* "ui" should not be used by third party developers
* variables and events use lower camel-case like pageChange and activePage
Underscore Private Methods
^^^^^^^^^^^^^^^^^^^^^^^^^^
Private methods should use a leading underscore to separate them from public methods (although this does not technically make a method private).
Good Example
.. code-block:: javascript
var person = {
"getName": function () {
return this._getFirst() + " " + this._getLast();
},
"_getFirst": function () {
// ...
},
"_getLast": function () {
// ...
}
};
Bad Example
.. code-block:: javascript
var person = {
"getName": function () {
return this.getFirst() + " " + this.getLast();
},
// private function
"getFirst": function () {
// ...
}
};
No Abbreviations
^^^^^^^^^^^^^^^^
Abbreviations should not be used to avoid confusion.
Good Example
.. code-block:: javascript
// delivery note
var delivery_note = 1;
Bad Example
.. code-block:: javascript
// delivery note
var del_note = 1;
No Plurals
^^^^^^^^^^
Plurals should not be used as variable names.
.. code-block:: javascript
// good example
var delivery_note_list = ["one", "two"];
// bad example
var delivery_notes = ["one", "two"];
Use Comments
^^^^^^^^^^^^
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
.. code-block:: javascript
var person = {
// returns full name string
"getName": function () {
return this._getFirst() + " " + this._getLast();
}
};
Bad Example
.. code-block:: javascript
var person = {
"getName": function () {
return this._getFirst() + " " + this._getLast();
}
};
Documentation
^^^^^^^^^^^^^
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
itself. Comments should look like this:
Good Example
.. code-block:: javascript
/**
* Reverse a string
*
* @param {String} input_string String to reverse
* @return {String} The reversed string
*/
function reverse(input_string) {
// ...
return output_string;
};
Bad Example
.. code-block:: javascript
function reverse(input_string) {
// ...
return output_string;
};
Additional Readings
-------------------
Resources, additional reading materials and links:
* `JavaScript Patterns <http://shop.oreilly.com/product/9780596806767.do>`_, main ressource used.
* `JSLint <http://www.jslint.com/>`_, code quality.
* `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_, generate documentation from code.
Revision Storages: Conflicts and Resolution
===========================================
Why Conflicts can Occur
-----------------------
Using jIO you can store documents in multiple storage locations. With
increasing number of users working on a document and some storages not being
available or responding too slow, conflicts are more likely to occur. jIO
defines a conflict as multiple versions of a document existing in a storage
tree and a user trying to save on a version that does not match the latest
version of the document.
To keep track of document versions a revision storage must be used. When doing
so, jIO creates a document tree file for every document. This file contains all
existing versions and their status and is modified whenever a version is
added/updated/removed or when storages are being synchronized.
How to solve conflicts
----------------------
Using the document tree, jIO tries to make every version of a document
available on every storage. When multiple versions of a document exist, jIO
will select the **latest**, **left-most** version on the document tree, along with the
conflicting versions (when option **conflicts: true** is set in order for
developers to setup a routine to solve conflicts.
Technically a conflict is solved by deleting alternative versions of a document
("cutting leaves off from the document tree"). When a user decides to keep a
version of a document and manually deletes all conflicting versions, the
storage tree is updated accordingly and the document is available in a single
version on all storages.
Simple Conflict Example
-----------------------
You are keeping a namecard file on your PC updating from your smartphone. Your
smartphone ran out of battery and is offline when you update your namecard on
your PC with your new email adress. Someone else changes this email from your PC
and once your smartphone is recharged, you go back online and the previous
update is executed.
#. Set up the storage tree
.. code-block:: javascript
var jio_instance = jIO.newJio({
// replicate revision storage
"type":"replicaterevision",
"storagelist":[{
"type": "revision",
"sub_storage": {
"type": "dav",
...
}
}, {
"type": "revision",
"sub_storage": {
"type": "local",
...
}
}]
});
#. Create the namecard on your smartphone
.. code-block:: javascript
jio_instance.post({
"_id": "myNameCard",
"email": "me@web.com"
}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "1-5782E71F1E4BF698FA3793D9D5A96393"
});
This will create the document on your webDav and local storage
#. Someone else updates your shared namecard on Webdav
.. code-block:: javascript
jio_instance.put({
"email": "my_new_me@web.com",
"_id": "myNameCard"
"_rev": "1-5782E71F1E4BF698FA3793D9D5A96393"
}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "2-068E73F5B44FEC987B51354DFC772891"
});
Your smartphone is offline, so now you will have one version (1-578...) on
your smartphone and another version on webDav (2-068...) on your PC.
#. You modify the namecard while being offline
.. code-block:: javascript
jio_instance.get({"_id": "myNameCard"}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "1-5782E71F1E4BF698FA3793D9D5A96393"
// response.data.email -> "me@web.com"
return jio_instance.put({
"_id": "myNameCard",
"email": "me_again@web.com"
});
}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "2-3753476B70A49EA4D8C9039E7B04254C"
});
#. Later, your smartphone is online and you retrieve the other version of the namecard.
.. code-block:: javascript
jio_instance.get({"_id": "myNameCard"}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "2-3753476B70A49EA4D8C9039E7B04254C"
// response.data.email -> "me_again@web.com"
});
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
.. code-block:: javascript
jio_instance.get({"_id": "myNameCard"}, {
"conflicts": true
}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "2-3753476B70A49EA4D8C9039E7B04254C",
// response.conflicts -> ["2-068E73F5B44FEC987B51354DFC772891"]
});
The conflicting version (*2-068E...*) is displayed, because **{conflicts: true}** was
specified in the GET call. Deleting either version will solve the conflict.
#. Delete conflicting version
.. code-block:: javascript
jio_instance.remove({
"_id": "myNameCard",
"_rev": "2-068E73F5B44FEC987B51354DFC772891"
}).then(function (response) {
// response.id -> "myNameCard"
// response.rev -> "3-28910A4937537B5168E772896B70EC98"
});
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
deleted. All storages now contain just a single version of the namecard
(2-3753...). Note that, on the document tree, removing a revison will
create a new revision with status set to *deleted*.
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar #searchbox input[type="text"] {
width: 170px;
}
div.sphinxsidebar #searchbox input[type="submit"] {
width: 30px;
}
img {
border: 0;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable dl, table.indextable dd {
margin-top: 0;
margin-bottom: 0;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- general body styles --------------------------------------------------- */
a.headerlink {
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.field-list ul {
padding-left: 1em;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px 7px 0 7px;
background-color: #ffe;
width: 40%;
float: right;
}
p.sidebar-title {
font-weight: bold;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
div.admonition dl {
margin-bottom: 0;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
border: 0;
border-collapse: collapse;
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.field-list td, table.field-list th {
border: 0 !important;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
dl {
margin-bottom: 15px;
}
dd p {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dt:target, .highlighted {
background-color: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.refcount {
color: #060;
}
.optional {
font-size: 1.3em;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
td.linenos pre {
padding: 5px 0px;
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
margin-left: 0.5em;
}
table.highlighttable td {
padding: 0 0.5em 0 0.5em;
}
tt.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
tt.descclassname {
background-color: transparent;
}
tt.xref, a tt {
background-color: transparent;
font-weight: bold;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}
\ No newline at end of file
/*
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* select a different prefix for underscore
*/
$u = _.noConflict();
/**
* make the code below compatible with browsers without
* an installed firebug like debugger
if (!window.console || !console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
"profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {};
}
*/
/**
* small helper function to urldecode strings
*/
jQuery.urldecode = function(x) {
return decodeURIComponent(x).replace(/\+/g, ' ');
}
/**
* small helper function to urlencode strings
*/
jQuery.urlencode = encodeURIComponent;
/**
* This function returns the parsed url parameters of the
* current request. Multiple values per key are supported,
* it will always return arrays of strings for the value parts.
*/
jQuery.getQueryParameters = function(s) {
if (typeof s == 'undefined')
s = document.location.search;
var parts = s.substr(s.indexOf('?') + 1).split('&');
var result = {};
for (var i = 0; i < parts.length; i++) {
var tmp = parts[i].split('=', 2);
var key = jQuery.urldecode(tmp[0]);
var value = jQuery.urldecode(tmp[1]);
if (key in result)
result[key].push(value);
else
result[key] = [value];
}
return result;
};
/**
* small function to check if an array contains
* a given item.
*/
jQuery.contains = function(arr, item) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == item)
return true;
}
return false;
};
/**
* highlight a given string on a jquery object by wrapping it in
* span elements with the given class name.
*/
jQuery.fn.highlightText = function(text, className) {
function highlight(node) {
if (node.nodeType == 3) {
var val = node.nodeValue;
var pos = val.toLowerCase().indexOf(text);
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
var span = document.createElement("span");
span.className = className;
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling));
node.nodeValue = val.substr(0, pos);
}
}
else if (!jQuery(node).is("button, select, textarea")) {
jQuery.each(node.childNodes, function() {
highlight(this);
});
}
}
return this.each(function() {
highlight(this);
});
};
/**
* Small JavaScript module for the documentation.
*/
var Documentation = {
init : function() {
this.fixFirefoxAnchorBug();
this.highlightSearchWords();
this.initIndexTable();
},
/**
* i18n support
*/
TRANSLATIONS : {},
PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
LOCALE : 'unknown',
// gettext and ngettext don't access this so that the functions
// can safely bound to a different name (_ = Documentation.gettext)
gettext : function(string) {
var translated = Documentation.TRANSLATIONS[string];
if (typeof translated == 'undefined')
return string;
return (typeof translated == 'string') ? translated : translated[0];
},
ngettext : function(singular, plural, n) {
var translated = Documentation.TRANSLATIONS[singular];
if (typeof translated == 'undefined')
return (n == 1) ? singular : plural;
return translated[Documentation.PLURALEXPR(n)];
},
addTranslations : function(catalog) {
for (var key in catalog.messages)
this.TRANSLATIONS[key] = catalog.messages[key];
this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
this.LOCALE = catalog.locale;
},
/**
* add context elements like header anchor links
*/
addContextElements : function() {
$('div[id] > :header:first').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this headline')).
appendTo(this);
});
$('dt[id]').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this definition')).
appendTo(this);
});
},
/**
* workaround a firefox stupidity
*/
fixFirefoxAnchorBug : function() {
if (document.location.hash && $.browser.mozilla)
window.setTimeout(function() {
document.location.href += '';
}, 10);
},
/**
* highlight the search words provided in the url in the text
*/
highlightSearchWords : function() {
var params = $.getQueryParameters();
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
if (terms.length) {
var body = $('div.body');
window.setTimeout(function() {
$.each(terms, function() {
body.highlightText(this.toLowerCase(), 'highlighted');
});
}, 10);
$('<p class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
.appendTo($('#searchbox'));
}
},
/**
* init the domain index toggle buttons
*/
initIndexTable : function() {
var togglers = $('img.toggler').click(function() {
var src = $(this).attr('src');
var idnum = $(this).attr('id').substr(7);
$('tr.cg-' + idnum).toggle();
if (src.substr(-9) == 'minus.png')
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
else
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
}).css('display', '');
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
togglers.click();
}
},
/**
* helper function to hide the search marks again
*/
hideSearchWords : function() {
$('#searchbox .highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
},
/**
* make the url absolute
*/
makeURL : function(relativeURL) {
return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
},
/**
* get the current relative url
*/
getCurrentURL : function() {
var path = document.location.pathname;
var parts = path.split(/\//);
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
if (this == '..')
parts.pop();
});
var url = parts.join('/');
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
}
};
// quick alias for translations
_ = Documentation.gettext;
$(document).ready(function() {
Documentation.init();
});
/*!
* jQuery JavaScript Library v1.4.2
* http://jquery.com/
*
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2010, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Sat Feb 13 22:33:48 2010 -0500
*/
(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=
j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,
"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=
true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||
c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",
L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,
"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],
d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===
a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&
!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=
true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",
i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",
" ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=
this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=
e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=
null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=
e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,
"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=
a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,
isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=
{setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};
if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&
!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},
toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,
u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];
if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];
for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=
l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];
h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=
m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||
!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=
h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";
if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,
gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
{},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?
a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||
u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===
1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==
"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},
serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),
function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,
global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&
e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?
"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===
false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=
false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",
c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||
d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);
g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===
1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===
"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;
if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");
this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],
"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},
animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=
j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);
this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===
"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||
c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;
this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=
this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,
e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||
c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?
function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=
this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;
k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&
f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);
c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,
d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":
"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f0f3f3; }
.highlight .c { color: #0099FF; font-style: italic } /* Comment */
.highlight .err { color: #AA0000; background-color: #FFAAAA } /* Error */
.highlight .k { color: #006699; font-weight: bold } /* Keyword */
.highlight .o { color: #555555 } /* Operator */
.highlight .cm { color: #0099FF; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #009999 } /* Comment.Preproc */
.highlight .c1 { color: #0099FF; font-style: italic } /* Comment.Single */
.highlight .cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #003300; font-weight: bold } /* Generic.Heading */
.highlight .gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */
.highlight .go { color: #AAAAAA } /* Generic.Output */
.highlight .gp { color: #000099; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #003300; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #99CC66 } /* Generic.Traceback */
.highlight .kc { color: #006699; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #006699; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #006699; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #006699 } /* Keyword.Pseudo */
.highlight .kr { color: #006699; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #007788; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #FF6600 } /* Literal.Number */
.highlight .s { color: #CC3300 } /* Literal.String */
.highlight .na { color: #330099 } /* Name.Attribute */
.highlight .nb { color: #336666 } /* Name.Builtin */
.highlight .nc { color: #00AA88; font-weight: bold } /* Name.Class */
.highlight .no { color: #336600 } /* Name.Constant */
.highlight .nd { color: #9999FF } /* Name.Decorator */
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #CC0000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #CC00FF } /* Name.Function */
.highlight .nl { color: #9999FF } /* Name.Label */
.highlight .nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #330099; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #003333 } /* Name.Variable */
.highlight .ow { color: #000000; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mf { color: #FF6600 } /* Literal.Number.Float */
.highlight .mh { color: #FF6600 } /* Literal.Number.Hex */
.highlight .mi { color: #FF6600 } /* Literal.Number.Integer */
.highlight .mo { color: #FF6600 } /* Literal.Number.Oct */
.highlight .sb { color: #CC3300 } /* Literal.String.Backtick */
.highlight .sc { color: #CC3300 } /* Literal.String.Char */
.highlight .sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #CC3300 } /* Literal.String.Double */
.highlight .se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #CC3300 } /* Literal.String.Heredoc */
.highlight .si { color: #AA0000 } /* Literal.String.Interpol */
.highlight .sx { color: #CC3300 } /* Literal.String.Other */
.highlight .sr { color: #33AAAA } /* Literal.String.Regex */
.highlight .s1 { color: #CC3300 } /* Literal.String.Single */
.highlight .ss { color: #FFCC33 } /* Literal.String.Symbol */
.highlight .bp { color: #336666 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #003333 } /* Name.Variable.Class */
.highlight .vg { color: #003333 } /* Name.Variable.Global */
.highlight .vi { color: #003333 } /* Name.Variable.Instance */
.highlight .il { color: #FF6600 } /* Literal.Number.Integer.Long */
\ No newline at end of file
/*
* searchtools.js_t
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilties for the full-text search.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* helper function to return a node containing the
* search summary for a given text. keywords is a list
* of stemmed words, hlwords is the list of normal, unstemmed
* words. the first one is used to find the occurance, the
* latter for highlighting it.
*/
jQuery.makeSearchSummary = function(text, keywords, hlwords) {
var textLower = text.toLowerCase();
var start = 0;
$.each(keywords, function() {
var i = textLower.indexOf(this.toLowerCase());
if (i > -1)
start = i;
});
start = Math.max(start - 120, 0);
var excerpt = ((start > 0) ? '...' : '') +
$.trim(text.substr(start, 240)) +
((start + 240 - text.length) ? '...' : '');
var rv = $('<div class="context"></div>').text(excerpt);
$.each(hlwords, function() {
rv = rv.highlightText(this, 'highlighted');
});
return rv;
}
/**
* Porter Stemmer
*/
var Stemmer = function() {
var step2list = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
bli: 'ble',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness: 'ful',
ousness: 'ous',
aliti: 'al',
iviti: 'ive',
biliti: 'ble',
logi: 'log'
};
var step3list = {
icate: 'ic',
ative: '',
alize: 'al',
iciti: 'ic',
ical: 'ic',
ful: '',
ness: ''
};
var c = "[^aeiou]"; // consonant
var v = "[aeiouy]"; // vowel
var C = c + "[^aeiouy]*"; // consonant sequence
var V = v + "[aeiou]*"; // vowel sequence
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
var s_v = "^(" + C + ")?" + v; // vowel in stem
this.stemWord = function (w) {
var stem;
var suffix;
var firstch;
var origword = w;
if (w.length < 3)
return w;
var re;
var re2;
var re3;
var re4;
firstch = w.substr(0,1);
if (firstch == "y")
w = firstch.toUpperCase() + w.substr(1);
// Step 1a
re = /^(.+?)(ss|i)es$/;
re2 = /^(.+?)([^s])s$/;
if (re.test(w))
w = w.replace(re,"$1$2");
else if (re2.test(w))
w = w.replace(re2,"$1$2");
// Step 1b
re = /^(.+?)eed$/;
re2 = /^(.+?)(ed|ing)$/;
if (re.test(w)) {
var fp = re.exec(w);
re = new RegExp(mgr0);
if (re.test(fp[1])) {
re = /.$/;
w = w.replace(re,"");
}
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1];
re2 = new RegExp(s_v);
if (re2.test(stem)) {
w = stem;
re2 = /(at|bl|iz)$/;
re3 = new RegExp("([^aeiouylsz])\\1$");
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re2.test(w))
w = w + "e";
else if (re3.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
else if (re4.test(w))
w = w + "e";
}
}
// Step 1c
re = /^(.+?)y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem))
w = stem + "i";
}
// Step 2
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step2list[suffix];
}
// Step 3
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step3list[suffix];
}
// Step 4
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
re2 = /^(.+?)(s|t)(ion)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
if (re.test(stem))
w = stem;
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1] + fp[2];
re2 = new RegExp(mgr1);
if (re2.test(stem))
w = stem;
}
// Step 5
re = /^(.+?)e$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
re2 = new RegExp(meq1);
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
w = stem;
}
re = /ll$/;
re2 = new RegExp(mgr1);
if (re.test(w) && re2.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
// and turn initial Y back to y
if (firstch == "y")
w = firstch.toLowerCase() + w.substr(1);
return w;
}
}
/**
* Search Module
*/
var Search = {
_index : null,
_queued_query : null,
_pulse_status : -1,
init : function() {
var params = $.getQueryParameters();
if (params.q) {
var query = params.q[0];
$('input[name="q"]')[0].value = query;
this.performSearch(query);
}
},
loadIndex : function(url) {
$.ajax({type: "GET", url: url, data: null, success: null,
dataType: "script", cache: true});
},
setIndex : function(index) {
var q;
this._index = index;
if ((q = this._queued_query) !== null) {
this._queued_query = null;
Search.query(q);
}
},
hasIndex : function() {
return this._index !== null;
},
deferQuery : function(query) {
this._queued_query = query;
},
stopPulse : function() {
this._pulse_status = 0;
},
startPulse : function() {
if (this._pulse_status >= 0)
return;
function pulse() {
Search._pulse_status = (Search._pulse_status + 1) % 4;
var dotString = '';
for (var i = 0; i < Search._pulse_status; i++)
dotString += '.';
Search.dots.text(dotString);
if (Search._pulse_status > -1)
window.setTimeout(pulse, 500);
};
pulse();
},
/**
* perform a search for something
*/
performSearch : function(query) {
// create the required interface elements
this.out = $('#search-results');
this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
this.dots = $('<span></span>').appendTo(this.title);
this.status = $('<p style="display: none"></p>').appendTo(this.out);
this.output = $('<ul class="search"/>').appendTo(this.out);
$('#search-progress').text(_('Preparing search...'));
this.startPulse();
// index already loaded, the browser was quick!
if (this.hasIndex())
this.query(query);
else
this.deferQuery(query);
},
query : function(query) {
var stopwords = ["and","then","into","it","as","are","in","if","for","no","there","their","was","is","be","to","that","but","they","not","such","with","by","a","on","these","of","will","this","near","the","or","at"];
// Stem the searchterms and add them to the correct list
var stemmer = new Stemmer();
var searchterms = [];
var excluded = [];
var hlterms = [];
var tmp = query.split(/\s+/);
var objectterms = [];
for (var i = 0; i < tmp.length; i++) {
if (tmp[i] != "") {
objectterms.push(tmp[i].toLowerCase());
}
if ($u.indexOf(stopwords, tmp[i]) != -1 || tmp[i].match(/^\d+$/) ||
tmp[i] == "") {
// skip this "word"
continue;
}
// stem the word
var word = stemmer.stemWord(tmp[i]).toLowerCase();
// select the correct list
if (word[0] == '-') {
var toAppend = excluded;
word = word.substr(1);
}
else {
var toAppend = searchterms;
hlterms.push(tmp[i].toLowerCase());
}
// only add if not already in the list
if (!$.contains(toAppend, word))
toAppend.push(word);
};
var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
// console.debug('SEARCH: searching for:');
// console.info('required: ', searchterms);
// console.info('excluded: ', excluded);
// prepare search
var filenames = this._index.filenames;
var titles = this._index.titles;
var terms = this._index.terms;
var fileMap = {};
var files = null;
// different result priorities
var importantResults = [];
var objectResults = [];
var regularResults = [];
var unimportantResults = [];
$('#search-progress').empty();
// lookup as object
for (var i = 0; i < objectterms.length; i++) {
var others = [].concat(objectterms.slice(0,i),
objectterms.slice(i+1, objectterms.length))
var results = this.performObjectSearch(objectterms[i], others);
// Assume first word is most likely to be the object,
// other words more likely to be in description.
// Therefore put matches for earlier words first.
// (Results are eventually used in reverse order).
objectResults = results[0].concat(objectResults);
importantResults = results[1].concat(importantResults);
unimportantResults = results[2].concat(unimportantResults);
}
// perform the search on the required terms
for (var i = 0; i < searchterms.length; i++) {
var word = searchterms[i];
// no match but word was a required one
if ((files = terms[word]) == null)
break;
if (files.length == undefined) {
files = [files];
}
// create the mapping
for (var j = 0; j < files.length; j++) {
var file = files[j];
if (file in fileMap)
fileMap[file].push(word);
else
fileMap[file] = [word];
}
}
// now check if the files don't contain excluded terms
for (var file in fileMap) {
var valid = true;
// check if all requirements are matched
if (fileMap[file].length != searchterms.length)
continue;
// ensure that none of the excluded terms is in the
// search result.
for (var i = 0; i < excluded.length; i++) {
if (terms[excluded[i]] == file ||
$.contains(terms[excluded[i]] || [], file)) {
valid = false;
break;
}
}
// if we have still a valid result we can add it
// to the result list
if (valid)
regularResults.push([filenames[file], titles[file], '', null]);
}
// delete unused variables in order to not waste
// memory until list is retrieved completely
delete filenames, titles, terms;
// now sort the regular results descending by title
regularResults.sort(function(a, b) {
var left = a[1].toLowerCase();
var right = b[1].toLowerCase();
return (left > right) ? -1 : ((left < right) ? 1 : 0);
});
// combine all results
var results = unimportantResults.concat(regularResults)
.concat(objectResults).concat(importantResults);
// print the results
var resultCount = results.length;
function displayNextItem() {
// results left, load the summary and display it
if (results.length) {
var item = results.pop();
var listItem = $('<li style="display:none"></li>');
if (DOCUMENTATION_OPTIONS.FILE_SUFFIX == '') {
// dirhtml builder
var dirname = item[0] + '/';
if (dirname.match(/\/index\/$/)) {
dirname = dirname.substring(0, dirname.length-6);
} else if (dirname == 'index/') {
dirname = '';
}
listItem.append($('<a/>').attr('href',
DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
highlightstring + item[2]).html(item[1]));
} else {
// normal html builders
listItem.append($('<a/>').attr('href',
item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
highlightstring + item[2]).html(item[1]));
}
if (item[3]) {
listItem.append($('<span> (' + item[3] + ')</span>'));
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.get(DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' +
item[0] + '.txt', function(data) {
if (data != '') {
listItem.append($.makeSearchSummary(data, searchterms, hlterms));
Search.output.append(listItem);
}
listItem.slideDown(5, function() {
displayNextItem();
});
}, "text");
} else {
// no source available, just display title
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
}
}
// search finished, update title and status message
else {
Search.stopPulse();
Search.title.text(_('Search Results'));
if (!resultCount)
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
else
Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
Search.status.fadeIn(500);
}
}
displayNextItem();
},
performObjectSearch : function(object, otherterms) {
var filenames = this._index.filenames;
var objects = this._index.objects;
var objnames = this._index.objnames;
var titles = this._index.titles;
var importantResults = [];
var objectResults = [];
var unimportantResults = [];
for (var prefix in objects) {
for (var name in objects[prefix]) {
var fullname = (prefix ? prefix + '.' : '') + name;
if (fullname.toLowerCase().indexOf(object) > -1) {
var match = objects[prefix][name];
var objname = objnames[match[1]][2];
var title = titles[match[0]];
// If more than one term searched for, we require other words to be
// found in the name/title/description
if (otherterms.length > 0) {
var haystack = (prefix + ' ' + name + ' ' +
objname + ' ' + title).toLowerCase();
var allfound = true;
for (var i = 0; i < otherterms.length; i++) {
if (haystack.indexOf(otherterms[i]) == -1) {
allfound = false;
break;
}
}
if (!allfound) {
continue;
}
}
var descr = objname + _(', in ') + title;
anchor = match[3];
if (anchor == '')
anchor = fullname;
else if (anchor == '-')
anchor = objnames[match[1]][1] + '-' + fullname;
result = [filenames[match[0]], fullname, '#'+anchor, descr];
switch (match[2]) {
case 1: objectResults.push(result); break;
case 0: importantResults.push(result); break;
case 2: unimportantResults.push(result); break;
}
}
}
}
// sort results descending
objectResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
importantResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
unimportantResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
return [importantResults, objectResults, unimportantResults]
}
}
$(document).ready(function() {
Search.init();
});
\ No newline at end of file
/*
* sidebar.js
* ~~~~~~~~~~
*
* This script makes the Sphinx sidebar collapsible.
*
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
* used to collapse and expand the sidebar.
*
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
* and the width of the sidebar and the margin-left of the document
* are decreased. When the sidebar is expanded the opposite happens.
* This script saves a per-browser/per-session cookie used to
* remember the position of the sidebar among the pages.
* Once the browser is closed the cookie is deleted and the position
* reset to the default (expanded).
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
$(function() {
// global elements used by the functions.
// the 'sidebarbutton' element is defined as global after its
// creation, in the add_sidebar_button function
var bodywrapper = $('.bodywrapper');
var sidebar = $('.sphinxsidebar');
var sidebarwrapper = $('.sphinxsidebarwrapper');
// for some reason, the document has no sidebar; do not run into errors
if (!sidebar.length) return;
// original margin-left of the bodywrapper and width of the sidebar
// with the sidebar expanded
var bw_margin_expanded = bodywrapper.css('margin-left');
var ssb_width_expanded = sidebar.width();
// margin-left of the bodywrapper and width of the sidebar
// with the sidebar collapsed
var bw_margin_collapsed = '.8em';
var ssb_width_collapsed = '.8em';
// colors used by the current theme
var dark_color = $('.related').css('background-color');
var light_color = $('.document').css('background-color');
function sidebar_is_collapsed() {
return sidebarwrapper.is(':not(:visible)');
}
function toggle_sidebar() {
if (sidebar_is_collapsed())
expand_sidebar();
else
collapse_sidebar();
}
function collapse_sidebar() {
sidebarwrapper.hide();
sidebar.css('width', ssb_width_collapsed);
bodywrapper.css('margin-left', bw_margin_collapsed);
sidebarbutton.css({
'margin-left': '0',
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('»');
sidebarbutton.attr('title', _('Expand sidebar'));
document.cookie = 'sidebar=collapsed';
}
function expand_sidebar() {
bodywrapper.css('margin-left', bw_margin_expanded);
sidebar.css('width', ssb_width_expanded);
sidebarwrapper.show();
sidebarbutton.css({
'margin-left': ssb_width_expanded-12,
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('«');
sidebarbutton.attr('title', _('Collapse sidebar'));
document.cookie = 'sidebar=expanded';
}
function add_sidebar_button() {
sidebarwrapper.css({
'float': 'left',
'margin-right': '0',
'width': ssb_width_expanded - 28
});
// create the button
sidebar.append(
'<div id="sidebarbutton"><span>&laquo;</span></div>'
);
var sidebarbutton = $('#sidebarbutton');
light_color = sidebarbutton.css('background-color');
// find the height of the viewport to center the '<<' in the page
var viewport_height;
if (window.innerHeight)
viewport_height = window.innerHeight;
else
viewport_height = $(window).height();
sidebarbutton.find('span').css({
'display': 'block',
'margin-top': (viewport_height - sidebar.position().top - 20) / 2
});
sidebarbutton.click(toggle_sidebar);
sidebarbutton.attr('title', _('Collapse sidebar'));
sidebarbutton.css({
'color': '#FFFFFF',
'border-left': '1px solid ' + dark_color,
'font-size': '1.2em',
'cursor': 'pointer',
'height': bodywrapper.height(),
'padding-top': '1px',
'margin-left': ssb_width_expanded - 12
});
sidebarbutton.hover(
function () {
$(this).css('background-color', dark_color);
},
function () {
$(this).css('background-color', light_color);
}
);
}
function set_position_from_cookie() {
if (!document.cookie)
return;
var items = document.cookie.split(';');
for(var k=0; k<items.length; k++) {
var key_val = items[k].split('=');
var key = key_val[0];
if (key == 'sidebar') {
var value = key_val[1];
if ((value == 'collapsed') && (!sidebar_is_collapsed()))
collapse_sidebar();
else if ((value == 'expanded') && (sidebar_is_collapsed()))
expand_sidebar();
}
}
}
add_sidebar_button();
var sidebarbutton = $('#sidebarbutton');
set_position_from_cookie();
});
// Underscore.js 0.5.5
// (c) 2009 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the terms of the MIT license.
// Portions of Underscore are inspired by or borrowed from Prototype.js,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore/
(function(){var j=this,n=j._,i=function(a){this._wrapped=a},m=typeof StopIteration!=="undefined"?StopIteration:"__break__",b=j._=function(a){return new i(a)};if(typeof exports!=="undefined")exports._=b;var k=Array.prototype.slice,o=Array.prototype.unshift,p=Object.prototype.toString,q=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;b.VERSION="0.5.5";b.each=function(a,c,d){try{if(a.forEach)a.forEach(c,d);else if(b.isArray(a)||b.isArguments(a))for(var e=0,f=a.length;e<f;e++)c.call(d,
a[e],e,a);else{var g=b.keys(a);f=g.length;for(e=0;e<f;e++)c.call(d,a[g[e]],g[e],a)}}catch(h){if(h!=m)throw h;}return a};b.map=function(a,c,d){if(a&&b.isFunction(a.map))return a.map(c,d);var e=[];b.each(a,function(f,g,h){e.push(c.call(d,f,g,h))});return e};b.reduce=function(a,c,d,e){if(a&&b.isFunction(a.reduce))return a.reduce(b.bind(d,e),c);b.each(a,function(f,g,h){c=d.call(e,c,f,g,h)});return c};b.reduceRight=function(a,c,d,e){if(a&&b.isFunction(a.reduceRight))return a.reduceRight(b.bind(d,e),c);
var f=b.clone(b.toArray(a)).reverse();b.each(f,function(g,h){c=d.call(e,c,g,h,a)});return c};b.detect=function(a,c,d){var e;b.each(a,function(f,g,h){if(c.call(d,f,g,h)){e=f;b.breakLoop()}});return e};b.select=function(a,c,d){if(a&&b.isFunction(a.filter))return a.filter(c,d);var e=[];b.each(a,function(f,g,h){c.call(d,f,g,h)&&e.push(f)});return e};b.reject=function(a,c,d){var e=[];b.each(a,function(f,g,h){!c.call(d,f,g,h)&&e.push(f)});return e};b.all=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.every))return a.every(c,
d);var e=true;b.each(a,function(f,g,h){(e=e&&c.call(d,f,g,h))||b.breakLoop()});return e};b.any=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.some))return a.some(c,d);var e=false;b.each(a,function(f,g,h){if(e=c.call(d,f,g,h))b.breakLoop()});return e};b.include=function(a,c){if(b.isArray(a))return b.indexOf(a,c)!=-1;var d=false;b.each(a,function(e){if(d=e===c)b.breakLoop()});return d};b.invoke=function(a,c){var d=b.rest(arguments,2);return b.map(a,function(e){return(c?e[c]:e).apply(e,d)})};b.pluck=
function(a,c){return b.map(a,function(d){return d[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);var e={computed:-Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g>=e.computed&&(e={value:f,computed:g})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g<e.computed&&(e={value:f,computed:g})});return e.value};b.sortBy=function(a,c,d){return b.pluck(b.map(a,
function(e,f,g){return{value:e,criteria:c.call(d,e,f,g)}}).sort(function(e,f){e=e.criteria;f=f.criteria;return e<f?-1:e>f?1:0}),"value")};b.sortedIndex=function(a,c,d){d=d||b.identity;for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?(e=g+1):(f=g)}return e};b.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(b.isArray(a))return a;if(b.isArguments(a))return k.call(a);return b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=function(a,c,d){return c&&!d?k.call(a,
0,c):a[0]};b.rest=function(a,c,d){return k.call(a,b.isUndefined(c)||d?1:c)};b.last=function(a){return a[a.length-1]};b.compact=function(a){return b.select(a,function(c){return!!c})};b.flatten=function(a){return b.reduce(a,[],function(c,d){if(b.isArray(d))return c.concat(b.flatten(d));c.push(d);return c})};b.without=function(a){var c=b.rest(arguments);return b.select(a,function(d){return!b.include(c,d)})};b.uniq=function(a,c){return b.reduce(a,[],function(d,e,f){if(0==f||(c===true?b.last(d)!=e:!b.include(d,
e)))d.push(e);return d})};b.intersect=function(a){var c=b.rest(arguments);return b.select(b.uniq(a),function(d){return b.all(c,function(e){return b.indexOf(e,d)>=0})})};b.zip=function(){for(var a=b.toArray(arguments),c=b.max(b.pluck(a,"length")),d=new Array(c),e=0;e<c;e++)d[e]=b.pluck(a,String(e));return d};b.indexOf=function(a,c){if(a.indexOf)return a.indexOf(c);for(var d=0,e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,c){if(a.lastIndexOf)return a.lastIndexOf(c);for(var d=
a.length;d--;)if(a[d]===c)return d;return-1};b.range=function(a,c,d){var e=b.toArray(arguments),f=e.length<=1;a=f?0:e[0];c=f?e[0]:e[1];d=e[2]||1;e=Math.ceil((c-a)/d);if(e<=0)return[];e=new Array(e);f=a;for(var g=0;1;f+=d){if((d>0?f-c:c-f)>=0)return e;e[g++]=f}};b.bind=function(a,c){var d=b.rest(arguments,2);return function(){return a.apply(c||j,d.concat(b.toArray(arguments)))}};b.bindAll=function(a){var c=b.rest(arguments);if(c.length==0)c=b.functions(a);b.each(c,function(d){a[d]=b.bind(a[d],a)});
return a};b.delay=function(a,c){var d=b.rest(arguments,2);return setTimeout(function(){return a.apply(a,d)},c)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(b.rest(arguments)))};b.wrap=function(a,c){return function(){var d=[a].concat(b.toArray(arguments));return c.apply(c,d)}};b.compose=function(){var a=b.toArray(arguments);return function(){for(var c=b.toArray(arguments),d=a.length-1;d>=0;d--)c=[a[d].apply(this,c)];return c[0]}};b.keys=function(a){if(b.isArray(a))return b.range(0,a.length);
var c=[];for(var d in a)q.call(a,d)&&c.push(d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=function(a){return b.select(b.keys(a),function(c){return b.isFunction(a[c])}).sort()};b.extend=function(a,c){for(var d in c)a[d]=c[d];return a};b.clone=function(a){if(b.isArray(a))return a.slice(0);return b.extend({},a)};b.tap=function(a,c){c(a);return a};b.isEqual=function(a,c){if(a===c)return true;var d=typeof a;if(d!=typeof c)return false;if(a==c)return true;if(!a&&c||a&&!c)return false;
if(a.isEqual)return a.isEqual(c);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return true;if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return false;if(a.length&&a.length!==c.length)return false;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return false;for(var f in a)if(!b.isEqual(a[f],c[f]))return false;return true};b.isEmpty=function(a){return b.keys(a).length==
0};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=function(a){return!!(a&&a.concat&&a.unshift)};b.isArguments=function(a){return a&&b.isNumber(a.length)&&!b.isArray(a)&&!r.call(a,"length")};b.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};b.isNumber=function(a){return p.call(a)==="[object Number]"};b.isDate=function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)};b.isRegExp=function(a){return!!(a&&
a.test&&a.exec&&(a.ignoreCase||a.ignoreCase===false))};b.isNaN=function(a){return b.isNumber(a)&&isNaN(a)};b.isNull=function(a){return a===null};b.isUndefined=function(a){return typeof a=="undefined"};b.noConflict=function(){j._=n;return this};b.identity=function(a){return a};b.breakLoop=function(){throw m;};var s=0;b.uniqueId=function(a){var c=s++;return a?a+c:c};b.template=function(a,c){a=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g,
" ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return c?a(c):a};b.forEach=b.each;b.foldl=b.inject=b.reduce;b.foldr=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.any;b.head=b.first;b.tail=b.rest;b.methods=b.functions;var l=function(a,c){return c?b(a).chain():a};b.each(b.functions(b),function(a){var c=b[a];i.prototype[a]=function(){var d=b.toArray(arguments);
o.call(d,this._wrapped);return l(c.apply(b,d),this._chain)}});b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){c.apply(this._wrapped,arguments);return l(this._wrapped,this._chain)}});b.each(["concat","join","slice"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){return l(c.apply(this._wrapped,arguments),this._chain)}});i.prototype.chain=function(){this._chain=true;return this};i.prototype.value=function(){return this._wrapped}})();
/*
* websupport.js
* ~~~~~~~~~~~~~
*
* sphinx.websupport utilties for all documentation.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
(function($) {
$.fn.autogrow = function() {
return this.each(function() {
var textarea = this;
$.fn.autogrow.resize(textarea);
$(textarea)
.focus(function() {
textarea.interval = setInterval(function() {
$.fn.autogrow.resize(textarea);
}, 500);
})
.blur(function() {
clearInterval(textarea.interval);
});
});
};
$.fn.autogrow.resize = function(textarea) {
var lineHeight = parseInt($(textarea).css('line-height'), 10);
var lines = textarea.value.split('\n');
var columns = textarea.cols;
var lineCount = 0;
$.each(lines, function() {
lineCount += Math.ceil(this.length / columns) || 1;
});
var height = lineHeight * (lineCount + 1);
$(textarea).css('height', height);
};
})(jQuery);
(function($) {
var comp, by;
function init() {
initEvents();
initComparator();
}
function initEvents() {
$('a.comment-close').live("click", function(event) {
event.preventDefault();
hide($(this).attr('id').substring(2));
});
$('a.vote').live("click", function(event) {
event.preventDefault();
handleVote($(this));
});
$('a.reply').live("click", function(event) {
event.preventDefault();
openReply($(this).attr('id').substring(2));
});
$('a.close-reply').live("click", function(event) {
event.preventDefault();
closeReply($(this).attr('id').substring(2));
});
$('a.sort-option').live("click", function(event) {
event.preventDefault();
handleReSort($(this));
});
$('a.show-proposal').live("click", function(event) {
event.preventDefault();
showProposal($(this).attr('id').substring(2));
});
$('a.hide-proposal').live("click", function(event) {
event.preventDefault();
hideProposal($(this).attr('id').substring(2));
});
$('a.show-propose-change').live("click", function(event) {
event.preventDefault();
showProposeChange($(this).attr('id').substring(2));
});
$('a.hide-propose-change').live("click", function(event) {
event.preventDefault();
hideProposeChange($(this).attr('id').substring(2));
});
$('a.accept-comment').live("click", function(event) {
event.preventDefault();
acceptComment($(this).attr('id').substring(2));
});
$('a.delete-comment').live("click", function(event) {
event.preventDefault();
deleteComment($(this).attr('id').substring(2));
});
$('a.comment-markup').live("click", function(event) {
event.preventDefault();
toggleCommentMarkupBox($(this).attr('id').substring(2));
});
}
/**
* Set comp, which is a comparator function used for sorting and
* inserting comments into the list.
*/
function setComparator() {
// If the first three letters are "asc", sort in ascending order
// and remove the prefix.
if (by.substring(0,3) == 'asc') {
var i = by.substring(3);
comp = function(a, b) { return a[i] - b[i]; };
} else {
// Otherwise sort in descending order.
comp = function(a, b) { return b[by] - a[by]; };
}
// Reset link styles and format the selected sort option.
$('a.sel').attr('href', '#').removeClass('sel');
$('a.by' + by).removeAttr('href').addClass('sel');
}
/**
* Create a comp function. If the user has preferences stored in
* the sortBy cookie, use those, otherwise use the default.
*/
function initComparator() {
by = 'rating'; // Default to sort by rating.
// If the sortBy cookie is set, use that instead.
if (document.cookie.length > 0) {
var start = document.cookie.indexOf('sortBy=');
if (start != -1) {
start = start + 7;
var end = document.cookie.indexOf(";", start);
if (end == -1) {
end = document.cookie.length;
by = unescape(document.cookie.substring(start, end));
}
}
}
setComparator();
}
/**
* Show a comment div.
*/
function show(id) {
$('#ao' + id).hide();
$('#ah' + id).show();
var context = $.extend({id: id}, opts);
var popup = $(renderTemplate(popupTemplate, context)).hide();
popup.find('textarea[name="proposal"]').hide();
popup.find('a.by' + by).addClass('sel');
var form = popup.find('#cf' + id);
form.submit(function(event) {
event.preventDefault();
addComment(form);
});
$('#s' + id).after(popup);
popup.slideDown('fast', function() {
getComments(id);
});
}
/**
* Hide a comment div.
*/
function hide(id) {
$('#ah' + id).hide();
$('#ao' + id).show();
var div = $('#sc' + id);
div.slideUp('fast', function() {
div.remove();
});
}
/**
* Perform an ajax request to get comments for a node
* and insert the comments into the comments tree.
*/
function getComments(id) {
$.ajax({
type: 'GET',
url: opts.getCommentsURL,
data: {node: id},
success: function(data, textStatus, request) {
var ul = $('#cl' + id);
var speed = 100;
$('#cf' + id)
.find('textarea[name="proposal"]')
.data('source', data.source);
if (data.comments.length === 0) {
ul.html('<li>No comments yet.</li>');
ul.data('empty', true);
} else {
// If there are comments, sort them and put them in the list.
var comments = sortComments(data.comments);
speed = data.comments.length * 100;
appendComments(comments, ul);
ul.data('empty', false);
}
$('#cn' + id).slideUp(speed + 200);
ul.slideDown(speed);
},
error: function(request, textStatus, error) {
showError('Oops, there was a problem retrieving the comments.');
},
dataType: 'json'
});
}
/**
* Add a comment via ajax and insert the comment into the comment tree.
*/
function addComment(form) {
var node_id = form.find('input[name="node"]').val();
var parent_id = form.find('input[name="parent"]').val();
var text = form.find('textarea[name="comment"]').val();
var proposal = form.find('textarea[name="proposal"]').val();
if (text == '') {
showError('Please enter a comment.');
return;
}
// Disable the form that is being submitted.
form.find('textarea,input').attr('disabled', 'disabled');
// Send the comment to the server.
$.ajax({
type: "POST",
url: opts.addCommentURL,
dataType: 'json',
data: {
node: node_id,
parent: parent_id,
text: text,
proposal: proposal
},
success: function(data, textStatus, error) {
// Reset the form.
if (node_id) {
hideProposeChange(node_id);
}
form.find('textarea')
.val('')
.add(form.find('input'))
.removeAttr('disabled');
var ul = $('#cl' + (node_id || parent_id));
if (ul.data('empty')) {
$(ul).empty();
ul.data('empty', false);
}
insertComment(data.comment);
var ao = $('#ao' + node_id);
ao.find('img').attr({'src': opts.commentBrightImage});
if (node_id) {
// if this was a "root" comment, remove the commenting box
// (the user can get it back by reopening the comment popup)
$('#ca' + node_id).slideUp();
}
},
error: function(request, textStatus, error) {
form.find('textarea,input').removeAttr('disabled');
showError('Oops, there was a problem adding the comment.');
}
});
}
/**
* Recursively append comments to the main comment list and children
* lists, creating the comment tree.
*/
function appendComments(comments, ul) {
$.each(comments, function() {
var div = createCommentDiv(this);
ul.append($(document.createElement('li')).html(div));
appendComments(this.children, div.find('ul.comment-children'));
// To avoid stagnating data, don't store the comments children in data.
this.children = null;
div.data('comment', this);
});
}
/**
* After adding a new comment, it must be inserted in the correct
* location in the comment tree.
*/
function insertComment(comment) {
var div = createCommentDiv(comment);
// To avoid stagnating data, don't store the comments children in data.
comment.children = null;
div.data('comment', comment);
var ul = $('#cl' + (comment.node || comment.parent));
var siblings = getChildren(ul);
var li = $(document.createElement('li'));
li.hide();
// Determine where in the parents children list to insert this comment.
for(i=0; i < siblings.length; i++) {
if (comp(comment, siblings[i]) <= 0) {
$('#cd' + siblings[i].id)
.parent()
.before(li.html(div));
li.slideDown('fast');
return;
}
}
// If we get here, this comment rates lower than all the others,
// or it is the only comment in the list.
ul.append(li.html(div));
li.slideDown('fast');
}
function acceptComment(id) {
$.ajax({
type: 'POST',
url: opts.acceptCommentURL,
data: {id: id},
success: function(data, textStatus, request) {
$('#cm' + id).fadeOut('fast');
$('#cd' + id).removeClass('moderate');
},
error: function(request, textStatus, error) {
showError('Oops, there was a problem accepting the comment.');
}
});
}
function deleteComment(id) {
$.ajax({
type: 'POST',
url: opts.deleteCommentURL,
data: {id: id},
success: function(data, textStatus, request) {
var div = $('#cd' + id);
if (data == 'delete') {
// Moderator mode: remove the comment and all children immediately
div.slideUp('fast', function() {
div.remove();
});
return;
}
// User mode: only mark the comment as deleted
div
.find('span.user-id:first')
.text('[deleted]').end()
.find('div.comment-text:first')
.text('[deleted]').end()
.find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
.remove();
var comment = div.data('comment');
comment.username = '[deleted]';
comment.text = '[deleted]';
div.data('comment', comment);
},
error: function(request, textStatus, error) {
showError('Oops, there was a problem deleting the comment.');
}
});
}
function showProposal(id) {
$('#sp' + id).hide();
$('#hp' + id).show();
$('#pr' + id).slideDown('fast');
}
function hideProposal(id) {
$('#hp' + id).hide();
$('#sp' + id).show();
$('#pr' + id).slideUp('fast');
}
function showProposeChange(id) {
$('#pc' + id).hide();
$('#hc' + id).show();
var textarea = $('#pt' + id);
textarea.val(textarea.data('source'));
$.fn.autogrow.resize(textarea[0]);
textarea.slideDown('fast');
}
function hideProposeChange(id) {
$('#hc' + id).hide();
$('#pc' + id).show();
var textarea = $('#pt' + id);
textarea.val('').removeAttr('disabled');
textarea.slideUp('fast');
}
function toggleCommentMarkupBox(id) {
$('#mb' + id).toggle();
}
/** Handle when the user clicks on a sort by link. */
function handleReSort(link) {
var classes = link.attr('class').split(/\s+/);
for (var i=0; i<classes.length; i++) {
if (classes[i] != 'sort-option') {
by = classes[i].substring(2);
}
}
setComparator();
// Save/update the sortBy cookie.
var expiration = new Date();
expiration.setDate(expiration.getDate() + 365);
document.cookie= 'sortBy=' + escape(by) +
';expires=' + expiration.toUTCString();
$('ul.comment-ul').each(function(index, ul) {
var comments = getChildren($(ul), true);
comments = sortComments(comments);
appendComments(comments, $(ul).empty());
});
}
/**
* Function to process a vote when a user clicks an arrow.
*/
function handleVote(link) {
if (!opts.voting) {
showError("You'll need to login to vote.");
return;
}
var id = link.attr('id');
if (!id) {
// Didn't click on one of the voting arrows.
return;
}
// If it is an unvote, the new vote value is 0,
// Otherwise it's 1 for an upvote, or -1 for a downvote.
var value = 0;
if (id.charAt(1) != 'u') {
value = id.charAt(0) == 'u' ? 1 : -1;
}
// The data to be sent to the server.
var d = {
comment_id: id.substring(2),
value: value
};
// Swap the vote and unvote links.
link.hide();
$('#' + id.charAt(0) + (id.charAt(1) == 'u' ? 'v' : 'u') + d.comment_id)
.show();
// The div the comment is displayed in.
var div = $('div#cd' + d.comment_id);
var data = div.data('comment');
// If this is not an unvote, and the other vote arrow has
// already been pressed, unpress it.
if ((d.value !== 0) && (data.vote === d.value * -1)) {
$('#' + (d.value == 1 ? 'd' : 'u') + 'u' + d.comment_id).hide();
$('#' + (d.value == 1 ? 'd' : 'u') + 'v' + d.comment_id).show();
}
// Update the comments rating in the local data.
data.rating += (data.vote === 0) ? d.value : (d.value - data.vote);
data.vote = d.value;
div.data('comment', data);
// Change the rating text.
div.find('.rating:first')
.text(data.rating + ' point' + (data.rating == 1 ? '' : 's'));
// Send the vote information to the server.
$.ajax({
type: "POST",
url: opts.processVoteURL,
data: d,
error: function(request, textStatus, error) {
showError('Oops, there was a problem casting that vote.');
}
});
}
/**
* Open a reply form used to reply to an existing comment.
*/
function openReply(id) {
// Swap out the reply link for the hide link
$('#rl' + id).hide();
$('#cr' + id).show();
// Add the reply li to the children ul.
var div = $(renderTemplate(replyTemplate, {id: id})).hide();
$('#cl' + id)
.prepend(div)
// Setup the submit handler for the reply form.
.find('#rf' + id)
.submit(function(event) {
event.preventDefault();
addComment($('#rf' + id));
closeReply(id);
})
.find('input[type=button]')
.click(function() {
closeReply(id);
});
div.slideDown('fast', function() {
$('#rf' + id).find('textarea').focus();
});
}
/**
* Close the reply form opened with openReply.
*/
function closeReply(id) {
// Remove the reply div from the DOM.
$('#rd' + id).slideUp('fast', function() {
$(this).remove();
});
// Swap out the hide link for the reply link
$('#cr' + id).hide();
$('#rl' + id).show();
}
/**
* Recursively sort a tree of comments using the comp comparator.
*/
function sortComments(comments) {
comments.sort(comp);
$.each(comments, function() {
this.children = sortComments(this.children);
});
return comments;
}
/**
* Get the children comments from a ul. If recursive is true,
* recursively include childrens' children.
*/
function getChildren(ul, recursive) {
var children = [];
ul.children().children("[id^='cd']")
.each(function() {
var comment = $(this).data('comment');
if (recursive)
comment.children = getChildren($(this).find('#cl' + comment.id), true);
children.push(comment);
});
return children;
}
/** Create a div to display a comment in. */
function createCommentDiv(comment) {
if (!comment.displayed && !opts.moderator) {
return $('<div class="moderate">Thank you! Your comment will show up '
+ 'once it is has been approved by a moderator.</div>');
}
// Prettify the comment rating.
comment.pretty_rating = comment.rating + ' point' +
(comment.rating == 1 ? '' : 's');
// Make a class (for displaying not yet moderated comments differently)
comment.css_class = comment.displayed ? '' : ' moderate';
// Create a div for this comment.
var context = $.extend({}, opts, comment);
var div = $(renderTemplate(commentTemplate, context));
// If the user has voted on this comment, highlight the correct arrow.
if (comment.vote) {
var direction = (comment.vote == 1) ? 'u' : 'd';
div.find('#' + direction + 'v' + comment.id).hide();
div.find('#' + direction + 'u' + comment.id).show();
}
if (opts.moderator || comment.text != '[deleted]') {
div.find('a.reply').show();
if (comment.proposal_diff)
div.find('#sp' + comment.id).show();
if (opts.moderator && !comment.displayed)
div.find('#cm' + comment.id).show();
if (opts.moderator || (opts.username == comment.username))
div.find('#dc' + comment.id).show();
}
return div;
}
/**
* A simple template renderer. Placeholders such as <%id%> are replaced
* by context['id'] with items being escaped. Placeholders such as <#id#>
* are not escaped.
*/
function renderTemplate(template, context) {
var esc = $(document.createElement('div'));
function handle(ph, escape) {
var cur = context;
$.each(ph.split('.'), function() {
cur = cur[this];
});
return escape ? esc.text(cur || "").html() : cur;
}
return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
return handle(arguments[2], arguments[1] == '%' ? true : false);
});
}
/** Flash an error message briefly. */
function showError(message) {
$(document.createElement('div')).attr({'class': 'popup-error'})
.append($(document.createElement('div'))
.attr({'class': 'error-message'}).text(message))
.appendTo('body')
.fadeIn("slow")
.delay(2000)
.fadeOut("slow");
}
/** Add a link the user uses to open the comments popup. */
$.fn.comment = function() {
return this.each(function() {
var id = $(this).attr('id').substring(1);
var count = COMMENT_METADATA[id];
var title = count + ' comment' + (count == 1 ? '' : 's');
var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
var addcls = count == 0 ? ' nocomment' : '';
$(this)
.append(
$(document.createElement('a')).attr({
href: '#',
'class': 'sphinx-comment-open' + addcls,
id: 'ao' + id
})
.append($(document.createElement('img')).attr({
src: image,
alt: 'comment',
title: title
}))
.click(function(event) {
event.preventDefault();
show($(this).attr('id').substring(2));
})
)
.append(
$(document.createElement('a')).attr({
href: '#',
'class': 'sphinx-comment-close hidden',
id: 'ah' + id
})
.append($(document.createElement('img')).attr({
src: opts.closeCommentImage,
alt: 'close',
title: 'close'
}))
.click(function(event) {
event.preventDefault();
hide($(this).attr('id').substring(2));
})
);
});
};
var opts = {
processVoteURL: '/_process_vote',
addCommentURL: '/_add_comment',
getCommentsURL: '/_get_comments',
acceptCommentURL: '/_accept_comment',
deleteCommentURL: '/_delete_comment',
commentImage: '/static/_static/comment.png',
closeCommentImage: '/static/_static/comment-close.png',
loadingImage: '/static/_static/ajax-loader.gif',
commentBrightImage: '/static/_static/comment-bright.png',
upArrow: '/static/_static/up.png',
downArrow: '/static/_static/down.png',
upArrowPressed: '/static/_static/up-pressed.png',
downArrowPressed: '/static/_static/down-pressed.png',
voting: false,
moderator: false
};
if (typeof COMMENT_OPTIONS != "undefined") {
opts = jQuery.extend(opts, COMMENT_OPTIONS);
}
var popupTemplate = '\
<div class="sphinx-comments" id="sc<%id%>">\
<p class="sort-options">\
Sort by:\
<a href="#" class="sort-option byrating">best rated</a>\
<a href="#" class="sort-option byascage">newest</a>\
<a href="#" class="sort-option byage">oldest</a>\
</p>\
<div class="comment-header">Comments</div>\
<div class="comment-loading" id="cn<%id%>">\
loading comments... <img src="<%loadingImage%>" alt="" /></div>\
<ul id="cl<%id%>" class="comment-ul"></ul>\
<div id="ca<%id%>">\
<p class="add-a-comment">Add a comment\
(<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\
<div class="comment-markup-box" id="mb<%id%>">\
reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \
<tt>``code``</tt>, \
code blocks: <tt>::</tt> and an indented block after blank line</div>\
<form method="post" id="cf<%id%>" class="comment-form" action="">\
<textarea name="comment" cols="80"></textarea>\
<p class="propose-button">\
<a href="#" id="pc<%id%>" class="show-propose-change">\
Propose a change &#9657;\
</a>\
<a href="#" id="hc<%id%>" class="hide-propose-change">\
Propose a change &#9663;\
</a>\
</p>\
<textarea name="proposal" id="pt<%id%>" cols="80"\
spellcheck="false"></textarea>\
<input type="submit" value="Add comment" />\
<input type="hidden" name="node" value="<%id%>" />\
<input type="hidden" name="parent" value="" />\
</form>\
</div>\
</div>';
var commentTemplate = '\
<div id="cd<%id%>" class="sphinx-comment<%css_class%>">\
<div class="vote">\
<div class="arrow">\
<a href="#" id="uv<%id%>" class="vote" title="vote up">\
<img src="<%upArrow%>" />\
</a>\
<a href="#" id="uu<%id%>" class="un vote" title="vote up">\
<img src="<%upArrowPressed%>" />\
</a>\
</div>\
<div class="arrow">\
<a href="#" id="dv<%id%>" class="vote" title="vote down">\
<img src="<%downArrow%>" id="da<%id%>" />\
</a>\
<a href="#" id="du<%id%>" class="un vote" title="vote down">\
<img src="<%downArrowPressed%>" />\
</a>\
</div>\
</div>\
<div class="comment-content">\
<p class="tagline comment">\
<span class="user-id"><%username%></span>\
<span class="rating"><%pretty_rating%></span>\
<span class="delta"><%time.delta%></span>\
</p>\
<div class="comment-text comment"><#text#></div>\
<p class="comment-opts comment">\
<a href="#" class="reply hidden" id="rl<%id%>">reply &#9657;</a>\
<a href="#" class="close-reply" id="cr<%id%>">reply &#9663;</a>\
<a href="#" id="sp<%id%>" class="show-proposal">proposal &#9657;</a>\
<a href="#" id="hp<%id%>" class="hide-proposal">proposal &#9663;</a>\
<a href="#" id="dc<%id%>" class="delete-comment hidden">delete</a>\
<span id="cm<%id%>" class="moderation hidden">\
<a href="#" id="ac<%id%>" class="accept-comment">accept</a>\
</span>\
</p>\
<pre class="proposal" id="pr<%id%>">\
<#proposal_diff#>\
</pre>\
<ul class="comment-children" id="cl<%id%>"></ul>\
</div>\
<div class="clearleft"></div>\
</div>\
</div>';
var replyTemplate = '\
<li>\
<div class="reply-div" id="rd<%id%>">\
<form id="rf<%id%>">\
<textarea name="comment" cols="80"></textarea>\
<input type="submit" value="Add reply" />\
<input type="button" value="Cancel" />\
<input type="hidden" name="parent" value="<%id%>" />\
<input type="hidden" name="node" value="" />\
</form>\
</div>\
</li>';
$(document).ready(function() {
init();
});
})(jQuery);
$(document).ready(function() {
// add comment anchors for all paragraphs that are commentable
$('.sphinx-has-comment').comment();
// highlight search words in search results
$("div.context").each(function() {
var params = $.getQueryParameters();
var terms = (params.q) ? params.q[0].split(/\s+/) : [];
var result = $(this);
$.each(terms, function() {
result.highlightText(this.toLowerCase(), 'highlighted');
});
});
// directly open comment window if requested
var anchor = document.location.hash;
if (anchor.substring(0, 9) == '#comment-') {
$('#ao' + anchor.substring(9)).click();
document.location.hash = '#s' + anchor.substring(9);
}
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Authors &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="Copyright and license" href="license.html" />
<link rel="prev" title="JavaScript Naming Conventions" href="naming_conventions.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="license.html" title="Copyright and license"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="naming_conventions.html" title="JavaScript Naming Conventions"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="authors">
<h1>Authors<a class="headerlink" href="#authors" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li>Francois Billioud</li>
<li>Tristan Cavelier</li>
<li>Sven Franck</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h4>Previous topic</h4>
<p class="topless"><a href="naming_conventions.html"
title="previous chapter">JavaScript Naming Conventions</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="license.html"
title="next chapter">Copyright and license</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/authors.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="license.html" title="Copyright and license"
>next</a> |</li>
<li class="right" >
<a href="naming_conventions.html" title="JavaScript Naming Conventions"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>List of Available Storages &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="jIO GIDStorage" href="gid_storage.html" />
<link rel="prev" title="Revision Storages: Conflicts and Resolution" href="revision_storages.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="gid_storage.html" title="jIO GIDStorage"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="revision_storages.html" title="Revision Storages: Conflicts and Resolution"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="list-of-available-storages">
<span id="id1"></span><h1>List of Available Storages<a class="headerlink" href="#list-of-available-storages" title="Permalink to this headline"></a></h1>
<p>jIO saves his job queue in a workspace which is localStorage by default.
Provided storage descriptions are also stored, and it can be dangerous to
store passwords.</p>
<p>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
cleartext, readable passwords (as opposed to encrypted passwords for instance).</p>
<p>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 compatibility of simple and
revision based storages.</p>
<div class="section" id="connectors">
<h2>Connectors<a class="headerlink" href="#connectors" title="Permalink to this headline"></a></h2>
<div class="section" id="localstorage">
<h3>LocalStorage<a class="headerlink" href="#localstorage" title="Permalink to this headline"></a></h3>
<p>Three methods are provided:</p>
<ul class="simple">
<li><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">createDescription</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">username</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">application_name</span></span><span class="punctuation"><span class="pre">],</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">mode</span></span><span class="operator"><span class="pre">=</span></span><span class="literal string double"><span class="pre">&quot;localStorage&quot;</span></span><span class="punctuation"><span class="pre">])</span></span></tt></li>
<li><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">createLocalDescription</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">username</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">application_name</span></span><span class="punctuation"><span class="pre">])</span></span></tt></li>
<li><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">createMemoryDescription</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">username</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">application_name</span></span><span class="punctuation"><span class="pre">])</span></span></tt></li>
</ul>
<p>All parameters are strings.</p>
<p>Examples:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// to work on browser localStorage</span>
<span class="kd">var</span> <span class="nx">jio</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">local_storage</span><span class="p">.</span><span class="nx">createDescription</span><span class="p">(</span><span class="s2">&quot;me&quot;</span><span class="p">));</span>
<span class="c1">// to work on browser memory</span>
<span class="kd">var</span> <span class="nx">jio</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">local_storage</span><span class="p">.</span><span class="nx">createMemoryDescription</span><span class="p">(</span><span class="s2">&quot;me&quot;</span><span class="p">));</span>
</pre></div>
</div>
</div>
<div class="section" id="davstorage">
<h3>DavStorage<a class="headerlink" href="#davstorage" title="Permalink to this headline"></a></h3>
<p>The method <tt class="docutils literal"><span class="pre">dav_storage.createDescription()</span></tt> generates a DAV storage description for
<em>none</em>, <em>basic</em> or <em>digest</em> authentication.</p>
<p>NB: digest <strong>is not implemented yet</strong>.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">dav_storage</span><span class="p">.</span><span class="nx">createDescription</span><span class="p">(</span><span class="nx">url</span><span class="p">,</span> <span class="nx">auth_type</span><span class="p">,</span> <span class="p">[</span><span class="nx">realm</span><span class="p">],</span> <span class="p">[</span><span class="nx">username</span><span class="p">],</span> <span class="p">[</span><span class="nx">password</span><span class="p">]);</span>
</pre></div>
</div>
<p>All parameters are strings.</p>
<table border="1" class="docutils">
<colgroup>
<col width="35%" />
<col width="65%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">parameter</th>
<th class="head">required?</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">url</span></tt></td>
<td>yes</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">auth_type</span></tt></td>
<td>yes</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">realm</span></tt></td>
<td>if auth_type == &#8216;digest&#8217;</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">username</span></tt></td>
<td>if auth_type != &#8216;none&#8217;</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">password</span></tt></td>
<td>if auth-type != &#8216;none&#8217;</td>
</tr>
</tbody>
</table>
<p>If <tt class="docutils literal"><span class="pre">auth_type</span></tt> is &#8220;none&#8221;, then <tt class="docutils literal"><span class="pre">realm</span></tt>, <tt class="docutils literal"><span class="pre">username</span></tt> and <tt class="docutils literal"><span class="pre">password</span></tt> are never used.</p>
<p><strong>Be careful</strong>: The generated description never contains a readable password, but
for basic authentication, the password will just be base64 encoded.</p>
</div>
<div class="section" id="s3storage">
<h3>S3Storage<a class="headerlink" href="#s3storage" title="Permalink to this headline"></a></h3>
<p>Updating to v2.0</p>
</div>
<div class="section" id="xwikistorage">
<h3>XWikiStorage<a class="headerlink" href="#xwikistorage" title="Permalink to this headline"></a></h3>
<p>Updating to v2.0</p>
</div>
</div>
<div class="section" id="handlers">
<h2>Handlers<a class="headerlink" href="#handlers" title="Permalink to this headline"></a></h2>
<div class="section" id="indexstorage">
<h3>IndexStorage<a class="headerlink" href="#indexstorage" title="Permalink to this headline"></a></h3>
<p>This handler indexes documents metadata into a database (which is a simple
document) to increase the speed of <tt class="docutils literal"><span class="pre">allDocs()</span></tt> requests. However, it is not able to
manage the <tt class="docutils literal"><span class="pre">include_docs</span></tt> option.</p>
<p>The sub storages have to manage <tt class="docutils literal"><span class="pre">query</span></tt> and <tt class="docutils literal"><span class="pre">include_docs</span></tt> options.</p>
<p>Here is the description:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;index&quot;</span><span class="p">,</span>
<span class="s2">&quot;indices&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;index_title_subject.json&quot;</span><span class="p">,</span> <span class="c1">// doc id where to store indices</span>
<span class="s2">&quot;index&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">,</span> <span class="s2">&quot;subject&quot;</span><span class="p">],</span> <span class="c1">// metadata to index</span>
<span class="s2">&quot;attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;db.json&quot;</span><span class="p">,</span> <span class="c1">// default &quot;body&quot;</span>
<span class="s2">&quot;metadata&quot;</span><span class="o">:</span> <span class="p">{</span> <span class="c1">// additional metadata to add to database, default undefined</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;Dataset&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;application/json&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;My index database&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span><span class="o">:</span> <span class="s2">&quot;Me&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;sub_storage&quot;</span><span class="o">:</span> <span class="o">&lt;</span><span class="nx">sub</span> <span class="nx">storage</span> <span class="nx">where</span> <span class="nx">to</span> <span class="nx">store</span> <span class="nx">index</span><span class="o">&gt;</span>
<span class="c1">// default equal to parent sub_storage field</span>
<span class="p">},</span> <span class="p">{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;index_year.json&quot;</span><span class="p">,</span>
<span class="s2">&quot;index&quot;</span><span class="o">:</span> <span class="s2">&quot;year&quot;</span>
<span class="p">...</span>
<span class="p">}],</span>
<span class="s2">&quot;sub_storage&quot;</span><span class="o">:</span> <span class="o">&lt;</span><span class="nx">sub</span> <span class="nx">storage</span> <span class="nx">description</span><span class="o">&gt;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="gidstorage">
<h3>GIDStorage<a class="headerlink" href="#gidstorage" title="Permalink to this headline"></a></h3>
<p><a class="reference internal" href="gid_storage.html#gid-storage"><em>Full description here</em></a>.</p>
<p>Updating to v2.0</p>
</div>
<div class="section" id="splitstorage">
<h3>SplitStorage<a class="headerlink" href="#splitstorage" title="Permalink to this headline"></a></h3>
<p>Updating to v2.0</p>
</div>
<div class="section" id="replicate-storage">
<h3>Replicate Storage<a class="headerlink" href="#replicate-storage" title="Permalink to this headline"></a></h3>
<p>Comming soon</p>
</div>
</div>
<div class="section" id="revision-based-handlers">
<h2>Revision Based Handlers<a class="headerlink" href="#revision-based-handlers" title="Permalink to this headline"></a></h2>
<p>A revision based handler is a storage which is able to do some document
versioning using simple storages listed above.</p>
<p>On jIO command parameter, <tt class="docutils literal"><span class="pre">_id</span></tt> is still used to identify a document, but
another id <tt class="docutils literal"><span class="pre">_rev</span></tt> must be defined to use a specific revision of that document.</p>
<p>On command responses, you will find another field <tt class="docutils literal"><span class="pre">rev</span></tt> which will represent the
new revision produced by your action. All the document history is kept unless
you decide to delete older revisions.</p>
<p>Other fields <tt class="docutils literal"><span class="pre">conflicts</span></tt>, <tt class="docutils literal"><span class="pre">revisions</span></tt> and <tt class="docutils literal"><span class="pre">revs_info</span></tt> can be returned if the
options <strong>conflicts: true</strong>, <strong>revs: true</strong> or <strong>revs_info: true</strong> are set.</p>
<div class="section" id="revision-storage">
<h3>Revision Storage<a class="headerlink" href="#revision-storage" title="Permalink to this headline"></a></h3>
<p>Updating to v2.0</p>
</div>
<div class="section" id="replicate-revision-storage">
<h3>Replicate Revision Storage<a class="headerlink" href="#replicate-revision-storage" title="Permalink to this headline"></a></h3>
<p>Updating to v2.0</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">List of Available Storages</a><ul>
<li><a class="reference internal" href="#connectors">Connectors</a><ul>
<li><a class="reference internal" href="#localstorage">LocalStorage</a></li>
<li><a class="reference internal" href="#davstorage">DavStorage</a></li>
<li><a class="reference internal" href="#s3storage">S3Storage</a></li>
<li><a class="reference internal" href="#xwikistorage">XWikiStorage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#handlers">Handlers</a><ul>
<li><a class="reference internal" href="#indexstorage">IndexStorage</a></li>
<li><a class="reference internal" href="#gidstorage">GIDStorage</a></li>
<li><a class="reference internal" href="#splitstorage">SplitStorage</a></li>
<li><a class="reference internal" href="#replicate-storage">Replicate Storage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#revision-based-handlers">Revision Based Handlers</a><ul>
<li><a class="reference internal" href="#revision-storage">Revision Storage</a></li>
<li><a class="reference internal" href="#replicate-revision-storage">Replicate Revision Storage</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="revision_storages.html"
title="previous chapter">Revision Storages: Conflicts and Resolution</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="gid_storage.html"
title="next chapter">jIO GIDStorage</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/available_storages.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="gid_storage.html" title="jIO GIDStorage"
>next</a> |</li>
<li class="right" >
<a href="revision_storages.html" title="Revision Storages: Conflicts and Resolution"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jIO Complex Queries &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="Metadata" href="metadata.html" />
<link rel="prev" title="jIO GIDStorage" href="gid_storage.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="metadata.html" title="Metadata"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="gid_storage.html" title="jIO GIDStorage"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="jio-complex-queries">
<h1>jIO Complex Queries<a class="headerlink" href="#jio-complex-queries" title="Permalink to this headline"></a></h1>
<div class="section" id="what-are-complex-queries">
<h2>What are Complex Queries?<a class="headerlink" href="#what-are-complex-queries" title="Permalink to this headline"></a></h2>
<p>In jIO, a complex query can ask a storage server to select, filter, sort, or
limit a document list before sending it back. If the server is not able to do
so, the complex query tool can act on the retreived list by itself. Only the
<tt class="docutils literal"><span class="pre">allDocs()</span></tt> method can use complex queries.</p>
<p>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
complex queries, jIO uses a parsed grammar file which is compiled using <a class="reference external" href="http://jscc.phorward-software.com/">JSCC</a>.</p>
</div>
<div class="section" id="why-use-complex-queries">
<h2>Why use Complex Queries?<a class="headerlink" href="#why-use-complex-queries" title="Permalink to this headline"></a></h2>
<p>Complex queries can be used like database queries, for tasks such as:</p>
<ul class="simple">
<li>search a specific document</li>
<li>sort a list of documents in a certain order</li>
<li>avoid retrieving a list of ten thousand documents</li>
<li>limit the list to show only N documents per page</li>
</ul>
<p>For some storages (like localStorage), complex queries can be a powerful tool
to query accessible documents. When querying documents on a distant storage,
some server-side logic should be run to avoid having to request large amount of
documents to run a query on the client. If distant storages are static, an
alternative would be to use an indexStorage with appropriate indices as complex
queries will always try to run the query on the index before querying documents
itself.</p>
</div>
<div class="section" id="how-to-use-complex-queries-with-jio">
<h2>How to use Complex Queries with jIO?<a class="headerlink" href="#how-to-use-complex-queries-with-jio" title="Permalink to this headline"></a></h2>
<p>Complex queries can be triggered by including the option named query in the <tt class="docutils literal"><span class="pre">allDocs()</span></tt> method call.</p>
<p>Example:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="p">{};</span>
<span class="c1">// search text query</span>
<span class="nx">options</span><span class="p">[</span><span class="s1">&#39;query&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;(creator:&quot;John Doe&quot;) AND (format:&quot;pdf&quot;)&#39;</span><span class="p">;</span>
<span class="c1">// OR query tree</span>
<span class="nx">options</span><span class="p">[</span><span class="s1">&#39;query&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">type</span><span class="o">:</span><span class="s1">&#39;complex&#39;</span><span class="p">,</span>
<span class="nx">operator</span><span class="o">:</span><span class="s1">&#39;AND&#39;</span><span class="p">,</span>
<span class="nx">query_list</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;simple&quot;</span><span class="p">,</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="s2">&quot;creator&quot;</span><span class="p">,</span>
<span class="s2">&quot;value&quot;</span><span class="o">:</span> <span class="s2">&quot;John Doe&quot;</span>
<span class="p">},</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;simple&quot;</span><span class="p">,</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="s2">&quot;format&quot;</span><span class="p">,</span>
<span class="s2">&quot;value&quot;</span><span class="o">:</span> <span class="s2">&quot;pdf&quot;</span>
<span class="p">}]</span>
<span class="p">};</span>
<span class="c1">// FULL example using filtering criteria</span>
<span class="nx">options</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">query</span><span class="o">:</span> <span class="s1">&#39;(creator:&quot;% Doe&quot;) AND (format:&quot;pdf&quot;)&#39;</span><span class="p">,</span>
<span class="nx">limit</span><span class="o">:</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">100</span><span class="p">],</span>
<span class="nx">sort_on</span><span class="o">:</span> <span class="p">[[</span><span class="s1">&#39;last_modified&#39;</span><span class="p">,</span> <span class="s1">&#39;descending&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;creation_date&#39;</span><span class="p">,</span> <span class="s1">&#39;descending&#39;</span><span class="p">]],</span>
<span class="nx">select_list</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">],</span>
<span class="nx">wildcard_character</span><span class="o">:</span> <span class="s1">&#39;%&#39;</span>
<span class="p">};</span>
<span class="c1">// execution</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">allDocs</span><span class="p">(</span><span class="nx">options</span><span class="p">,</span> <span class="nx">callback</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="how-to-use-complex-queries-outside-jio">
<h2>How to use Complex Queries outside jIO?<a class="headerlink" href="#how-to-use-complex-queries-outside-jio" title="Permalink to this headline"></a></h2>
<p>Complex Queries provides an API - which namespace is complex_queries.
Refer to the <a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/complex_example.html?js=1">Complex Queries sample page</a>
for how to use these methods, in and outside jIO. The module provides:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="nx">parseStringToObject</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">parseStringToObject</span><span class="p">],</span>
<span class="nx">stringEscapeRegexpCharacters</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">stringEscapeRegexpCharacters</span><span class="p">],</span>
<span class="nx">select</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">select</span><span class="p">],</span>
<span class="nx">sortOn</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">sortOn</span><span class="p">],</span>
<span class="nx">limit</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">limit</span><span class="p">],</span>
<span class="nx">convertStringToRegExp</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">convertStringToRegExp</span><span class="p">],</span>
<span class="nx">QueryFactory</span><span class="o">:</span> <span class="p">{</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">QueryFactory</span><span class="p">]</span> <span class="nx">create</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="p">]</span> <span class="p">},</span>
<span class="nx">Query</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">Query</span><span class="p">],</span>
<span class="nx">SimpleQuery</span><span class="o">:</span> <span class="p">{</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">SimpleQuery</span><span class="p">]</span> <span class="nx">super_</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">Query</span><span class="p">]</span> <span class="p">},</span>
<span class="nx">ComplexQuery</span><span class="o">:</span> <span class="p">{</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">ComplexQuery</span><span class="p">]</span> <span class="nx">super_</span><span class="o">:</span> <span class="p">[</span><span class="nb">Function</span><span class="o">:</span> <span class="nx">Query</span><span class="p">]</span> <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>(Reference API coming soon.)</p>
<p>Basic example:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// object list (generated from documents in storage or index)</span>
<span class="kd">var</span> <span class="nx">object_list</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">{</span><span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;Document number 1&quot;</span><span class="p">,</span> <span class="s2">&quot;creator&quot;</span><span class="o">:</span> <span class="s2">&quot;John Doe&quot;</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;Document number 2&quot;</span><span class="p">,</span> <span class="s2">&quot;creator&quot;</span><span class="o">:</span> <span class="s2">&quot;James Bond&quot;</span><span class="p">}</span>
<span class="p">];</span>
<span class="c1">// the query to run</span>
<span class="kd">var</span> <span class="nx">query</span> <span class="o">=</span> <span class="s1">&#39;title: &quot;Document number 1&quot;&#39;</span><span class="p">;</span>
<span class="c1">// running the query</span>
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">complex_queries</span><span class="p">.</span><span class="nx">QueryFactory</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="nx">query</span><span class="p">).</span><span class="nx">exec</span><span class="p">(</span><span class="nx">object_list</span><span class="p">);</span>
<span class="c1">// console.log(result);</span>
<span class="c1">// [ { &quot;title&quot;: &quot;Document number 1&quot;, &quot;creator&quot;: &quot;John Doe&quot;} ]</span>
</pre></div>
</div>
<p>Other example:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">complex_queries</span><span class="p">.</span><span class="nx">QueryFactory</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="nx">query</span><span class="p">).</span><span class="nx">exec</span><span class="p">(</span>
<span class="nx">object_list</span><span class="p">,</span>
<span class="p">{</span>
<span class="s2">&quot;select&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">,</span> <span class="s1">&#39;year&#39;</span><span class="p">],</span>
<span class="s2">&quot;limit&quot;</span><span class="o">:</span> <span class="p">[</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">],</span> <span class="c1">// from 20th to 40th document</span>
<span class="s2">&quot;sort_on&quot;</span><span class="o">:</span> <span class="p">[[</span><span class="s1">&#39;title&#39;</span><span class="p">,</span> <span class="s1">&#39;ascending&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;year&#39;</span><span class="p">,</span> <span class="s1">&#39;descending&#39;</span><span class="p">]],</span>
<span class="s2">&quot;other_keys_and_values&quot;</span><span class="o">:</span> <span class="s2">&quot;are_ignored&quot;</span>
<span class="p">}</span>
<span class="p">);</span>
<span class="c1">// this case is equal to:</span>
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">complex_queries</span><span class="p">.</span><span class="nx">QueryFactory</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="nx">query</span><span class="p">).</span><span class="nx">exec</span><span class="p">(</span><span class="nx">object_list</span><span class="p">);</span>
<span class="nx">complex_queries</span><span class="p">.</span><span class="nx">sortOn</span><span class="p">([[</span><span class="s1">&#39;title&#39;</span><span class="p">,</span> <span class="s1">&#39;ascending&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;year&#39;</span><span class="p">,</span> <span class="s1">&#39;descending&#39;</span><span class="p">]],</span> <span class="nx">result</span><span class="p">);</span>
<span class="nx">complex_queries</span><span class="p">.</span><span class="nx">limit</span><span class="p">([</span><span class="mi">20</span><span class="p">,</span> <span class="mi">20</span><span class="p">],</span> <span class="nx">result</span><span class="p">);</span>
<span class="nx">complex_queries</span><span class="p">.</span><span class="nx">select</span><span class="p">([</span><span class="s1">&#39;title&#39;</span><span class="p">,</span> <span class="s1">&#39;year&#39;</span><span class="p">],</span> <span class="nx">result</span><span class="p">);</span>
</pre></div>
</div>
<div class="section" id="complex-queries-in-storage-connectors">
<h3>Complex Queries in storage connectors<a class="headerlink" href="#complex-queries-in-storage-connectors" title="Permalink to this headline"></a></h3>
<p>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
indices with key information on all documents in a storage. This index file
will then be used to run queries, if all of the fields required in the query answer
are available in the index.</p>
</div>
<div class="section" id="matching-properties">
<h3>Matching properties<a class="headerlink" href="#matching-properties" title="Permalink to this headline"></a></h3>
<p>Complex Queries select items which exactly match the value given in the
query. You can use wildcards (&#8216;%&#8217; is the default wildcard character), and you
can change the wildcard character in the query options object. If you don&#8217;t
want to use a wildcard, just set the wildcard character to an empty string.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">query</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;query&quot;</span><span class="o">:</span> <span class="s1">&#39;creator:&quot;* Doe&quot;&#39;</span><span class="p">,</span>
<span class="s2">&quot;wildcard_character&quot;</span><span class="o">:</span> <span class="s2">&quot;*&quot;</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="should-default-search-types-be-defined-in-jio-or-in-user-interface-components">
<h3>Should default search types be defined in jIO or in user interface components?<a class="headerlink" href="#should-default-search-types-be-defined-in-jio-or-in-user-interface-components" title="Permalink to this headline"></a></h3>
<p>Default search types should be defined in the application&#8217;s user interface
components because criteria like filters will be changed frequently by the
component (change <tt class="docutils literal"><span class="pre">limit:</span> <span class="pre">[0,</span> <span class="pre">10]</span></tt> to <tt class="docutils literal"><span class="pre">limit:</span> <span class="pre">[10,</span> <span class="pre">10]</span></tt> or <tt class="docutils literal"><span class="pre">sort_on:</span> <span class="pre">[['title',</span>
<span class="pre">'ascending']]</span></tt> to <tt class="docutils literal"><span class="pre">sort_on:</span> <span class="pre">[['creator',</span> <span class="pre">'ascending']]</span></tt>) and each component must
have its own default properties to keep their own behavior.</p>
</div>
<div class="section" id="convert-complex-queries-into-another-type">
<h3>Convert Complex Queries into another type<a class="headerlink" href="#convert-complex-queries-into-another-type" title="Permalink to this headline"></a></h3>
<p>Example, convert Query object into a human readable string:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">query</span> <span class="o">=</span> <span class="nx">complex_queries</span><span class="p">.</span><span class="nx">QueryFactory</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">&#39;year: &lt; 2000 OR title: &quot;*a&quot;&#39;</span><span class="p">),</span>
<span class="nx">option</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;wildcard_character&quot;</span><span class="o">:</span> <span class="s2">&quot;*&quot;</span><span class="p">,</span>
<span class="s2">&quot;limit&quot;</span><span class="o">:</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">]</span>
<span class="p">},</span>
<span class="nx">human_read</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;&lt;&quot;</span><span class="o">:</span> <span class="s2">&quot;is lower than &quot;</span><span class="p">,</span>
<span class="s2">&quot;&lt;=&quot;</span><span class="o">:</span> <span class="s2">&quot;is lower or equal than &quot;</span><span class="p">,</span>
<span class="s2">&quot;&gt;&quot;</span><span class="o">:</span> <span class="s2">&quot;is greater than &quot;</span><span class="p">,</span>
<span class="s2">&quot;&gt;=&quot;</span><span class="o">:</span> <span class="s2">&quot;is greater or equal than &quot;</span><span class="p">,</span>
<span class="s2">&quot;=&quot;</span><span class="o">:</span> <span class="s2">&quot;matches &quot;</span><span class="p">,</span>
<span class="s2">&quot;!=&quot;</span><span class="o">:</span> <span class="s2">&quot;doesn&#39;t match &quot;</span>
<span class="p">};</span>
<span class="nx">query</span><span class="p">.</span><span class="nx">onParseStart</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">object</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">object</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="s2">&quot;The wildcard character is &#39;&quot;</span> <span class="o">+</span>
<span class="p">(</span><span class="nx">option</span><span class="p">.</span><span class="nx">wildcard_character</span> <span class="o">||</span> <span class="s2">&quot;%&quot;</span><span class="p">)</span> <span class="o">+</span>
<span class="s2">&quot;&#39; and we need only the &quot;</span> <span class="o">+</span> <span class="nx">option</span><span class="p">.</span><span class="nx">limit</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot; elements from the numero &quot;</span> <span class="o">+</span>
<span class="nx">option</span><span class="p">.</span><span class="nx">limit</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;. &quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="nx">query</span><span class="p">.</span><span class="nx">onParseSimpleQuery</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">object</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span> <span class="o">=</span> <span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span><span class="p">.</span><span class="nx">key</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">human_read</span><span class="p">[</span><span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span><span class="p">.</span><span class="nx">operator</span><span class="p">]</span> <span class="o">+</span>
<span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span><span class="p">.</span><span class="nx">value</span><span class="p">;</span>
<span class="p">};</span>
<span class="nx">query</span><span class="p">.</span><span class="nx">onParseComplexQuery</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">object</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span> <span class="o">=</span> <span class="s2">&quot;I want all document where &quot;</span> <span class="o">+</span>
<span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span><span class="p">.</span><span class="nx">query_list</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span><span class="p">.</span><span class="nx">operator</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">+</span>
<span class="s2">&quot; &quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;. &quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="nx">query</span><span class="p">.</span><span class="nx">onParseEnd</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">object</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span> <span class="o">=</span> <span class="nx">object</span><span class="p">.</span><span class="nx">start</span> <span class="o">+</span> <span class="nx">object</span><span class="p">.</span><span class="nx">parsed</span> <span class="o">+</span> <span class="s2">&quot;Thank you!&quot;</span><span class="p">;</span>
<span class="p">};</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">query</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">option</span><span class="p">));</span>
<span class="c1">// logged: &quot;The wildcard character is &#39;*&#39; and we need only the 10 elements</span>
<span class="c1">// from the numero 0. I want all document where year is lower than 2000 or title</span>
<span class="c1">// matches *a. Thank you!&quot;</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="json-schemas-and-grammar">
<h2>JSON Schemas and Grammar<a class="headerlink" href="#json-schemas-and-grammar" title="Permalink to this headline"></a></h2>
<p>Below you can find schemas for constructing queries.</p>
<ul>
<li><p class="first">Complex Queries JSON Schema:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;ComplexQuery&quot;</span><span class="p">,</span>
<span class="s2">&quot;properties&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;complex&quot;</span><span class="p">,</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="s2">&quot;complex&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;The type is used to recognize the query type.&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;operator&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;(AND|OR|NOT)&quot;</span><span class="p">,</span>
<span class="s2">&quot;required&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;Can be &#39;AND&#39;, &#39;OR&#39; or &#39;NOT&#39;.&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;query_list&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;array&quot;</span><span class="p">,</span>
<span class="s2">&quot;items&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;object&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;required&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="p">[],</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;query_list is a list of queries which can be in serialized format of in object format.&quot;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p class="first">Simple Queries JSON Schema:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;SimpleQuery&quot;</span><span class="p">,</span>
<span class="s2">&quot;properties&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;simple&quot;</span><span class="p">,</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="s2">&quot;simple&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;The type is used to recognize the query type.&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;operator&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="s2">&quot;=&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;(&gt;=?|&lt;=?|!?=)&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;The operator used to compare.&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;The column id.&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;value&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;The value we want to search.&quot;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p class="first">Complex Queries Grammar:</p>
<div class="highlight-python"><pre>search_text
: and_expression
| and_expression search_text
| and_expression OR search_text
and_expression
: boolean_expression
| boolean_expression AND and_expression
boolean_expression
: NOT expression
| expression
expression
: ( search_text )
| COLUMN expression
| value
value
: OPERATOR string
| string
string
: WORD
| STRING
terminal:
OR -&gt; /OR[ ]/
AND -&gt; /AND[ ]/
NOT -&gt; /NOT[ ]/
COLUMN -&gt; /[^&gt;&lt;= :\(\)"][^ :\(\)"]*:/
STRING -&gt; /"(\\.|[^\\"])*"/
WORD -&gt; /[^&gt;&lt;= :\(\)"][^ :\(\)"]*/
OPERATOR -&gt; /(&gt;=?|&lt;=?|!?=)/
LEFT_PARENTHESE -&gt; /\(/
RIGHT_PARENTHESE -&gt; /\)/
ignore: " "</pre>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">jIO Complex Queries</a><ul>
<li><a class="reference internal" href="#what-are-complex-queries">What are Complex Queries?</a></li>
<li><a class="reference internal" href="#why-use-complex-queries">Why use Complex Queries?</a></li>
<li><a class="reference internal" href="#how-to-use-complex-queries-with-jio">How to use Complex Queries with jIO?</a></li>
<li><a class="reference internal" href="#how-to-use-complex-queries-outside-jio">How to use Complex Queries outside jIO?</a><ul>
<li><a class="reference internal" href="#complex-queries-in-storage-connectors">Complex Queries in storage connectors</a></li>
<li><a class="reference internal" href="#matching-properties">Matching properties</a></li>
<li><a class="reference internal" href="#should-default-search-types-be-defined-in-jio-or-in-user-interface-components">Should default search types be defined in jIO or in user interface components?</a></li>
<li><a class="reference internal" href="#convert-complex-queries-into-another-type">Convert Complex Queries into another type</a></li>
</ul>
</li>
<li><a class="reference internal" href="#json-schemas-and-grammar">JSON Schemas and Grammar</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="gid_storage.html"
title="previous chapter">jIO GIDStorage</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="metadata.html"
title="next chapter">Metadata</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/complex_queries.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="metadata.html" title="Metadata"
>next</a> |</li>
<li class="right" >
<a href="gid_storage.html" title="jIO GIDStorage"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>For developers &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="JavaScript Naming Conventions" href="naming_conventions.html" />
<link rel="prev" title="Metadata" href="metadata.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="naming_conventions.html" title="JavaScript Naming Conventions"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="metadata.html" title="Metadata"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="for-developers">
<h1>For developers<a class="headerlink" href="#for-developers" title="Permalink to this headline"></a></h1>
<div class="section" id="quick-start">
<h2>Quick start<a class="headerlink" href="#quick-start" title="Permalink to this headline"></a></h2>
<p>To get started with jIO, clone one of the repositories linked in <a class="reference internal" href="download.html#download-fork"><em>Download &amp; Fork</em></a>.</p>
<p>To build the library you have to:</p>
<ul>
<li><p class="first">Install <a class="reference external" href="http://nodejs.org/">NodeJS</a> (including NPM)</p>
</li>
<li><p class="first">Install Grunt command line with npm.</p>
<p><tt class="docutils literal"><span class="pre">#</span> <span class="pre">npm</span> <span class="pre">-g</span> <span class="pre">install</span> <span class="pre">grunt-cli</span></tt></p>
</li>
<li><p class="first">Install dev dependencies.</p>
<p><tt class="docutils literal"><span class="pre">$</span> <span class="pre">npm</span> <span class="pre">install</span></tt></p>
</li>
<li><p class="first">Compile JS/CC parser.</p>
<p><tt class="docutils literal"><span class="pre">$</span> <span class="pre">make</span></tt> (until we find how to compile it with grunt)</p>
</li>
<li><p class="first">Run build.</p>
<p><tt class="docutils literal"><span class="pre">$</span> <span class="pre">grunt</span></tt></p>
</li>
</ul>
<p>The repository also includes the built ready-to-use files, so in case you do
not want to build jIO yourself, just use <em>jio.js</em> as well as <em>complex_queries.js</em>
plus the storages and dependencies you need and you will be good to go.</p>
</div>
<div class="section" id="naming-conventions">
<h2>Naming Conventions<a class="headerlink" href="#naming-conventions" title="Permalink to this headline"></a></h2>
<p>All the code follows these <a class="reference internal" href="naming_conventions.html#naming-conventions"><em>JavaScript Naming Conventions</em></a>.</p>
</div>
<div class="section" id="how-to-design-your-own-jio-storage-library">
<h2>How to design your own jIO Storage Library<a class="headerlink" href="#how-to-design-your-own-jio-storage-library" title="Permalink to this headline"></a></h2>
<p>Create a constructor:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">MyStorage</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_value</span> <span class="o">=</span> <span class="nx">storage_description</span><span class="p">.</span><span class="nx">value</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="k">this</span><span class="p">.</span><span class="nx">_value</span> <span class="o">!==</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nx">TypeError</span><span class="p">(</span><span class="s2">&quot;&#39;value&#39; description property is not a string&quot;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Create 10 methods: <tt class="docutils literal"><span class="pre">post</span></tt>, <tt class="docutils literal"><span class="pre">put</span></tt>, <tt class="docutils literal"><span class="pre">putAttachment</span></tt>, <tt class="docutils literal"><span class="pre">get</span></tt>, <tt class="docutils literal"><span class="pre">getAttachment</span></tt>,
<tt class="docutils literal"><span class="pre">remove</span></tt>, <tt class="docutils literal"><span class="pre">removeAttachment</span></tt>, <tt class="docutils literal"><span class="pre">allDocs</span></tt>, <tt class="docutils literal"><span class="pre">check</span></tt> and <tt class="docutils literal"><span class="pre">repair</span></tt>.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MyStorage</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">post</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">metadata</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">document_id</span> <span class="o">=</span> <span class="nx">metadata</span><span class="p">.</span><span class="nx">_id</span><span class="p">;</span>
<span class="c1">// [...]</span>
<span class="p">};</span>
<span class="nx">MyStorage</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">param</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">document_id</span> <span class="o">=</span> <span class="nx">param</span><span class="p">.</span><span class="nx">_id</span><span class="p">;</span>
<span class="c1">// [...]</span>
<span class="p">};</span>
<span class="nx">MyStorage</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">putAttachment</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">command</span><span class="p">,</span> <span class="nx">param</span><span class="p">,</span> <span class="nx">option</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">document_id</span> <span class="o">=</span> <span class="nx">param</span><span class="p">.</span><span class="nx">_id</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">attachment_id</span> <span class="o">=</span> <span class="nx">param</span><span class="p">.</span><span class="nx">_attachment</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">attachment_data</span> <span class="o">=</span> <span class="nx">param</span><span class="p">.</span><span class="nx">_blob</span><span class="p">;</span>
<span class="c1">// [...]</span>
<span class="p">};</span>
<span class="c1">// [...]</span>
</pre></div>
</div>
<p>(To help you design your methods, some tools are provided by jIO.util.)</p>
<p>The first parameter command provides some methods to act on the jIO job:</p>
<ul>
<li><p class="first"><tt class="docutils literal"><span class="pre">success</span></tt>, to tell jIO that the job is successfully terminated</p>
<p><tt class="docutils literal"><span class="pre">command.success(status[Text],</span> <span class="pre">[{custom</span> <span class="pre">key</span> <span class="pre">to</span> <span class="pre">add</span> <span class="pre">to</span> <span class="pre">the</span> <span class="pre">response}]);</span></tt></p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">resolve</span></tt>, is equal to success</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">error</span></tt>, to tell jIO that the job cannot be done</p>
<p><tt class="docutils literal"><span class="pre">command.error(status[Text],</span> <span class="pre">[reason],</span> <span class="pre">[message],</span> <span class="pre">[{custom</span> <span class="pre">key</span> <span class="pre">to</span> <span class="pre">add</span> <span class="pre">to</span> <span class="pre">the</span> <span class="pre">response}])</span></tt></p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">retry</span></tt>, to tell jIO that the job cannot be done now, but can be retried later. (same API than error)</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">reject</span></tt>, to tell jIO that the job cannot be done, let jIO to decide whether to retry or not. (same API than error)</p>
</li>
</ul>
<p>The second parameter <tt class="docutils literal"><span class="pre">metadata</span></tt> or <tt class="docutils literal"><span class="pre">param</span></tt> is the first parameter provided by the jIO user.</p>
<p>The third parameter <tt class="docutils literal"><span class="pre">option</span></tt> is the option parameter provided by the jIO user.</p>
<p>Methods should return the following objects:</p>
<ul>
<li><p class="first">post &#8211;&gt; success(&#8220;created&#8221;, {&#8220;id&#8221;: new_generated_id})</p>
</li>
<li><p class="first">put, remove, putAttachment or removeAttachment &#8211;&gt; success(204)</p>
</li>
<li><p class="first">get &#8211;&gt; success(&#8220;ok&#8221;, {&#8220;data&#8221;: document_metadata})</p>
</li>
<li><p class="first">getAttachment &#8211;&gt;</p>
<p>success(&#8220;ok&#8221;, {&#8220;data&#8221;: binary_string, &#8220;content_type&#8221;: content_type})
// or
success(&#8220;ok&#8221;, {&#8220;data&#8221;: new Blob([data], {&#8220;type&#8221;: content_type})})</p>
</li>
<li><p class="first">allDocs &#8211;&gt; success(&#8220;ok&#8221;, {&#8220;data&#8221;: row_object})</p>
</li>
<li><p class="first">check &#8211;&gt;</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// if metadata provides &quot;_id&quot; -&gt; check document state</span>
<span class="c1">// if metadata doesn&#39;t promides &quot;_id&quot; -&gt; check storage state</span>
<span class="nx">success</span><span class="p">(</span><span class="s2">&quot;no_content&quot;</span><span class="p">)</span>
<span class="c1">// or</span>
<span class="nx">error</span><span class="p">(</span><span class="s2">&quot;conflict&quot;</span><span class="p">,</span> <span class="s2">&quot;corrupted&quot;</span><span class="p">,</span> <span class="s2">&quot;incoherent document or storage&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">repair &#8211;&gt;</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// if metadata provides &quot;_id&quot; -&gt; repair document state</span>
<span class="c1">// if metadata doesn&#39;t promides &quot;_id&quot; -&gt; repair storage state</span>
<span class="nx">success</span><span class="p">(</span><span class="s2">&quot;no_content&quot;</span><span class="p">)</span>
<span class="c1">// or</span>
<span class="nx">error</span><span class="p">(</span><span class="s2">&quot;conflict&quot;</span><span class="p">,</span> <span class="s2">&quot;corrupted&quot;</span><span class="p">,</span> <span class="s2">&quot;impossible to repair document or storage&quot;</span><span class="p">)</span>
<span class="c1">// DON&#39;T DESIGN STORAGES IF THEIR IS NO WAY TO REPAIR INCOHERENT STATES</span>
</pre></div>
</div>
</li>
</ul>
<p>After creating all methods, your storage must be added to jIO. This is done
with the <tt class="docutils literal"><span class="pre">jIO.addStorage()</span></tt> method, which requires two parameters: the storage
type (string) and a constructor (function). It is called like this:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// add custom storage to jIO</span>
<span class="nx">jIO</span><span class="p">.</span><span class="nx">addStorage</span><span class="p">(</span><span class="s1">&#39;mystoragetype&#39;</span><span class="p">,</span> <span class="nx">MyStorage</span><span class="p">);</span>
</pre></div>
</div>
<p>Please refer to <em>localstorage.js</em> implementation for a good example on how to
setup a storage and what methods are required.</p>
<p>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.</p>
</div>
<div class="section" id="job-rules">
<h2>Job rules<a class="headerlink" href="#job-rules" title="Permalink to this headline"></a></h2>
<p>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
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
can also add your own rules, as we&#8217;re going to see now.</p>
<p>These are the jIO <strong>default rules</strong>:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">,</span> <span class="p">{</span>
<span class="s2">&quot;job_rules&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;code_name&quot;</span><span class="o">:</span> <span class="s2">&quot;readers update&quot;</span><span class="p">,</span>
<span class="s2">&quot;conditions&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="s2">&quot;sameStorageDescription&quot;</span><span class="p">,</span>
<span class="s2">&quot;areReaders&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameMethod&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameParameters&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameOptions&quot;</span>
<span class="p">],</span>
<span class="s2">&quot;action&quot;</span><span class="o">:</span> <span class="s2">&quot;update&quot;</span>
<span class="p">},</span> <span class="p">{</span>
<span class="s2">&quot;code_name&quot;</span><span class="o">:</span> <span class="s2">&quot;metadata writers update&quot;</span><span class="p">,</span>
<span class="s2">&quot;conditions&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="s2">&quot;sameStorageDescription&quot;</span><span class="p">,</span>
<span class="s2">&quot;areWriters&quot;</span><span class="p">,</span>
<span class="s2">&quot;useMetadataOnly&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameMethod&quot;</span><span class="p">,</span>
<span class="s2">&quot;haveDocumentIds&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameParameters&quot;</span>
<span class="p">],</span>
<span class="s2">&quot;action&quot;</span><span class="o">:</span> <span class="s2">&quot;update&quot;</span>
<span class="p">},</span> <span class="p">{</span>
<span class="s2">&quot;code_name&quot;</span><span class="o">:</span> <span class="s2">&quot;writers wait&quot;</span><span class="p">,</span>
<span class="s2">&quot;conditions&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="s2">&quot;sameStorageDescription&quot;</span><span class="p">,</span>
<span class="s2">&quot;areWriters&quot;</span><span class="p">,</span>
<span class="s2">&quot;haveDocumentIds&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameDocumentId&quot;</span>
<span class="p">],</span>
<span class="s2">&quot;action&quot;</span><span class="o">:</span> <span class="s2">&quot;wait&quot;</span>
<span class="p">}]</span>
<span class="p">});</span>
</pre></div>
</div>
<p>The following actions can be used:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">ok</span></tt> - accept the job</li>
<li><tt class="docutils literal"><span class="pre">wait</span></tt> - wait until the end of the selected job</li>
<li><tt class="docutils literal"><span class="pre">update</span></tt> - bind the selected job to this one</li>
<li><tt class="docutils literal"><span class="pre">deny</span></tt> - reject the job</li>
</ul>
<p>The following condition function can be used:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">sameStorageDescription</span></tt> - check if the storage descriptions are different.</li>
<li><tt class="docutils literal"><span class="pre">areWriters</span></tt> - check if the commands are <tt class="docutils literal"><span class="pre">post</span></tt>, <tt class="docutils literal"><span class="pre">put</span></tt>, <tt class="docutils literal"><span class="pre">putAttachment</span></tt>, <tt class="docutils literal"><span class="pre">remove</span></tt>, <tt class="docutils literal"><span class="pre">removeAttachment</span></tt>, or <tt class="docutils literal"><span class="pre">repair</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">areReaders</span></tt> - check if the commands are <tt class="docutils literal"><span class="pre">get</span></tt>, <tt class="docutils literal"><span class="pre">getAttachment</span></tt>, <tt class="docutils literal"><span class="pre">allDocs</span></tt> or <tt class="docutils literal"><span class="pre">check</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">useMetadataOnly</span></tt> - check if the commands are <tt class="docutils literal"><span class="pre">post</span></tt>, <tt class="docutils literal"><span class="pre">put</span></tt>, <tt class="docutils literal"><span class="pre">get</span></tt>, <tt class="docutils literal"><span class="pre">remove</span></tt> or <tt class="docutils literal"><span class="pre">allDocs</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">sameMethod</span></tt> - check if the commands are equal.</li>
<li><tt class="docutils literal"><span class="pre">sameDocumentId</span></tt> - check if the document ids are equal.</li>
<li><tt class="docutils literal"><span class="pre">sameParameters</span></tt> - check if the metadata or param are equal (deep comparison).</li>
<li><tt class="docutils literal"><span class="pre">sameOptions</span></tt> - check if the command options are equal.</li>
<li><tt class="docutils literal"><span class="pre">haveDocumentIds</span></tt> - test if the two commands contain document ids.</li>
</ul>
</div>
<div class="section" id="create-job-condition">
<h2>Create Job Condition<a class="headerlink" href="#create-job-condition" title="Permalink to this headline"></a></h2>
<p>You can create two types of function: job condition, and job comparison.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// Job Condition</span>
<span class="c1">// Check if the job is a get command</span>
<span class="nx">jIO</span><span class="p">.</span><span class="nx">addJobRuleCondition</span><span class="p">(</span><span class="s2">&quot;isGetMethod&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">job</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">job</span><span class="p">.</span><span class="nx">method</span> <span class="o">===</span> <span class="s1">&#39;get&#39;</span><span class="p">;</span>
<span class="p">});</span>
<span class="c1">// Job Comparison</span>
<span class="c1">// Check if the jobs have the same &#39;title&#39; property only if they are strings</span>
<span class="nx">jIO</span><span class="p">.</span><span class="nx">addJobRuleCondition</span><span class="p">(</span><span class="s2">&quot;sameTitleIfString&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">job</span><span class="p">,</span> <span class="nx">selected_job</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">job</span><span class="p">.</span><span class="nx">kwargs</span><span class="p">.</span><span class="nx">title</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span> <span class="o">&amp;&amp;</span>
<span class="k">typeof</span> <span class="nx">selected_job</span><span class="p">.</span><span class="nx">kwargs</span><span class="p">.</span><span class="nx">title</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">job</span><span class="p">.</span><span class="nx">kwargs</span><span class="p">.</span><span class="nx">title</span> <span class="o">===</span> <span class="nx">selected_job</span><span class="p">.</span><span class="nx">kwargs</span><span class="p">.</span><span class="nx">title</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
<div class="section" id="add-job-rules">
<h2>Add job rules<a class="headerlink" href="#add-job-rules" title="Permalink to this headline"></a></h2>
<p>You just have to define job rules in the jIO options:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// Do not accept to post or put a document which title is equal to another</span>
<span class="c1">// already running post or put document title</span>
<span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">,</span> <span class="p">{</span>
<span class="s2">&quot;job_rules&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;code_name&quot;</span><span class="o">:</span> <span class="s2">&quot;avoid similar title&quot;</span><span class="p">,</span>
<span class="s2">&quot;conditions&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="s2">&quot;sameStorageDescription&quot;</span><span class="p">,</span>
<span class="s2">&quot;areWriters&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameTitleIfString&quot;</span>
<span class="p">],</span>
<span class="s2">&quot;action&quot;</span><span class="o">:</span> <span class="s2">&quot;deny&quot;</span><span class="p">,</span>
<span class="s2">&quot;before&quot;</span><span class="o">:</span> <span class="s2">&quot;writers update&quot;</span> <span class="c1">// optional</span>
<span class="c1">// &quot;after&quot;: also exists</span>
<span class="p">}]</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
<div class="section" id="clear-replace-default-job-rules">
<h2>Clear/Replace default job rules<a class="headerlink" href="#clear-replace-default-job-rules" title="Permalink to this headline"></a></h2>
<p>If a job&#8217;s <tt class="docutils literal"><span class="pre">code_name</span></tt> is equal to <tt class="docutils literal"><span class="pre">readers</span> <span class="pre">update</span></tt>, then adding this rule will replace it:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">,</span> <span class="p">{</span>
<span class="s2">&quot;job_rules&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;code_name&quot;</span><span class="o">:</span> <span class="s2">&quot;readers update&quot;</span><span class="p">,</span>
<span class="s2">&quot;conditions&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="s2">&quot;sameStorageDescription&quot;</span><span class="p">,</span>
<span class="s2">&quot;areReaders&quot;</span><span class="p">,</span>
<span class="s2">&quot;sameMethod&quot;</span><span class="p">,</span>
<span class="s2">&quot;haveDocumentIds&quot;</span>
<span class="s2">&quot;sameParameters&quot;</span>
<span class="c1">// sameOptions is removed</span>
<span class="p">],</span>
<span class="s2">&quot;action&quot;</span><span class="o">:</span> <span class="s2">&quot;update&quot;</span>
<span class="p">}]</span>
<span class="p">});</span>
</pre></div>
</div>
<p>Or you can just clear all rules before adding new ones:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">,</span> <span class="p">{</span>
<span class="s2">&quot;clear_job_rules&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="s2">&quot;job_rules&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="c1">// ...</span>
<span class="p">}]</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">For developers</a><ul>
<li><a class="reference internal" href="#quick-start">Quick start</a></li>
<li><a class="reference internal" href="#naming-conventions">Naming Conventions</a></li>
<li><a class="reference internal" href="#how-to-design-your-own-jio-storage-library">How to design your own jIO Storage Library</a></li>
<li><a class="reference internal" href="#job-rules">Job rules</a></li>
<li><a class="reference internal" href="#create-job-condition">Create Job Condition</a></li>
<li><a class="reference internal" href="#add-job-rules">Add job rules</a></li>
<li><a class="reference internal" href="#clear-replace-default-job-rules">Clear/Replace default job rules</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="metadata.html"
title="previous chapter">Metadata</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="naming_conventions.html"
title="next chapter">JavaScript Naming Conventions</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/developers.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="naming_conventions.html" title="JavaScript Naming Conventions"
>next</a> |</li>
<li class="right" >
<a href="metadata.html" title="Metadata"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Downloads &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="How to manage documents?" href="manage_documents.html" />
<link rel="prev" title="Introduction" href="introduction.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="manage_documents.html" title="How to manage documents?"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="introduction.html" title="Introduction"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="downloads">
<span id="download-fork"></span><h1>Downloads<a class="headerlink" href="#downloads" title="Permalink to this headline"></a></h1>
<div class="section" id="core">
<h2>Core<a class="headerlink" href="#core" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha256.amd.js">sha256.amd.js</a></li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/lib/rsvp/rsvp-custom.js">rsvp-custom.js</a>, AMD only version: <a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/lib/rsvp/rsvp-custom.amd.js">rsvp-custom.amd.js</a></li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/jio.js">jio.js</a></li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/complex_queries.js">complex_queries.js</a></li>
</ul>
</div>
<div class="section" id="storage-dependencies">
<h2>Storage dependencies<a class="headerlink" href="#storage-dependencies" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="http://code.jquery.com/jquery.js">jquery.js</a></li>
<li><a class="reference external" href="https://crypto.stanford.edu/sjcl/">sjcl</a>, [<a class="reference external" href="https://crypto.stanford.edu/sjcl/sjcl.zip">sjcl.zip</a>]</li>
<li><a class="reference external" href="http://pajhome.org.uk/crypt/md5/sha1.html">sha1</a>, [<a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/lib/jsSha1/sha1.js">sha1.js</a>], AMD compatible version: <a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha1.amd.js">sha1.amd.js</a></li>
<li><a class="reference external" href="http://anmar.eu.org/projects/jssha2/">sha2, sha256</a>, <a class="reference external" href="http://anmar.eu.org/projects/jssha2/files/jssha2-0.3.zip">jssha2.zip</a>, AMD compatible versions: <a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha2.amd.js">sha2.amd.js</a>, <a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha256.amd.js">sha256.amd.js</a></li>
</ul>
</div>
<div class="section" id="storage-connectors">
<h2>Storage connectors<a class="headerlink" href="#storage-connectors" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/localstorage.js">localstorage.js</a></li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/davstorage.js">davstorage.js</a></li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/s3storage.js">s3storage.js</a> (depends on sha1, jQuery) (WIP)</li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/xwikistorage.js">xwikistorage.js</a> (depends on jQuery) (WIP)</li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/erp5storage.js">erp5storage.js</a> (depends on jQuery) (WIP)</li>
<li>restsqlstorage.js (depends on jQuery) (WIP)</li>
<li>mioga2storage.js (depends on jQuery) (WIP)</li>
</ul>
</div>
<div class="section" id="storage-handlers">
<h2>Storage handlers<a class="headerlink" href="#storage-handlers" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/indexstorage.js">indexstorage.js</a> (WIP)</li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/gidstorage.js">gidstorage.js</a> (WIP)</li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/splitstorage.js">splitstorage.js</a> (WIP)</li>
<li>replicatestorage.js (WIP)</li>
</ul>
</div>
<div class="section" id="revision-based-storage-handlers">
<h2>Revision based storage handlers<a class="headerlink" href="#revision-based-storage-handlers" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/revisionstorage.js">revisionstorage.js</a> (depends on sha256) (WIP)</li>
<li><a class="reference external" href="http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/replicatestorage.js">replicaterevisionstorage.js</a> (WIP)</li>
</ul>
</div>
<div class="section" id="minified-version">
<h2>Minified version<a class="headerlink" href="#minified-version" title="Permalink to this headline"></a></h2>
<p>To get the minified version of the jIO library, you have to build it yourself. See documentation.</p>
</div>
<div class="section" id="fork">
<h2>Fork<a class="headerlink" href="#fork" title="Permalink to this headline"></a></h2>
<p>jIO source code</p>
<table border="1" class="docutils">
<colgroup>
<col width="27%" />
<col width="26%" />
<col width="24%" />
<col width="23%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>Clone (read only)</td>
<td>Git Erp5</td>
<td>Gitorious</td>
<td>Github</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">http://git.erp5.org/repos/jio.git</span></tt></td>
<td><a class="reference external" href="http://git.erp5.org/gitweb/jio.git">View</a></td>
<td><a class="reference external" href="https://gitorious.org/nexedi/jio">View</a></td>
<td><a class="reference external" href="https://github.com/nexedi/jio">View</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Downloads</a><ul>
<li><a class="reference internal" href="#core">Core</a></li>
<li><a class="reference internal" href="#storage-dependencies">Storage dependencies</a></li>
<li><a class="reference internal" href="#storage-connectors">Storage connectors</a></li>
<li><a class="reference internal" href="#storage-handlers">Storage handlers</a></li>
<li><a class="reference internal" href="#revision-based-storage-handlers">Revision based storage handlers</a></li>
<li><a class="reference internal" href="#minified-version">Minified version</a></li>
<li><a class="reference internal" href="#fork">Fork</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="introduction.html"
title="previous chapter">Introduction</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="manage_documents.html"
title="next chapter">How to manage documents?</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/download.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="manage_documents.html" title="How to manage documents?"
>next</a> |</li>
<li class="right" >
<a href="introduction.html" title="Introduction"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="#" title="General Index"
accesskey="I">index</a></li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1 id="index">Index</h1>
<div class="genindex-jumpbox">
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="#" title="General Index"
>index</a></li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jIO GIDStorage &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="jIO Complex Queries" href="complex_queries.html" />
<link rel="prev" title="List of Available Storages" href="available_storages.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="complex_queries.html" title="jIO Complex Queries"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="available_storages.html" title="List of Available Storages"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="jio-gidstorage">
<span id="gid-storage"></span><h1>jIO GIDStorage<a class="headerlink" href="#jio-gidstorage" title="Permalink to this headline"></a></h1>
<p>A storage to enable interoperability between all kind of storages.</p>
<p>A global ID (GID) is a document id which represents a unique document. This ID
is then used to find this unique document on all types of backends.</p>
<p>This storage uses sub storage allDocs and complex queries to find unique documents, and converts their ids to gids.</p>
<div class="section" id="where-it-can-be-used">
<h2>Where it can be used<a class="headerlink" href="#where-it-can-be-used" title="Permalink to this headline"></a></h2>
<p>When you want to duplicate / synchronize / split / edit data in different kind of storages (ERP5 + XWiki + Dav + ...).</p>
</div>
<div class="section" id="storage-description">
<h2>Storage Description<a class="headerlink" href="#storage-description" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">type</span></tt> - <tt class="docutils literal"><span class="pre">&quot;gid&quot;</span></tt></li>
<li><tt class="docutils literal"><span class="pre">sub_storage</span></tt> - the sub storage description.</li>
<li><tt class="docutils literal"><span class="pre">constraints</span></tt> - the constraints to use to generate a gid by defining metadata types for some kind of document.</li>
</ul>
<p>Example:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;gid&quot;</span><span class="p">,</span>
<span class="s2">&quot;sub_storage&quot;</span><span class="o">:</span> <span class="p">{</span><span class="o">&lt;</span><span class="nx">storage</span> <span class="nx">description</span><span class="o">&gt;</span><span class="p">},</span>
<span class="s2">&quot;constraints&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;default&quot;</span><span class="o">:</span> <span class="p">{</span> <span class="c1">// constraints for all kind of documents</span>
<span class="c1">// &quot;document metadata&quot;: &quot;type of metadata&quot;</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;list&quot;</span>
<span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;Text&quot;</span><span class="o">:</span> <span class="p">{</span> <span class="c1">// document of type &#39;Text&#39; additional constraints</span>
<span class="s2">&quot;language&quot;</span><span class="o">:</span> <span class="s2">&quot;string&quot;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>This description tells the <em>GIDStorage</em> to use 2 metadata attributes (<tt class="docutils literal"><span class="pre">type</span></tt>, <tt class="docutils literal"><span class="pre">title</span></tt>) to define a
document as unique in the default case. If the document is of type <tt class="docutils literal"><span class="pre">Text</span></tt>, then
the handler will use 3 metadata (<tt class="docutils literal"><span class="pre">type</span></tt>, <tt class="docutils literal"><span class="pre">title</span></tt>, <tt class="docutils literal"><span class="pre">language</span></tt>).
If these constraints are not respected, then the storage returns an error telling us to
review the document metadata. Here are samples of document respecting the above
constraints:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;Text&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;Hello World!&quot;</span><span class="p">,</span>
<span class="s2">&quot;language&quot;</span><span class="o">:</span> <span class="s2">&quot;en&quot;</span>
<span class="p">}</span>
<span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Text&quot;</span><span class="p">,</span> <span class="s2">&quot;Web Page&quot;</span><span class="p">],</span>
<span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;My Web Page Title&quot;</span><span class="p">,</span>
<span class="s2">&quot;language&quot;</span><span class="o">:</span> <span class="s2">&quot;en-US&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;text/html&quot;</span>
<span class="p">}</span>
<span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;Image&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;My Image Title&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Available metadata types are:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">&quot;json&quot;</span></tt> - The json value of the metadata.</li>
<li><tt class="docutils literal"><span class="pre">&quot;string&quot;</span></tt> - The value as string if it is not a list.</li>
<li><tt class="docutils literal"><span class="pre">&quot;list&quot;</span></tt> - The value as list.</li>
<li><tt class="docutils literal"><span class="pre">&quot;date&quot;</span></tt> - The value if it can be converted to a date (as string).</li>
<li><tt class="docutils literal"><span class="pre">&quot;DCMIType&quot;</span></tt> - A value matching one of the DCMIType Vocabulary (as string).</li>
<li><tt class="docutils literal"><span class="pre">&quot;contentType&quot;</span></tt> - A value which is a content type (as string).</li>
<li><tt class="docutils literal"><span class="pre">[&quot;DCMIType&quot;,</span> <span class="pre">&quot;list&quot;]</span></tt> - The value which contains a DCMIType (as list).</li>
<li><tt class="docutils literal"><span class="pre">[...]</span></tt> - make your own combination.</li>
</ul>
</div>
<div class="section" id="document-requirements">
<h2>Document Requirements<a class="headerlink" href="#document-requirements" title="Permalink to this headline"></a></h2>
<p>A metadata value must be a string. This string can be placed in an attribute within
a <tt class="docutils literal"><span class="pre">&quot;content&quot;</span></tt> key. The object can contains custom keys with string values. A
metadata object can contain several values. Example:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="s2">&quot;value&quot;</span><span class="p">,</span>
<span class="c1">// or</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;value1&quot;</span><span class="p">,</span> <span class="s2">&quot;value2&quot;</span><span class="p">],</span>
<span class="c1">// or</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="p">{</span><span class="s2">&quot;attribute name&quot;</span><span class="o">:</span> <span class="s2">&quot;attribute value&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="s2">&quot;value&quot;</span><span class="p">},</span>
<span class="c1">// or</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="p">{</span><span class="s2">&quot;scheme&quot;</span><span class="o">:</span> <span class="s2">&quot;DCTERMS.URI&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="s2">&quot;http://foo.com/bar&quot;</span><span class="p">},</span>
<span class="s2">&quot;value2&quot;</span><span class="p">,</span>
<span class="s2">&quot;value3&quot;</span><span class="p">,</span>
<span class="p">...</span>
<span class="p">],</span>
<span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Metadata attributes which names begin with an underscore can contain anything.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;_key&quot;</span><span class="o">:</span> <span class="p">{</span><span class="s2">&quot;whatever&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;blue&quot;</span><span class="p">,</span> <span class="p">[]],</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span> <span class="kc">null</span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="storage-requirements">
<h2>Storage Requirements<a class="headerlink" href="#storage-requirements" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>This storage is not compatible with <em>RevisionStorage</em> and <em>ReplicateRevisionStorage</em>.</li>
<li>Sub storages have to support options for <tt class="docutils literal"><span class="pre">complex</span> <span class="pre">queries</span></tt> and <tt class="docutils literal"><span class="pre">include_docs</span></tt>.</li>
</ul>
</div>
<div class="section" id="dependencies">
<h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h2>
<p>No dependency.</p>
</div>
<div class="section" id="suggested-storage-tree">
<h2>Suggested storage tree<a class="headerlink" href="#suggested-storage-tree" title="Permalink to this headline"></a></h2>
<p>Replication between storages:</p>
<div class="highlight-python"><pre>Replicate Storage
+-- GID Storage
| `-- Local Storage
+-- GID Storage
| `-- Remote Storage 1
`-- GID Storage
`-- Remote Storage 2</pre>
</div>
<p><strong>CAUTION: All gid storage must have the same description!</strong></p>
<p>Offline application usage:</p>
<div class="highlight-python"><pre>Replicate Storage
+-- Index Storage with DB in Local Storage
| `-- GID Storage
| `-- ERP5 Storage
`-- GID Storage
`-- Local Storage</pre>
</div>
<p><strong>CAUTION: All gid storage must have the same description!</strong></p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">jIO GIDStorage</a><ul>
<li><a class="reference internal" href="#where-it-can-be-used">Where it can be used</a></li>
<li><a class="reference internal" href="#storage-description">Storage Description</a></li>
<li><a class="reference internal" href="#document-requirements">Document Requirements</a></li>
<li><a class="reference internal" href="#storage-requirements">Storage Requirements</a></li>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#suggested-storage-tree">Suggested storage tree</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="available_storages.html"
title="previous chapter">List of Available Storages</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="complex_queries.html"
title="next chapter">jIO Complex Queries</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/gid_storage.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="complex_queries.html" title="jIO Complex Queries"
>next</a> |</li>
<li class="right" >
<a href="available_storages.html" title="List of Available Storages"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to jIO’s documentation! &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="#" />
<link rel="next" title="Introduction" href="introduction.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="introduction.html" title="Introduction"
accesskey="N">next</a> |</li>
<li><a href="#">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="welcome-to-jio-s-documentation">
<h1>Welcome to jIO&#8217;s documentation!<a class="headerlink" href="#welcome-to-jio-s-documentation" title="Permalink to this headline"></a></h1>
<p>Contents:</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#what-is-jio">What is jIO?</a></li>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#how-does-it-work">How does it work?</a></li>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#getting-started">Getting started</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="download.html">Downloads</a><ul>
<li class="toctree-l2"><a class="reference internal" href="download.html#core">Core</a></li>
<li class="toctree-l2"><a class="reference internal" href="download.html#storage-dependencies">Storage dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="download.html#storage-connectors">Storage connectors</a></li>
<li class="toctree-l2"><a class="reference internal" href="download.html#storage-handlers">Storage handlers</a></li>
<li class="toctree-l2"><a class="reference internal" href="download.html#revision-based-storage-handlers">Revision based storage handlers</a></li>
<li class="toctree-l2"><a class="reference internal" href="download.html#minified-version">Minified version</a></li>
<li class="toctree-l2"><a class="reference internal" href="download.html#fork">Fork</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="manage_documents.html">How to manage documents?</a><ul>
<li class="toctree-l2"><a class="reference internal" href="manage_documents.html#what-is-a-document">What is a document?</a></li>
<li class="toctree-l2"><a class="reference internal" href="manage_documents.html#basic-methods">Basic Methods</a></li>
<li class="toctree-l2"><a class="reference internal" href="manage_documents.html#promises">Promises</a></li>
<li class="toctree-l2"><a class="reference internal" href="manage_documents.html#method-options-and-callback-responses">Method Options and Callback Responses</a></li>
<li class="toctree-l2"><a class="reference internal" href="manage_documents.html#example-how-to-store-a-video-on-localstorage">Example: How to store a video on localStorage</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="revision_storages.html">Revision Storages: Conflicts and Resolution</a><ul>
<li class="toctree-l2"><a class="reference internal" href="revision_storages.html#why-conflicts-can-occur">Why Conflicts can Occur</a></li>
<li class="toctree-l2"><a class="reference internal" href="revision_storages.html#how-to-solve-conflicts">How to solve conflicts</a></li>
<li class="toctree-l2"><a class="reference internal" href="revision_storages.html#simple-conflict-example">Simple Conflict Example</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="available_storages.html">List of Available Storages</a><ul>
<li class="toctree-l2"><a class="reference internal" href="available_storages.html#connectors">Connectors</a></li>
<li class="toctree-l2"><a class="reference internal" href="available_storages.html#handlers">Handlers</a></li>
<li class="toctree-l2"><a class="reference internal" href="available_storages.html#revision-based-handlers">Revision Based Handlers</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="gid_storage.html">jIO GIDStorage</a><ul>
<li class="toctree-l2"><a class="reference internal" href="gid_storage.html#where-it-can-be-used">Where it can be used</a></li>
<li class="toctree-l2"><a class="reference internal" href="gid_storage.html#storage-description">Storage Description</a></li>
<li class="toctree-l2"><a class="reference internal" href="gid_storage.html#document-requirements">Document Requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="gid_storage.html#storage-requirements">Storage Requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="gid_storage.html#dependencies">Dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="gid_storage.html#suggested-storage-tree">Suggested storage tree</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="complex_queries.html">jIO Complex Queries</a><ul>
<li class="toctree-l2"><a class="reference internal" href="complex_queries.html#what-are-complex-queries">What are Complex Queries?</a></li>
<li class="toctree-l2"><a class="reference internal" href="complex_queries.html#why-use-complex-queries">Why use Complex Queries?</a></li>
<li class="toctree-l2"><a class="reference internal" href="complex_queries.html#how-to-use-complex-queries-with-jio">How to use Complex Queries with jIO?</a></li>
<li class="toctree-l2"><a class="reference internal" href="complex_queries.html#how-to-use-complex-queries-outside-jio">How to use Complex Queries outside jIO?</a></li>
<li class="toctree-l2"><a class="reference internal" href="complex_queries.html#json-schemas-and-grammar">JSON Schemas and Grammar</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="metadata.html">Metadata</a><ul>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#what-is-metadata">What is metadata?</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#why-use-metadata">Why use metadata?</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#how-to-format-metadata-with-jio">How to format metadata with jIO</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#list-of-metadata-to-use">List of metadata to use</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#examples">Examples</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#tools">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="metadata.html#sources">Sources</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="developers.html">For developers</a><ul>
<li class="toctree-l2"><a class="reference internal" href="developers.html#quick-start">Quick start</a></li>
<li class="toctree-l2"><a class="reference internal" href="developers.html#naming-conventions">Naming Conventions</a></li>
<li class="toctree-l2"><a class="reference internal" href="developers.html#how-to-design-your-own-jio-storage-library">How to design your own jIO Storage Library</a></li>
<li class="toctree-l2"><a class="reference internal" href="developers.html#job-rules">Job rules</a></li>
<li class="toctree-l2"><a class="reference internal" href="developers.html#create-job-condition">Create Job Condition</a></li>
<li class="toctree-l2"><a class="reference internal" href="developers.html#add-job-rules">Add job rules</a></li>
<li class="toctree-l2"><a class="reference internal" href="developers.html#clear-replace-default-job-rules">Clear/Replace default job rules</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="naming_conventions.html">JavaScript Naming Conventions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="naming_conventions.html#essential-conventions">Essential Conventions</a></li>
<li class="toctree-l2"><a class="reference internal" href="naming_conventions.html#coding-conventions">Coding Conventions</a></li>
<li class="toctree-l2"><a class="reference internal" href="naming_conventions.html#id1">Naming Conventions</a></li>
<li class="toctree-l2"><a class="reference internal" href="naming_conventions.html#additional-readings">Additional Readings</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="authors.html">Authors</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">Copyright and license</a></li>
</ul>
</div>
<ul class="simple">
<li><a class="reference internal" href="search.html"><em>Search Page</em></a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="#">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="introduction.html"
title="next chapter">Introduction</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/index.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="introduction.html" title="Introduction"
>next</a> |</li>
<li><a href="#">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Introduction &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="Downloads" href="download.html" />
<link rel="prev" title="Welcome to jIO’s documentation!" href="index.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="download.html" title="Downloads"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to jIO’s documentation!"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<div class="section" id="what-is-jio">
<h2>What is jIO?<a class="headerlink" href="#what-is-jio" title="Permalink to this headline"></a></h2>
<p>jIO is a JavaScript library that allows to manage JSON documents on local or
remote storages in asynchronous fashion. jIO is an abstracted API mapped after
CouchDB, that offers connectors to multiple storages, special handlers to
enhance functionality (replication, revisions, indexing) and a query module to
retrieve documents and specific information across storage trees.</p>
</div>
<div class="section" id="how-does-it-work">
<h2>How does it work?<a class="headerlink" href="#how-does-it-work" title="Permalink to this headline"></a></h2>
<p>jIO is composed of two parts - jIO core and storage library(ies). The core
is using storage libraries (connectors) to interact with the associated remote
storage servers. Some queries can be used on top of the jIO <tt class="docutils literal"><span class="pre">allDocs()</span></tt> method to
query documents based on defined criteria.</p>
<p>jIO uses a job management system, so every method call adds a job into a
queue. The queue is copied in the browser&#8217;s local storage (by default), so it
can be restored in case of browser crash. Jobs are invoked
asynchronously and ongoing jobs are not able to re-trigger to prevent
conflicts.</p>
</div>
<div class="section" id="getting-started">
<h2>Getting started<a class="headerlink" href="#getting-started" title="Permalink to this headline"></a></h2>
<p>This walkthrough is designed to get you started using a basic jIO instance.</p>
<ol class="arabic">
<li><p class="first">Download jIO core, the storages you want to use as well as the
complex-queries scripts and the dependencies required for the storages
you intend to use. <a class="reference internal" href="download.html#download-fork"><em>[Download &amp; Fork]</em></a></p>
</li>
<li><p class="first">Add the scripts to your HTML page in the following order:</p>
<div class="highlight-html"><pre>&lt;!-- jio core + dependency --&gt;
&lt;script src="sha256.amd.js"&gt;&lt;/script&gt;
&lt;script src="rsvp-custom.js"&gt;&lt;/script&gt;
&lt;script src="jio.js"&gt;&lt;/script&gt;
&lt;!-- storages + dependencies --&gt;
&lt;script src="complex_queries.js"&gt;&lt;/script&gt;
&lt;script src="localstorage.js"&gt;&lt;/script&gt;
&lt;script src="davstorage.js"&gt;&lt;/script&gt;
&lt;script ...&gt;</pre>
</div>
<p>With <a class="reference external" href="http://requirejs.org/">RequireJS</a>, the main.js will look like:</p>
<div class="highlight-javascript"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14</pre></div></td><td class="code"><div class="highlight"><pre><span class="nx">require</span><span class="p">.</span><span class="nx">config</span><span class="p">({</span>
<span class="s2">&quot;paths&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="c1">// jio core + dependency</span>
<span class="c1">// the AMD compatible version of sha256.js -&gt; see Download and Fork</span>
<span class="s2">&quot;sha256&quot;</span><span class="o">:</span> <span class="s2">&quot;sha256.amd&quot;</span><span class="p">,</span>
<span class="s2">&quot;rsvp&quot;</span><span class="o">:</span> <span class="s2">&quot;rsvp-custom&quot;</span><span class="p">,</span>
<span class="s2">&quot;jio&quot;</span><span class="o">:</span> <span class="s2">&quot;jio&quot;</span><span class="p">,</span>
<span class="c1">// storages + dependencies</span>
<span class="s2">&quot;complex_queries&quot;</span><span class="o">:</span> <span class="s2">&quot;complex_queries&quot;</span><span class="p">,</span>
<span class="s2">&quot;localstorage&quot;</span><span class="o">:</span> <span class="s2">&quot;localstorage&quot;</span><span class="p">,</span>
<span class="s2">&quot;davstorage&quot;</span><span class="o">:</span> <span class="s2">&quot;davstorage&quot;</span>
<span class="p">}</span>
<span class="p">});</span>
</pre></div>
</td></tr></table></div>
</li>
<li><p class="first">jIO connects to a number of storages and allows adding handlers (or
functions) to specifc storages.
You can use both handlers and available storages to build a storage
tree across which all documents will be maintained and managed by jIO.</p>
<p>See <a class="reference internal" href="available_storages.html#list-of-available-storages"><em>List of Available Storages</em></a>.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// create your jio instance</span>
<span class="kd">var</span> <span class="nx">my_jio</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">);</span>
</pre></div>
</div>
</li>
<li><p class="first">The jIO API provides ten main methods to manage documents across the storage(s) specified in your jIO storage tree.</p>
<table border="1" class="docutils">
<colgroup>
<col width="19%" />
<col width="46%" />
<col width="35%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method</th>
<th class="head">Example call</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">post()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">post</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Creates a new document</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">put()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">put</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Creates/Updates a document</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">putAttachment()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">putAttachement</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">attachment</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Updates/Adds an attachment to a document</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">get()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">get</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Reads a document</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">getAttachment()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">getAttachment</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">attachment</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Reads a document attachment</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">remove()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">remove</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Deletes a document and its attachments</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">removeAttachment()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">removeAttachment</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">attachment</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Deletes a document attachment</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">allDocs()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">allDocs</span></span><span class="punctuation"><span class="pre">(</span></span><span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Retrieves a list of existing documents</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">check()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">check</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Check the document state</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">repair()</span></tt></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">repair</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Repair the document</td>
</tr>
</tbody>
</table>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Introduction</a><ul>
<li><a class="reference internal" href="#what-is-jio">What is jIO?</a></li>
<li><a class="reference internal" href="#how-does-it-work">How does it work?</a></li>
<li><a class="reference internal" href="#getting-started">Getting started</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Welcome to jIO&#8217;s documentation!</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="download.html"
title="next chapter">Downloads</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/introduction.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="download.html" title="Downloads"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to jIO’s documentation!"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Copyright and license &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="prev" title="Authors" href="authors.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="authors.html" title="Authors"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="copyright-and-license">
<h1>Copyright and license<a class="headerlink" href="#copyright-and-license" title="Permalink to this headline"></a></h1>
<p>jIO is an open-source library and is licensed under the LGPL license. More
information on LGPL can be found <a class="reference external" href="http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License">here</a></p>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h4>Previous topic</h4>
<p class="topless"><a href="authors.html"
title="previous chapter">Authors</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/license.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="authors.html" title="Authors"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>How to manage documents? &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="Revision Storages: Conflicts and Resolution" href="revision_storages.html" />
<link rel="prev" title="Downloads" href="download.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="revision_storages.html" title="Revision Storages: Conflicts and Resolution"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="download.html" title="Downloads"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="how-to-manage-documents">
<h1>How to manage documents?<a class="headerlink" href="#how-to-manage-documents" title="Permalink to this headline"></a></h1>
<p>jIO is mapped after the CouchDB APIs and extends them to provide unified, scalable
and high performance access via JavaScript to a wide variety of different
storage backends.</p>
<p>If you are not familiar with <a class="reference external" href="http://couchdb.apache.org/">Apache CouchDB</a>:
it is a scalable, fault-tolerant, and schema-free document-oriented database.
It is used in large and small organizations for a variety of applications where
traditional SQL databases are not the best solution for the problem at hand.
CouchDB provides a RESTful HTTP/JSON API accessible by many programming
libraries and tools (like <a class="reference external" href="http://curl.haxx.se/">curl</a> or <a class="reference external" href="http://pouchdb.com/">Pouchdb</a>)
and has its own conflict management system.</p>
<div class="section" id="what-is-a-document">
<h2>What is a document?<a class="headerlink" href="#what-is-a-document" title="Permalink to this headline"></a></h2>
<p>A document is an association of metadata and attachment(s). The metadata is the
set of properties of the document and the attachments are the binaries of the content
of the document.</p>
<p>In jIO, metadata is just a dictionary with keys and values (JSON object), and
attachments are just simple strings.</p>
<div class="highlight-javascript"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6</pre></div></td><td class="code"><div class="highlight"><pre><span class="p">{</span>
<span class="c1">// document metadata</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;Identifier&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;A Title!&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span><span class="o">:</span> <span class="s2">&quot;Mr.Author&quot;</span>
<span class="p">}</span>
</pre></div>
</td></tr></table></div>
<p>You can also retrieve document attachment metadata in this object.</p>
<div class="highlight-javascript"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14</pre></div></td><td class="code"><div class="highlight"><pre><span class="p">{</span>
<span class="c1">// document metadata</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;Identifier&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;A Title!&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span><span class="o">:</span> <span class="s2">&quot;Mr.Author&quot;</span><span class="p">,</span>
<span class="s2">&quot;_attachments&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="c1">// attachment metadata</span>
<span class="s2">&quot;body.html&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;length&quot;</span><span class="o">:</span> <span class="mi">12893</span><span class="p">,</span>
<span class="s2">&quot;digest&quot;</span><span class="o">:</span> <span class="s2">&quot;sha256-XXXX...&quot;</span><span class="p">,</span>
<span class="s2">&quot;content_type&quot;</span><span class="o">:</span> <span class="s2">&quot;text/html&quot;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</td></tr></table></div>
<p><a class="reference internal" href="metadata.html#metadata-head"><em>Here</em></a> is a draft about metadata to use with jIO.</p>
</div>
<div class="section" id="basic-methods">
<h2>Basic Methods<a class="headerlink" href="#basic-methods" title="Permalink to this headline"></a></h2>
<p>Below you can see examples of the main jIO methods. All examples are using
revisions (as in revision storage or replicate revision storage), so you can
see how method calls should be made with either of these storages.</p>
<div class="highlight-javascript"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50</pre></div></td><td class="code"><div class="highlight"><pre><span class="c1">// Create a new jIO instance</span>
<span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">newJio</span><span class="p">(</span><span class="nx">storage</span> <span class="nx">tree</span> <span class="nx">description</span><span class="p">);</span>
<span class="c1">// create and store new document</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">post</span><span class="p">({</span><span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;some title&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// create or update an existing document</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_document&quot;</span><span class="p">,</span> <span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;New Title&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// add an attachment to a document</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">putAttachment</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_document&quot;</span><span class="p">,</span> <span class="s2">&quot;_attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;its_attachment&quot;</span><span class="p">,</span>
<span class="s2">&quot;_data&quot;</span><span class="o">:</span> <span class="s2">&quot;abc&quot;</span><span class="p">,</span> <span class="s2">&quot;_mimetype&quot;</span><span class="o">:</span> <span class="s2">&quot;text/plain&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// read a document</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">get</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_document&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// read an attachment</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">getAttachment</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_document&quot;</span><span class="p">,</span> <span class="s2">&quot;_attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;its_attachment&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// delete a document and its attachment(s)</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">remove</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_document&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// delete an attachment</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">removeAttachment</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_document&quot;</span><span class="p">,</span> <span class="s2">&quot;_attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;its_attachment&quot;</span><span class="p">}).</span>
<span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
<span class="c1">// get all documents</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">allDocs</span><span class="p">().</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// console.log(response);</span>
<span class="p">});</span>
</pre></div>
</td></tr></table></div>
</div>
<div class="section" id="promises">
<h2>Promises<a class="headerlink" href="#promises" title="Permalink to this headline"></a></h2>
<p>Each jIO method returns a Promise object, which allows us to get responses into
callback parameters and to chain callbacks with other returned values.</p>
<p>jIO uses a custom version of <a class="reference external" href="https://github.com/tildeio/rsvp.js">RSVP.js</a>, adding canceler and progression features.</p>
<p>You can read more about promises:</p>
<ul class="simple">
<li><a class="reference external" href="https://github.com/tildeio/rsvp.js#rsvpjs--">RSVP.js</a> on GitHub</li>
<li><a class="reference external" href="http://promisesaplus.com/">Promises/A+</a></li>
<li><a class="reference external" href="http://wiki.commonjs.org/wiki/Promises">CommonJS Promises</a></li>
</ul>
</div>
<div class="section" id="method-options-and-callback-responses">
<h2>Method Options and Callback Responses<a class="headerlink" href="#method-options-and-callback-responses" title="Permalink to this headline"></a></h2>
<p>To retrieve jIO responses, you have to provide callbacks like this:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">post</span><span class="p">(</span><span class="nx">metadata</span><span class="p">,</span> <span class="p">[</span><span class="nx">options</span><span class="p">]).</span>
<span class="nx">then</span><span class="p">([</span><span class="nx">responseCallback</span><span class="p">],</span> <span class="p">[</span><span class="nx">errorCallback</span><span class="p">],</span> <span class="p">[</span><span class="nx">progressionCallback</span><span class="p">]);</span>
</pre></div>
</div>
<ul class="simple">
<li>On command success, <tt class="docutils literal"><span class="pre">responseCallback</span></tt> will be called with the jIO response as first parameter.</li>
<li>On command error, <tt class="docutils literal"><span class="pre">errorCallback</span></tt> will be called with the jIO error as first parameter.</li>
<li>On command notification, <tt class="docutils literal"><span class="pre">progressionCallback</span></tt> will be called with the storage notification.</li>
</ul>
<p>Here is a list of responses returned by jIO according to methods and options:</p>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="40%" />
<col width="44%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Option</th>
<th class="head">Available for</th>
<th class="head">Response (Callback first parameter)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>No options</td>
<td><tt class="docutils literal"><span class="pre">post()</span></tt>, <tt class="docutils literal"><span class="pre">put()</span></tt>, <tt class="docutils literal"><span class="pre">remove()</span></tt></td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;post&quot;</span><span class="p">,</span>
<span class="c1">// or put or remove</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_doc_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">204</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;No Content&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-odd"><td>No options</td>
<td><tt class="docutils literal"><span class="pre">putAttachment()</span></tt>, <tt class="docutils literal"><span class="pre">removeAttachment()</span></tt></td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;putAttachment&quot;</span><span class="p">,</span>
<span class="c1">// or removeAttachment</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_doc_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;my_attachment_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">204</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;No Content&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-even"><td>No options</td>
<td><tt class="docutils literal"><span class="pre">get()</span></tt></td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;get&quot;</span><span class="p">,</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_doc_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;Ok&quot;</span><span class="p">,</span>
<span class="s2">&quot;data&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="c1">// Here, the document metadata</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-odd"><td>No options</td>
<td><tt class="docutils literal"><span class="pre">getAttachment()</span></tt></td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;getAttachment&quot;</span><span class="p">,</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_doc_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;my_attachment_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;Ok&quot;</span><span class="p">,</span>
<span class="s2">&quot;data&quot;</span><span class="o">:</span> <span class="nx">Blob</span> <span class="c1">// Here, the attachment content</span>
<span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-even"><td>No option</td>
<td><tt class="docutils literal"><span class="pre">allDocs()</span></tt></td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;allDocs&quot;</span><span class="p">,</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_doc_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;Ok&quot;</span><span class="p">,</span>
<span class="s2">&quot;data&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;total_rows&quot;</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="s2">&quot;rows&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;mydoc&quot;</span><span class="p">,</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="s2">&quot;mydoc&quot;</span><span class="p">,</span> <span class="c1">// optional</span>
<span class="s2">&quot;value&quot;</span><span class="o">:</span> <span class="p">{},</span>
<span class="p">}]</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-odd"><td>include_docs: true</td>
<td><tt class="docutils literal"><span class="pre">allDocs()</span></tt></td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;allDocs&quot;</span><span class="p">,</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;my_doc_id&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;Ok&quot;</span><span class="p">,</span>
<span class="s2">&quot;data&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;total_rows&quot;</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="s2">&quot;rows&quot;</span><span class="o">:</span> <span class="p">[{</span>
<span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="s2">&quot;mydoc&quot;</span><span class="p">,</span>
<span class="s2">&quot;key&quot;</span><span class="o">:</span> <span class="s2">&quot;mydoc&quot;</span><span class="p">,</span> <span class="c1">// optional</span>
<span class="s2">&quot;value&quot;</span><span class="o">:</span> <span class="p">{},</span>
<span class="s2">&quot;doc&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="c1">// Here, &quot;mydoc&quot; metadata</span>
<span class="p">}</span>
<span class="p">}]</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
<p>In case of error, the <tt class="docutils literal"><span class="pre">errorCallback</span></tt> first parameter will look like:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;result&quot;</span><span class="o">:</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span>
<span class="s2">&quot;method&quot;</span><span class="o">:</span> <span class="s2">&quot;get&quot;</span><span class="p">,</span>
<span class="s2">&quot;status&quot;</span><span class="o">:</span> <span class="mi">404</span><span class="p">,</span>
<span class="s2">&quot;statusText&quot;</span><span class="o">:</span> <span class="s2">&quot;Not Found&quot;</span><span class="p">,</span>
<span class="s2">&quot;error&quot;</span><span class="o">:</span> <span class="s2">&quot;not_found&quot;</span><span class="p">,</span>
<span class="s2">&quot;reason&quot;</span><span class="o">:</span> <span class="s2">&quot;document missing&quot;</span><span class="p">,</span>
<span class="s2">&quot;message&quot;</span><span class="o">:</span> <span class="s2">&quot;Unable to get the requseted document&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="example-how-to-store-a-video-on-localstorage">
<h2>Example: How to store a video on localStorage<a class="headerlink" href="#example-how-to-store-a-video-on-localstorage" title="Permalink to this headline"></a></h2>
<p>The following shows how to create a new jIO in localStorage and then post a document with two attachments.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// create a new jIO</span>
<span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">newJio</span><span class="p">({</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;local&quot;</span><span class="p">,</span>
<span class="s2">&quot;username&quot;</span><span class="o">:</span> <span class="s2">&quot;usr&quot;</span><span class="p">,</span>
<span class="s2">&quot;application_name&quot;</span><span class="o">:</span><span class="s2">&quot;app&quot;</span>
<span class="p">});</span>
<span class="c1">// post the document &quot;metadata&quot;</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">post</span><span class="p">({</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;My Video&quot;</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;MovingImage&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="s2">&quot;video/ogg&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;Images Compilation&quot;</span>
<span class="p">},</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">id</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Error posting the document meta&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">id</span> <span class="o">=</span> <span class="nx">response</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span>
<span class="c1">// post a thumbnail attachment</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">putAttachment</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="nx">id</span><span class="p">,</span>
<span class="s2">&quot;_attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;thumbnail&quot;</span><span class="p">,</span>
<span class="s2">&quot;_data&quot;</span><span class="o">:</span> <span class="nx">my_image</span><span class="p">,</span>
<span class="s2">&quot;_mimetype&quot;</span><span class="o">:</span> <span class="s2">&quot;image/jpeg&quot;</span>
<span class="p">},</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Error attaching thumbnail&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="c1">// post video attachment</span>
<span class="nx">jio_instance</span><span class="p">.</span><span class="nx">putAttachment</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="nx">id</span><span class="p">,</span>
<span class="s2">&quot;_attachment&quot;</span><span class="o">:</span> <span class="s2">&quot;video&quot;</span><span class="p">,</span>
<span class="s2">&quot;_data&quot;</span><span class="o">:</span> <span class="nx">my_video</span><span class="p">,</span>
<span class="s2">&quot;_mimetype&quot;</span><span class="o">:</span><span class="s2">&quot;video/ogg&quot;</span>
<span class="p">},</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Error attaching the video&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Video Stored&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">});</span>
</pre></div>
</div>
<p>localStorage contents:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="p">{</span>
<span class="s2">&quot;jio/local/usr/app/12345678-1234-1234-1234-123456789012&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;12345678-1234-1234-1234-123456789012&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;My Video&quot;</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;MovingImage&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span><span class="o">:</span> <span class="s2">&quot;video/ogg&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="o">:</span> <span class="s2">&quot;Images Compilation&quot;</span><span class="p">,</span>
<span class="s2">&quot;_attachments&quot;</span><span class="o">:</span><span class="p">{</span>
<span class="s2">&quot;thumbnail&quot;</span><span class="o">:</span><span class="p">{</span>
<span class="s2">&quot;digest&quot;</span><span class="o">:</span> <span class="s2">&quot;md5-3ue...&quot;</span><span class="p">,</span>
<span class="s2">&quot;content_type&quot;</span><span class="o">:</span> <span class="s2">&quot;image/jpeg&quot;</span><span class="p">,</span>
<span class="s2">&quot;length&quot;</span><span class="o">:</span> <span class="mi">17863</span>
<span class="p">},</span>
<span class="s2">&quot;video&quot;</span><span class="o">:</span><span class="p">{</span>
<span class="s2">&quot;digest&quot;</span><span class="o">:</span> <span class="s2">&quot;md5-0oe...&quot;</span><span class="p">,</span>
<span class="s2">&quot;content_type&quot;</span><span class="o">:</span> <span class="s2">&quot;video/ogg&quot;</span><span class="p">,</span>
<span class="s2">&quot;length&quot;</span><span class="o">:</span> <span class="mi">2840824</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">},</span>
<span class="s2">&quot;jio/local/usr/app/myVideo/thumbnail&quot;</span><span class="o">:</span> <span class="s2">&quot;/9j/4AAQSkZ...&quot;</span><span class="p">,</span>
<span class="s2">&quot;jio/local/usr/app/myVideo/video&quot;</span><span class="o">:</span> <span class="s2">&quot;...&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">How to manage documents?</a><ul>
<li><a class="reference internal" href="#what-is-a-document">What is a document?</a></li>
<li><a class="reference internal" href="#basic-methods">Basic Methods</a></li>
<li><a class="reference internal" href="#promises">Promises</a></li>
<li><a class="reference internal" href="#method-options-and-callback-responses">Method Options and Callback Responses</a></li>
<li><a class="reference internal" href="#example-how-to-store-a-video-on-localstorage">Example: How to store a video on localStorage</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="download.html"
title="previous chapter">Downloads</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="revision_storages.html"
title="next chapter">Revision Storages: Conflicts and Resolution</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/manage_documents.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="revision_storages.html" title="Revision Storages: Conflicts and Resolution"
>next</a> |</li>
<li class="right" >
<a href="download.html" title="Downloads"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Metadata &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="For developers" href="developers.html" />
<link rel="prev" title="jIO Complex Queries" href="complex_queries.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="developers.html" title="For developers"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="complex_queries.html" title="jIO Complex Queries"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="metadata">
<span id="metadata-head"></span><h1>Metadata<a class="headerlink" href="#metadata" title="Permalink to this headline"></a></h1>
<div class="section" id="what-is-metadata">
<h2>What is metadata?<a class="headerlink" href="#what-is-metadata" title="Permalink to this headline"></a></h2>
<p>The word &#8220;metadata&#8221; means &#8220;data about data&#8221;. Metadata articulates a context for
objects of interest &#8211; &#8220;resources&#8221; such as MP3 files, library books, or
satellite images &#8211; in the form of &#8220;resource descriptions&#8221;. As a tradition,
resource description dates back to the earliest archives and library catalogs.
During the Web revolution of the mid-1990s, <a class="reference external" href="http://dublincore.org/metadata-basics/">Dublic Core</a>
has emerged as one of the prominent metadata standards.</p>
</div>
<div class="section" id="why-use-metadata">
<h2>Why use metadata?<a class="headerlink" href="#why-use-metadata" title="Permalink to this headline"></a></h2>
<p>Uploading a document to several servers can be very tricky, because the
document has to be saved in a place where it can be easily found with basic
searches in all storages (For instance: ERP5, XWiki and Mioga2 have their own
way to save documents and to get them). So we must use metadata for
<em>interoperability reasons</em>. Interoperability is the ability of diverse systems
and organizations to work together.</p>
</div>
<div class="section" id="how-to-format-metadata-with-jio">
<h2>How to format metadata with jIO<a class="headerlink" href="#how-to-format-metadata-with-jio" title="Permalink to this headline"></a></h2>
<p>See below XML and its JSON equivalent:</p>
<table border="1" class="docutils">
<colgroup>
<col width="53%" />
<col width="47%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">XML</th>
<th class="head">JSON</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><div class="first last highlight-xml"><div class="highlight"><pre><span class="nt">&lt;dc:title&gt;</span>My Title<span class="nt">&lt;/dc:title&gt;</span>
</pre></div>
</div>
</td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span><span class="s2">&quot;title&quot;</span><span class="o">:</span><span class="s2">&quot;My Title&quot;</span><span class="p">}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-odd"><td><div class="first last highlight-xml"><div class="highlight"><pre><span class="nt">&lt;dc:contributor&gt;</span>Me<span class="nt">&lt;/dc:contributor&gt;</span>
<span class="nt">&lt;dc:contributor&gt;</span>And You<span class="nt">&lt;/dc:contributor&gt;</span>
</pre></div>
</div>
</td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span><span class="s2">&quot;contributor&quot;</span><span class="o">:</span><span class="p">[</span><span class="s2">&quot;Me&quot;</span><span class="p">,</span> <span class="s2">&quot;And You&quot;</span><span class="p">]}</span>
</pre></div>
</div>
</td>
</tr>
<tr class="row-even"><td><div class="first last highlight-xml"><div class="highlight"><pre><span class="nt">&lt;dc:identifier</span> <span class="na">scheme=</span><span class="s">&quot;DCTERMS.URI&quot;</span><span class="nt">&gt;</span>
http://my/resource
<span class="nt">&lt;/dc:identifier&gt;</span>
<span class="nt">&lt;dc:identifier&gt;</span>
Xaoe41PAPNIWz
<span class="nt">&lt;/dc:identifier&gt;</span>
</pre></div>
</div>
</td>
<td><div class="first last highlight-javascript"><div class="highlight"><pre><span class="p">{</span><span class="s2">&quot;identifier&quot;</span><span class="o">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="s2">&quot;scheme&quot;</span><span class="o">:</span> <span class="s2">&quot;DCTERMS.URI&quot;</span><span class="p">,</span>
<span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="s2">&quot;http://my/resource&quot;</span>
<span class="p">},</span>
<span class="s2">&quot;Xaoe41PAPNIWz&quot;</span><span class="p">]}</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="list-of-metadata-to-use">
<h2>List of metadata to use<a class="headerlink" href="#list-of-metadata-to-use" title="Permalink to this headline"></a></h2>
<div class="section" id="identification">
<h3>Identification<a class="headerlink" href="#identification" title="Permalink to this headline"></a></h3>
<ul>
<li><p class="first"><strong>_id</strong>, a specific jIO metadata which helps the storage to find a document
(can be a real path name, a dc:identifier, a uuid, ...). <strong>String Only</strong></p>
</li>
<li><p class="first"><strong>identifer</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;identifier&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;http://domain/jio_home_page&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;identifier&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;urn:ISBN:978-1-2345-6789-X&quot;</span></span><span class="punctuation"><span class="pre">},</span></span>
<span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;identifier&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;scheme&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;DCTERMS.URI&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;content&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;http://domain/jio_home_page&quot;</span></span><span class="punctuation"><span class="pre">}]}</span></span></tt></p>
<p>an unambiguous reference to the resource within a given context. Recommended
best practice is to identify the resource by means of a string or number
conforming to a formal identification system. Examples of formal identification
systems include the Uniform Resource Identifier (URI) (including the Uniform
Resource Locator (URL), the Digital Object Identifier (DOI) and the
International Standard Book Number (ISBN).</p>
</li>
<li><p class="first"><strong>format</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;format&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;text/html&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;52</span> <span class="pre">kB&quot;</span></span><span class="punctuation"><span class="pre">]},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;format&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;image/jpeg&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;100</span> <span class="pre">x</span> <span class="pre">100</span> <span class="pre">pixels&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;13.2</span> <span class="pre">KiB&quot;</span></span><span class="punctuation"><span class="pre">]}</span></span></tt></p>
<p>the physical or digital manifestation of the resource. Typically, Format may
include the media-type or dimensions of the resource. Examples of dimensions
include size and duration. Format may be used to determine the software,
hardware or other equipment needed to display or operate the resource.</p>
</li>
<li><p class="first"><strong>date</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;date&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;2011-12-13T14:15:16Z&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;date&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;scheme&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;DCTERMS.W3CDTF&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;content&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;2011-12-13&quot;</span></span><span class="punctuation"><span class="pre">}}</span></span></tt></p>
<p>a date associated with an event in the life cycle of the resource. Typically,
Date will be associated with the creation or availability of the resource.
Recommended best practice for encoding the date value is defined in a profile
of ISO 8601 <a class="reference external" href="http://www.w3.org/TR/NOTE-datetime">Date and Time Formats, W3C Note</a>
and follows the YYYY-MM-DD format.</p>
</li>
<li><p class="first"><strong>type</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;type&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Text&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;type&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Image&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;type&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Dataset&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>the nature or genre of the content of the resource. Type includes terms describing
general categories, functions, genres, or aggregation levels for content.
Recommended best practice is to select a value from a controlled vocabulary.
<strong>The type is not a MIME Type!</strong></p>
</li>
</ul>
</div>
<div class="section" id="intellectual-property">
<h3>Intellectual property<a class="headerlink" href="#intellectual-property" title="Permalink to this headline"></a></h3>
<ul>
<li><p class="first"><strong>creator</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;creator&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Tristan</span> <span class="pre">Cavelier&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;creator&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;Tristan</span> <span class="pre">Cavelier&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;Sven</span> <span class="pre">Franck&quot;</span></span><span class="punctuation"><span class="pre">]}</span></span></tt></p>
<p>an entity primarily responsible for creating the content of the resource.
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.</p>
</li>
<li><p class="first"><strong>publisher</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;publisher&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Nexedi&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>the entity responsible for making the resource available. Examples of a
Publisher include a person, an organization, or a service. Typically, the name
of a Publisher should be used to indicate the entity.</p>
</li>
<li><p class="first"><strong>contributor</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;contributor&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;Full</span> <span class="pre">Name&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;Full</span> <span class="pre">Name&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">...]}</span></span></tt></p>
<p>an entity responsible for making contributions to the content of the
resource. Examples of a Contributor include a person, an organization or a
service. Typically, the name of a Contributor should be used to indicate the
entity.</p>
</li>
<li><p class="first"><strong>rights</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;rights&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Access</span> <span class="pre">limited</span> <span class="pre">to</span> <span class="pre">members&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;rights&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;https://www.j-io.org/documentation/jio-documentation/#copyright-and-license&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>information about rights held in and over the resource. Typically a Rights
element will contain a rights management statement for the resource, or
reference a service providing such information. Rights information often
encompasses Intellectual Property Rights (IPR), Copyright, and various Property
Rights. If the rights element is absent, no assumptions can be made about the
status of these and other rights with respect to the resource.</p>
</li>
</ul>
</div>
<div class="section" id="content">
<h3>Content<a class="headerlink" href="#content" title="Permalink to this headline"></a></h3>
<ul>
<li><p class="first"><strong>title</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;title&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;jIO</span> <span class="pre">Home</span> <span class="pre">Page&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>the name given to the resource. Typically, a Title will be a name by which the resource is formally known.</p>
</li>
<li><p class="first"><strong>subject</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;subject&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;jIO&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;subject&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;jIO&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;basics&quot;</span></span><span class="punctuation"><span class="pre">]}</span></span></tt></p>
<p>the topic of the content of the resource. Typically, a Subject will be
expressed as keywords or key phrases or classification codes that describe the
topic of the resource. Recommended best practice is to select a value from a
controlled vocabulary or formal classification scheme.</p>
</li>
<li><p class="first"><strong>description</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;description&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Simple</span> <span class="pre">guide</span> <span class="pre">to</span> <span class="pre">show</span> <span class="pre">the</span> <span class="pre">basics</span> <span class="pre">of</span> <span class="pre">jIO&quot;</span></span><span class="punctuation"><span class="pre">},</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;description&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;lang&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;fr&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;content&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Ma</span> <span class="pre">description&quot;</span></span><span class="punctuation"><span class="pre">}}</span></span></tt></p>
<p>an account of the content of the resource. Description may include but is not
limited to: an abstract, table of contents, reference to a graphical
representation of content or a free-text account of the content.</p>
</li>
<li><p class="first"><strong>language</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;language&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;en&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>the language of the intellectual content of the resource. Recommended best
practice for the values of the Language element is defined by <a class="reference external" href="http://www.ietf.org/rfc/rfc3066.txt">RFC 3066</a>
which, in conjunction with <a class="reference external" href="http://www.oasis-open.org/cover/iso639a.html">ISO 639</a>, defines two- and
three-letter primary language tags with optional subtags. Examples include &#8220;en&#8221;
or &#8220;eng&#8221; for English, &#8220;akk&#8221; for Akkadian, and &#8220;en-GB&#8221; for English used in the
United Kingdom.</p>
</li>
<li><p class="first"><strong>source</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;source&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;Image</span> <span class="pre">taken</span> <span class="pre">from</span> <span class="pre">a</span> <span class="pre">drawing</span> <span class="pre">by</span> <span class="pre">Mr.</span> <span class="pre">Artist&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;&lt;phone</span> <span class="pre">number&gt;&quot;</span></span><span class="punctuation"><span class="pre">]}</span></span></tt>,</p>
<p>a Reference to a resource from which the present resource is derived. The
present resource may be derived from the Source resource in whole or part.
Recommended best practice is to reference the resource by means of a string or
number conforming to a formal identification system.</p>
</li>
<li><p class="first"><strong>relation</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;relation&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;Resilience</span> <span class="pre">project&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>a reference to a related resource. Recommended best practice is to reference
the resource by means of a string or number conforming to a formal
identification system.</p>
</li>
<li><p class="first"><strong>coverage</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;coverage&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;France&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>the extent or scope of the content of the resource. Coverage will typically
include spatial location (a place name or geographic co-ordinates), temporal
period (a period label, date, or date range) or jurisdiction (such as a named
administrative entity). Recommended best practice is to select a value from a
controlled vocabulary (for example, the <a class="reference external" href="http://www.getty.edu/research/tools/vocabulary/tgn/">Getty Thesaurus of Geographic Names</a>. Where appropriate, named
places or time periods should be used in preference to numeric identifiers such
as sets of co-ordinates or date ranges.</p>
</li>
<li><p class="first"><strong>category</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;category&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="literal string double"><span class="pre">&quot;parent/26323&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;resilience/javascript&quot;</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="literal string double"><span class="pre">&quot;javascript/library/io&quot;</span></span><span class="punctuation"><span class="pre">]}</span></span></tt></p>
<p>the category the resource is associated with. The categories may look like
navigational facets, they correspond to the properties of the resource which
can be generated with metadata or some other information (see <a class="reference external" href="https://en.wikipedia.org/wiki/Faceted_search">faceted search</a>).</p>
</li>
<li><p class="first"><strong>product</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="literal string double"><span class="pre">&quot;product&quot;</span></span><span class="operator"><span class="pre">:</span></span> <span class="literal string double"><span class="pre">&quot;...&quot;</span></span><span class="punctuation"><span class="pre">}</span></span></tt></p>
<p>for e-commerce use.</p>
</li>
<li><p class="first"><strong>custom</strong>, <tt class="code js javascript docutils literal"><span class="punctuation"><span class="pre">{</span></span><span class="name other"><span class="pre">custom1</span></span><span class="operator"><span class="pre">:</span></span> <span class="name other"><span class="pre">value1</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="name other"><span class="pre">custom2</span></span><span class="operator"><span class="pre">:</span></span> <span class="name other"><span class="pre">value2</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">...}</span></span></tt></p>
</li>
</ul>
</div>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<div class="section" id="posting-a-webpage-for-jio">
<h3>Posting a webpage for jIO<a class="headerlink" href="#posting-a-webpage-for-jio" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;identifier&quot;</span> <span class="o">:</span> <span class="s2">&quot;http://domain/jio_home_page&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;text/html&quot;</span><span class="p">,</span> <span class="s2">&quot;52 kB&quot;</span><span class="p">],</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">(),</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Text&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Nexedi&quot;</span><span class="p">,</span> <span class="s2">&quot;Tristan Cavelier&quot;</span><span class="p">,</span> <span class="s2">&quot;Sven Franck&quot;</span><span class="p">],</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;jIO Home Page&quot;</span><span class="p">,</span>
<span class="s2">&quot;subject&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;jIO&quot;</span><span class="p">,</span> <span class="s2">&quot;basics&quot;</span><span class="p">],</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;Simple guide to show the basics of jIO&quot;</span><span class="p">,</span>
<span class="s2">&quot;category&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;resilience/jio&quot;</span><span class="p">,</span> <span class="s2">&quot;webpage&quot;</span><span class="p">],</span>
<span class="s2">&quot;language&quot;</span> <span class="o">:</span> <span class="s2">&quot;en&quot;</span>
<span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
</pre></div>
</div>
</div>
<div class="section" id="posting-jio-library">
<h3>Posting jIO library<a class="headerlink" href="#posting-jio-library" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;identifier&quot;</span> <span class="o">:</span> <span class="s2">&quot;jio.js&quot;</span><span class="p">,</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="s2">&quot;2013-02-15&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="s2">&quot;application/javascript&quot;</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Software&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Tristan Cavelier&quot;</span><span class="p">,</span> <span class="s2">&quot;Sven Franck&quot;</span><span class="p">],</span>
<span class="s2">&quot;publisher&quot;</span> <span class="o">:</span> <span class="s2">&quot;Nexedi&quot;</span><span class="p">,</span>
<span class="s2">&quot;rights&quot;</span> <span class="o">:</span>
<span class="s2">&quot;https://www.j-io.org/documentation/jio-documentation/#copyright-and-license&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;Javascript Input/Output&quot;</span><span class="p">,</span>
<span class="s2">&quot;subject&quot;</span> <span class="o">:</span> <span class="s2">&quot;jIO&quot;</span><span class="p">,</span>
<span class="s2">&quot;category&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;resilience/javascript&quot;</span><span class="p">,</span> <span class="s2">&quot;javascript/library/io&quot;</span><span class="p">]</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;jIO is a client-side JavaScript library to manage &quot;</span> <span class="o">+</span>
<span class="s2">&quot;documents across multiple storages.&quot;</span>
<span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
</pre></div>
</div>
</div>
<div class="section" id="posting-a-webpage-for-interoperability-levels">
<h3>Posting a webpage for interoperability levels<a class="headerlink" href="#posting-a-webpage-for-interoperability-levels" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;identifier&quot;</span> <span class="o">:</span> <span class="s2">&quot;http://dublincore.org/documents/interoperability-levels/&quot;</span><span class="p">,</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="s2">&quot;2009-05-01&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="s2">&quot;text/html&quot;</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Text&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Mikael Nilsson&quot;</span><span class="p">,</span> <span class="s2">&quot;Thomas Baker&quot;</span><span class="p">,</span> <span class="s2">&quot;Pete Johnston&quot;</span><span class="p">],</span>
<span class="s2">&quot;publisher&quot;</span> <span class="o">:</span> <span class="s2">&quot;Dublin Core Metadata Initiative&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;Interoperability Levels for Dublin Core Metadata&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;This document discusses the design choices involved &quot;</span> <span class="o">+</span>
<span class="s2">&quot;in designing applications for different types of &quot;</span> <span class="o">+</span>
<span class="s2">&quot;interoperability. [...]&quot;</span><span class="p">,</span>
<span class="s2">&quot;language&quot;</span> <span class="o">:</span> <span class="s2">&quot;en&quot;</span>
<span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
</pre></div>
</div>
</div>
<div class="section" id="posting-an-image">
<h3>Posting an image<a class="headerlink" href="#posting-an-image" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;identifier&quot;</span> <span class="o">:</span> <span class="s2">&quot;new_york_city_at_night&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;image/jpeg&quot;</span><span class="p">,</span> <span class="s2">&quot;7.2 MB&quot;</span><span class="p">,</span> <span class="s2">&quot;8192 x 4096 pixels&quot;</span><span class="p">],</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="s2">&quot;1999&quot;</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Image&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="s2">&quot;Mr. Someone&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;New York City at Night&quot;</span><span class="p">,</span>
<span class="s2">&quot;subject&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;New York&quot;</span><span class="p">],</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;A photo of New York City taken just after midnight&quot;</span><span class="p">,</span>
<span class="s2">&quot;coverage&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;New York&quot;</span><span class="p">,</span> <span class="s2">&quot;1996-1997&quot;</span><span class="p">]</span>
<span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
</pre></div>
</div>
</div>
<div class="section" id="posting-a-book">
<h3>Posting a book<a class="headerlink" href="#posting-a-book" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;identifier&quot;</span> <span class="o">:</span> <span class="p">{</span><span class="s2">&quot;scheme&quot;</span><span class="o">:</span> <span class="s2">&quot;DCTERMS.URI&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="s2">&quot;urn:ISBN:0385424728&quot;</span><span class="p">},</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="s2">&quot;application/pdf&quot;</span><span class="p">,</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="p">{</span><span class="s2">&quot;scheme&quot;</span><span class="o">:</span> <span class="s2">&quot;DCTERMS.W3CDTF&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="nx">getW3CDate</span><span class="p">()},</span> <span class="c1">// see tools below</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="s2">&quot;Original Author(s)&quot;</span><span class="p">,</span>
<span class="s2">&quot;publisher&quot;</span> <span class="o">:</span> <span class="s2">&quot;Me&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="p">{</span><span class="s2">&quot;lang&quot;</span><span class="o">:</span> <span class="s2">&quot;en&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">},</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="p">{</span><span class="s2">&quot;lang&quot;</span><span class="o">:</span> <span class="s2">&quot;en&quot;</span><span class="p">,</span> <span class="s2">&quot;Summary: ...&quot;</span><span class="p">},</span>
<span class="s2">&quot;language&quot;</span> <span class="o">:</span> <span class="p">{</span><span class="s2">&quot;scheme&quot;</span><span class="o">:</span> <span class="s2">&quot;DCTERMS.RFC4646&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="o">:</span> <span class="s2">&quot;en-GB&quot;</span><span class="p">}</span>
<span class="p">},</span> <span class="nx">callbakcs</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
</pre></div>
</div>
</div>
<div class="section" id="posting-a-video">
<h3>Posting a video<a class="headerlink" href="#posting-a-video" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;identifier&quot;</span> <span class="o">:</span> <span class="s2">&quot;my_video&quot;</span><span class="p">,</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;video/ogg&quot;</span><span class="p">,</span> <span class="s2">&quot;130 MB&quot;</span><span class="p">,</span> <span class="s2">&quot;1080p&quot;</span><span class="p">,</span> <span class="s2">&quot;20 seconds&quot;</span><span class="p">],</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="nx">getW3CDate</span><span class="p">(),</span> <span class="c1">// see tools below</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Video&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="s2">&quot;Me&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;My life&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;A video about my life&quot;</span>
<span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
</pre></div>
</div>
</div>
<div class="section" id="posting-a-job-announcement">
<h3>Posting a job announcement<a class="headerlink" href="#posting-a-job-announcement" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">post</span><span class="p">({</span>
<span class="s2">&quot;format&quot;</span> <span class="o">:</span> <span class="s2">&quot;text/html&quot;</span><span class="p">,</span>
<span class="s2">&quot;date&quot;</span> <span class="o">:</span> <span class="s2">&quot;2013-02-14T14:44Z&quot;</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Text&quot;</span><span class="p">,</span>
<span class="s2">&quot;creator&quot;</span> <span class="o">:</span> <span class="s2">&quot;James Douglas&quot;</span><span class="p">,</span>
<span class="s2">&quot;publisher&quot;</span> <span class="o">:</span> <span class="s2">&quot;Morgan Healey Ltd&quot;</span><span class="p">,</span>
<span class="s2">&quot;title&quot;</span> <span class="o">:</span> <span class="s2">&quot;E-Commerce Product Manager&quot;</span><span class="p">,</span>
<span class="s2">&quot;subject&quot;</span> <span class="o">:</span> <span class="s2">&quot;Job Announcement&quot;</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span> <span class="o">:</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span>
<span class="s2">&quot;language&quot;</span> <span class="o">:</span> <span class="s2">&quot;en-GB&quot;</span><span class="p">,</span>
<span class="s2">&quot;source&quot;</span> <span class="o">:</span> <span class="s2">&quot;James@morganhealey.com&quot;</span><span class="p">,</span>
<span class="s2">&quot;relation&quot;</span> <span class="o">:</span> <span class="p">[</span><span class="s2">&quot;Totaljobs&quot;</span><span class="p">],</span>
<span class="s2">&quot;coverage&quot;</span> <span class="o">:</span> <span class="s2">&quot;London, South East&quot;</span><span class="p">,</span>
<span class="s2">&quot;job_type&quot;</span> <span class="o">:</span> <span class="s2">&quot;Permanent&quot;</span><span class="p">,</span>
<span class="s2">&quot;salary&quot;</span> <span class="o">:</span> <span class="s2">&quot;£45,000 per annum&quot;</span>
<span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span> <span class="c1">// send content as attachment</span>
<span class="c1">// result: http://www.totaljobs.com/JobSeeking/E-Commerce-Product-Manager_job55787655</span>
</pre></div>
</div>
</div>
<div class="section" id="getting-a-list-of-document-created-by-someone">
<h3>Getting a list of document created by someone<a class="headerlink" href="#getting-a-list-of-document-created-by-someone" title="Permalink to this headline"></a></h3>
<p>With complex query:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">allDocs</span><span class="p">({</span><span class="s2">&quot;query&quot;</span><span class="o">:</span> <span class="s2">&quot;creator: \&quot;someone\&quot;&quot;</span><span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="getting-all-documents-about-jio-in-the-resilience-project">
<h3>Getting all documents about jIO in the resilience project<a class="headerlink" href="#getting-all-documents-about-jio-in-the-resilience-project" title="Permalink to this headline"></a></h3>
<p>With complex query:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio</span><span class="p">.</span><span class="nx">allDocs</span><span class="p">({</span><span class="s2">&quot;query&quot;</span><span class="o">:</span> <span class="s2">&quot;subject: \&quot;jIO\&quot; AND category: \&quot;resilience\&quot;&quot;</span><span class="p">},</span> <span class="nx">callbacks</span><span class="p">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="tools">
<h2>Tools<a class="headerlink" href="#tools" title="Permalink to this headline"></a></h2>
<div class="section" id="w3c-date-function">
<h3>W3C Date function<a class="headerlink" href="#w3c-date-function" title="Permalink to this headline"></a></h3>
<div class="highlight-javascript"><div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * Tool to get the date in W3C date format</span>
<span class="cm"> * - &quot;2011-12-13T14:15:16+01:00&quot; with use_utc = false (by default)</span>
<span class="cm"> * - &quot;2011-12-13T13:15:16Z&quot; with use_utc = true</span>
<span class="cm"> *</span>
<span class="cm"> * @param {Boolean} use_utc Use UTC format</span>
<span class="cm"> * @return {String} The date in W3C date format</span>
<span class="cm"> */</span>
<span class="kd">function</span> <span class="nx">getW3CDate</span><span class="p">(</span><span class="nx">use_utc</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">d</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">(),</span> <span class="nx">offset</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">use_utc</span> <span class="o">===</span> <span class="kc">true</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">d</span><span class="p">.</span><span class="nx">toISOString</span><span class="p">();</span>
<span class="p">}</span>
<span class="nx">offset</span> <span class="o">=</span> <span class="o">-</span> <span class="nx">d</span><span class="p">.</span><span class="nx">getTimezoneOffset</span><span class="p">();</span>
<span class="k">return</span> <span class="p">(</span>
<span class="nx">d</span><span class="p">.</span><span class="nx">getFullYear</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span> <span class="o">+</span>
<span class="p">(</span><span class="nx">d</span><span class="p">.</span><span class="nx">getMonth</span><span class="p">()</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span> <span class="o">+</span>
<span class="nx">d</span><span class="p">.</span><span class="nx">getDate</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot;T&quot;</span> <span class="o">+</span>
<span class="nx">d</span><span class="p">.</span><span class="nx">getHours</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot;:&quot;</span> <span class="o">+</span>
<span class="nx">d</span><span class="p">.</span><span class="nx">getMinutes</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot;:&quot;</span> <span class="o">+</span>
<span class="nx">d</span><span class="p">.</span><span class="nx">getSeconds</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot;.&quot;</span> <span class="o">+</span>
<span class="nx">d</span><span class="p">.</span><span class="nx">getMilliseconds</span><span class="p">()</span> <span class="o">+</span>
<span class="p">(</span><span class="nx">offset</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="o">?</span> <span class="s2">&quot;-&quot;</span> <span class="o">:</span> <span class="s2">&quot;+&quot;</span><span class="p">)</span> <span class="o">+</span>
<span class="p">(</span><span class="nx">offset</span> <span class="o">/</span> <span class="mi">60</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;:&quot;</span> <span class="o">+</span>
<span class="p">(</span><span class="nx">offset</span> <span class="o">%</span> <span class="mi">60</span><span class="p">)</span>
<span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/[0-9]+/g</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">found</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">found</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="s1">&#39;0&#39;</span> <span class="o">+</span> <span class="nx">found</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">found</span><span class="p">;</span>
<span class="p">});</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="sources">
<h2>Sources<a class="headerlink" href="#sources" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="https://en.wikipedia.org/wiki/Interoperability">Interoperability definition</a></li>
<li><a class="reference external" href="https://en.wikipedia.org/wiki/Faceted_search">Faceted search</a></li>
<li><a class="reference external" href="http://dublincore.org/">DublinCore</a><ul>
<li><a class="reference external" href="http://dublincore.org/documents/interoperability-levels/">Interoperability levels</a></li>
<li><a class="reference external" href="http://dublincore.org/documents/usageguide/elements.shtml">Metadata elements</a></li>
<li><a class="reference external" href="http://www.chu-rouen.fr/documed/eahilsantander.html">http://www.chu-rouen.fr/documed/eahilsantander.html</a></li>
<li><a class="reference external" href="http://openweb.eu.org/articles/dublin_core">http://openweb.eu.org/articles/dublin_core</a> (French)</li>
</ul>
</li>
<li><a class="reference external" href="https://couchdb.apache.org/">CouchDB</a></li>
<li><a class="reference external" href="http://www.w3.org/RDF/">Resource Description Framework (RDF)</a></li>
<li><a class="reference external" href="https://en.wikipedia.org/wiki/Five_Ws">Five Ws</a></li>
<li><a class="reference external" href="https://en.wikipedia.org/wiki/Metadata">Metadata</a></li>
<li>MIME Types<ul>
<li><a class="reference external" href="https://en.wikipedia.org/wiki/Internet_media_type">https://en.wikipedia.org/wiki/Internet_media_type</a></li>
<li><a class="reference external" href="https://www.iana.org/assignments/media-types">https://www.iana.org/assignments/media-types</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Metadata</a><ul>
<li><a class="reference internal" href="#what-is-metadata">What is metadata?</a></li>
<li><a class="reference internal" href="#why-use-metadata">Why use metadata?</a></li>
<li><a class="reference internal" href="#how-to-format-metadata-with-jio">How to format metadata with jIO</a></li>
<li><a class="reference internal" href="#list-of-metadata-to-use">List of metadata to use</a><ul>
<li><a class="reference internal" href="#identification">Identification</a></li>
<li><a class="reference internal" href="#intellectual-property">Intellectual property</a></li>
<li><a class="reference internal" href="#content">Content</a></li>
</ul>
</li>
<li><a class="reference internal" href="#examples">Examples</a><ul>
<li><a class="reference internal" href="#posting-a-webpage-for-jio">Posting a webpage for jIO</a></li>
<li><a class="reference internal" href="#posting-jio-library">Posting jIO library</a></li>
<li><a class="reference internal" href="#posting-a-webpage-for-interoperability-levels">Posting a webpage for interoperability levels</a></li>
<li><a class="reference internal" href="#posting-an-image">Posting an image</a></li>
<li><a class="reference internal" href="#posting-a-book">Posting a book</a></li>
<li><a class="reference internal" href="#posting-a-video">Posting a video</a></li>
<li><a class="reference internal" href="#posting-a-job-announcement">Posting a job announcement</a></li>
<li><a class="reference internal" href="#getting-a-list-of-document-created-by-someone">Getting a list of document created by someone</a></li>
<li><a class="reference internal" href="#getting-all-documents-about-jio-in-the-resilience-project">Getting all documents about jIO in the resilience project</a></li>
</ul>
</li>
<li><a class="reference internal" href="#tools">Tools</a><ul>
<li><a class="reference internal" href="#w3c-date-function">W3C Date function</a></li>
</ul>
</li>
<li><a class="reference internal" href="#sources">Sources</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="complex_queries.html"
title="previous chapter">jIO Complex Queries</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="developers.html"
title="next chapter">For developers</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/metadata.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="developers.html" title="For developers"
>next</a> |</li>
<li class="right" >
<a href="complex_queries.html" title="jIO Complex Queries"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript Naming Conventions &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="Authors" href="authors.html" />
<link rel="prev" title="For developers" href="developers.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="authors.html" title="Authors"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="developers.html" title="For developers"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="javascript-naming-conventions">
<span id="naming-conventions"></span><h1>JavaScript Naming Conventions<a class="headerlink" href="#javascript-naming-conventions" title="Permalink to this headline"></a></h1>
<p>This document defines JavaScript naming conventions, which are split into essential, coding and naming conventions.</p>
<div class="section" id="essential-conventions">
<h2>Essential Conventions<a class="headerlink" href="#essential-conventions" title="Permalink to this headline"></a></h2>
<p>Essential conventions include generic patterns that should be adhered to in order to write <em>readable</em>, <em>consistent</em> and <em>maintainable</em> code.</p>
<div class="section" id="minimizing-globals">
<h3>Minimizing Globals<a class="headerlink" href="#minimizing-globals" title="Permalink to this headline"></a></h3>
<p>Variable declarations should always be done using <em>var</em> to not declare them as
global variables. This avoids conflicts from using a variable name across
different functions as well as conflicts with global variables declared by third
party plugins.</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">sum</span><span class="p">(</span><span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">x</span> <span class="o">+</span> <span class="nx">y</span><span class="p">;</span>
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">sum</span><span class="p">(</span><span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// missing var declaration, implied global</span>
<span class="nx">result</span> <span class="o">=</span> <span class="nx">x</span> <span class="o">+</span> <span class="nx">y</span><span class="p">;</span>
<span class="k">return</span> <span class="nx">result</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="use-jslint">
<h3>Use JSLint<a class="headerlink" href="#use-jslint" title="Permalink to this headline"></a></h3>
<p><a class="reference external" href="http://www.jslint.com/">JSLint</a> is a quality tool that inspects code and warns
about potential problems. It is available online and can also be integrated
into several development environments, so errors will be highlighted when
writing code.</p>
<p>Before validating your code in JSLint, you should use a code
beautifier to fix basic syntax errors (like indentation) automatically. There
are a number of beautifiers available online. The following ones seem to work best:</p>
<ul class="simple">
<li><a class="reference external" href="http://jsbeautifier.org/">JSbeautifier.org</a></li>
<li><a class="reference external" href="http://alexis.m2osw.com/js-beautify/">JS-Beautify</a></li>
</ul>
<p>In this project, JavaScript sources have to begin with the header: <tt class="code js javascript docutils literal"><span class="comment multiline"><span class="pre">/*jslint</span> <span class="pre">indent:</span> <span class="pre">2,</span>
<span class="pre">maxlen:</span> <span class="pre">80,</span> <span class="pre">nomen:</span> <span class="pre">true</span> <span class="pre">*/</span></span></tt>, which means it uses two spaces indentation, 80
maximum characters per line and the use of &#8216;_&#8217; as first character in a variable name is allowed.
Other JSLint options can be added in sub functions if necessary.</p>
<p>Some allowed options are:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">ass:</span> <span class="pre">true</span></tt> if assignment should be allowed outside of statement position.</li>
<li><tt class="docutils literal"><span class="pre">bitwise:</span> <span class="pre">true</span></tt> if bitwise operators should be allowed.</li>
<li><tt class="docutils literal"><span class="pre">continue:</span> <span class="pre">true</span></tt> if the continue statement should be allowed.</li>
<li><tt class="docutils literal"><span class="pre">newcap:</span> <span class="pre">true</span></tt> if Initial Caps with constructor function is optional.</li>
<li><tt class="docutils literal"><span class="pre">regexp:</span> <span class="pre">true</span></tt> if <tt class="docutils literal"><span class="pre">.</span></tt> and <tt class="docutils literal"><span class="pre">[^...]</span></tt> 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.</li>
<li><tt class="docutils literal"><span class="pre">unparam:</span> <span class="pre">true</span></tt> if warnings should be silenced for unused parameters.</li>
</ul>
</div>
</div>
<div class="section" id="coding-conventions">
<h2>Coding Conventions<a class="headerlink" href="#coding-conventions" title="Permalink to this headline"></a></h2>
<p>Coding conventions include generic patterns that ensure that written code follows certain formatting conventions.</p>
<div class="section" id="uses-two-space-indentation">
<h3>Uses two-space indentation<a class="headerlink" href="#uses-two-space-indentation" title="Permalink to this headline"></a></h3>
<p>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
prevents these errors up front.</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">outer</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="nx">d</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span>
<span class="nx">inner</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">a</span> <span class="o">&gt;</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">inner</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;r&quot;</span><span class="o">:</span> <span class="nx">c</span> <span class="o">-</span> <span class="nx">d</span>
<span class="p">};</span>
<span class="p">};</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">inner</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;r&quot;</span><span class="o">:</span> <span class="nx">c</span> <span class="o">+</span> <span class="nx">d</span>
<span class="p">};</span>
<span class="p">};</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">inner</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">outer</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="nx">d</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span>
<span class="nx">inner</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">a</span> <span class="o">&gt;</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">inner</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="nx">r</span><span class="o">:</span> <span class="nx">c</span> <span class="o">-</span> <span class="nx">d</span>
<span class="p">}}}};</span>
</pre></div>
</div>
</div>
<div class="section" id="using-shorthand-for-conditional-statements">
<h3>Using shorthand for conditional statements<a class="headerlink" href="#using-shorthand-for-conditional-statements" title="Permalink to this headline"></a></h3>
<p>An alternative for using braces is the shorthand notation for conditional
statements. When using multiple conditions, the conditional statement can be
split on multiple lines.</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// single line</span>
<span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="nx">test</span> <span class="o">===</span> <span class="kc">true</span> <span class="o">?</span> <span class="nx">alert</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">:</span> <span class="nx">alert</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span>
<span class="c1">// multiple lines</span>
<span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="p">(</span><span class="nx">test</span> <span class="o">===</span> <span class="kc">true</span> <span class="o">&amp;&amp;</span> <span class="nx">number</span> <span class="o">===</span> <span class="kc">undefined</span> <span class="o">?</span>
<span class="nx">alert</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">:</span> <span class="nx">alert</span><span class="p">(</span><span class="mi">2</span><span class="p">));</span>
<span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="p">(</span><span class="nx">test</span> <span class="o">===</span> <span class="kc">true</span> <span class="o">?</span>
<span class="nx">alert</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">:</span> <span class="nx">number</span> <span class="o">===</span> <span class="kc">undefined</span> <span class="o">?</span>
<span class="nx">alert</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">:</span> <span class="nx">alert</span><span class="p">(</span><span class="mi">3</span><span class="p">));</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// multiple conditions</span>
<span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="p">(</span><span class="nx">test</span> <span class="o">===</span> <span class="kc">true</span> <span class="o">&amp;&amp;</span> <span class="nx">number</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="o">?</span>
<span class="nx">alert</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">:</span>
<span class="nx">alert</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="opening-brace-location">
<h3>Opening Brace Location<a class="headerlink" href="#opening-brace-location" title="Permalink to this headline"></a></h3>
<p>Always put the opening brace on the same line as the previous statement.</p>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">func</span><span class="p">()</span>
<span class="p">{</span>
<span class="k">return</span>
<span class="p">{</span>
<span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;Batman&quot;</span>
<span class="p">};</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">func</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;Batman&quot;</span>
<span class="p">};</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="closing-brace-location">
<h3>Closing Brace Location<a class="headerlink" href="#closing-brace-location" title="Permalink to this headline"></a></h3>
<p>The closing brace should be on the same indent level as the original function call.</p>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">func</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;Batman&quot;</span>
<span class="p">};</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">func</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;Batman&quot;</span>
<span class="p">};</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="function-declaration-location">
<h3>Function Declaration Location<a class="headerlink" href="#function-declaration-location" title="Permalink to this headline"></a></h3>
<p>Non anonymous functions should be declared before use.</p>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// [...]</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;namedFunction&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="nx">namedFunction</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">};</span>
</pre></div>
</div>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// [...]</span>
<span class="kd">function</span> <span class="nx">namedFunction</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s2">&quot;namedFunction&quot;</span><span class="o">:</span> <span class="nx">namedFunction</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="id1">
<h2>Naming Conventions<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2>
<p>Naming conventions include generic patterns for setting names and identifiers throughout a script.</p>
<div class="section" id="constructors">
<h3>Constructors<a class="headerlink" href="#constructors" title="Permalink to this headline"></a></h3>
<p>Constructor functions (called with the <tt class="docutils literal"><span class="pre">new</span></tt> statement) should always start with a capital letter:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// bad example</span>
<span class="kd">var</span> <span class="nx">test</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">application</span><span class="p">();</span>
<span class="c1">// good example</span>
<span class="kd">var</span> <span class="nx">test</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Application</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="methods-functions">
<h3>Methods/Functions<a class="headerlink" href="#methods-functions" title="Permalink to this headline"></a></h3>
<p>A method/function should always start with a small letter.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// bad example</span>
<span class="kd">function</span> <span class="nx">MyFunction</span><span class="p">()</span> <span class="p">{...}</span>
<span class="c1">// good example</span>
<span class="kd">function</span> <span class="nx">myFunction</span><span class="p">()</span> <span class="p">{...}</span>
</pre></div>
</div>
</div>
<div class="section" id="titlecase-camelcase">
<h3>TitleCase, camelCase<a class="headerlink" href="#titlecase-camelcase" title="Permalink to this headline"></a></h3>
<p>Follow the camel case convention, typing the words in lower-case, only capitalizing the first letter in each word.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// Good example constructor = TitleCase</span>
<span class="kd">var</span> <span class="nx">test</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">PrototypeApplication</span><span class="p">();</span>
<span class="c1">// Bad example constructor</span>
<span class="kd">var</span> <span class="nx">test</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">PROTOTYPEAPPLICATION</span><span class="p">();</span>
<span class="c1">// Good example functions/methods = camelCase</span>
<span class="nx">myFunction</span><span class="p">();</span>
<span class="nx">calculateArea</span><span class="p">();</span>
<span class="c1">// Bad example functions/methods</span>
<span class="nx">MyFunction</span><span class="p">();</span>
<span class="nx">CalculateArea</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="variables">
<h3>Variables<a class="headerlink" href="#variables" title="Permalink to this headline"></a></h3>
<p>Variable names with multiple words should always use an underscore between them.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// bad example</span>
<span class="kd">var</span> <span class="nx">deliveryNote</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">// good example</span>
<span class="kd">var</span> <span class="nx">delivery_note</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
</pre></div>
</div>
<p>Confusing variable names should end with the variable type.</p>
<p>Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// implicit type</span>
<span class="kd">var</span> <span class="nx">my_callback</span> <span class="o">=</span> <span class="nx">doSomething</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">Person</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s2">&quot;./person&quot;</span><span class="p">);</span>
<span class="c1">// confusing names + var type</span>
<span class="kd">var</span> <span class="nx">do_something_function</span> <span class="o">=</span> <span class="nx">doSomething</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="nx">context</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">value_list</span> <span class="o">=</span> <span class="nx">getObjectOrArray</span><span class="p">();</span>
<span class="c1">// value_list can be an object which can be cast into an array</span>
</pre></div>
</div>
<p>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.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// good example</span>
<span class="kd">var</span> <span class="nx">doSomethingFunction</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="p">...</span> <span class="p">};</span>
<span class="c1">// or</span>
<span class="kd">var</span> <span class="nx">tool</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;doSomething&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}};</span>
<span class="c1">// bad example</span>
<span class="kd">var</span> <span class="nx">doSomething</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="p">...</span> <span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="element-classes-and-ids">
<h3>Element Classes and IDs<a class="headerlink" href="#element-classes-and-ids" title="Permalink to this headline"></a></h3>
<p>JavaScript can access elements by their ID attribute and class names. When
assigning IDs and class names with multiple words, these should also be
separated by an underscore (same as variables).</p>
<p>Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// bad example</span>
<span class="nx">test</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;id&quot;</span><span class="p">,</span> <span class="s2">&quot;uniqueIdentifier&quot;</span><span class="p">);</span>
<span class="c1">// good example</span>
<span class="nx">test</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;id&quot;</span><span class="p">,</span> <span class="s2">&quot;unique_identifier&quot;</span><span class="p">);</span>
</pre></div>
</div>
<p>Discuss - checked with jQuery UI/jQuery Mobile, they don&#8217;t use written name conventions, only</p>
<ul class="simple">
<li>events names should fit their purpose (pageChange for changing a page)</li>
<li>element classes use “-” like in ui-shadow</li>
<li>&#8220;ui&#8221; should not be used by third party developers</li>
<li>variables and events use lower camel-case like pageChange and activePage</li>
</ul>
</div>
<div class="section" id="underscore-private-methods">
<h3>Underscore Private Methods<a class="headerlink" href="#underscore-private-methods" title="Permalink to this headline"></a></h3>
<p>Private methods should use a leading underscore to separate them from public methods (although this does not technically make a method private).</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">person</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;getName&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getFirst</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getLast</span><span class="p">();</span>
<span class="p">},</span>
<span class="s2">&quot;_getFirst&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="c1">// ...</span>
<span class="p">},</span>
<span class="s2">&quot;_getLast&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="c1">// ...</span>
<span class="p">}</span>
<span class="p">};</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">person</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;getName&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">getFirst</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLast</span><span class="p">();</span>
<span class="p">},</span>
<span class="c1">// private function</span>
<span class="s2">&quot;getFirst&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="c1">// ...</span>
<span class="p">}</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="no-abbreviations">
<h3>No Abbreviations<a class="headerlink" href="#no-abbreviations" title="Permalink to this headline"></a></h3>
<p>Abbreviations should not be used to avoid confusion.</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// delivery note</span>
<span class="kd">var</span> <span class="nx">delivery_note</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// delivery note</span>
<span class="kd">var</span> <span class="nx">del_note</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="no-plurals">
<h3>No Plurals<a class="headerlink" href="#no-plurals" title="Permalink to this headline"></a></h3>
<p>Plurals should not be used as variable names.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// good example</span>
<span class="kd">var</span> <span class="nx">delivery_note_list</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;one&quot;</span><span class="p">,</span> <span class="s2">&quot;two&quot;</span><span class="p">];</span>
<span class="c1">// bad example</span>
<span class="kd">var</span> <span class="nx">delivery_notes</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;one&quot;</span><span class="p">,</span> <span class="s2">&quot;two&quot;</span><span class="p">];</span>
</pre></div>
</div>
</div>
<div class="section" id="use-comments">
<h3>Use Comments<a class="headerlink" href="#use-comments" title="Permalink to this headline"></a></h3>
<p>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.</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">person</span> <span class="o">=</span> <span class="p">{</span>
<span class="c1">// returns full name string</span>
<span class="s2">&quot;getName&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getFirst</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getLast</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">};</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">person</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;getName&quot;</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getFirst</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getLast</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="documentation">
<h3>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline"></a></h3>
<p>You can use <a class="reference external" href="http://yuilibrary.com/projects/yuidoc">YUIDoc</a> and its custom comment
tags together with Node.js to generate the documentation from the script file
itself. Comments should look like this:</p>
<p>Good Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * Reverse a string</span>
<span class="cm"> *</span>
<span class="cm"> * @param {String} input_string String to reverse</span>
<span class="cm"> * @return {String} The reversed string</span>
<span class="cm"> */</span>
<span class="kd">function</span> <span class="nx">reverse</span><span class="p">(</span><span class="nx">input_string</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// ...</span>
<span class="k">return</span> <span class="nx">output_string</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
<p>Bad Example</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">reverse</span><span class="p">(</span><span class="nx">input_string</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// ...</span>
<span class="k">return</span> <span class="nx">output_string</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="additional-readings">
<h2>Additional Readings<a class="headerlink" href="#additional-readings" title="Permalink to this headline"></a></h2>
<p>Resources, additional reading materials and links:</p>
<ul class="simple">
<li><a class="reference external" href="http://shop.oreilly.com/product/9780596806767.do">JavaScript Patterns</a>, main ressource used.</li>
<li><a class="reference external" href="http://www.jslint.com/">JSLint</a>, code quality.</li>
<li><a class="reference external" href="http://yuilibrary.com/projects/yuidoc">YUIDoc</a>, generate documentation from code.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">JavaScript Naming Conventions</a><ul>
<li><a class="reference internal" href="#essential-conventions">Essential Conventions</a><ul>
<li><a class="reference internal" href="#minimizing-globals">Minimizing Globals</a></li>
<li><a class="reference internal" href="#use-jslint">Use JSLint</a></li>
</ul>
</li>
<li><a class="reference internal" href="#coding-conventions">Coding Conventions</a><ul>
<li><a class="reference internal" href="#uses-two-space-indentation">Uses two-space indentation</a></li>
<li><a class="reference internal" href="#using-shorthand-for-conditional-statements">Using shorthand for conditional statements</a></li>
<li><a class="reference internal" href="#opening-brace-location">Opening Brace Location</a></li>
<li><a class="reference internal" href="#closing-brace-location">Closing Brace Location</a></li>
<li><a class="reference internal" href="#function-declaration-location">Function Declaration Location</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id1">Naming Conventions</a><ul>
<li><a class="reference internal" href="#constructors">Constructors</a></li>
<li><a class="reference internal" href="#methods-functions">Methods/Functions</a></li>
<li><a class="reference internal" href="#titlecase-camelcase">TitleCase, camelCase</a></li>
<li><a class="reference internal" href="#variables">Variables</a></li>
<li><a class="reference internal" href="#element-classes-and-ids">Element Classes and IDs</a></li>
<li><a class="reference internal" href="#underscore-private-methods">Underscore Private Methods</a></li>
<li><a class="reference internal" href="#no-abbreviations">No Abbreviations</a></li>
<li><a class="reference internal" href="#no-plurals">No Plurals</a></li>
<li><a class="reference internal" href="#use-comments">Use Comments</a></li>
<li><a class="reference internal" href="#documentation">Documentation</a></li>
</ul>
</li>
<li><a class="reference internal" href="#additional-readings">Additional Readings</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="developers.html"
title="previous chapter">For developers</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="authors.html"
title="next chapter">Authors</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/naming_conventions.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="authors.html" title="Authors"
>next</a> |</li>
<li class="right" >
<a href="developers.html" title="For developers"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
# Sphinx inventory version 2
# Project: jIO
# Version: 2.0.0
# The remainder of this file is compressed using zlib.
xmN@ Duz冨IݬRڿoh@*y3Gơ &zcv =v &[6{Z[K8qHNB'ǟJ OXՃ;& xL/yvX5R3ߒi9R5'&Ի4vFҳI?V}ݿ@xVL&#Җ2߆+xA yF-ͬMHwHkj_k#X
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Revision Storages: Conflicts and Resolution &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<link rel="next" title="List of Available Storages" href="available_storages.html" />
<link rel="prev" title="How to manage documents?" href="manage_documents.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="available_storages.html" title="List of Available Storages"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="manage_documents.html" title="How to manage documents?"
accesskey="P">previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="revision-storages-conflicts-and-resolution">
<h1>Revision Storages: Conflicts and Resolution<a class="headerlink" href="#revision-storages-conflicts-and-resolution" title="Permalink to this headline"></a></h1>
<div class="section" id="why-conflicts-can-occur">
<h2>Why Conflicts can Occur<a class="headerlink" href="#why-conflicts-can-occur" title="Permalink to this headline"></a></h2>
<p>Using jIO you can store documents in multiple storage locations. With
increasing number of users working on a document and some storages not being
available or responding too slow, conflicts are more likely to occur. jIO
defines a conflict as multiple versions of a document existing in a storage
tree and a user trying to save on a version that does not match the latest
version of the document.</p>
<p>To keep track of document versions a revision storage must be used. When doing
so, jIO creates a document tree file for every document. This file contains all
existing versions and their status and is modified whenever a version is
added/updated/removed or when storages are being synchronized.</p>
</div>
<div class="section" id="how-to-solve-conflicts">
<h2>How to solve conflicts<a class="headerlink" href="#how-to-solve-conflicts" title="Permalink to this headline"></a></h2>
<p>Using the document tree, jIO tries to make every version of a document
available on every storage. When multiple versions of a document exist, jIO
will select the <strong>latest</strong>, <strong>left-most</strong> version on the document tree, along with the
conflicting versions (when option <strong>conflicts: true</strong> is set in order for
developers to setup a routine to solve conflicts.</p>
<p>Technically a conflict is solved by deleting alternative versions of a document
(&#8220;cutting leaves off from the document tree&#8221;). When a user decides to keep a
version of a document and manually deletes all conflicting versions, the
storage tree is updated accordingly and the document is available in a single
version on all storages.</p>
</div>
<div class="section" id="simple-conflict-example">
<h2>Simple Conflict Example<a class="headerlink" href="#simple-conflict-example" title="Permalink to this headline"></a></h2>
<p>You are keeping a namecard file on your PC updating from your smartphone. Your
smartphone ran out of battery and is offline when you update your namecard on
your PC with your new email adress. Someone else changes this email from your PC
and once your smartphone is recharged, you go back online and the previous
update is executed.</p>
<ol class="arabic simple">
<li>Set up the storage tree</li>
</ol>
<blockquote>
<div><div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">jio_instance</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">newJio</span><span class="p">({</span>
<span class="c1">// replicate revision storage</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span><span class="s2">&quot;replicaterevision&quot;</span><span class="p">,</span>
<span class="s2">&quot;storagelist&quot;</span><span class="o">:</span><span class="p">[{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;revision&quot;</span><span class="p">,</span>
<span class="s2">&quot;sub_storage&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;dav&quot;</span><span class="p">,</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="p">},</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;revision&quot;</span><span class="p">,</span>
<span class="s2">&quot;sub_storage&quot;</span><span class="o">:</span> <span class="p">{</span>
<span class="s2">&quot;type&quot;</span><span class="o">:</span> <span class="s2">&quot;local&quot;</span><span class="p">,</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="p">}]</span>
<span class="p">});</span>
</pre></div>
</div>
</div></blockquote>
<ol class="arabic">
<li><p class="first">Create the namecard on your smartphone</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">post</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span><span class="p">,</span>
<span class="s2">&quot;email&quot;</span><span class="o">:</span> <span class="s2">&quot;me@web.com&quot;</span>
<span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;1-5782E71F1E4BF698FA3793D9D5A96393&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
<p>This will create the document on your webDav and local storage</p>
</li>
<li><p class="first">Someone else updates your shared namecard on Webdav</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;email&quot;</span><span class="o">:</span> <span class="s2">&quot;my_new_me@web.com&quot;</span><span class="p">,</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span>
<span class="s2">&quot;_rev&quot;</span><span class="o">:</span> <span class="s2">&quot;1-5782E71F1E4BF698FA3793D9D5A96393&quot;</span>
<span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;2-068E73F5B44FEC987B51354DFC772891&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
<p>Your smartphone is offline, so now you will have one version (1-578...) on
your smartphone and another version on webDav (2-068...) on your PC.</p>
</li>
<li><p class="first">You modify the namecard while being offline</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">get</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span><span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;1-5782E71F1E4BF698FA3793D9D5A96393&quot;</span>
<span class="c1">// response.data.email -&gt; &quot;me@web.com&quot;</span>
<span class="k">return</span> <span class="nx">jio_instance</span><span class="p">.</span><span class="nx">put</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span><span class="p">,</span>
<span class="s2">&quot;email&quot;</span><span class="o">:</span> <span class="s2">&quot;me_again@web.com&quot;</span>
<span class="p">});</span>
<span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;2-3753476B70A49EA4D8C9039E7B04254C&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
</li>
<li><p class="first">Later, your smartphone is online and you retrieve the other version of the namecard.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">get</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span><span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;2-3753476B70A49EA4D8C9039E7B04254C&quot;</span>
<span class="c1">// response.data.email -&gt; &quot;me_again@web.com&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
<p>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...).</p>
</li>
<li><p class="first">Retrieve conflicts by setting option</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">get</span><span class="p">({</span><span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span><span class="p">},</span> <span class="p">{</span>
<span class="s2">&quot;conflicts&quot;</span><span class="o">:</span> <span class="kc">true</span>
<span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;2-3753476B70A49EA4D8C9039E7B04254C&quot;,</span>
<span class="c1">// response.conflicts -&gt; [&quot;2-068E73F5B44FEC987B51354DFC772891&quot;]</span>
<span class="p">});</span>
</pre></div>
</div>
<p>The conflicting version (<em>2-068E...</em>) is displayed, because <strong>{conflicts: true}</strong> was
specified in the GET call. Deleting either version will solve the conflict.</p>
</li>
<li><p class="first">Delete conflicting version</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">jio_instance</span><span class="p">.</span><span class="nx">remove</span><span class="p">({</span>
<span class="s2">&quot;_id&quot;</span><span class="o">:</span> <span class="s2">&quot;myNameCard&quot;</span><span class="p">,</span>
<span class="s2">&quot;_rev&quot;</span><span class="o">:</span> <span class="s2">&quot;2-068E73F5B44FEC987B51354DFC772891&quot;</span>
<span class="p">}).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">response</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// response.id -&gt; &quot;myNameCard&quot;</span>
<span class="c1">// response.rev -&gt; &quot;3-28910A4937537B5168E772896B70EC98&quot;</span>
<span class="p">});</span>
</pre></div>
</div>
<p>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
deleted. All storages now contain just a single version of the namecard
(2-3753...). Note that, on the document tree, removing a revison will
create a new revision with status set to <em>deleted</em>.</p>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Revision Storages: Conflicts and Resolution</a><ul>
<li><a class="reference internal" href="#why-conflicts-can-occur">Why Conflicts can Occur</a></li>
<li><a class="reference internal" href="#how-to-solve-conflicts">How to solve conflicts</a></li>
<li><a class="reference internal" href="#simple-conflict-example">Simple Conflict Example</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="manage_documents.html"
title="previous chapter">How to manage documents?</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="available_storages.html"
title="next chapter">List of Available Storages</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/revision_storages.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="available_storages.html" title="List of Available Storages"
>next</a> |</li>
<li class="right" >
<a href="manage_documents.html" title="How to manage documents?"
>previous</a> |</li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search &mdash; jIO 2.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '2.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/searchtools.js"></script>
<link rel="top" title="jIO 2.0.0 documentation" href="index.html" />
<script type="text/javascript">
jQuery(function() { Search.loadIndex("searchindex.js"); });
</script>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1 id="search-documentation">Search</h1>
<div id="fallback" class="admonition warning">
<script type="text/javascript">$('#fallback').hide();</script>
<p>
Please activate JavaScript to enable the search
functionality.
</p>
</div>
<p>
From here you can search these documents. Enter your search
words into the box below and click "search". Note that the search
function will automatically search for all of the words. Pages
containing fewer words won't appear in the result list.
</p>
<form action="" method="get">
<input type="text" name="q" value="" />
<input type="submit" value="search" />
<span id="search-progress" style="padding-left: 10px"></span>
</form>
<div id="search-results">
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/jio-logo.png" alt="Logo"/>
</a></p>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li><a href="index.html">jIO 2.0.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2013, Nexedi.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
\ No newline at end of file
Search.setIndex({objects:{},terms:{represent:12,all:[4,1,2,5,7,10,11,12],code:[9,0,11,12,6],rfc4646:12,workspac:2,chain:7,whatev:4,queri:[0,1,2,4,5,12],grunt:11,global:[4,6],job_typ:12,w3cdtf:12,mp3:12,boolean_express:1,follow:[5,7,11,12,6],other_keys_and_valu:1,categori:12,decid:[10,11,2],nodej:11,depend:[5,0,9,11,4],system:[5,7,12],xml:12,base64:2,readabl:[1,2,6],attachment_data:11,send:[1,12],articl:12,program:7,under:3,larg:[1,7],sha256:[5,9,7],"1080p":12,"068e":10,digit:12,sourc:[9,0,12,3,6],everi:[5,10],string:[4,1,2,6,7,11,12],fals:[11,12],rise:[],caveli:[12,8],account:12,unfamiliar:[],util:11,graphic:12,veri:12,retriev:[5,10,1,7],brows:1,tri:10,and_express:1,contenttyp:4,administr:12,level:[12,6],descend:1,scalabl:7,list:[0,1,2,4,5,7,12],upload:12,"try":[10,1,11],item:1,commonj:7,quick:[0,11],getdat:12,refer:[1,11,12],servic:12,"20th":1,pleas:11,prevent:[5,6],healei:12,cap:6,abil:12,ten:[5,1],binary_str:11,natur:12,dimens:12,convertstringtoregexp:1,"13t13":12,second:[11,12],design:[5,0,11,12],aggreg:12,"13t14":12,download:[5,0,9,11],compat:[5,4,9,2],index:[5,4,1,2],what:[0,1,5,6,7,11,12],abc:7,newcap:6,sub:[4,2,6],compar:1,defin:[4,1,2,5,6,10,11,12],sum:6,abl:[5,1,2],invok:5,uniform:12,access:[1,12,7,6],delet:[5,10,7,2],abbrevi:6,version:[0,2,5,7,9,10],"new":[2,5,6,7,10,11,12],calculatearea:6,row:7,setattribut:6,method:[0,1,2,5,6,7,11],metadata:[0,2,4,7,11,12],gethour:12,full:[1,12,2,6],deriv:12,newjio:[10,7],gener:[4,1,12,2,6],never:2,privat:6,here:[4,7,2,3],bodi:[7,2],lgpl:3,let:11,path:[5,12],along:10,replicaterevisionstorag:[9,4],modifi:10,sinc:6,valu:[4,1,11,7,12],wait:11,dublic:12,search:[0,1,12],samedocumentid:11,include_doc:[4,7,2],across:[5,12,6],dublin:12,queue:[5,11,2],jame:[1,12],amount:1,rdf:12,action:[11,2],implement:[11,2],human_read:1,via:7,shorthand:6,iana:12,danger:2,auth_typ:2,modul:[5,1],offset:12,prefer:12,ipr:12,ask:1,api:[5,1,11,7],dav_storag:2,job_rul:11,wip:9,instal:11,do_something_funct:6,"28910a4937537b5168e772896b70ec98":10,select:[10,1,11,12],franck:[12,8],from:[10,1,12,6],describ:12,would:1,memori:2,myvideo:7,two:[5,7,11,12,6],coverag:12,connector:[5,0,1,2,9],complex_queri:[5,9,1,11],handler:[5,0,9,2,4],call:[1,5,6,7,10,11],value2:[4,12],value1:[4,12],recommend:12,taken:12,scope:12,care:2,type:[4,1,2,6,7,10,11,12],until:11,more:[10,7,3,6],sort:1,capit:6,progressioncallback:7,createdescript:2,comparison:11,relat:12,enhanc:5,warn:6,phone:12,manager_job55787655:12,prototyp:11,known:12,content_typ:[7,11],must:[4,1,2,10,11,12],topic:12,none:2,jssha2:9,join:1,err:7,restor:5,setup:[10,11],work:[0,2,5,6,10,12],uniqu:4,dev:11,histori:2,other:[1,2,6,7,10,12],tag:[12,6],dublin_cor:12,morgan:12,arewrit:11,purpos:6,control:12,tab:6,process:11,dcmityp:4,share:10,custom1:12,indic:[1,2,12],high:7,"_attach":[7,11],caution:4,want:[5,4,1,11],onlin:[10,6],phrase:12,serial:1,made:[7,12],occur:[0,10],contribut:12,alwai:[1,6],end:[11,6],eng:12,deliverynot:6,anoth:[10,1,11,2],object_list:1,write:[1,6],how:[0,1,5,7,10,11,12],reject:11,answer:1,place:[4,12],left_parenthes:1,updat:[5,10,7,11,2],npm:11,map:[5,7],product:12,recogn:1,clone:[9,11],after:[5,7,11,12],befor:[1,11,6],catalog:12,offlin:[4,10],date:[4,12],multipl:[5,10,12,6],underscor:[4,6],data:[4,7,11,12,10],physic:12,github:[9,7],essenti:[0,6],practic:12,third:[11,6],read:[5,0,7,9,6],bind:[11,6],secur:[2,6],correspond:12,replicaterevis:10,element:[1,12,6],inform:[5,1,12,3,6],maintain:[5,1,6],combin:4,thesauru:12,allow:[5,7,6],parti:6,order:[5,10,1,6],oper:[1,12,6],w3c:12,six:[],help:[11,12],repair:[5,11],"_rev":[10,2],"068e73f5b44fec987b51354dfc772891":10,midnight:12,indexstorag:[9,1,2],jpeg:[7,12],held:12,london:12,localstorag:[0,1,2,5,7,9,11],equip:12,still:2,digest:[7,2],paramet:[7,11,2,6],conjunct:12,outer:6,thank:[1,11],fit:6,jio:[0,1,2,3,4,5,7,9,10,11,12],fix:6,complex:[5,0,1,12,4],mystorag:11,main:[5,7,6],might:6,pixel:12,rsvp:[5,9,7],them:[7,12,6],good:[11,6],"return":[4,2,6,7,10,11,12],greater:1,thei:[11,12,6],francoi:8,handl:1,promin:12,auth:2,repositori:11,mention:1,dav:[4,2,10],"_valu":11,storage_descript:[5,11],front:6,isgetmethod:11,now:[10,11],discuss:[12,6],introduct:[5,0],choic:12,term:12,grammar:[0,1],name:[0,1,4,6,11,12],anyth:4,edit:4,simpl:[0,1,2,7,10,12],revers:6,smartphon:10,authent:2,separ:6,easili:12,mode:2,each:[1,7,6],found:[7,3,12],notif:7,side:[1,12],bond:1,compil:[1,11,7],last_modifi:1,replac:[0,11,12],dataset:[2,12],continu:6,my_video:[7,12],realli:11,ensur:6,meta:7,"static":1,connect:5,year:[1,2],resourc:[12,6],orient:7,special:5,out:10,variabl:6,space:6,open:[3,6],rev:[10,2],publish:12,profil:12,xwikistorag:[9,2],code_nam:11,reader:[11,6],hardwar:12,plural:6,ass:6,franc:12,navig:12,selected_job:11,cleartext:2,"3753476b70a49ea4d8c9039e7b04254c":10,given:[1,2,12],free:[7,12],standard:12,"_getfirst":6,small:[7,6],reason:[7,11,12,6],base:[5,0,9,11,2],mime:12,york:12,dictionari:7,latest:10,put:[5,6,7,10,11,12],org:[9,12,6],earliest:12,md5:7,indent:6,s3storag:[9,2],could:1,synchron:[4,10],sven:[12,8],gidstorag:[9,0,2,4],keep:[10,1,11],filter:1,thing:2,length:[7,12],toler:7,iso:12,perman:12,outsid:[0,1,6],ltd:12,view:9,confus:6,imposs:11,getfirst:6,first:[7,11,6],origin:[12,6],softwar:12,rang:12,isbn:12,its_attach:7,directli:6,"44z":12,onc:10,queryfactori:1,qualiti:6,number:[1,2,5,6,10,12],yourself:[9,11],mai:12,alreadi:11,done:[11,6],construct:1,oppos:2,miss:[7,6],primari:12,size:12,differ:[4,7,11,12,6],convent:[0,11,6],script:[5,6],associ:[5,7,12],top:5,creator:[1,2,7,12],sometim:6,messag:[7,11],citi:12,attack:6,activepag:6,draft:7,too:10,accept:11,termin:[1,11],john:1,"40th":1,store:[0,7,2,10],schema:[0,1,7],adher:6,removeattach:[5,7,11],consol:[1,7],option:[0,1,2,4,5,6,7,10,11,12],nilsson:12,namespac:1,tool:[0,1,2,6,7,11,12],copi:5,specifi:[5,10],task:1,part:[5,12,6],pars:1,nomen:6,kept:2,ogg:[7,12],exactli:1,than:[1,11,6],wide:7,kind:4,scheme:[4,12],right_parenthes:1,keyword:12,whenev:[10,11],remot:[5,4],remov:[5,10,7,11],tree:[0,1,2,4,5,7,10],see:[5,9,7,11,12],charact:[1,6],jqueri:[9,6],ressourc:6,posit:6,video:[0,7,12],unique_identifi:6,browser:[5,2],pre:1,getmillisecond:12,fashion:5,rouen:12,ran:10,well:[5,11,6],xaoe41papniwz:12,modern:[],mind:11,onparseend:1,geograph:12,titl:[4,1,2,7,11,12],mikael:12,have:[4,1,2,6,7,9,10,11,12],tabl:12,need:[1,11,12],areread:11,seem:6,onparsecomplexqueri:1,input_str:6,recharg:10,bitwis:6,realm:2,built:11,equival:12,callback:[0,1,7,12],namedfunct:6,new_generated_id:11,mid:12,client:[1,12],note:[10,12,6],mix:6,satellit:12,revisionstorag:[9,4],build:[5,9,11,2],which:[4,1,2,5,6,7,11,12],are_ignor:1,thoma:12,environ:6,local_storag:2,brace:6,divers:12,singl:[10,6],incoher:11,getsecond:12,begin:[4,6],sure:11,unless:2,exec:1,usernam:[7,2],previou:[10,6],numero:1,most:10,letter:[12,6],my_doc_id:7,why:[0,1,12,10],getmonth:12,tradit:[7,12],sub_storag:[4,2,10],annum:12,doi:12,don:[1,11,6],url:[2,12],doc:[7,2],clear:[0,11],later:[10,11],request:[1,2],uri:[4,12],doe:[5,0,1,10,6],salari:12,deni:11,declar:6,wildcard:1,databas:[1,2,7],subtag:12,"_id":[10,7,11,2,12],commerc:12,jurisdict:12,show:[1,12,7,6],text:[4,1,11,7,12],syntax:6,row_object:11,creatememorydescript:2,jio_inst:[10,1,11,7],my_attachment_id:7,find:[4,1,11,2,12],internet_media_typ:12,involv:12,frequent:1,onli:[1,2,6,9,11,12],slow:10,locat:[10,12,6],just:[1,2,7,10,11,12],copyright:[0,3,12],"true":[1,2,6,7,10,11,12],writer:11,apach:7,state:[5,11],should:[12,1,11,7,6],email:10,suppos:6,local:[5,4,7,10],over:12,movingimag:7,uniqueidentifi:6,unus:6,variou:12,get:[0,5,6,7,9,10,11,12],familiar:7,express:[1,12],soon:[1,2],repo:9,cannot:11,jscc:1,increas:[10,2],requir:[0,1,2,4,5,6,11],sameparamet:11,retreiv:1,replicatestorag:9,bar:4,enabl:4,organ:[7,12],artist:12,specif:[5,1,2,12],"public":6,rfc:12,provid:[1,2,5,7,11,12],bad:6,integr:6,contain:[4,11,2,12,10],where:[0,1,2,4,7,12],summari:12,respond:10,conform:12,set:[1,2,6,7,10,11,12],ongo:5,accord:7,displai:[10,12],super_:1,intellectu:12,result:[1,12,7,6],respons:[0,2,7,10,11,12],corrupt:11,close:6,becaus:[10,1,12],best:[7,12,2,6],subject:[2,12],pete:12,awar:2,statu:[10,7,11,12],beautifi:6,parent:[2,12],pattern:6,review:4,creation_d:1,wikipedia:12,label:[10,12],written:6,between:[4,6],progress:7,namecard:10,thumbnail:7,speed:2,attribut:[4,6],altern:[10,1,6],sorton:1,assumpt:12,getminut:12,tristan:[12,8],kei:[4,1,11,7,12],numer:12,javascript:[0,5,6,7,11,12],onparsestart:1,cycl:12,job:[5,0,11,2,12],unabl:7,french:12,extent:12,select_list:1,solv:[0,10],simplequeri:1,"0oe":7,come:1,cli:11,both:5,plugin:6,fault:7,howev:2,equal:[1,11,2,6],tempor:12,facet:12,index_year:2,instanc:[5,7,11,2,12],context:[12,6],logic:1,pdf:[1,12],articul:12,com:[4,12,2,10],comment:6,putattach:[5,7,11],licens:[0,3,12],author:[0,7,12,8],technic:[10,6],can:[0,1,2,3,4,5,6,7,10,11,12],within:[4,12,6],xwiki:[4,12],period:12,header:6,dcterm:[4,12],mystoragetyp:11,"16z":12,pagechang:6,dougla:12,respect:[4,12],not_found:7,assign:[12,6],duplic:4,becom:[],complexqueri:1,index_title_subject:2,"5782e71f1e4bf698fa3793d9d5a96393":10,three:[2,12],empti:1,implicit:6,compon:1,offer:5,json:[0,1,2,4,5,7,12],trigger:[5,1,11],my_imag:7,total_row:7,basic:[0,1,2,5,6,7,12],unambigu:12,silenc:6,"abstract":[5,12],createlocaldescript:2,revison:10,field:[1,2],life:12,me_again:10,backend:[4,7],jio_home_pag:12,thousand:1,resolut:[0,10],convert:[4,1],erp5storag:9,minifi:[9,0],doesn:[1,11],func:6,input:12,specifc:5,present:12,titlecas:6,"case":[4,1,5,6,7,11],replic:[5,4,7,2,10],"3ue":7,interoper:[4,12],look:[5,7,12,6],"14t14":12,plain:7,wiki:12,properti:[1,11,7,12],durat:12,cast:6,"while":10,unifi:7,"typeof":11,abov:[4,2],error:[4,7,11,6],anonym:6,gave:[],clear_job_rul:11,real:12,attachment_id:11,"_blob":11,readi:11,genr:12,samestoragedescript:11,non:6,kwarg:11,my_jio:5,no_cont:11,responsecallback:7,crash:5,revis:[0,2,5,7,9,10],sametitleifstr:11,attach:[5,7,2,12],sever:[4,11,12,6],onparsesimplequeri:1,akk:12,"null":4,develop:[0,11,10,6],welcom:0,minim:6,perform:7,suggest:[0,4],make:[4,11,12,10,6],couchdb:[5,7,12],same:[4,11,6],member:12,binari:7,html:[5,4,7,12],akkadian:12,split:[4,6],south:12,requset:7,mydoc:7,document:[0,1,2,4,5,6,7,9,10,11,12],conflict:[0,2,5,6,7,10,11],archiv:12,blue:4,someon:[10,12],solut:7,jslint:6,"_kei":4,dublincor:12,storagelist:10,initi:[12,6],mani:7,kib:12,"_data":7,typic:12,recent:[],jsbeautifi:6,lower:[1,6],appropri:[1,12],off:10,addjobrulecondit:11,older:2,whole:12,alldoc:[4,1,2,5,7,11,12],itself:[1,6],person:[12,6],promid:11,exampl:[0,1,2,4,5,6,7,10,11,12],command:[7,11,2],sha2:9,thi:[4,1,2,5,6,7,10,11,12],english:12,entiti:12,promis:[0,7],left:10,identifi:[7,12,2,6],execut:[10,1,11],camel:6,photo:12,ordin:12,rest:7,tolowercas:1,distant:1,my_new_m:10,human:1,world:4,config:5,document_metadata:11,yet:2,languag:[4,1,12],web:[4,12,10],cut:10,sjcl:9,also:[7,11,2,6],pouchdb:7,jobseek:12,param:[11,12,6],identif:12,add:[5,0,7,11,2],book:12,inner:6,blob:[7,11],unparam:6,els:[10,6],tell:[4,11],save:[10,2,12],adress:10,app:7,match:[4,1,10,6],useless:[],kingdom:12,applic:[4,1,2,6,7,12],format:[0,1,2,4,6,7,12],webpag:12,varieti:7,amd:[5,9],sha1:9,camelcas:6,five:12,know:11,nexedi:12,output_str:6,shadow:6,password:2,you:[4,1,2,5,6,7,9,10,11,12],document_id:11,mioga2:12,application_nam:[7,2],like:[1,5,6,7,10,11,12],success:[7,11],manual:10,resolv:11,manifest:12,"boolean":12,necessari:[11,6],either:[10,1,7],night:12,output:12,"function":[1,5,6,7,10,11,12],manag:[0,2,5,7,11,12],yyyi:12,use_utc:12,www:12,right:12,often:[12,2,6],typeerror:11,callbakc:12,del_not:6,arrai:[1,6],interact:5,ascend:1,back:[10,1,12],yuidoc:6,havedocumentid:11,batteri:10,intern:12,sampl:[4,1],act:[1,11],mobil:6,billioud:8,erp5:[9,4,12],server:[5,1,12],librari:[0,2,3,5,7,9,11,12],absent:12,guid:12,leaf:10,dictionnari:[],lead:6,deliveri:6,getobjectorarrai:6,avoid:[1,11,2,6],definit:12,restsqlstorag:9,per:[1,12,6],track:10,retri:11,leav:10,unit:12,statustext:7,condit:[0,11,6],foo:4,getnam:6,myfunct:6,core:[5,0,9,12],plu:11,object:[4,1,6,7,11,12],run:[1,11],power:1,word:[1,12,6],inspect:6,usag:4,curl:7,revs_info:2,my_callback:6,although:6,parsestringtoobject:1,regexp:6,post:[5,10,7,11,12],"throw":11,src:5,about:[7,12,6],zip:9,constraint:4,column:1,materi:6,http:[9,4,7,12],gettimezoneoffset:12,page:[0,1,4,5,6,12],maxlen:6,revolut:12,statement:[12,6],includ:[1,11,12,6],alert:[7,6],constructor:[11,6],johnston:12,mynamecard:10,produc:2,toisostr:12,routin:10,own:[0,1,4,7,11,12],delivery_note_list:6,chu:12,primarili:12,wildcard_charact:1,query_list:1,getfullyear:12,encod:[2,12],domain:12,automat:6,compos:5,value_list:6,getattach:[5,7,11],new_york_city_at_night:12,resili:12,addstorag:11,notat:6,contributor:12,chang:[10,1,6],announc:12,storag:[0,1,2,4,5,7,9,10,11,12],your:[0,2,4,5,6,10,11],webdav:10,east:12,accordingli:10,git:9,log:[1,7],wai:[11,2,12],dosomethingfunct:6,support:4,openweb:12,stringescaperegexpcharact:1,custom:[4,5,6,7,9,11,12],avail:[0,1,2,4,5,6,7,10,12],start:[5,0,1,11,6],gid:4,interfac:1,errorcallback:7,lot:6,"var":[1,2,5,6,7,10,11,12],value3:4,xxxx:7,eahilsantand:12,cancel:7,usr:7,fork:[5,0,9,11],project:[12,6],"4aaqskz":7,creation:[11,12],getti:12,interest:12,form:[12,6],enough:6,batman:6,criteria:[5,1],"_getlast":6,davstorag:[5,9,2],createjio:[5,11,2],content:[0,7,12,4],morganhealei:12,mioga2storag:9,link:[11,6],totaljob:12,line:[11,6],walkthrough:5,framework:12,extend:7,utc:12,getlast:6,search_text:1,consist:6,possibl:6,whether:11,maximum:6,getw3cdat:12,asynchron:5,below:[1,7,12],limit:[1,2,12],hand:7,usemetadataonli:11,grasp:6,highlight:6,problem:[7,6],similar:11,urn:12,expect:6,classif:12,featur:7,creat:[0,1,2,5,7,10,11,12],certain:[1,6],dure:12,parser:11,deep:11,repres:[4,2],exist:[5,10,7,11],file:[10,1,11,12,6],behavior:1,some:[4,1,2,5,6,7,10,11,12],encompass:12,addit:[0,6,2,4],check:[5,11,6],splitstorag:[9,2],successfulli:11,encrypt:2,my_docu:7,user:[10,1,11],when:[4,1,2,6,10,11],gitori:9,event:[12,6],"default":[0,1,2,4,5,11,12],undefin:[2,6],valid:6,custom2:12,spatial:12,test:[11,6],uuid:12,sameopt:11,imag:[4,7,12],node:6,draw:12,media:12,intend:5,determin:12,dosometh:6,liter:6,docum:12,"class":6,samemethod:11,prototypeappl:6,vocabulari:[4,12],sql:7,throughout:6,formal:12,impli:6,sort_on:1,lang:12,requirej:5,"_mimetyp":7,home:12,baker:12,descript:[0,1,2,4,5,7,11,12],rule:[0,11],tricki:12,delivery_not:6,emerg:12,ignor:1,potenti:6,time:12,mean:[12,6],hello:4,togeth:[12,6]},objtypes:{},titles:["Welcome to jIO&#8217;s documentation!","jIO Complex Queries","List of Available Storages","Copyright and license","jIO GIDStorage","Introduction","JavaScript Naming Conventions","How to manage documents?","Authors","Downloads","Revision Storages: Conflicts and Resolution","For developers","Metadata"],objnames:{},filenames:["index","complex_queries","available_storages","license","gid_storage","introduction","naming_conventions","manage_documents","authors","download","revision_storages","developers","metadata"]})
\ No newline at end of file
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=/home/marco/src/jio/docs/sphinx/build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% /home/marco/src/jio/docs/sphinx/source
set I18NSPHINXOPTS=%SPHINXOPTS% /home/marco/src/jio/docs/sphinx/source
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. warnings-html to make standalone HTML files (turn warnings into errors)
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "warnings-html" (
%SPHINXBUILD% -W -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\sphinx.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\sphinx.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end
.. _download-fork:
Downloads
=========
Core
^^^^
* `sha256.amd.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha256.amd.js>`_
* `rsvp-custom.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/lib/rsvp/rsvp-custom.js>`_, AMD only version: `rsvp-custom.amd.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/lib/rsvp/rsvp-custom.amd.js>`_
* `jio.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/jio.js>`_
* `complex_queries.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/complex_queries.js>`_
Storage dependencies
^^^^^^^^^^^^^^^^^^^^
.. XXX this is a little confusing. Also, the link to sha1.js is broken (404)
* `jquery.js <http://code.jquery.com/jquery.js>`_
* `sjcl <https://crypto.stanford.edu/sjcl/>`_, [`sjcl.zip <https://crypto.stanford.edu/sjcl/sjcl.zip>`_]
* `sha1 <http://pajhome.org.uk/crypt/md5/sha1.html>`_, [`sha1.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/lib/jsSha1/sha1.js>`_], AMD compatible version: `sha1.amd.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha1.amd.js>`_
* `sha2, sha256 <http://anmar.eu.org/projects/jssha2/>`_, `jssha2.zip <http://anmar.eu.org/projects/jssha2/files/jssha2-0.3.zip>`_, AMD compatible versions: `sha2.amd.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha2.amd.js>`_, `sha256.amd.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/sha256.amd.js>`_
Storage connectors
^^^^^^^^^^^^^^^^^^
* `localstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/localstorage.js>`_
* `davstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/davstorage.js>`_
* `s3storage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/s3storage.js>`_ (depends on sha1, jQuery) (WIP)
* `xwikistorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/xwikistorage.js>`_ (depends on jQuery) (WIP)
* `erp5storage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/erp5storage.js>`_ (depends on jQuery) (WIP)
* restsqlstorage.js (depends on jQuery) (WIP)
* mioga2storage.js (depends on jQuery) (WIP)
Storage handlers
^^^^^^^^^^^^^^^^
* `indexstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/indexstorage.js>`_ (WIP)
* `gidstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/gidstorage.js>`_ (WIP)
* `splitstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/splitstorage.js>`_ (WIP)
* replicatestorage.js (WIP)
Revision based storage handlers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* `revisionstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/revisionstorage.js>`_ (depends on sha256) (WIP)
* `replicaterevisionstorage.js <http://git.erp5.org/gitweb/jio.git/blob_plain/refs/heads/master:/src/jio.storage/replicatestorage.js>`_ (WIP)
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.
Fork
^^^^
jIO source code
=============================================== ============================================= ========================================== =======================================
Clone (read only) Git Erp5 Gitorious Github
``git clone http://git.erp5.org/repos/jio.git`` `View <http://git.erp5.org/gitweb/jio.git>`_ `View <https://gitorious.org/nexedi/jio>`_ `View <https://github.com/nexedi/jio>`_
=============================================== ============================================= ========================================== =======================================
.. jIO documentation master file, created by
sphinx-quickstart on Fri Nov 15 11:55:08 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to jIO's documentation!
===============================
Contents:
.. toctree::
:maxdepth: 2
introduction
download
manage_documents
revision_storages
available_storages
gid_storage
complex_queries
metadata
developers
naming_conventions
authors
license
* :ref:`search`
.. role:: js(code)
:language: javascript
Introduction
============
What is jIO?
------------
jIO is a JavaScript library that allows to manage JSON documents on local or
remote storages in asynchronous fashion. jIO is an abstracted API mapped after
CouchDB, that offers connectors to multiple storages, special handlers to
enhance functionality (replication, revisions, indexing) and a query module to
retrieve documents and specific information across storage trees.
How does it work?
-----------------
jIO is composed of two parts - jIO core and storage library(ies). The core
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
query documents based on defined criteria.
jIO uses a job management system, so every method call adds a job into a
queue. The queue is copied in the browser's local storage (by default), so it
can be restored in case of browser crash. Jobs are invoked
asynchronously and ongoing jobs are not able to re-trigger to prevent
conflicts.
Getting started
---------------
This walkthrough is designed to get you started using a basic jIO instance.
#. Download jIO core, the storages you want to use as well as the
complex-queries scripts and the dependencies required for the storages
you intend to use. :ref:`[Download & Fork] <download-fork>`
#. Add the scripts to your HTML page in the following order:
.. code-block:: html
<!-- jio core + dependency -->
<script src="sha256.amd.js"></script>
<script src="rsvp-custom.js"></script>
<script src="jio.js"></script>
<!-- storages + dependencies -->
<script src="complex_queries.js"></script>
<script src="localstorage.js"></script>
<script src="davstorage.js"></script>
<script ...>
With `RequireJS <http://requirejs.org/>`_, the main.js will look like:
.. code-block:: javascript
:linenos:
require.config({
"paths": {
// jio core + dependency
// the AMD compatible version of sha256.js -> see Download and Fork
"sha256": "sha256.amd",
"rsvp": "rsvp-custom",
"jio": "jio",
// storages + dependencies
"complex_queries": "complex_queries",
"localstorage": "localstorage",
"davstorage": "davstorage"
}
});
#. jIO connects to a number of storages and allows adding handlers (or
functions) to specifc storages.
You can use both handlers and available storages to build a storage
tree across which all documents will be maintained and managed by jIO.
See :ref:`List of Available Storages <list-of-available-storages>`.
.. code-block:: javascript
// create your jio instance
var my_jio = jIO.createJIO(storage_description);
#. The jIO API provides ten main methods to manage documents across the storage(s) specified in your jIO storage tree.
====================== ===================================================== ========================================
Method Example call Description
====================== ===================================================== ========================================
``post()`` :js:`my_jio.post(document, [options]);` Creates a new document
``put()`` :js:`my_jio.put(document, [options]);` Creates/Updates a document
``putAttachment()`` :js:`my_jio.putAttachement(attachment, [options]);` Updates/Adds an attachment to a document
``get()`` :js:`my_jio.get(document, [options]);` Reads a document
``getAttachment()`` :js:`my_jio.getAttachment(attachment, [options]);` Reads a document attachment
``remove()`` :js:`my_jio.remove(document, [options]);` Deletes a document and its attachments
``removeAttachment()`` :js:`my_jio.removeAttachment(attachment, [options]);` Deletes a document attachment
``allDocs()`` :js:`my_jio.allDocs([options]);` Retrieves a list of existing documents
``check()`` :js:`my_jio.check(document, [options]);` Check the document state
``repair()`` :js:`my_jio.repair(document, [options]);` Repair the document
====================== ===================================================== ========================================
Copyright and license
=====================
jIO is an open-source library and is licensed under the LGPL license. More
information on LGPL can be found `here <http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License>`_
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