Sotaro KARASAWA hace 9 años
padre
commit
a95650c635
Se han modificado 1 ficheros con 47 adiciones y 1 borrados
  1. 47 1
      lib/routes/page.js

+ 47 - 1
lib/routes/page.js

@@ -526,9 +526,55 @@ module.exports = function(crowi, app) {
    *
    * @apiParam {String} body
    * @apiParam {String} path
-   * @apiParam {String} revision_id
+   * @apiParam {String} grant
    */
   api.create = function(req, res){
+    var pageForm = req.body.pageForm;
+    var body = pageForm.body;
+    var currentRevision = pageForm.currentRevision;
+
+    var grant = pageForm.grant;
+    var path = pageForm.path;
+    var body = req.body.page_id || null;
+    var pagePath = req.body.path || null;
+    var grant = req.body.grant || null;
+    if (body === null || pagePath === null) {
+      return res.json(ApiResponse.error('Parameters body and path are required.'));
+    }
+
+    var ignoreNotFound = true;
+    Page.findPage(path, req.user, null, ignoreNotFound)
+    .then(function(data) {
+      pageData = data;
+      if (pageData !== null) {
+        throw new Error('Page exists');
+      }
+
+      return Page.create(path, body, req.user, {grant: grant});
+    }).catch(function(err) {
+      return res.json(ApiResponse.error(err));
+    });;
+
+  };
+
+  /**
+   * @api {post} /pages.update Update page
+   * @apiName UpdatePage
+   * @apiGroup Page
+   *
+   * @apiParam {String} body
+   * @apiParam {String} page_id
+   * @apiParam {String} revision_id
+   *
+   * In the case of the page exists:
+   * - If revision_id is specified => update the page,
+   * - If revision_id is not specified => error.
+   */
+  api.update = function(req, res){
+    var pagePath = req.query.path || null;
+    var pageId = req.query.page_id || null;
+    var revisionId = req.query.revision_id || null;
+
   };
 
   /**