From b2b1be3dda406312add39997ad8bd9494f20b7f8 Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Tue, 16 Feb 2016 20:08:44 -0800 Subject: Support set url path and use relative url, move raphael to bower and fixed minor issue in history --- lib/response.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'lib/response.js') diff --git a/lib/response.js b/lib/response.js index 41723b32..cc1020b3 100644 --- a/lib/response.js +++ b/lib/response.js @@ -68,6 +68,7 @@ function responseError(res, code, detail, msg) { }); var template = config.errorpath; var content = ejs.render(fs.readFileSync(template, 'utf8'), { + url: config.getserverurl(), title: code + ' ' + detail + ' ' + msg, cache: !config.debug, filename: template, @@ -86,6 +87,7 @@ function showIndex(req, res, next) { }); var template = config.indexpath; var content = ejs.render(fs.readFileSync(template, 'utf8'), { + url: config.getserverurl(), useCDN: config.usecdn }); res.write(content); @@ -115,6 +117,7 @@ function responseHackMD(res, noteId) { }; var compiled = ejs.compile(fs.readFileSync(template, 'utf8'), options); var html = compiled({ + url: config.getserverurl(), title: title, useCDN: config.usecdn, robots: (meta && meta.robots) || false //default allow robots @@ -145,7 +148,7 @@ function newNote(req, res, next) { if (err) { return response.errorInternalError(res); } - res.redirect("/" + LZString.compressToBase64(newId)); + res.redirect(config.getserverurl() + "/" + LZString.compressToBase64(newId)); }); }); } @@ -272,6 +275,7 @@ function showPublishNote(req, res, next) { function renderPublish(data, res) { var template = config.prettypath; var options = { + url: config.getserverurl(), cache: !config.debug, filename: template }; @@ -296,7 +300,7 @@ function actionPublish(req, res, noteId) { if (err) { return response.errorNotFound(res); } - res.redirect("/s/" + note.shortid); + res.redirect(config.getserverurl() + "/s/" + note.shortid); }); }); } @@ -311,7 +315,7 @@ function actionSlide(req, res, noteId) { if (err) { return response.errorNotFound(res); } - res.redirect("/p/" + note.shortid); + res.redirect(config.getserverurl() + "/p/" + note.shortid); }); }); } @@ -433,9 +437,9 @@ function noteActions(req, res, next) { break; default: if (noteId != config.featuresnotename) - res.redirect('/' + LZString.compressToBase64(noteId)); + res.redirect(config.getserverurl() + '/' + LZString.compressToBase64(noteId)); else - res.redirect('/' + noteId); + res.redirect(config.getserverurl() + '/' + noteId); break; } }); @@ -463,9 +467,9 @@ function publishNoteActions(req, res, next) { switch (action) { case "edit": if (note.id != config.featuresnotename) - res.redirect('/' + LZString.compressToBase64(note.id)); + res.redirect(config.getserverurl() + '/' + LZString.compressToBase64(note.id)); else - res.redirect('/' + note.id); + res.redirect(config.getserverurl() + '/' + note.id); break; } }); @@ -505,9 +509,9 @@ function githubActions(req, res, next) { break; default: if (noteId != config.featuresnotename) - res.redirect('/' + LZString.compressToBase64(noteId)); + res.redirect(config.getserverurl() + '/' + LZString.compressToBase64(noteId)); else - res.redirect('/' + noteId); + res.redirect(config.getserverurl() + '/' + noteId); break; } }); @@ -627,6 +631,7 @@ var render = function (res, title, markdown) { var slides = md.slidify(markdown, opts); res.end(Mustache.to_html(opts.template, { + url: config.getserverurl(), title: title, theme: opts.theme, highlightTheme: opts.highlightTheme, -- cgit v1.2.3