OSDN Git Service

modified dirInfo api
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Sun, 2 Aug 2015 01:16:31 +0000 (10:16 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Sun, 2 Aug 2015 01:16:31 +0000 (10:16 +0900)
client/index.html
server/api/dirInfo/index.js

index 7b0ece5..4fd18df 100644 (file)
         <script src="/client/app/components/commandModal/commandModal.controller.js"></script>
         <script src="/client/app/components/login/login.controller.js"></script>
         <script src="/client/app/components/login/login.js"></script>
-        <script src="/client/app/components/notes/notes.controller.js"></script>
-        <script src="/client/app/components/notes/notes.js"></script>
         <script src="/client/app/components/previewModal/previewModal.controller.js"></script>
         <script src="/client/app/components/saveFileModal/saveFileModal.controller.js"></script>
         <script src="/client/app/components/signup/signup.controller.js"></script>
         <script src="/client/app/components/signup/signup.js"></script>
         <script src="/client/app/components/workspace/workspace.controller.js"></script>
         <script src="/client/app/components/workspace/workspace.js"></script>
+        <script src="/client/app/components/notes/notes.controller.js"></script>
+        <script src="/client/app/components/notes/notes.js"></script>
         <!-- endinject -->
     </body>
 </html>
index a8ac719..a5a46dd 100644 (file)
@@ -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;