|
@@ -12,7 +12,7 @@ module.exports = function(crowi, app) {
|
|
|
const manifest = require(path.join(crowi.publicDir, 'manifest.json'));
|
|
const manifest = require(path.join(crowi.publicDir, 'manifest.json'));
|
|
|
const agentScriptPath = path.join(crowi.publicDir, manifest['js/agent-for-hackmd.js']);
|
|
const agentScriptPath = path.join(crowi.publicDir, manifest['js/agent-for-hackmd.js']);
|
|
|
// generate swig template
|
|
// generate swig template
|
|
|
- const agentScriptContentTpl = swig.compileFile(agentScriptPath);
|
|
|
|
|
|
|
+ let agentScriptContentTpl = undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -23,6 +23,11 @@ module.exports = function(crowi, app) {
|
|
|
* @param {object} res
|
|
* @param {object} res
|
|
|
*/
|
|
*/
|
|
|
const loadAgent = function(req, res) {
|
|
const loadAgent = function(req, res) {
|
|
|
|
|
+ // generate swig template
|
|
|
|
|
+ if (agentScriptContentTpl == null) {
|
|
|
|
|
+ agentScriptContentTpl = swig.compileFile(agentScriptPath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const origin = `${req.protocol}://${req.get('host')}`;
|
|
const origin = `${req.protocol}://${req.get('host')}`;
|
|
|
const styleFilePath = origin + manifest['styles/style-hackmd.css'];
|
|
const styleFilePath = origin + manifest['styles/style-hackmd.css'];
|
|
|
|
|
|