got build js path working with mathjax

This commit is contained in:
Henry Oswald 2016-07-19 15:10:07 +01:00
parent 0cbd9d0ff9
commit f8c38f30a8
2 changed files with 14 additions and 6 deletions

View file

@ -68,11 +68,19 @@ module.exports = (app, webRouter, apiRouter)->
cssPath = "/stylesheets/"
res.locals.buildJsPath = (jsFile, fingerprint)->
if !fingerprint?
fingerprint = getFingerprint(jsPath + jsFile)
res.locals.buildJsPath = (jsFile, opts = {})->
if !opts.qs?
opts.qs = {}
if !opts.fingerprint?
opts.fingerprint = getFingerprint(jsPath + jsFile)
else
opts.qs.fingerprint = opts.fingerprint
p = Path.join(jsPath, jsFile)
return url.resolve(staticFilesBase, p) + "?fingerprint=" + fingerprint
p = url.resolve(staticFilesBase, p)
qs = querystring.stringify(opts.qs)
if qs?
p = p + "?" + qs
return p
res.locals.buildCssPath = (cssFile)->

View file

@ -100,7 +100,7 @@ block content
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
window.requirejs = {
"paths" : {
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML",
"mathjax": "#{buildJsPath('/libs/mathjax/MathJax.js', {qs:{config:'TeX-AMS_HTML'}})}",
"moment": "libs/moment-2.7.0",
"libs/pdf": "libs/pdfjs-1.3.91/pdf"
},
@ -129,7 +129,7 @@ block content
- var pdfPath = 'libs/pdfjs-1.3.91/pdf.worker.js'
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
- var pdfJsWorkerPath = buildJsPath(pdfPath, fingerprintedPath)
- var pdfJsWorkerPath = buildJsPath(pdfPath, {fingerprint:fingerprintedPath})
script(type='text/javascript').