mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(rest) add markdown
This commit is contained in:
parent
351ceac00e
commit
68757ec6fd
3 changed files with 28 additions and 14 deletions
|
|
@ -28,19 +28,21 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
'#help li {' +
|
||||
'list-style-type' + ': disc;' +
|
||||
'}'
|
||||
'}' +
|
||||
'img {' +
|
||||
'max-width: 100%' +
|
||||
'}'
|
||||
});
|
||||
|
||||
DOM.ajax({
|
||||
url : '/HELP.md',
|
||||
success : function (pData) {
|
||||
var lData = {text: pData};
|
||||
|
||||
success : function (data) {
|
||||
DOM.ajax({
|
||||
method : 'post',
|
||||
url : 'https://api.github.com/markdown',
|
||||
data : Util.stringifyJSON(lData),
|
||||
success : function(pResult){
|
||||
method : 'put',
|
||||
url : '/api/v1/markdown',
|
||||
data : data,
|
||||
success : function(pResult) {
|
||||
|
||||
var div = DOM.anyload({
|
||||
name : 'div',
|
||||
id : 'help',
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
onFSGet = main.srvrequire('rest/fs/get').onGet,
|
||||
onFSPut = main.srvrequire('rest/fs/put').onPut,
|
||||
onDelete = main.srvrequire('rest/fs/delete').onDelete,
|
||||
markdown = main.srvrequire('rest/markdown/put'),
|
||||
|
||||
JSONDIR = main.JSONDIR,
|
||||
OK = 200,
|
||||
|
|
@ -33,6 +34,8 @@
|
|||
name:'api.json'
|
||||
}),
|
||||
|
||||
NOT_LOG = true,
|
||||
|
||||
fse = main.require('fs-extra') || {
|
||||
copy : function(from, to, callback) {
|
||||
pipe.create({
|
||||
|
|
@ -91,13 +94,22 @@
|
|||
* @param pParams {command, method, body, requrest, response}
|
||||
*/
|
||||
function sendData(pParams) {
|
||||
var p, ret = main.checkParams(pParams);
|
||||
var p, isFS, isMD,
|
||||
ret = main.checkParams(pParams);
|
||||
|
||||
if (ret) {
|
||||
p = pParams;
|
||||
ret = Util.isContainStrAtBegin(p.name, CloudFunc.FS);
|
||||
isFS = Util.isContainStrAtBegin(p.name, CloudFunc.FS),
|
||||
isMD = Util.isContainStrAtBegin(p.name, '/markdown');
|
||||
|
||||
if (ret)
|
||||
if (isFS)
|
||||
onFS(pParams);
|
||||
else if (isMD)
|
||||
pipe.getBody(p.request, function(data) {
|
||||
markdown.parse(data, function(data) {
|
||||
sendResponse(p, data, NOT_LOG);
|
||||
});
|
||||
});
|
||||
else {
|
||||
if (p.name[0] === '/')
|
||||
p.command = Util.removeStrOneTime(p.name, '/');
|
||||
|
|
@ -131,8 +143,7 @@
|
|||
switch (p.request.method) {
|
||||
case 'GET':
|
||||
onFSGet(query, p.name, function(error, data, isFile) {
|
||||
var str,
|
||||
NOT_LOG = true;
|
||||
var str;
|
||||
|
||||
if (error)
|
||||
sendError(params, error);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
"socket.io": "0.9.16",
|
||||
"express": "3.4.x",
|
||||
"http-auth": "2.1.x",
|
||||
"fs-extra": "0.8.x"
|
||||
"fs-extra": "0.8.x",
|
||||
"marked": "~0.3.2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue