mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
created buildCssPath img and js path funcs
This commit is contained in:
@@ -12,8 +12,7 @@ fingerprints = {}
|
|||||||
Path = require 'path'
|
Path = require 'path'
|
||||||
|
|
||||||
|
|
||||||
imgPath = "/img/"
|
|
||||||
cssPath = "/stylesheets/"
|
|
||||||
jsPath =
|
jsPath =
|
||||||
if Settings.useMinifiedJs
|
if Settings.useMinifiedJs
|
||||||
"/minjs/"
|
"/minjs/"
|
||||||
@@ -43,12 +42,19 @@ for path in [
|
|||||||
else
|
else
|
||||||
logger.log filePath:filePath, "file does not exist for fingerprints"
|
logger.log filePath:filePath, "file does not exist for fingerprints"
|
||||||
|
|
||||||
|
getFingerprint = (path) ->
|
||||||
|
if fingerprints[path]?
|
||||||
|
return fingerprints[path]
|
||||||
|
else
|
||||||
|
logger.err "No fingerprint for file: #{path}"
|
||||||
|
return ""
|
||||||
|
|
||||||
logger.log "Finished generating file fingerprints"
|
logger.log "Finished generating file fingerprints"
|
||||||
|
|
||||||
|
|
||||||
|
staticFilesBase = ""
|
||||||
if Settings.cdn?.web?.host?
|
if Settings.cdn?.web?.host?
|
||||||
jsPath = "#{Settings.cdn?.web?.host}#{jsPath}"
|
staticFilesBase = Settings.cdn?.web?.host
|
||||||
imgPath = "#{Settings.cdn?.web?.host}#{imgPath}"
|
|
||||||
cssPath = "#{Settings.cdn?.web?.host}#{cssPath}"
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = (app, webRouter, apiRouter)->
|
module.exports = (app, webRouter, apiRouter)->
|
||||||
@@ -58,10 +64,26 @@ module.exports = (app, webRouter, apiRouter)->
|
|||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
res.locals.jsPath = jsPath
|
res.locals.jsPath = jsPath
|
||||||
res.locals.imgPath = imgPath
|
imgPath = "/img/"
|
||||||
res.locals.cssPath = cssPath
|
cssPath = "/stylesheets/"
|
||||||
|
|
||||||
|
|
||||||
|
res.locals.buildJsPath = (jsFile, fingerprint)->
|
||||||
|
if !fingerprint?
|
||||||
|
fingerprint = getFingerprint(jsPath + jsFile)
|
||||||
|
p = Path.join(staticFilesBase, jsPath, jsFile) + "?fingerprint=" + fingerprint
|
||||||
|
|
||||||
|
|
||||||
|
res.locals.buildCssPath = (cssFile)->
|
||||||
|
return Path.join(staticFilesBase, cssPath, cssFile) + "?fingerprint=" + getFingerprint(cssPath + cssFile)
|
||||||
|
|
||||||
|
res.locals.buildImgPath = (imgFile)->
|
||||||
|
return Path.join(staticFilesBase, imgPath, imgFile)
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
res.locals.settings = Settings
|
res.locals.settings = Settings
|
||||||
next()
|
next()
|
||||||
@@ -127,12 +149,7 @@ module.exports = (app, webRouter, apiRouter)->
|
|||||||
next()
|
next()
|
||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
res.locals.fingerprint = (path) ->
|
res.locals.fingerprint = getFingerprint
|
||||||
if fingerprints[path]?
|
|
||||||
return fingerprints[path]
|
|
||||||
else
|
|
||||||
logger.err "No fingerprint for file: #{path}"
|
|
||||||
return ""
|
|
||||||
next()
|
next()
|
||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||||||
head
|
head
|
||||||
title Something went wrong
|
title Something went wrong
|
||||||
link(rel="icon", href="/favicon.ico")
|
link(rel="icon", href="/favicon.ico")
|
||||||
link(rel='stylesheet', href=cssPath+'/style.css')
|
link(rel='stylesheet', href=buildCssPath('/style.css'))
|
||||||
link(href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css",rel="stylesheet")
|
link(href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css",rel="stylesheet")
|
||||||
body
|
body
|
||||||
.content
|
.content
|
||||||
@@ -12,7 +12,7 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||||||
.col-md-8.col-md-offset-2.text-center
|
.col-md-8.col-md-offset-2.text-center
|
||||||
.page-header
|
.page-header
|
||||||
h2 Oh dear, something went wrong.
|
h2 Oh dear, something went wrong.
|
||||||
p: img(src=imgPath+"lion-sad-128.png", alt="Sad Lion")
|
p: img(src=buildImgPath("lion-sad-128.png"), alt="Sad Lion")
|
||||||
p
|
p
|
||||||
| Something went wrong with your request, sorry. Our staff are probably looking into this, but if it continues, please contact us at #{settings.adminEmail}
|
| Something went wrong with your request, sorry. Our staff are probably looking into this, but if it continues, please contact us at #{settings.adminEmail}
|
||||||
p
|
p
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||||||
-if (typeof(title) == "undefined")
|
-if (typeof(title) == "undefined")
|
||||||
title= 'ShareLaTeX, '+ translate("online_latex_editor")
|
title= 'ShareLaTeX, '+ translate("online_latex_editor")
|
||||||
-else
|
-else
|
||||||
title= translate(title) + ' - ShareLaTeX, '+translate("online_latex_editor")
|
title= translate(title) + ' - ShareLaTeX, ' + translate("online_latex_editor")
|
||||||
|
|
||||||
link(rel="icon", href="/favicon.ico")
|
link(rel="icon", href="/favicon.ico")
|
||||||
link(rel='stylesheet', href=cssPath+'/style.css?fingerprint='+fingerprint('/stylesheets/style.css'))
|
link(rel='stylesheet', href=buildCssPath('/style.css'))
|
||||||
|
|
||||||
if settings.i18n.subdomainLang
|
if settings.i18n.subdomainLang
|
||||||
each subdomainDetails in settings.i18n.subdomainLang
|
each subdomainDetails in settings.i18n.subdomainLang
|
||||||
@@ -124,8 +124,8 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||||||
window.csrfToken = "#{csrfToken}";
|
window.csrfToken = "#{csrfToken}";
|
||||||
|
|
||||||
block scripts
|
block scripts
|
||||||
script(src="#{jsPath}libs/jquery-1.11.1.min.js")
|
script(src=buildJsPath("libs/jquery-1.11.1.min.js"))
|
||||||
script(src="#{jsPath}libs/angular-1.3.15.min.js")
|
script(src=buildJsPath("libs/angular-1.3.15.min.js"))
|
||||||
script.
|
script.
|
||||||
window.sharelatex = {
|
window.sharelatex = {
|
||||||
siteUrl: '#{settings.siteUrl}',
|
siteUrl: '#{settings.siteUrl}',
|
||||||
@@ -196,7 +196,7 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||||||
script(
|
script(
|
||||||
data-main=jsPath+'main.js',
|
data-main=jsPath+'main.js',
|
||||||
baseurl=jsPath,
|
baseurl=jsPath,
|
||||||
src=jsPath+'libs/require.js?fingerprint='+fingerprint(jsPath + 'libs/require.js')
|
src=buildJsPath('libs/require.js')
|
||||||
)
|
)
|
||||||
|
|
||||||
include contact-us-modal
|
include contact-us-modal
|
||||||
|
|||||||
@@ -129,7 +129,9 @@ block content
|
|||||||
|
|
||||||
- var pdfPath = 'libs/pdfjs-1.3.91/pdf.worker.js'
|
- var pdfPath = 'libs/pdfjs-1.3.91/pdf.worker.js'
|
||||||
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
||||||
- var pdfJsWorkerPath = jsPath+pdfPath+'?fingerprint='+fingerprintedPath
|
- var pdfJsWorkerPath = buildJsPath(pdfPath, fingerprintedPath)
|
||||||
|
|
||||||
|
|
||||||
script(type='text/javascript').
|
script(type='text/javascript').
|
||||||
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@ block content
|
|||||||
data-main=jsPath+"ide.js",
|
data-main=jsPath+"ide.js",
|
||||||
baseurl=jsPath,
|
baseurl=jsPath,
|
||||||
data-ace-base=jsPath+'ace',
|
data-ace-base=jsPath+'ace',
|
||||||
src=jsPath+'libs/require.js?fingerprint='+fingerprint(jsPath + 'libs/require.js')
|
src=buildJsPath('libs/require.js')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@
|
|||||||
p
|
p
|
||||||
span Get Dropbox Sync
|
span Get Dropbox Sync
|
||||||
p
|
p
|
||||||
img(src=imgPath+"dropbox/simple_logo.png")
|
img(src=buildImgPath("dropbox/simple_logo.png"))
|
||||||
p
|
p
|
||||||
a(href="/user/subscription/plans", sixpack-convert="left-menu-upgraed-rotation").btn.btn-primary #{translate("upgrade")}
|
a(href="/user/subscription/plans", sixpack-convert="left-menu-upgraed-rotation").btn.btn-primary #{translate("upgrade")}
|
||||||
p.small.text-centered
|
p.small.text-centered
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
p
|
p
|
||||||
span Get Github Sync
|
span Get Github Sync
|
||||||
p
|
p
|
||||||
img(src=imgPath+"github/octocat.jpg")
|
img(src=buildImgPath("github/octocat.jpg"))
|
||||||
p
|
p
|
||||||
a(href="/user/subscription/plans", sixpack-convert="left-menu-upgraed-rotation").btn.btn-primary #{translate("upgrade")}
|
a(href="/user/subscription/plans", sixpack-convert="left-menu-upgraed-rotation").btn.btn-primary #{translate("upgrade")}
|
||||||
p.small.text-centered
|
p.small.text-centered
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
- if (sentrySrc.match(/^([a-z]+:)?\/\//i))
|
- if (sentrySrc.match(/^([a-z]+:)?\/\//i))
|
||||||
script(src="#{sentrySrc}")
|
script(src="#{sentrySrc}")
|
||||||
- else
|
- else
|
||||||
script(src="#{jsPath}libs/#{sentrySrc}")
|
script(src=buildJsPath("libs/#{sentrySrc}"))
|
||||||
- if (typeof(sentrySrc) != "undefined")
|
- if (typeof(sentrySrc) != "undefined")
|
||||||
script(type="text/javascript").
|
script(type="text/javascript").
|
||||||
if (typeof(Raven) != "undefined" && Raven.config) {
|
if (typeof(Raven) != "undefined" && Raven.config) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ extends ../layout
|
|||||||
block content
|
block content
|
||||||
- locals.supressDefaultJs = true
|
- locals.supressDefaultJs = true
|
||||||
script(data-main=jsPath+'main.js', src=jsPath+'libs/require.js', baseurl=jsPath)
|
script(data-main=jsPath+'main.js', src=jsPath+'libs/require.js', baseurl=jsPath)
|
||||||
script(src=jsPath+'libs/recurly.min.js')
|
script(src=buildJsPath('libs/recurly.min.js'))
|
||||||
|
|
||||||
.content.content-alt
|
.content.content-alt
|
||||||
.container
|
.container
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ block content
|
|||||||
| Henry and James
|
| Henry and James
|
||||||
.portraits
|
.portraits
|
||||||
span.img-circle
|
span.img-circle
|
||||||
img(src=imgPath+"about/henry_oswald.jpg")
|
img(src=buildImgPath("about/henry_oswald.jpg"))
|
||||||
|
|
|
|
||||||
span.img-circle
|
span.img-circle
|
||||||
img(src=imgPath+"about/james_allen.jpg")
|
img(src=buildImgPath("about/james_allen.jpg"))
|
||||||
p
|
p
|
||||||
a.btn.btn-primary(href="/project") < #{translate("back_to_your_projects")}
|
a.btn.btn-primary(href="/project") < #{translate("back_to_your_projects")}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
span(ng-controller="TranslationsPopupController", ng-cloak)
|
span(ng-controller="TranslationsPopupController", ng-cloak)
|
||||||
.translations-message(ng-hide="hidei18nNotification")
|
.translations-message(ng-hide="hidei18nNotification")
|
||||||
a(href=recomendSubdomain.url+currentUrl) !{translate("click_here_to_view_sl_in_lng", {lngName:"<strong>" + translate(recomendSubdomain.lngCode) + "</strong>"})}
|
a(href=recomendSubdomain.url+currentUrl) !{translate("click_here_to_view_sl_in_lng", {lngName:"<strong>" + translate(recomendSubdomain.lngCode) + "</strong>"})}
|
||||||
img(src=imgPath+"flags/24/#{recomendSubdomain.lngCode}.png")
|
img(src=buildImgPath("flags/24/#{recomendSubdomain.lngCode}.png"))
|
||||||
button(ng-click="dismiss()").close.pull-right
|
button(ng-click="dismiss()").close.pull-right
|
||||||
span(aria-hidden="true") ×
|
span(aria-hidden="true") ×
|
||||||
span.sr-only #{translate("close")}
|
span.sr-only #{translate("close")}
|
||||||
Reference in New Issue
Block a user