Skip to content

Commit 6e233ed

Browse files
committed
Merge pull request #59 from killme2008/feature/2015.02.26
Feature/2015.02.26
2 parents a51d917 + f2960c8 commit 6e233ed

File tree

10 files changed

+67
-29
lines changed

10 files changed

+67
-29
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ $ npm install avoscloud-sdk
1919
* [云代码开发指南](http://leancloud.cn/docs/cloud_code_guide.html)
2020

2121

22+
## Build
23+
24+
We use [gulp](http://gulpjs.com/) to build the project.
25+
26+
how to use:
27+
28+
```sh
29+
npm install -g gulp
30+
cd javascript-sdk
31+
npm install
32+
gulp pack
33+
gulp release
34+
```
35+
2236
# 协议
2337

2438
[MIT License](http://opensource.org/licenses/MIT)

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.4.8 日期: 2015 年 2 月 26 日
2+
* 拆分 sdk,按照模块划分成多个文件。
3+
* 使用 gulp 构建 sdk,清理代码。
4+
* 修复事件流无法发送带有 `AV.File``AV.Object` 等类型的 Status。
5+
* 修复 node.js 环境下上传文件没有扩展名的 Bug。
6+
17
# 0.4.7 日期: 2015 年 1 月 23 日
28
* 修复页面跳转更新 user 导致 current user 属性丢失的 Bug。
39
* 增加 `AV.User.updatePassword` 方法,根据老密码修改成新密码。

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ gulp.task('compress-scripts', ['uglify'], function() {
7474

7575
gulp.task('docs', shell.task([
7676
'mkdir -p dist/js-sdk-api-docs',
77-
'JSDOCDIR=tools/jsdoc-toolkit/ sh tools/jsdoc-toolkit/jsrun.sh -d=dist/js-sdk-api-docs -t=tools/jsdoc-toolkit/templates/jsdoc lib/av.js lib/cloud.js',
77+
'JSDOCDIR=tools/jsdoc-toolkit/ sh tools/jsdoc-toolkit/jsrun.sh -d=dist/js-sdk-api-docs -t=tools/jsdoc-toolkit/templates/jsdoc dist/av.js lib/cloud.js',
7878
]));
7979

8080
gulp.task('compress-docs', ['docs'], function() {

lib/av.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* AVOSCloud JavaScript SDK
3-
* Version: 0.4.7
3+
* Version: 0.4.8
44
* Built: Mon Jun 03 2013 13:45:00
55
* https://leancloud.cn
66
*

lib/cloud.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,19 @@
194194
*/
195195
AV.Cloud.afterDelete = function(name, func){};
196196

197+
/**
198+
* Registers an on-login function.
199+
* <br/><strong>Available in Cloud Code only</strong>.
200+
* If you want to use onLogin for an user in the AV JavaScript SDK, you should pass the function:
201+
* <code><pre>
202+
AV.Cloud.onLogin(function(request, response) {
203+
// code here
204+
});
205+
* </pre></code>
206+
* @param {Function} func The function to run before an user signin. This function should take two parameters a AV.Cloud.FunctionRequest and a AV.Cloud.FunctionResponse.
207+
*/
208+
AV.Cloud.onLogin = function(func) {};
209+
197210
/**
198211
* Makes an HTTP Request.
199212
* <br/><strong>Available in Cloud Code only</strong>.

lib/file.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,14 @@
505505
if(AV._isNode){
506506
//Use qiniu sdk to upload files to qiniu.
507507
var qiniu = require('qiniu');
508+
var path = require('path');
508509
self._previousSave = self._source.then(function(base64, type) {
509510
//Create 16-bits uuid as qiniu key.
510511
var hexOctet = function() {
511512
return Math.floor((1+Math.random())*0x10000).toString(16).substring(1);
512513
};
513-
var key = hexOctet() + hexOctet() + hexOctet() + hexOctet();
514+
var key = hexOctet() + hexOctet() + hexOctet() + hexOctet()
515+
+ path.extname(self._name);
514516
var data = {
515517
key: key,
516518
ACL: self._acl,

lib/status.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
return null;
6767
return AV.Object.createWithoutData('_Status', this.id);
6868
},
69+
_getDataJSON: function() {
70+
var json = AV._.clone(this.data);
71+
return AV._encode(json);
72+
},
6973
/**
7074
* Send a status by a AV.Query object.
7175
* <p>For example,send a status to male users:<br/><pre>
@@ -101,7 +105,7 @@
101105
this.data = this.data || {};
102106
var currUser = AV.Object.createWithoutData('_User', AV.User.current().id)._toPointer();
103107
this.data.source = this.data.source || currUser;
104-
data.data = this.data;
108+
data.data = this._getDataJSON();
105109
data.inboxType = this.inboxType || 'default';
106110

107111
var request = AV._request('statuses', null, null, 'POST', data);
@@ -113,16 +117,16 @@
113117
})._thenRunCallbacks(options);
114118
},
115119

116-
_finishFetch: function(data){
117-
this.id = data.objectId;
118-
this.createdAt = AV._parseDate(data.createdAt);
119-
this.updatedAt = AV._parseDate(data.updatedAt);
120-
this.messageId = data.messageId;
121-
delete data.messageId;
122-
delete data.objectId;
123-
delete data.createdAt;
124-
delete data.updatedAt;
125-
this.data = data;
120+
_finishFetch: function(serverData){
121+
this.id = serverData.objectId;
122+
this.createdAt = AV._parseDate(serverData.createdAt);
123+
this.updatedAt = AV._parseDate(serverData.updatedAt);
124+
this.messageId = serverData.messageId;
125+
delete serverData.messageId;
126+
delete serverData.objectId;
127+
delete serverData.createdAt;
128+
delete serverData.updatedAt;
129+
this.data = AV._decode(undefined, serverData);
126130
}
127131
};
128132

@@ -158,7 +162,7 @@
158162
data.query = query;
159163
status.data = status.data || {};
160164
status.data.source = status.data.source || currUser;
161-
data.data = status.data;
165+
data.data = status._getDataJSON();
162166
data.inboxType = status.inboxType || 'default';
163167

164168
var request = AV._request('statuses', null, null, 'POST', data);
@@ -210,7 +214,7 @@
210214
data.query = query;
211215
status.data = status.data || {};
212216
status.data.source = status.data.source || currUser;
213-
data.data = status.data;
217+
data.data = status._getDataJSON();
214218
data.inboxType = 'private';
215219
status.inboxType = 'private';
216220

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(function(root) {
22
root.AV = root.AV || {};
3-
root.AV.VERSION = "js0.4.7";
3+
root.AV.VERSION = "js0.4.8";
44
}(this));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "avoscloud-sdk",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"main": "./lib/av.js",
55
"description": "AVOSCloud JavaScript SDK.",
66
"repository": {

tools/jsdoc-toolkit/templates/jsdoc/index.tmpl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,36 @@
33
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
44
<head>
55
<meta http-equiv="content-type" content="text/html; charset={+IO.encoding+}" />
6-
7-
<title>JsDoc Reference - Index</title>
6+
7+
<title>LeanCloud JavaScript SDK Reference - Index</title>
88
<meta name="generator" content="JsDoc Toolkit" />
9-
9+
1010
<style type="text/css">
1111
{+include("static/default.css")+}
1212
</style>
1313
</head>
14-
14+
1515
<body>
1616
{+include("static/header.html")+}
17-
17+
1818
<div id="index">
1919
{+publish.classesIndex+}
2020
</div>
21-
21+
2222
<div id="content">
2323
<h1 class="classTitle">Class Index</h1>
24-
24+
2525
<for each="thisClass" in="data">
2626
<div>
2727
<h2>{+(new Link().toSymbol(thisClass.alias))+}</h2>
2828
{+resolveLinks(summarize(thisClass.classDesc))+}
2929
</div>
3030
<hr />
3131
</for>
32-
32+
3333
</div>
3434
<div class="fineprint" style="clear:both">
35-
<if test="JSDOC.opt.D.copyright">&copy;{+JSDOC.opt.D.copyright+}<br /></if>
36-
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> {+JSDOC.VERSION+} on {+new Date()+}
35+
Documentation generated by <a href="https://leancloud.cn" target="_blankt">LeanCloud.cn</a> {+JSDOC.VERSION+} on {+new Date()+}
3736
</div>
3837
</body>
39-
</html>
38+
</html>

0 commit comments

Comments
 (0)