Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
jio
Commits
31e65d17
Commit
31e65d17
authored
Dec 14, 2012
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added revision management, POST working, PUT partially
parent
2c7d952d
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
808 additions
and
143 deletions
+808
-143
examples/complex_example.html
examples/complex_example.html
+1
-0
src/jio.dummystorages.js
src/jio.dummystorages.js
+39
-3
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+472
-84
src/jio/commands/command.js
src/jio/commands/command.js
+7
-3
src/jio/commands/putAttachmentCommand.js
src/jio/commands/putAttachmentCommand.js
+1
-1
src/jio/jio.outro.js
src/jio/jio.outro.js
+8
-2
test/jiotests.js
test/jiotests.js
+280
-50
No files found.
examples/complex_example.html
View file @
31e65d17
...
...
@@ -238,6 +238,7 @@ var command = function (method) {
log
(
'
revision:
'
+
other
.
revision
);
log
(
'
content:
'
+
other
.
content
);
log
(
'
mimetype:
'
+
other
.
mimetype
);
break
;
case
'
post
'
:
case
'
put
'
:
doc
=
JSON
.
parse
(
$
(
'
#metadata
'
).
attr
(
'
value
'
));
...
...
src/jio.dummystorages.js
View file @
31e65d17
...
...
@@ -18,12 +18,47 @@
return
o
;
};
// Fake revisions
var
fakeCount
=
0
;
var
generateRevision
=
function
(
command
,
action
,
reset
){
var
that
=
{},
priv
=
{},
fakeRevision
=
""
,
fakeCount
=
reset
===
true
?
0
:
fakeCount
,
now
=
Date
.
now
();
that
.
makeHash
=
function
(){
return
that
.
hashCode
(
''
+
command
.
getDocId
()
+
'
'
+
now
+
''
);
};
that
.
hashCode
=
function
(
string
)
{
return
hex_sha256
(
string
);
};
that
.
generateNextRev
=
function
(
previous_revision
,
string
)
{
return
(
parseInt
(
previous_revision
.
split
(
'
-
'
)[
0
],
10
)
+
1
)
+
'
-
'
+
priv
.
hashCode
(
previous_revision
+
string
);
};
if
(
fakeRevision
===
""
&&
fakeCount
===
0
){
fakeRevision
=
'
1-
'
+
that
.
makeHash
();
}
else
{
if
(
action
!==
"
post
"
){
fakeRevision
=
that
.
generateNextRev
(
fakeRev
,
that
.
makeHash
);
}
}
return
fakeRevision
;
};
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
that
.
success
({
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()
id
:
command
.
getDocId
(),
rev
:
generateRevision
(
command
,
"
post
"
,
true
)
});
},
100
);
};
// end post
...
...
@@ -32,7 +67,8 @@
setTimeout
(
function
()
{
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()
id
:
command
.
getDocId
(),
rev
:
generateRevision
(
command
,
"
put
"
,
true
)
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end put
...
...
src/jio.storage/localstorage.js
View file @
31e65d17
This diff is collapsed.
Click to expand it.
src/jio/commands/command.js
View file @
31e65d17
...
...
@@ -23,9 +23,13 @@ var command = function(spec, my) {
priv
.
doc
=
spec
.
doc
||
{};
priv
.
doc
.
_id
=
priv
.
doc
.
_id
||
generateUuid
();
priv
.
docid
=
spec
.
docid
||
''
;
priv
.
content
=
typeof
spec
.
content
===
'
string
'
?
spec
.
content
:
undefined
;
// xxx fixed spec.content to spec.doc.content for PUTATTACHMENT
// xxx need extra check for GET, otherwise spec.doc is undefined
priv
.
content
=
spec
.
doc
===
undefined
?
undefined
:
typeof
spec
.
doc
.
content
===
'
string
'
?
spec
.
doc
.
content
:
undefined
;
priv
.
option
=
spec
.
options
||
{};
priv
.
callbacks
=
spec
.
callbacks
||
{};
priv
.
success
=
priv
.
callbacks
.
success
||
function
(){};
...
...
src/jio/commands/putAttachmentCommand.js
View file @
31e65d17
...
...
@@ -11,7 +11,7 @@ var putAttachmentCommand = function(spec, my) {
that
.
executeOn
=
function
(
storage
)
{
storage
.
putAttachment
(
that
);
};
that
.
validateState
=
function
()
{
if
(
typeof
that
.
getContent
()
!==
'
string
'
)
{
that
.
error
({
...
...
src/jio/jio.outro.js
View file @
31e65d17
...
...
@@ -194,6 +194,7 @@
[
options
,
success
,
error
],
{
max_retry
:
0
}
);
priv
.
addJob
(
postCommand
,{
doc
:
doc
,
options
:
param
.
options
,
...
...
@@ -223,6 +224,7 @@
[
options
,
success
,
error
],
{
max_retry
:
0
}
);
priv
.
addJob
(
putCommand
,{
doc
:
doc
,
options
:
param
.
options
,
...
...
@@ -253,6 +255,7 @@
[
options
,
success
,
error
],
{
max_retry
:
3
}
);
priv
.
addJob
(
getCommand
,{
docid
:
id
,
options
:
param
.
options
,
...
...
@@ -282,6 +285,7 @@
[
options
,
success
,
callback
],
{
max_retry
:
0
}
);
priv
.
addJob
(
removeCommand
,{
doc
:
doc
,
options
:
param
.
options
,
...
...
@@ -311,6 +315,7 @@
[
options
,
success
.
error
],
{
max_retry
:
3
}
);
priv
.
addJob
(
allDocsCommand
,{
options
:
param
.
options
,
callbacks
:{
success
:
param
.
success
,
error
:
param
.
error
}
...
...
@@ -342,8 +347,9 @@
[
options
,
success
,
error
],
{
max_retry
:
0
}
);
priv
.
addJob
(
putAttachmentCommand
,{
doc
:{
_id
:
id
,
content
:
doc
},
priv
.
addJob
(
putAttachmentCommand
,{
doc
:{
_id
:
id
,
content
:
doc
,
_rev
:
rev
,
mimetype
:
mimetype
},
options
:
param
.
options
,
callbacks
:{
success
:
param
.
success
,
error
:
param
.
error
}
});
...
...
test/jiotests.js
View file @
31e65d17
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment