-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
259 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-0"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.localeappPull = localeappPull; | ||
exports.localeappPush = localeappPush; | ||
|
||
var _request = require('request'); | ||
|
||
var _request2 = _interopRequireDefault(_request); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var localeapp = 'https://api.localeapp.com'; | ||
|
||
function request(type, url, key) { | ||
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
|
||
return new Promise(function (resolve, reject) { | ||
// console.log(data); | ||
console.log(url); | ||
var fullUrl = localeapp + '/v1/projects/' + key + '/' + url.replace(/^\//, ''); | ||
console.log(fullUrl); | ||
|
||
_request2.default.get(fullUrl, function (error, response, body) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve({ response: response, body: body }); | ||
} | ||
}); | ||
|
||
// jquery.ajax({ | ||
// url: fullUrl, | ||
// type, | ||
// data: JSON.stringify(data), | ||
// dataType: 'json', | ||
// contentType: 'application/json', | ||
// beforeSend(request) { | ||
// // request.setRequestHeader( | ||
// // 'Authorization', | ||
// // 'Token token=' + window.gon.current_user.authentication_token | ||
// // ); | ||
// } | ||
// }).then(resolve, reject).fail(reject); | ||
}); | ||
}; | ||
|
||
function localeappPull(key) { | ||
return request('GET', '/translations/all.yml', key); | ||
}; | ||
|
||
function localeappPush(key, file) {}; | ||
|
||
// export const Annotation = { | ||
// create(data) { | ||
// const entity = data.toEntity ? data.toEntity() : data; | ||
// const annotation = annotationToServer(entity); | ||
// let result; | ||
// return request('POST', '/studio/annotations', { annotation }); | ||
// }, | ||
// update(id, data) { | ||
// const entity = data.toEntity ? data.toEntity() : data; | ||
// const annotation = { | ||
// ...annotationToServer(entity), | ||
// id, | ||
// }; | ||
// let result; | ||
// return request('POST', `/studio/annotations`, { annotation }); | ||
// }, | ||
// delete(id) { | ||
// return request('DELETE', `/studio/annotations/${id}`); | ||
// }, | ||
// }; | ||
|
||
|
||
// export default { | ||
// localeappPush, | ||
// localeappPull, | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import rq from 'request'; | ||
|
||
|
||
const localeapp = 'https://api.localeapp.com'; | ||
|
||
|
||
function request(type, url, key, data={}) { | ||
return new Promise((resolve, reject) => { | ||
// console.log(data); | ||
console.log(url); | ||
const fullUrl = `${localeapp}/v1/projects/${key}/${url.replace(/^\//, '')}`; | ||
console.log(fullUrl); | ||
|
||
rq.get(fullUrl, (error, response, body) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
resolve({ response, body }); | ||
} | ||
}); | ||
|
||
// jquery.ajax({ | ||
// url: fullUrl, | ||
// type, | ||
// data: JSON.stringify(data), | ||
// dataType: 'json', | ||
// contentType: 'application/json', | ||
// beforeSend(request) { | ||
// // request.setRequestHeader( | ||
// // 'Authorization', | ||
// // 'Token token=' + window.gon.current_user.authentication_token | ||
// // ); | ||
// } | ||
// }).then(resolve, reject).fail(reject); | ||
}); | ||
}; | ||
|
||
|
||
export function localeappPull(key) { | ||
return request('GET', '/translations/all.yml', key); | ||
}; | ||
|
||
|
||
export function localeappPush(key, file) { | ||
|
||
}; | ||
|
||
|
||
// export const Annotation = { | ||
// create(data) { | ||
// const entity = data.toEntity ? data.toEntity() : data; | ||
// const annotation = annotationToServer(entity); | ||
// let result; | ||
// return request('POST', '/studio/annotations', { annotation }); | ||
// }, | ||
// update(id, data) { | ||
// const entity = data.toEntity ? data.toEntity() : data; | ||
// const annotation = { | ||
// ...annotationToServer(entity), | ||
// id, | ||
// }; | ||
// let result; | ||
// return request('POST', `/studio/annotations`, { annotation }); | ||
// }, | ||
// delete(id) { | ||
// return request('DELETE', `/studio/annotations/${id}`); | ||
// }, | ||
// }; | ||
|
||
|
||
// export default { | ||
// localeappPush, | ||
// localeappPull, | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters