Просмотр исходного кода

moved templateChcker and require it in model/page.js

sou 7 лет назад
Родитель
Сommit
ecd95dd720

+ 2 - 9
lib/models/page.js

@@ -2,6 +2,7 @@ module.exports = function(crowi) {
   var debug = require('debug')('growi:models:page')
     , mongoose = require('mongoose')
     , escapeStringRegexp = require('escape-string-regexp')
+    , templateChecker = require('../util/templateChecker')
     , ObjectId = mongoose.Schema.Types.ObjectId
     , GRANT_PUBLIC = 1
     , GRANT_RESTRICTED = 2
@@ -28,14 +29,6 @@ module.exports = function(crowi) {
     return false;
   }
 
-  function isTemplatePath(path) {
-    if (path.match(/.*\/_{1,2}template$/)) {
-      return true;
-    }
-
-    return false;
-  }
-
   pageSchema = new mongoose.Schema({
     path: { type: String, required: true, index: true, unique: true },
     revision: { type: ObjectId, ref: 'Revision' },
@@ -105,7 +98,7 @@ module.exports = function(crowi) {
   };
 
   pageSchema.methods.isTemplate = function() {
-    return isTemplatePath(this.path);
+    return templateChecker(this.path);
   };
 
   pageSchema.methods.isCreator = function(userData) {

+ 0 - 0
resource/js/util/templateChecker.js → lib/util/templateChecker.js


+ 1 - 1
resource/js/components/PageList/PageListMeta.js

@@ -14,7 +14,7 @@ export default class PageListMeta extends React.Component {
   render() {
     // TODO isPortal()
     const page = this.props.page;
-    const templateChecker = require('../../util/templateChecker');
+    const templateChecker = require('../../../../lib/util/templateChecker');
 
     // portal check
     let PortalLabel;