mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-01 20:22:29 +00:00
feature(markdown) add
This commit is contained in:
parent
3785f9ee1e
commit
79c51c5120
3 changed files with 34 additions and 5 deletions
|
|
@ -24,7 +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'),
|
||||
markdown = main.srvrequire('rest/markdown'),
|
||||
|
||||
JSONDIR = main.JSONDIR,
|
||||
OK = 200,
|
||||
|
|
@ -105,10 +105,11 @@
|
|||
if (isFS)
|
||||
onFS(pParams);
|
||||
else if (isMD)
|
||||
pipe.getBody(p.request, function(data) {
|
||||
markdown.parse(data, function(data) {
|
||||
markdown.operate(p.request, function(error, data) {
|
||||
if (error)
|
||||
sendError(p, error);
|
||||
else
|
||||
sendResponse(p, data, NOT_LOG);
|
||||
});
|
||||
});
|
||||
else {
|
||||
if (p.name[0] === '/')
|
||||
|
|
|
|||
28
lib/server/rest/markdown.js
Normal file
28
lib/server/rest/markdown.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
(function(){
|
||||
'use strict';
|
||||
|
||||
var main = global.cloudcmd.main,
|
||||
DIR = main.DIR,
|
||||
MD_DIR = 'rest/markdown/',
|
||||
pipe = main.pipe,
|
||||
parse = main.srvrequire(MD_DIR + 'put').parse,
|
||||
Util = main.util;
|
||||
|
||||
exports.operate = operate;
|
||||
|
||||
function operate(request, callback) {
|
||||
var method = request.method;
|
||||
|
||||
|
||||
switch(method) {
|
||||
case 'GET':
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
pipe.getBody(request, function(data) {
|
||||
parse(data, callback);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
else
|
||||
md = '<pre>' + data + '</pre>';
|
||||
|
||||
Util.exec(callback, md);
|
||||
Util.exec(callback, null, md);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue