diff options
author | Cheng-Han, Wu | 2016-05-29 17:54:24 +0800 |
---|---|---|
committer | Cheng-Han, Wu | 2016-05-29 17:54:24 +0800 |
commit | 16990e35a209704aa7538bb3231085c11da05b06 (patch) | |
tree | 0e7a6ed0534559b4ee5cab6bb5e214776b3d9825 /lib | |
parent | c73c32d12759a44c46b18548e7d1ef3fc1678473 (diff) |
Update slide template using ejs instead of mustache to reduce similar package dependency
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config.js | 2 | ||||
-rw-r--r-- | lib/response.js | 19 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/config.js b/lib/config.js index 1f824d0a..9f11c5b5 100644 --- a/lib/config.js +++ b/lib/config.js @@ -38,7 +38,7 @@ var indexpath = config.indexpath || './public/views/index.ejs'; var hackmdpath = config.hackmdpath || './public/views/hackmd.ejs'; var errorpath = config.errorpath || './public/views/error.ejs'; var prettypath = config.prettypath || './public/views/pretty.ejs'; -var slidepath = config.slidepath || './public/views/slide.hbs'; +var slidepath = config.slidepath || './public/views/slide.ejs'; // session var sessionname = config.sessionname || 'connect.sid'; diff --git a/lib/response.js b/lib/response.js index 062bc5db..873dfe4e 100644 --- a/lib/response.js +++ b/lib/response.js @@ -18,7 +18,6 @@ var models = require("./models"); //slides var md = require('reveal.js/plugin/markdown/markdown'); -var Mustache = require('mustache'); //reveal.js var opts = { @@ -244,7 +243,6 @@ function showPublishNote(req, res, next) { function renderPublish(data, res) { var template = config.prettypath; var options = { - url: config.serverurl, cache: !config.debug, filename: template }; @@ -512,14 +510,27 @@ function showPublishSlide(req, res, next) { var render = function (res, title, markdown) { var slides = md.slidify(markdown, opts); - res.end(Mustache.to_html(opts.template, { + var template = config.slidepath; + var options = { + cache: !config.debug, + filename: template + }; + var compiled = ejs.compile(fs.readFileSync(template, 'utf8'), options); + var html = compiled({ url: config.serverurl, title: title, theme: opts.theme, highlightTheme: opts.highlightTheme, slides: slides, options: JSON.stringify(opts.revealOptions, null, 2) - })); + }); + var buf = html; + res.writeHead(200, { + 'Content-Type': 'text/html; charset=UTF-8', + 'Cache-Control': 'private', + 'Content-Length': buf.length + }); + res.end(buf); }; module.exports = response; |