From 3029fb6335135a40eec51a1b597a50b7bb771a66 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Thu, 21 Jul 2016 19:06:53 +0100 Subject: [PATCH] =?UTF-8?q?add=20dark=20host=20option=20and=20don=E2=80=99?= =?UTF-8?q?t=20load=20pdfjs=20worker=20via=20cdn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/app/coffee/infrastructure/ExpressLocals.coffee | 7 ++++++- services/web/app/views/project/editor.jade | 2 +- services/web/config/settings.defaults.coffee | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 2206b0fff1..ee7418dacc 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -52,6 +52,7 @@ getFingerprint = (path) -> logger.log "Finished generating file fingerprints" cdnAvailable = Settings.cdn?.web?.host? +darkCdnAvailable = Settings.cdn?.web?.darkHost? module.exports = (app, webRouter, apiRouter)-> webRouter.use (req, res, next)-> @@ -66,6 +67,8 @@ module.exports = (app, webRouter, apiRouter)-> if cdnAvailable and isLive staticFilesBase = Settings.cdn?.web?.host + else if darkCdnAvailable and isDark + staticFilesBase = Settings.cdn?.web?.darkHost else staticFilesBase = "" @@ -84,7 +87,9 @@ module.exports = (app, webRouter, apiRouter)-> if !opts.qs?.fingerprint? and doFingerPrint opts.qs.fingerprint = getFingerprint(path) - path = Url.resolve(staticFilesBase, path) + if opts.cdn != false + path = Url.resolve(staticFilesBase, path) + qs = querystring.stringify(opts.qs) if qs? and qs.length > 0 diff --git a/services/web/app/views/project/editor.jade b/services/web/app/views/project/editor.jade index eac92b56df..584c252ea8 100644 --- a/services/web/app/views/project/editor.jade +++ b/services/web/app/views/project/editor.jade @@ -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, {qs:{fingerprint:fingerprintedPath}}) + - var pdfJsWorkerPath = buildJsPath(pdfPath, {cdn:false,qs:{fingerprint:fingerprintedPath}}) script(type='text/javascript'). diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index 20c506027c..f345d14129 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -117,6 +117,7 @@ module.exports = settings = # cdn: # web: # host:"http://cdn.sharelatex.dev:3000" + # darkHost:"http://cdn.sharelatex.dev:3000" # Where your instance of ShareLaTeX can be found publically. Used in emails # that are sent out, generated links, etc.