sou пре 7 година
родитељ
комит
6a992e961d
3 измењених фајлова са 28 додато и 28 уклоњено
  1. 18 18
      lib/models/page.js
  2. 8 8
      lib/routes/page.js
  3. 2 2
      lib/views/modal/create_template.html

+ 18 - 18
lib/models/page.js

@@ -527,21 +527,21 @@ module.exports = function(crowi) {
     });
     });
   };
   };
 
 
-  // check if a given page has a local and global tempalte
+  // check if a given page has a children and decendants tempalte
   pageSchema.statics.checkIfTemplatesExist = function(path) {
   pageSchema.statics.checkIfTemplatesExist = function(path) {
     const Page = this;
     const Page = this;
     const pathList = generatePathsOnTree(path, []);
     const pathList = generatePathsOnTree(path, []);
     const regexpList = pathList.map(path => new RegExp(`${path}/_{1,2}template`));
     const regexpList = pathList.map(path => new RegExp(`${path}/_{1,2}template`));
     let templateInfo = {
     let templateInfo = {
-      localTemplateExists: false,
-      globalTemplateExists: false,
+      childrenTemplateExists: false,
+      decendantsTemplateExists: false,
     };
     };
 
 
     return Page
     return Page
       .find({path: {$in: regexpList}})
       .find({path: {$in: regexpList}})
       .then(templates => {
       .then(templates => {
-        templateInfo.localTemplateExists = (assignTemplateByType(templates, path, '__') ? true : false);
-        templateInfo.globalTemplateExists = (assignGlobalTemplate(templates, path) ? true : false);
+        templateInfo.childrenTemplateExists = (assignTemplateByType(templates, path, '_') ? true : false);
+        templateInfo.decendantsTemplateExists = (assignDecendantsTemplate(templates, path) ? true : false);
 
 
         return templateInfo;
         return templateInfo;
       });
       });
@@ -588,10 +588,10 @@ module.exports = function(crowi) {
     }
     }
   };
   };
 
 
-  const assignGlobalTemplate = (globalTemplates, path) => {
-    const globalTemplate = assignTemplateByType(globalTemplates, path, '_');
-    if (globalTemplate) {
-      return globalTemplate;
+  const assignDecendantsTemplate = (decendantsTemplates, path) => {
+    const decendantsTemplate = assignTemplateByType(decendantsTemplates, path, '__');
+    if (decendantsTemplate) {
+      return decendantsTemplate;
     }
     }
 
 
     if (path === '') {
     if (path === '') {
@@ -599,28 +599,28 @@ module.exports = function(crowi) {
     }
     }
 
 
     const newPath = cutOffLastSlash(path);
     const newPath = cutOffLastSlash(path);
-    return assignGlobalTemplate(globalTemplates, newPath);
+    return assignDecendantsTemplate(decendantsTemplates, newPath);
   };
   };
 
 
   const fetchTemplate = (templates, templatePath) => {
   const fetchTemplate = (templates, templatePath) => {
     let templateBody;
     let templateBody;
     /**
     /**
-     * get local template
+     * get children template
      * __tempate: applicable only to immediate decendants
      * __tempate: applicable only to immediate decendants
      */
      */
-    const localTemplate = assignTemplateByType(templates, templatePath, '__');
+    const childrenTemplate = assignTemplateByType(templates, templatePath, '_');
 
 
     /**
     /**
-     * get global templates
+     * get decendants templates
      * _tempate: applicable to all pages under
      * _tempate: applicable to all pages under
      */
      */
-    const globalTemplate = assignGlobalTemplate(templates, templatePath);
+    const decendantsTemplate = assignDecendantsTemplate(templates, templatePath);
 
 
-    if (localTemplate) {
-      templateBody =  localTemplate.revision.body;
+    if (childrenTemplate) {
+      templateBody =  childrenTemplate.revision.body;
     }
     }
-    else if (globalTemplate) {
-      templateBody = globalTemplate.revision.body;
+    else if (decendantsTemplate) {
+      templateBody = decendantsTemplate.revision.body;
     }
     }
 
 
     return templateBody;
     return templateBody;

+ 8 - 8
lib/routes/page.js

@@ -252,8 +252,8 @@ module.exports = function(crowi, app) {
       tree: [],
       tree: [],
       pageRelatedGroup: null,
       pageRelatedGroup: null,
       template: null,
       template: null,
-      localTemplateExists: false,
-      globalTemplateExists: false,
+      childrenTemplateExists: false,
+      decendantsTemplateExists: false,
     };
     };
 
 
     var pageTeamplate = 'customlayout-selector/page';
     var pageTeamplate = 'customlayout-selector/page';
@@ -286,8 +286,8 @@ module.exports = function(crowi, app) {
           return Page.checkIfTemplatesExist(originalPath);
           return Page.checkIfTemplatesExist(originalPath);
         })
         })
         .then(function(templateInfo) {
         .then(function(templateInfo) {
-          renderVars.localTemplateExists = templateInfo.localTemplateExists;
-          renderVars.globalTemplateExists = templateInfo.globalTemplateExists;
+          renderVars.childrenTemplateExists = templateInfo.childrenTemplateExists;
+          renderVars.decendantsTemplateExists = templateInfo.decendantsTemplateExists;
         })
         })
         .then(() => {
         .then(() => {
           return PageGroupRelation.findByPage(renderVars.page);
           return PageGroupRelation.findByPage(renderVars.page);
@@ -462,8 +462,8 @@ module.exports = function(crowi, app) {
       page: pageData,
       page: pageData,
       revision: pageData.revision || {},
       revision: pageData.revision || {},
       author: pageData.revision.author || false,
       author: pageData.revision.author || false,
-      localTemplateExists: false,
-      globalTemplateExists: false,
+      childrenTemplateExists: false,
+      decendantsTemplateExists: false,
     };
     };
     var userPage = isUserPage(pageData.path);
     var userPage = isUserPage(pageData.path);
     var userData = null;
     var userData = null;
@@ -511,8 +511,8 @@ module.exports = function(crowi, app) {
     }).then(function() {
     }).then(function() {
       return Page.checkIfTemplatesExist(pageData.path)
       return Page.checkIfTemplatesExist(pageData.path)
         .then(function(templateInfo) {
         .then(function(templateInfo) {
-          renderVars.localTemplateExists = templateInfo.localTemplateExists;
-          renderVars.globalTemplateExists = templateInfo.globalTemplateExists;
+          renderVars.childrenTemplateExists = templateInfo.childrenTemplateExists;
+          renderVars.decendantsTemplateExists = templateInfo.decendantsTemplateExists;
         });
         });
     }).then(function() {
     }).then(function() {
       var defaultPageTeamplate = 'customlayout-selector/page';
       var defaultPageTeamplate = 'customlayout-selector/page';

+ 2 - 2
lib/views/modal/create_template.html

@@ -18,7 +18,7 @@
                   <p class="help-block text-center"><small>{{ t('template.local.desc') }}</small></p>
                   <p class="help-block text-center"><small>{{ t('template.local.desc') }}</small></p>
                 </div>
                 </div>
                 <div class="panel-footer text-center">
                 <div class="panel-footer text-center">
-                  {% if localTemplateExists %}
+                  {% if childrenTemplateExists %}
                   <a href="{{ page.path }}/_template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Edit') }}</button></a>
                   <a href="{{ page.path }}/_template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Edit') }}</button></a>
                   {% else %}
                   {% else %}
                   <a href="{{ page.path }}/_template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Create') }}</button></a>
                   <a href="{{ page.path }}/_template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Create') }}</button></a>
@@ -34,7 +34,7 @@
                   <p class="help-block text-center"><small>{{ t('template.global.desc') }}</small></p>
                   <p class="help-block text-center"><small>{{ t('template.global.desc') }}</small></p>
                 </div>
                 </div>
                 <div class="panel-footer text-center">
                 <div class="panel-footer text-center">
-                  {% if globalTemplateExists %}
+                  {% if decendantsTemplateExists %}
                   <a href="{{ page.path }}/__template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Edit') }}</button></a>
                   <a href="{{ page.path }}/__template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Edit') }}</button></a>
                   {% else %}
                   {% else %}
                   <a href="{{ page.path }}/__template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Create') }}</button></a>
                   <a href="{{ page.path }}/__template#edit-form"><button class="btn btn-sm btn-primary">{{ t('Create') }}</button></a>