|
|
@@ -871,15 +871,15 @@ module.exports = function(crowi, app) {
|
|
|
return res.json(ApiResponse.error(new Error('Parameter path or page_id is required.')));
|
|
|
}
|
|
|
|
|
|
- let pageFinder;
|
|
|
+ let templateFinder;
|
|
|
if (pageId) { // prioritized
|
|
|
- pageFinder = Page.findPageByIdAndGrantedUser(pageId, req.user);
|
|
|
+ templateFinder = Page.findPageByIdAndGrantedUser(pageId, req.user);
|
|
|
}
|
|
|
else if (pagePath) {
|
|
|
- pageFinder = Page.findPage(pagePath, req.user, revisionId);
|
|
|
+ templateFinder = Page.findPage(pagePath, req.user, revisionId);
|
|
|
}
|
|
|
|
|
|
- pageFinder.then(function(pageData) {
|
|
|
+ templateFinder.then(function(pageData) {
|
|
|
var result = {};
|
|
|
result.page = pageData;
|
|
|
|
|
|
@@ -1185,5 +1185,33 @@ module.exports = function(crowi, app) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @api {get} /pages.get Get page data
|
|
|
+ * @apiName GetPage
|
|
|
+ * @apiGroup Page
|
|
|
+ *
|
|
|
+ * @apiParam {String} page_id
|
|
|
+ * @apiParam {String} path
|
|
|
+ * @apiParam {String} revision_id
|
|
|
+ */
|
|
|
+ api.template = function(req, res) {
|
|
|
+ const pagePath = req.query.path || null;
|
|
|
+
|
|
|
+ if (!pagePath) {
|
|
|
+ return res.json(ApiResponse.error(new Error('Parameter path is required.')));
|
|
|
+ }
|
|
|
+
|
|
|
+ const templateFinder = Page.checkIfTemplatesExist(pagePath);
|
|
|
+
|
|
|
+ templateFinder.then(function(templateInfo) {
|
|
|
+ var result = {};
|
|
|
+ result.templateInfo = templateInfo;
|
|
|
+
|
|
|
+ return res.json(ApiResponse.success(result));
|
|
|
+ }).catch(function(err) {
|
|
|
+ return res.json(ApiResponse.error(err));
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
return actions;
|
|
|
};
|