From: himetani_cafe Date: Sun, 2 Aug 2015 01:16:31 +0000 (+0900) Subject: modified dirInfo api X-Git-Tag: v0.3.0p0003~13 X-Git-Url: http://git.osdn.net/view?p=eos%2Fzephyr.git;a=commitdiff_plain;h=b76fb64b1aeb1465ec2baa251c1f2003cfd6d884 modified dirInfo api --- diff --git a/client/index.html b/client/index.html index 7b0ece5..4fd18df 100644 --- a/client/index.html +++ b/client/index.html @@ -48,14 +48,14 @@ - - + + diff --git a/server/api/dirInfo/index.js b/server/api/dirInfo/index.js index a8ac719..a5a46dd 100644 --- a/server/api/dirInfo/index.js +++ b/server/api/dirInfo/index.js @@ -9,36 +9,33 @@ var express = require('express'), router.post('', function(req, res) { var dir = req.body.dir, email = req.body.email, - dirPath, - filePath + dirPath, filesInfo - if(dir === 'root') + if(dir === 'root') { dirPath = path.normalize(__dirname+'/../../../workspace/') - else - dirPath = path.normalize(__dirname+'/../../../workspace/'+dir+'/') + jb.findOne('user', function(err, documents) { + filesInfo = documents.workspaces.map(function(file) { + var filePath = dirPath + file + var stat = fs.statSync(filePath) + stat.name = file + return stat + }) + res.send(filesInfo) + }) - jb.findOne('user', function(err, documents) { - var filesInfo = documents.workspaces.map(function(file) { - var filePath = dirPath + file - var stat = fs.statSync(filePath) + } else { + dirPath = path.normalize(__dirname+'/../../../workspace/'+dir) + var files = fs.readdirSync(dirPath) + var filesInfo = files.filter(function(file) { + return file.substring(0,1) !== '.' && file !== 'preview' + }) + .map(function(file) { + var stat = fs.statSync(dirPath+'/'+file) stat.name = file - return stat }) res.send(filesInfo) - }) - - /* - var files = fs.readdirSync(dirPath) - var filesInfo = files.filter(function(file) { - return file.substring(0,1) !== '.' && file !== 'preview' - }) - .map(function(file) { - var stat = fs.statSync(dirPath+'/'+file) - stat.name = file - return stat - }) - */ + } }) module.exports = router;