Просмотр исходного кода

got build js path working with mathjax

Henry Oswald 10 лет назад
Родитель
Сommit
f8c38f30a8

+ 12 - 4
services/web/app/coffee/infrastructure/ExpressLocals.coffee

@@ -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)->

+ 2 - 2
services/web/app/views/project/editor.jade

@@ -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').