mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
wip, this does not work minified yet
for some reason lib.js is not being requested no, console errors or network errors
This commit is contained in:
parent
edfc259c53
commit
80e6a660be
4 changed files with 34 additions and 5 deletions
9
services/web/.gitignore
vendored
9
services/web/.gitignore
vendored
|
@ -67,6 +67,15 @@ public/minjs/
|
|||
|
||||
Gemfile.lock
|
||||
|
||||
public/js/libs/fineuploader-5.15.4.*.js
|
||||
public/js/libs/fineuploader-*.js
|
||||
public/js/libs/pdfjs-1.7.225/compatibility.*.js
|
||||
public/js/libs/pdfjs-1.7.225/pdf.*.js
|
||||
public/js/libs/pdfjs-1.7.225/pdf.worker.*.js
|
||||
public/js/libs/require.*.js
|
||||
public/stylesheets/ol-style.*.css
|
||||
public/stylesheets/style.*.css
|
||||
|
||||
*.swp
|
||||
.DS_Store
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ Url = require "url"
|
|||
PackageVersions = require "./PackageVersions"
|
||||
htmlEncoder = new require("node-html-encoder").Encoder("numerical")
|
||||
fingerprints = {}
|
||||
hashedFiles = {}
|
||||
Path = require 'path'
|
||||
Features = require "./Features"
|
||||
|
||||
|
@ -59,6 +60,19 @@ for paths in pathList
|
|||
logger.log "#{filePath}: #{hash}"
|
||||
fingerprints[filePath] = hash
|
||||
|
||||
if paths.length == 1
|
||||
#todo deal with ace multi file hash
|
||||
path = paths[0]
|
||||
splitPath = path.split("/")
|
||||
filenameSplit = splitPath.pop().split(".")
|
||||
filenameSplit.splice(filenameSplit.length-1, 0, hash)
|
||||
splitPath.push(filenameSplit.join("."))
|
||||
hashPath = splitPath.join("/")
|
||||
fsHashPath = Path.join __dirname, "../../../", "public#{hashPath}"
|
||||
fs.writeFileSync(fsHashPath, content)
|
||||
hashedFiles[paths] = hashPath
|
||||
|
||||
|
||||
getFingerprint = (path) ->
|
||||
if fingerprints[path]?
|
||||
return fingerprints[path]
|
||||
|
@ -123,6 +137,9 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
res.locals.buildJsPath = (jsFile, opts = {})->
|
||||
path = Path.join(jsPath, jsFile)
|
||||
|
||||
if opts.hashedPath
|
||||
return hashedFiles[path]
|
||||
|
||||
doFingerPrint = opts.fingerprint != false
|
||||
|
||||
if !opts.qs?
|
||||
|
@ -140,8 +157,11 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
path = path + "?" + qs
|
||||
return path
|
||||
|
||||
res.locals.buildCssPath = (cssFile)->
|
||||
res.locals.buildCssPath = (cssFile, opts)->
|
||||
path = Path.join("/stylesheets/", cssFile)
|
||||
if opts.hashedPath
|
||||
hashedPath = hashedFiles[path]
|
||||
return Url.resolve(staticFilesBase, hashedPath)
|
||||
return Url.resolve(staticFilesBase, path) + "?fingerprint=" + getFingerprint(path)
|
||||
|
||||
res.locals.buildImgPath = (imgFile)->
|
||||
|
|
|
@ -23,7 +23,7 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||
link(rel="apple-touch-icon-precomposed", href="/" + settings.brandPrefix + "apple-touch-icon-precomposed.png")
|
||||
link(rel="mask-icon", href="/" + settings.brandPrefix + "mask-favicon.svg", color="#a93529")
|
||||
|
||||
link(rel='stylesheet', href=buildCssPath("/" + settings.brandPrefix + "style.css"))
|
||||
link(rel='stylesheet', href=buildCssPath("/" + settings.brandPrefix + "style.css", {hashedPath:true}))
|
||||
|
||||
block _headLinks
|
||||
|
||||
|
@ -152,7 +152,7 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||
}
|
||||
};
|
||||
script(
|
||||
data-main=buildJsPath('main.js', {fingerprint:false}),
|
||||
data-main=buildJsPath('main.js', {hashedPath:true}),
|
||||
baseurl=fullJsPath,
|
||||
src=buildJsPath('libs/require.js')
|
||||
)
|
||||
|
|
|
@ -161,8 +161,8 @@ block requirejs
|
|||
window.uiConfig = JSON.parse('!{JSON.stringify(uiConfig).replace(/\//g, "\\/")}');
|
||||
|
||||
script(
|
||||
data-main=buildJsPath("ide.js", {fingerprint:false}),
|
||||
data-main=buildJsPath("ide.js", {hashedPath:true}),
|
||||
baseurl=fullJsPath,
|
||||
data-ace-base=buildJsPath(lib('ace'), {fingerprint:false}),
|
||||
src=buildJsPath('libs/require.js')
|
||||
src=buildJsPath('libs/require.js', {hashedPath:true})
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue