sou 7 年之前
父節點
當前提交
14e213f641
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      lib/routes/page.js

+ 18 - 0
lib/routes/page.js

@@ -2,6 +2,7 @@ module.exports = function(crowi, app) {
   'use strict';
   'use strict';
 
 
   var debug = require('debug')('growi:routes:page')
   var debug = require('debug')('growi:routes:page')
+    , swig = require('swig-templates')
     , Page = crowi.model('Page')
     , Page = crowi.model('Page')
     , User = crowi.model('User')
     , User = crowi.model('User')
     , Config   = crowi.model('Config')
     , Config   = crowi.model('Config')
@@ -329,6 +330,23 @@ module.exports = function(crowi, app) {
 
 
       return Page.findTemplate(originalPath)
       return Page.findTemplate(originalPath)
         .then(template => {
         .then(template => {
+          if (template) {
+            const today = new Date();
+            const month = ('0' + (today.getMonth() + 1)).slice(-2);
+            const day = ('0' + today.getDate()).slice(-2);
+            const dateString = today.getFullYear() + '/' + month + '/' + day;
+
+            const definitions = {
+              pagepath: originalPath,
+              username: req.user.name,
+              today: dateString,
+            };
+
+            const compiledTemplate = swig.compile(template);
+
+            template = compiledTemplate(definitions);
+          }
+
           renderVars.template = template;
           renderVars.template = template;
         });
         });
     })
     })