mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 23:45:30 +00:00
got requirejs working nicely with cdn
This commit is contained in:
parent
f8c38f30a8
commit
6c78ab4ace
6 changed files with 29 additions and 26 deletions
|
@ -64,28 +64,34 @@ module.exports = (app, webRouter, apiRouter)->
|
|||
|
||||
webRouter.use (req, res, next)->
|
||||
res.locals.jsPath = jsPath
|
||||
res.locals.fullJsPath = url.resolve(staticFilesBase, jsPath)
|
||||
|
||||
imgPath = "/img/"
|
||||
cssPath = "/stylesheets/"
|
||||
|
||||
|
||||
res.locals.buildJsPath = (jsFile, opts = {})->
|
||||
p = Path.join(jsPath, jsFile)
|
||||
doFingerPrint = opts.fingerprint != false
|
||||
|
||||
if !opts.qs?
|
||||
opts.qs = {}
|
||||
if !opts.fingerprint?
|
||||
opts.fingerprint = getFingerprint(jsPath + jsFile)
|
||||
else
|
||||
|
||||
if !opts.fingerprint? and doFingerPrint
|
||||
opts.fingerprint = getFingerprint(p)
|
||||
else if doFingerPrint
|
||||
opts.qs.fingerprint = opts.fingerprint
|
||||
p = Path.join(jsPath, jsFile)
|
||||
|
||||
p = url.resolve(staticFilesBase, p)
|
||||
qs = querystring.stringify(opts.qs)
|
||||
if qs?
|
||||
|
||||
if qs? and qs.length > 0
|
||||
p = p + "?" + qs
|
||||
return p
|
||||
|
||||
|
||||
res.locals.buildCssPath = (cssFile)->
|
||||
p = Path.join(cssPath, cssFile)
|
||||
return url.resolve(staticFilesBase, p) + "?fingerprint=" + getFingerprint(cssPath + cssFile)
|
||||
return url.resolve(staticFilesBase, p) + "?fingerprint=" + getFingerprint(p)
|
||||
|
||||
res.locals.buildImgPath = (imgFile)->
|
||||
p = Path.join(imgPath, imgFile)
|
||||
|
|
|
@ -124,8 +124,8 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||
window.csrfToken = "#{csrfToken}";
|
||||
|
||||
block scripts
|
||||
script(src=buildJsPath("libs/jquery-1.11.1.min.js"))
|
||||
script(src=buildJsPath("libs/angular-1.3.15.min.js"))
|
||||
script(src=buildJsPath("libs/jquery-1.11.1.min.js", {fingerprint:false}))
|
||||
script(src=buildJsPath("libs/angular-1.3.15.min.js", {fingerprint:false}))
|
||||
script.
|
||||
window.sharelatex = {
|
||||
siteUrl: '#{settings.siteUrl}',
|
||||
|
@ -194,8 +194,8 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||
}
|
||||
};
|
||||
script(
|
||||
data-main=jsPath+'main.js',
|
||||
baseurl=jsPath,
|
||||
data-main=buildJsPath('main.js'),
|
||||
baseurl=fullJsPath,
|
||||
src=buildJsPath('libs/require.js')
|
||||
)
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ block content
|
|||
window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
|
||||
window.requirejs = {
|
||||
"paths" : {
|
||||
"mathjax": "#{buildJsPath('/libs/mathjax/MathJax.js', {qs:{config:'TeX-AMS_HTML'}})}",
|
||||
"mathjax": "#{buildJsPath('/libs/mathjax/MathJax.js', {qs:{config:'TeX-AMS_HTML', fingerprint:false}})}",
|
||||
"moment": "libs/moment-2.7.0",
|
||||
"libs/pdf": "libs/pdfjs-1.3.91/pdf"
|
||||
},
|
||||
|
@ -136,10 +136,11 @@ block content
|
|||
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
||||
|
||||
script(
|
||||
data-main=jsPath+"ide.js",
|
||||
baseurl=jsPath,
|
||||
data-ace-base=jsPath+'ace',
|
||||
data-main=buildJsPath("ide.js"),
|
||||
baseurl=fullJsPath,
|
||||
data-ace-base=buildJsPath('ace', {fingerprint:false}),
|
||||
src=buildJsPath('libs/require.js')
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ module.exports = settings =
|
|||
|
||||
# cdn:
|
||||
# web:
|
||||
# host:"https://www.somewhere.com"
|
||||
# host:"http://www.sharelatex.dev:3000"
|
||||
|
||||
# Where your instance of ShareLaTeX can be found publically. Used in emails
|
||||
# that are sent out, generated links, etc.
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
define [
|
||||
"base"
|
||||
"ide/pdfng/directives/pdfViewer"
|
||||
"text!libs/pdfListView/TextLayer.css"
|
||||
"text!libs/pdfListView/AnnotationsLayer.css"
|
||||
"text!libs/pdfListView/HighlightsLayer.css"
|
||||
], (
|
||||
App
|
||||
pdfViewer
|
||||
textLayerCss
|
||||
annotationsLayerCss
|
||||
highlightsLayerCss
|
||||
|
||||
) ->
|
||||
if PDFJS?
|
||||
PDFJS.workerSrc = window.pdfJsWorkerPath
|
||||
|
||||
style = $("<style/>")
|
||||
style.text(textLayerCss + "\n" + annotationsLayerCss + "\n" + highlightsLayerCss)
|
||||
$("body").append(style)
|
||||
|
||||
App.directive "pdfng", ["$timeout", "localStorage", ($timeout, localStorage) ->
|
||||
return {
|
||||
scope: {
|
||||
|
|
|
@ -76,3 +76,8 @@
|
|||
@import "app/translations.less";
|
||||
@import "app/contact-us.less";
|
||||
@import "app/sprites.less";
|
||||
|
||||
@import "../js/libs/pdfListView/TextLayer.css";
|
||||
@import "../js/libs/pdfListView/AnnotationsLayer.css";
|
||||
@import "../js/libs/pdfListView/HighlightsLayer.css";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue