sou 7 лет назад
Родитель
Сommit
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';
 
   var debug = require('debug')('growi:routes:page')
+    , swig = require('swig-templates')
     , Page = crowi.model('Page')
     , User = crowi.model('User')
     , Config   = crowi.model('Config')
@@ -329,6 +330,23 @@ module.exports = function(crowi, app) {
 
       return Page.findTemplate(originalPath)
         .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;
         });
     })