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

moved templateChcker and require it in model/page.js

sou 7 лет назад
Родитель
Сommit
ecd95dd720
3 измененных файлов с 3 добавлено и 10 удалено
  1. 2 9
      lib/models/page.js
  2. 0 0
      lib/util/templateChecker.js
  3. 1 1
      resource/js/components/PageList/PageListMeta.js

+ 2 - 9
lib/models/page.js

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