mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
introduce PackageVersions module
put all package versions in one central place
This commit is contained in:
parent
95a66bbf00
commit
8b6425317f
5 changed files with 34 additions and 15 deletions
|
@ -1,4 +1,6 @@
|
|||
fs = require "fs"
|
||||
PackageVersions = require "./app/coffee/infrastructure/PackageVersions"
|
||||
pdfjs = PackageVersions.lib('pdfjs')
|
||||
|
||||
module.exports = (grunt) ->
|
||||
grunt.loadNpmTasks 'grunt-contrib-coffee'
|
||||
|
@ -159,10 +161,10 @@ module.exports = (grunt) ->
|
|||
paths:
|
||||
"moment": "libs/moment-2.9.0"
|
||||
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML"
|
||||
"libs/pdf": "libs/pdfjs-1.3.91p1/pdf"
|
||||
"libs/pdf": "libs/#{pdfjs}/pdf"
|
||||
shim:
|
||||
"libs/pdf":
|
||||
deps: ["libs/pdfjs-1.3.91p1/compatibility"]
|
||||
deps: ["libs/#{pdfjs}/compatibility"]
|
||||
|
||||
skipDirOptimize: true
|
||||
modules: [
|
||||
|
|
|
@ -19,6 +19,7 @@ ProjectUpdateHandler = require("./ProjectUpdateHandler")
|
|||
ProjectGetter = require("./ProjectGetter")
|
||||
PrivilegeLevels = require("../Authorization/PrivilegeLevels")
|
||||
AuthenticationController = require("../Authentication/AuthenticationController")
|
||||
PackageVersions = require("../../infrastructure/PackageVersions")
|
||||
|
||||
module.exports = ProjectController =
|
||||
|
||||
|
@ -331,7 +332,7 @@ defaultSettingsForAnonymousUser = (user_id)->
|
|||
|
||||
THEME_LIST = []
|
||||
do generateThemeList = () ->
|
||||
files = fs.readdirSync __dirname + '/../../../../public/js/ace'
|
||||
files = fs.readdirSync __dirname + '/../../../../public/js/' + PackageVersions.lib('ace')
|
||||
for file in files
|
||||
if file.slice(-2) == "js" and file.match(/^theme-/)
|
||||
cleanName = file.slice(0,-3).slice(6)
|
||||
|
|
|
@ -10,17 +10,18 @@ _ = require("underscore")
|
|||
async = require("async")
|
||||
Modules = require "./Modules"
|
||||
Url = require "url"
|
||||
|
||||
PackageVersions = require "./PackageVersions"
|
||||
fingerprints = {}
|
||||
Path = require 'path'
|
||||
|
||||
|
||||
jsPath =
|
||||
if Settings.useMinifiedJs
|
||||
"/minjs/"
|
||||
else
|
||||
"/js/"
|
||||
|
||||
ace = PackageVersions.lib('ace')
|
||||
pdfjs = PackageVersions.lib('pdfjs')
|
||||
|
||||
getFileContent = (filePath)->
|
||||
filePath = Path.join __dirname, "../../../", "public#{filePath}"
|
||||
|
@ -38,10 +39,10 @@ pathList = [
|
|||
["#{jsPath}ide.js"]
|
||||
["#{jsPath}main.js"]
|
||||
["#{jsPath}libs.js"]
|
||||
["#{jsPath}ace/ace.js","#{jsPath}ace/mode-latex.js", "#{jsPath}ace/snippets/latex.js"]
|
||||
["#{jsPath}libs/pdfjs-1.3.91p1/pdf.js"]
|
||||
["#{jsPath}libs/pdfjs-1.3.91p1/pdf.worker.js"]
|
||||
["#{jsPath}libs/pdfjs-1.3.91p1/compatibility.js"]
|
||||
["#{jsPath}#{ace}/ace.js","#{jsPath}#{ace}/mode-latex.js", "#{jsPath}#{ace}/snippets/latex.js"]
|
||||
["#{jsPath}libs/#{pdfjs}/pdf.js"]
|
||||
["#{jsPath}libs/#{pdfjs}/pdf.worker.js"]
|
||||
["#{jsPath}libs/#{pdfjs}/compatibility.js"]
|
||||
["/stylesheets/style.css"]
|
||||
]
|
||||
|
||||
|
@ -92,6 +93,7 @@ module.exports = (app, webRouter, apiRouter)->
|
|||
|
||||
res.locals.jsPath = jsPath
|
||||
res.locals.fullJsPath = Url.resolve(staticFilesBase, jsPath)
|
||||
res.locals.lib = PackageVersions.lib
|
||||
|
||||
res.locals.buildJsPath = (jsFile, opts = {})->
|
||||
path = Path.join(jsPath, jsFile)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
version = {
|
||||
"pdfjs": "1.3.91p1"
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
version: version
|
||||
|
||||
lib: (name) ->
|
||||
if version[name]?
|
||||
return "#{name}-#{version[name]}"
|
||||
else
|
||||
return "#{name}"
|
||||
}
|
|
@ -102,13 +102,14 @@ block content
|
|||
"paths" : {
|
||||
"mathjax": "#{buildJsPath('/libs/mathjax/MathJax.js', {cdn:false, fingerprint:false, qs:{config:'TeX-AMS_HTML'}})}",
|
||||
"moment": "libs/moment-2.7.0",
|
||||
"libs/pdf": "libs/pdfjs-1.3.91p1/pdf",
|
||||
"libs/pdf": "libs/#{lib('pdfjs')}/pdf",
|
||||
"ace": "#{lib('ace')}"
|
||||
},
|
||||
"urlArgs" : "fingerprint=#{fingerprint(jsPath + 'ide.js')}-#{fingerprint(jsPath + 'libs.js')}",
|
||||
"waitSeconds": 0,
|
||||
"shim": {
|
||||
"libs/pdf": {
|
||||
deps: ["libs/pdfjs-1.3.91p1/compatibility"]
|
||||
deps: ["libs/#{lib('pdfjs')}/compatibility"]
|
||||
},
|
||||
"ace/ext-searchbox": {
|
||||
deps: ["ace/ace"]
|
||||
|
@ -123,14 +124,14 @@ block content
|
|||
}
|
||||
}
|
||||
};
|
||||
window.aceFingerprint = "#{fingerprint(jsPath + 'ace/ace.js')}"
|
||||
window.aceFingerprint = "#{fingerprint(jsPath + lib('ace') + '/ace.js')}"
|
||||
|
||||
- locals.suppressDefaultJs = true
|
||||
|
||||
- var pdfPath = 'libs/pdfjs-1.3.91p1/pdf.worker.js'
|
||||
- var pdfPath = "libs/" + lib('pdfjs') + "/pdf.worker.js"
|
||||
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
||||
- var pdfJsWorkerPath = buildJsPath(pdfPath, {cdn:false,qs:{fingerprint:fingerprintedPath}}) // don't use worker for cdn
|
||||
- var aceWorkerPath = user.betaProgram ? buildJsPath("ace", {cdn:false,fingerprint:false}) : "" // don't use worker for cdn
|
||||
- var aceWorkerPath = user.betaProgram ? buildJsPath(lib('ace'), {cdn:false,fingerprint:false}) : "" // don't use worker for cdn
|
||||
|
||||
script(type='text/javascript').
|
||||
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
||||
|
@ -139,7 +140,7 @@ block content
|
|||
script(
|
||||
data-main=buildJsPath("ide.js", {fingerprint:false}),
|
||||
baseurl=fullJsPath,
|
||||
data-ace-base=buildJsPath('ace', {fingerprint:false}),
|
||||
data-ace-base=buildJsPath(lib('ace'), {fingerprint:false}),
|
||||
src=buildJsPath('libs/require.js')
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue