Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Alain Takoudjou
jio
Commits
4fb5516e
Commit
4fb5516e
authored
Dec 12, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make old storages pass jslint
parent
21fc131a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
60 deletions
+62
-60
src/jio.storage/cryptstorage.js
src/jio.storage/cryptstorage.js
+7
-2
src/jio.storage/s3storage.js
src/jio.storage/s3storage.js
+27
-35
src/jio.storage/xwikistorage.js
src/jio.storage/xwikistorage.js
+18
-17
test/jio.storage/replicaterevisionstorage.tests.js
test/jio.storage/replicaterevisionstorage.tests.js
+4
-2
test/jio.storage/s3storage.tests.js
test/jio.storage/s3storage.tests.js
+2
-1
test/jio.storage/splitstorage.tests.js
test/jio.storage/splitstorage.tests.js
+1
-1
test/jio.storage/xwikistorage.tests.js
test/jio.storage/xwikistorage.tests.js
+3
-2
No files found.
src/jio.storage/cryptstorage.js
View file @
4fb5516e
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global jIO: true, sjcl: true, $: true, setTimeout: true */
jIO
.
addStorageType
(
'
crypt
'
,
function
(
spec
,
my
)
{
/*jslint todo: true*/
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{},
...
...
@@ -80,7 +81,9 @@ jIO.addStorageType('crypt', function (spec, my) {
obj
.
_wait
=
obj
.
_wait
||
{};
if
(
obj
.
_wait
[
function_name
])
{
obj
.
_wait
[
function_name
]
-=
1
;
return
function
()
{};
return
function
()
{
return
;
};
}
// ok if undef or 0
arglist
=
arglist
||
[];
...
...
@@ -97,7 +100,9 @@ jIO.addStorageType('crypt', function (spec, my) {
obj
.
_wait
[
function_name
]
=
times
;
};
async
.
end
=
function
()
{
async
.
call
=
function
()
{};
async
.
call
=
function
()
{
return
;
};
};
return
async
;
};
...
...
src/jio.storage/s3storage.js
View file @
4fb5516e
...
...
@@ -17,7 +17,7 @@
var
b64_hmac_sha1
=
sha1
.
b64_hmac_sha1
;
jIO
.
addStorageType
(
"
s3
"
,
function
(
spec
,
my
)
{
var
evt
,
that
,
priv
=
{};
var
that
,
priv
=
{};
spec
=
spec
||
{};
that
=
my
.
basicStorage
(
spec
,
my
);
...
...
@@ -258,10 +258,10 @@
that
.
encodePolicy
=
function
(
form
)
{
that
.
encodePolicy
=
function
()
{
//generates the policy
//enables the choice for the http response code
var
http_code
,
s3_policy
,
Signature
=
''
;
var
s3_policy
;
s3_policy
=
{
"
expiration
"
:
"
2020-01-01T00:00:00Z
"
,
"
conditions
"
:
[
...
...
@@ -269,7 +269,7 @@
[
"
starts-with
"
,
"
$key
"
,
""
],
{
"
acl
"
:
priv
.
acl
},
{
"
success_action_redirect
"
:
""
},
{
"
success_action_status
"
:
http_code
},
{
"
success_action_status
"
:
undefined
},
// http_code
[
"
starts-with
"
,
"
$Content-Type
"
,
""
],
[
"
content-length-range
"
,
0
,
524288000
]
]
...
...
@@ -280,7 +280,7 @@
priv
.
b64_policy
=
btoa
(
JSON
.
stringify
(
s3_policy
));
//generates the signature value using the policy and the secret access key
//use of sha1.js to generate the signature
Signature
=
that
.
signature
(
priv
.
b64_policy
);
//
Signature = that.signature(priv.b64_policy);
};
...
...
@@ -407,6 +407,7 @@
}
priv
.
updateMeta
=
function
(
doc
,
docid
,
attachid
,
action
,
data
)
{
/*jslint unparam: true */
doc
.
_attachments
=
doc
.
_attachments
||
{};
switch
(
action
)
{
case
"
add
"
:
...
...
@@ -453,7 +454,7 @@
return
error
;
};
that
.
encodeAuthorization
=
function
(
key
,
mime
)
{
that
.
encodeAuthorization
=
function
(
key
)
{
//GET oriented method
var
requestUTC
,
httpVerb
,
StringToSign
,
Signature
;
requestUTC
=
new
Date
().
toUTCString
();
...
...
@@ -670,7 +671,6 @@
docId
,
attachId
,
mime
,
attachment_id
,
attachment_data
,
attachment_md5
,
attachment_mimetype
,
...
...
@@ -682,7 +682,7 @@
mime
=
'
text/plain; charset=UTF-8
'
;
//récupération des variables de l'attachement
attachment_id
=
command
.
getAttachmentId
();
//
attachment_id = command.getAttachmentId();
attachment_data
=
command
.
getAttachmentData
();
attachment_md5
=
command
.
md5SumAttachmentData
();
attachment_mimetype
=
command
.
getAttachmentMimeType
();
...
...
@@ -697,7 +697,7 @@
attachment_data
,
false
,
true
,
function
(
reponse
)
{
function
()
{
that
.
success
({
// response
"
ok
"
:
true
,
...
...
@@ -722,7 +722,7 @@
doc
=
priv
.
updateMeta
(
data
,
docId
,
attachId
,
"
add
"
,
attachment_obj
);
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
PUT
'
,
mime
,
doc
,
false
,
false
,
function
(
reponse
)
{
function
()
{
putAttachment
();
}
);
...
...
@@ -760,7 +760,7 @@
function
deleteDocument
()
{
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
DELETE
'
,
mime
,
''
,
true
,
false
,
function
(
reponse
)
{
function
()
{
that
.
success
({
// response
"
ok
"
:
true
,
...
...
@@ -771,7 +771,8 @@
);
}
function
myCallback
(
response
)
{
function
myCallback
()
{
return
;
}
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
GET
'
,
mime
,
''
,
false
,
false
,
...
...
@@ -801,12 +802,7 @@
var
mon_document
,
docId
,
attachId
,
mime
,
attachment_id
,
attachment_data
,
attachment_md5
,
attachment_mimetype
,
attachment_length
;
mime
;
mon_document
=
null
;
docId
=
command
.
getDocId
();
...
...
@@ -814,17 +810,17 @@
mime
=
'
text/plain; charset=UTF-8
'
;
//récupération des variables de l'attachement
attachment_id
=
command
.
getAttachmentId
();
attachment_data
=
command
.
getAttachmentData
();
attachment_md5
=
command
.
md5SumAttachmentData
();
attachment_mimetype
=
command
.
getAttachmentMimeType
();
attachment_length
=
command
.
getAttachmentLength
();
//
attachment_id = command.getAttachmentId();
//
attachment_data = command.getAttachmentData();
//
attachment_md5 = command.md5SumAttachmentData();
//
attachment_mimetype = command.getAttachmentMimeType();
//
attachment_length = command.getAttachmentLength();
function
removeAttachment
()
{
that
.
XHRwrapper
(
command
,
docId
,
attachId
,
'
DELETE
'
,
mime
,
''
,
true
,
true
,
function
(
reponse
)
{
}
);
true
,
function
()
{
return
;
}
);
}
function
putDocument
()
{
...
...
@@ -832,10 +828,9 @@
data
=
JSON
.
parse
(
mon_document
);
doc
=
priv
.
updateMeta
(
data
,
docId
,
attachId
,
"
remove
"
,
''
);
that
.
XHRwrapper
(
command
,
docId
,
''
,
'
PUT
'
,
mime
,
doc
,
false
,
false
,
function
(
reponse
)
{
false
,
false
,
function
()
{
removeAttachment
();
}
);
});
}
function
getDocument
()
{
...
...
@@ -873,16 +868,14 @@
keyId
,
Signature
,
callURL
,
requestUTC
,
parse
,
checkCounter
;
requestUTC
;
keys
=
$
(
mon_document
).
find
(
'
Key
'
);
resultTable
=
[];
counter
=
0
;
keys
.
each
(
function
(
index
)
{
keys
.
each
(
function
()
{
var
that
,
filename
,
docId
;
that
=
$
(
this
);
filename
=
that
.
context
.
textContent
;
...
...
@@ -908,6 +901,7 @@
countB
=
0
;
dealCallback
=
function
(
i
,
countB
,
allDoc
)
{
/*jslint unparam: true */
return
function
(
doc
,
statustext
,
response
)
{
allDoc
.
rows
[
i
].
doc
=
response
.
responseText
;
if
(
count
===
0
)
{
...
...
@@ -941,14 +935,12 @@
Signature
=
that
.
encodeAuthorization
(
keyId
);
callURL
=
'
http://
'
+
priv
.
server
+
'
.s3.amazonaws.com/
'
+
keyId
;
requestUTC
=
new
Date
().
toUTCString
();
parse
=
true
;
allDocResponse
.
rows
[
i
]
=
{
"
id
"
:
priv
.
fileNameToIds
(
keyId
).
join
(),
"
key
"
:
keyId
,
"
value
"
:
{}
};
checkCounter
=
i
;
$
.
ajax
({
contentType
:
''
,
...
...
src/jio.storage/xwikistorage.js
View file @
4fb5516e
...
...
@@ -9,7 +9,8 @@
XMLHttpRequest: true,
Blob: true,
FormData: true,
window: true
window: true,
setTimeout: true
*/
/**
* JIO XWiki Storage. Type = 'xwiki'.
...
...
@@ -86,7 +87,7 @@
priv
.
xwikiurl
+
"
]
"
,
"
reason
"
:
cause
});
}
,
}
});
};
...
...
@@ -125,7 +126,7 @@
};
priv
.
isBlob
=
function
(
potentialBlob
)
{
return
typeof
(
potentialBlob
)
!==
'
undefined
'
&&
return
potentialBlob
!==
undefined
&&
potentialBlob
.
toString
()
===
"
[object Blob]
"
;
};
...
...
@@ -225,7 +226,7 @@
xhr
.
responseType
=
'
text
'
;
}
xhr
.
onload
=
function
(
e
)
{
xhr
.
onload
=
function
()
{
if
(
xhr
.
status
===
200
)
{
var
contentType
=
xhr
.
getResponseHeader
(
"
Content-Type
"
);
if
(
contentType
.
indexOf
(
'
;
'
)
>
-
1
)
{
...
...
@@ -327,7 +328,7 @@
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
POST
'
,
priv
.
xwikiurl
+
"
/bin/upload/
"
+
parts
.
space
+
'
/
'
+
parts
.
page
,
true
);
xhr
.
onload
=
function
(
e
)
{
xhr
.
onload
=
function
()
{
if
(
xhr
.
status
===
302
||
xhr
.
status
===
200
)
{
andThen
(
null
);
}
else
{
...
...
@@ -490,7 +491,7 @@
return
{
"
username
"
:
priv
.
username
,
"
language
"
:
priv
.
language
,
"
xwikiurl
"
:
priv
.
xwikiurl
,
"
xwikiurl
"
:
priv
.
xwikiurl
};
};
...
...
@@ -666,16 +667,16 @@
* @param {object} command The JIO command
*/
that
.
remove
=
that
.
removeAttachment
=
function
(
command
)
{
var
notFoundError
,
objId
,
complete
;
notFoundError
=
function
(
word
)
{
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
word
+
"
not found
"
,
"
reason
"
:
"
missing
"
});
};
var
objId
,
complete
;
//
notFoundError = function (word) {
//
that.error({
//
"status": 404,
//
"statusText": "Not Found",
//
"error": "not_found",
//
"message": word + " not found",
//
"reason": "missing"
//
});
//
};
objId
=
command
.
getDocId
();
complete
=
function
(
err
)
{
...
...
@@ -718,7 +719,7 @@
return
that
;
};
if
(
typeof
(
define
)
===
'
function
'
&&
define
.
amd
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
define
([
'
jquery
'
,
'
jio
'
],
function
(
jquery
,
jIO
)
{
$
=
jquery
;
jIO
.
addStorageType
(
'
xwiki
'
,
store
);
...
...
test/jio.storage/replicaterevisionstorage.tests.js
View file @
4fb5516e
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, hex_sha256, test, ok, deepEqual, sinon,
expect */
expect
, module
*/
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
...
...
@@ -75,6 +75,7 @@
module
(
"
Replicate Revision Storage
"
);
var
testReplicateRevisionStorage
=
function
(
sinon
,
jio_description
)
{
/*jslint unparam: true */
var
o
=
generateTools
(),
leavesAction
,
generateLocalPath
;
...
...
@@ -778,6 +779,7 @@
description
,
index
)
{
/*jslint unparam: true */
var
o
=
generateTools
();
o
.
jio
=
jIO
.
newJio
(
description
);
...
...
@@ -792,7 +794,7 @@
"
children
"
:
[{
"
rev
"
:
"
1-111
"
,
"
status
"
:
"
available
"
,
"
children
"
:
[]
,
"
children
"
:
[]
}]
};
o
.
doc1_1
=
{
"
_id
"
:
"
doc1.1-111
"
,
"
title
"
:
"
A
"
};
...
...
test/jio.storage/s3storage.tests.js
View file @
4fb5516e
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, window, test, ok, deepEqual, sinon, expect */
/*global define, jIO, jio_tests, window, test, ok, deepEqual, sinon, expect,
module */
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
...
...
test/jio.storage/splitstorage.tests.js
View file @
4fb5516e
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, test, ok, deepEqual, sinon */
/*global define, jIO, jio_tests, test, ok, deepEqual, sinon
, module
*/
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
...
...
test/jio.storage/xwikistorage.tests.js
View file @
4fb5516e
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, test, ok, sinon */
/*global define, jIO, jio_tests, test, ok, sinon
, module
*/
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
...
...
@@ -18,6 +18,7 @@
tick
:
util
.
otick
};
function
addFakeServerResponse
(
type
,
method
,
path
,
status
,
response
)
{
/*jslint unparam: true */
o
.
server
.
respondWith
(
method
,
new
RegExp
(
path
),
[
status
,
{
"
Content-Type
"
:
'
application/xml
'
},
...
...
@@ -30,7 +31,7 @@
module
(
'
XWikiStorage
'
);
function
setUp
(
that
,
liveTest
)
{
function
setUp
(
that
)
{
var
o
=
generateTools
(
that
);
o
.
server
=
sinon
.
fakeServer
.
create
();
o
.
jio
=
jIO
.
newJio
({
type
:
'
xwiki
'
,
formTokenPath
:
'
form_token
'
});
...
...
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