Skip to content
Snippets Groups Projects
Commit 083293df authored by Brian Gough's avatar Brian Gough Committed by GitHub
Browse files

Merge pull request #333 from sharelatex/support-package-versions

Support package versions
parents 91633dce 7d28d784
Branches
No related tags found
No related merge requests found
fs = require "fs" fs = require "fs"
PackageVersions = require "./app/coffee/infrastructure/PackageVersions"
module.exports = (grunt) -> module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-coffee' grunt.loadNpmTasks 'grunt-contrib-coffee'
...@@ -157,12 +158,12 @@ module.exports = (grunt) -> ...@@ -157,12 +158,12 @@ module.exports = (grunt) ->
inlineText: false inlineText: false
preserveLicenseComments: false preserveLicenseComments: false
paths: paths:
"moment": "libs/moment-2.9.0" "moment": "libs/#{PackageVersions.lib('moment')}"
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML" "mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML"
"libs/pdf": "libs/pdfjs-1.3.91p1/pdf" "libs/pdf": "libs/#{PackageVersions.lib('pdfjs')}/pdf"
shim: shim:
"libs/pdf": "libs/pdf":
deps: ["libs/pdfjs-1.3.91p1/compatibility"] deps: ["libs/#{PackageVersions.lib('pdfjs')}/compatibility"]
skipDirOptimize: true skipDirOptimize: true
modules: [ modules: [
......
...@@ -19,6 +19,7 @@ ProjectUpdateHandler = require("./ProjectUpdateHandler") ...@@ -19,6 +19,7 @@ ProjectUpdateHandler = require("./ProjectUpdateHandler")
ProjectGetter = require("./ProjectGetter") ProjectGetter = require("./ProjectGetter")
PrivilegeLevels = require("../Authorization/PrivilegeLevels") PrivilegeLevels = require("../Authorization/PrivilegeLevels")
AuthenticationController = require("../Authentication/AuthenticationController") AuthenticationController = require("../Authentication/AuthenticationController")
PackageVersions = require("../../infrastructure/PackageVersions")
module.exports = ProjectController = module.exports = ProjectController =
...@@ -333,7 +334,7 @@ defaultSettingsForAnonymousUser = (user_id)-> ...@@ -333,7 +334,7 @@ defaultSettingsForAnonymousUser = (user_id)->
THEME_LIST = [] THEME_LIST = []
do generateThemeList = () -> do generateThemeList = () ->
files = fs.readdirSync __dirname + '/../../../../public/js/ace' files = fs.readdirSync __dirname + '/../../../../public/js/' + PackageVersions.lib('ace')
for file in files for file in files
if file.slice(-2) == "js" and file.match(/^theme-/) if file.slice(-2) == "js" and file.match(/^theme-/)
cleanName = file.slice(0,-3).slice(6) cleanName = file.slice(0,-3).slice(6)
......
...@@ -10,17 +10,18 @@ _ = require("underscore") ...@@ -10,17 +10,18 @@ _ = require("underscore")
async = require("async") async = require("async")
Modules = require "./Modules" Modules = require "./Modules"
Url = require "url" Url = require "url"
PackageVersions = require "./PackageVersions"
fingerprints = {} fingerprints = {}
Path = require 'path' Path = require 'path'
jsPath = jsPath =
if Settings.useMinifiedJs if Settings.useMinifiedJs
"/minjs/" "/minjs/"
else else
"/js/" "/js/"
ace = PackageVersions.lib('ace')
pdfjs = PackageVersions.lib('pdfjs')
getFileContent = (filePath)-> getFileContent = (filePath)->
filePath = Path.join __dirname, "../../../", "public#{filePath}" filePath = Path.join __dirname, "../../../", "public#{filePath}"
...@@ -38,10 +39,10 @@ pathList = [ ...@@ -38,10 +39,10 @@ pathList = [
["#{jsPath}ide.js"] ["#{jsPath}ide.js"]
["#{jsPath}main.js"] ["#{jsPath}main.js"]
["#{jsPath}libs.js"] ["#{jsPath}libs.js"]
["#{jsPath}ace/ace.js","#{jsPath}ace/mode-latex.js", "#{jsPath}ace/snippets/latex.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}/pdf.js"]
["#{jsPath}libs/pdfjs-1.3.91p1/pdf.worker.js"] ["#{jsPath}libs/#{pdfjs}/pdf.worker.js"]
["#{jsPath}libs/pdfjs-1.3.91p1/compatibility.js"] ["#{jsPath}libs/#{pdfjs}/compatibility.js"]
["/stylesheets/style.css"] ["/stylesheets/style.css"]
] ]
...@@ -92,6 +93,7 @@ module.exports = (app, webRouter, apiRouter)-> ...@@ -92,6 +93,7 @@ module.exports = (app, webRouter, apiRouter)->
res.locals.jsPath = jsPath res.locals.jsPath = jsPath
res.locals.fullJsPath = Url.resolve(staticFilesBase, jsPath) res.locals.fullJsPath = Url.resolve(staticFilesBase, jsPath)
res.locals.lib = PackageVersions.lib
res.locals.buildJsPath = (jsFile, opts = {})-> res.locals.buildJsPath = (jsFile, opts = {})->
path = Path.join(jsPath, jsFile) path = Path.join(jsPath, jsFile)
......
version = {
"pdfjs": "1.3.91p1"
"moment": "2.9.0"
}
module.exports = {
version: version
lib: (name) ->
if version[name]?
return "#{name}-#{version[name]}"
else
return "#{name}"
}
...@@ -126,7 +126,12 @@ html(itemscope, itemtype='http://schema.org/Product') ...@@ -126,7 +126,12 @@ html(itemscope, itemtype='http://schema.org/Product')
window.requirejs = { window.requirejs = {
"urlArgs" : "fingerprint=#{fingerprint(jsPath + 'main.js')}-#{fingerprint(jsPath + 'libs.js')}", "urlArgs" : "fingerprint=#{fingerprint(jsPath + 'main.js')}-#{fingerprint(jsPath + 'libs.js')}",
"paths" : { "paths" : {
"moment": "libs/moment-2.7.0" "moment": "libs/#{lib('moment')}"
},
"config":{
"moment":{
"noGlobal": true
}
} }
}; };
script( script(
......
...@@ -101,36 +101,37 @@ block content ...@@ -101,36 +101,37 @@ block content
window.requirejs = { window.requirejs = {
"paths" : { "paths" : {
"mathjax": "#{buildJsPath('/libs/mathjax/MathJax.js', {cdn:false, fingerprint:false, qs:{config:'TeX-AMS_HTML'}})}", "mathjax": "#{buildJsPath('/libs/mathjax/MathJax.js', {cdn:false, fingerprint:false, qs:{config:'TeX-AMS_HTML'}})}",
"moment": "libs/moment-2.7.0", "moment": "libs/#{lib('moment')}",
"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')}", "urlArgs" : "fingerprint=#{fingerprint(jsPath + 'ide.js')}-#{fingerprint(jsPath + 'libs.js')}",
"waitSeconds": 0, "waitSeconds": 0,
"shim": { "shim": {
"libs/pdf": { "libs/pdf": {
deps: ["libs/pdfjs-1.3.91p1/compatibility"] "deps": ["libs/#{lib('pdfjs')}/compatibility"]
}, },
"ace/ext-searchbox": { "ace/ext-searchbox": {
deps: ["ace/ace"] "deps": ["ace/ace"]
}, },
"ace/ext-language_tools": { "ace/ext-language_tools": {
deps: ["ace/ace"] "deps": ["ace/ace"]
} }
}, },
config:{ "config":{
moment:{ "moment":{
noGlobal: true "noGlobal": true
} }
} }
}; };
window.aceFingerprint = "#{fingerprint(jsPath + 'ace/ace.js')}" window.aceFingerprint = "#{fingerprint(jsPath + lib('ace') + '/ace.js')}"
- locals.suppressDefaultJs = true - 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 fingerprintedPath = fingerprint(jsPath+pdfPath)
- var pdfJsWorkerPath = buildJsPath(pdfPath, {cdn:false,qs:{fingerprint:fingerprintedPath}}) // don't use worker for cdn - 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'). script(type='text/javascript').
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}"; window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
...@@ -139,7 +140,7 @@ block content ...@@ -139,7 +140,7 @@ block content
script( script(
data-main=buildJsPath("ide.js", {fingerprint:false}), data-main=buildJsPath("ide.js", {fingerprint:false}),
baseurl=fullJsPath, baseurl=fullJsPath,
data-ace-base=buildJsPath('ace', {fingerprint:false}), data-ace-base=buildJsPath(lib('ace'), {fingerprint:false}),
src=buildJsPath('libs/require.js') src=buildJsPath('libs/require.js')
) )
......
define [ define [
"base" "base"
"libs/moment-2.9.0" "moment"
], (App, moment) -> ], (App, moment) ->
moment.locale "en", calendar: moment.locale "en", calendar:
lastDay : '[Yesterday]' lastDay : '[Yesterday]'
......
define [ define [
"moment"
"ide/track-changes/controllers/TrackChangesListController" "ide/track-changes/controllers/TrackChangesListController"
"ide/track-changes/controllers/TrackChangesDiffController" "ide/track-changes/controllers/TrackChangesDiffController"
"ide/track-changes/directives/infiniteScroll" "ide/track-changes/directives/infiniteScroll"
], () -> ], (moment) ->
class TrackChangesManager class TrackChangesManager
constructor: (@ide, @$scope) -> constructor: (@ide, @$scope) ->
@reset() @reset()
......
define [ define [
"libs/moment-2.9.0" "moment"
"libs/angular-autocomplete/angular-autocomplete" "libs/angular-autocomplete/angular-autocomplete"
"libs/ui-bootstrap" "libs/ui-bootstrap"
"libs/ng-context-menu-0.1.4" "libs/ng-context-menu-0.1.4"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment