Yuki Takei 6 лет назад
Родитель
Сommit
84d00df638

+ 1 - 3
packages/growi-plugin-attachment-refs/src/client/js/util/RefsContext.js

@@ -62,8 +62,6 @@ export default class RefsContext extends TagContext {
     //   2: constructor argument
     const specifiedPath = this.options.page || this.fromPagePath;
     this.pagePath = this.getAbsolutePathFor(specifiedPath);
-
-    console.log('pagePath', this.pagePath);
   }
 
   /**
@@ -115,7 +113,7 @@ export default class RefsContext extends TagContext {
     return decodeURIComponent(
       pathUtils.normalizePath( // normalize like /foo/bar
         url.resolve(pathUtils.addTrailingSlash(this.fromPagePath), relativePath)
-      )
+      ),
     );
   }
 }

+ 18 - 0
packages/growi-plugin-attachment-refs/src/server/routes/refs.js

@@ -16,6 +16,7 @@ module.exports = (crowi) => {
   router.get('/ref', async(req, res) => {
     const user = req.user;
     const { pagePath, fileName } = req.query;
+    // eslint-disable-next-line no-unused-vars
     const options = JSON.parse(req.query.options);
 
     if (pagePath == null) {
@@ -57,5 +58,22 @@ module.exports = (crowi) => {
     res.status(200).send({ attachment });
   });
 
+  /**
+   * return a list of Attachment
+   */
+  router.get('/refs', async(req, res) => {
+    const user = req.user;
+    const { prefix, pagePath } = req.query;
+    // eslint-disable-next-line no-unused-vars
+    const options = JSON.parse(req.query.options);
+
+    if (prefix == null && pagePath == null) {
+      res.status(400).send('either the param \'prefix\' or \'pagePath\' must be set.');
+      return;
+    }
+
+    res.status(200).send({ attachments: [] });
+  });
+
   return router;
 };