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

local and global template separately

sou 7 лет назад
Родитель
Сommit
e82eace2f1
1 измененных файлов с 25 добавлено и 1 удалено
  1. 25 1
      lib/routes/page.js

+ 25 - 1
lib/routes/page.js

@@ -312,14 +312,38 @@ module.exports = function(crowi, app) {
       const rootPageName = originalUrl.replace(/^\/([^\/]*).*$/, '$1');
       const rootPageName = originalUrl.replace(/^\/([^\/]*).*$/, '$1');
       pageTeamplate = 'customlayout-selector/not_found';
       pageTeamplate = 'customlayout-selector/not_found';
 
 
-      return Page.findPage(`/${rootPageName}/_template`)
+      const getGlobalTemplate = Page.findPage(`/${rootPageName}/_template`)
       .then(function(page) {
       .then(function(page) {
         //use not_found template and read template into editor if it exists
         //use not_found template and read template into editor if it exists
         renderVars.template = page.revision.body;
         renderVars.template = page.revision.body;
 
 
         return Promise.resolve();
         return Promise.resolve();
+      })
+      .catch(function(err) {
+        return Promise.reject(err);
       });
       });
 
 
+      return getGlobalTemplate;
+
+      // const lastSlash = originalUrl.lastIndexOf('/');
+      // const templateUrl = `${originalUrl.substr(0, lastSlash)}/@template`;
+
+      // pageTeamplate = 'customlayout-selector/not_found';
+
+      // const getLocalTemplate = Page.findPage(templateUrl)
+      // .then(function(page) {
+      //   //use not_found template and read template into editor if it exists
+      //   renderVars.template = page.revision.body;
+
+      //   return Promise.resolve();
+      // })
+      // .catch(function(err) {
+      //   console.log('no @template for you');
+      //   return Promise.reject(err);
+      // });
+
+      // return getLocalTemplate;
+
 
 
     })
     })
     // get list pages
     // get list pages