From c21549220c96979a04786cffbce809288f584736 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 18 Jul 2016 14:05:07 +0100 Subject: [PATCH] mvp for cdn --- .../app/coffee/infrastructure/ExpressLocals.coffee | 11 +++++++++++ services/web/app/views/general/500.jade | 4 ++-- services/web/app/views/layout.jade | 2 +- services/web/app/views/project/list/side-bar.jade | 4 ++-- .../views/subscriptions/successful_subscription.jade | 4 ++-- .../app/views/translations/translation_message.jade | 2 +- services/web/config/settings.defaults.coffee | 4 ++++ 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index faba1e4623..ce5bf50b87 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -16,6 +16,15 @@ jsPath = else "/js/" + +imgPath = "/img/" +cssPath = "/stylesheets/" + +if Settings.cdn?.web?.host? + jsPath = "#{Settings.cdn?.web?.host}#{jsPath}" + imgPath = "#{Settings.cdn?.web?.host}#{imgPath}" + cssPath = "#{Settings.cdn?.web?.host}#{cssPath}" + logger.log "Generating file fingerprints..." for path in [ "#{jsPath}libs/require.js", @@ -46,6 +55,8 @@ module.exports = (app, webRouter, apiRouter)-> webRouter.use (req, res, next)-> res.locals.jsPath = jsPath + res.locals.imgPath = imgPath + res.locals.cssPath = cssPath next() webRouter.use (req, res, next)-> diff --git a/services/web/app/views/general/500.jade b/services/web/app/views/general/500.jade index e045a7d457..c6f32ae448 100644 --- a/services/web/app/views/general/500.jade +++ b/services/web/app/views/general/500.jade @@ -3,7 +3,7 @@ html(itemscope, itemtype='http://schema.org/Product') head title Something went wrong link(rel="icon", href="/favicon.ico") - link(rel='stylesheet', href='/stylesheets/style.css') + link(rel='stylesheet', href=cssPath+'/style.css') link(href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css",rel="stylesheet") body .content @@ -12,7 +12,7 @@ html(itemscope, itemtype='http://schema.org/Product') .col-md-8.col-md-offset-2.text-center .page-header h2 Oh dear, something went wrong. - p: img(src="/img/lion-sad-128.png", alt="Sad Lion") + p: img(src=imgPath+"lion-sad-128.png", alt="Sad Lion") 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} p diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index efe1691df9..f1e4693008 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -18,7 +18,7 @@ html(itemscope, itemtype='http://schema.org/Product') title= translate(title) + ' - ShareLaTeX, '+translate("online_latex_editor") link(rel="icon", href="/favicon.ico") - link(rel='stylesheet', href='/stylesheets/style.css?fingerprint='+fingerprint('/stylesheets/style.css')) + link(rel='stylesheet', href=cssPath+'/style.css?fingerprint='+fingerprint('/stylesheets/style.css')) if settings.i18n.subdomainLang each subdomainDetails in settings.i18n.subdomainLang diff --git a/services/web/app/views/project/list/side-bar.jade b/services/web/app/views/project/list/side-bar.jade index 11de6e3b14..10f28aa496 100644 --- a/services/web/app/views/project/list/side-bar.jade +++ b/services/web/app/views/project/list/side-bar.jade @@ -135,7 +135,7 @@ p span Get Dropbox Sync p - img(src="/img/dropbox/simple_logo.png") + img(src=imgPath+"dropbox/simple_logo.png") p a(href="/user/subscription/plans", sixpack-convert="left-menu-upgraed-rotation").btn.btn-primary #{translate("upgrade")} p.small.text-centered @@ -148,7 +148,7 @@ p span Get Github Sync p - img(src="/img/github/octocat.jpg") + img(src=imgPath+"github/octocat.jpg") p a(href="/user/subscription/plans", sixpack-convert="left-menu-upgraed-rotation").btn.btn-primary #{translate("upgrade")} p.small.text-centered diff --git a/services/web/app/views/subscriptions/successful_subscription.jade b/services/web/app/views/subscriptions/successful_subscription.jade index 86b0263238..7ed77b6518 100644 --- a/services/web/app/views/subscriptions/successful_subscription.jade +++ b/services/web/app/views/subscriptions/successful_subscription.jade @@ -30,10 +30,10 @@ block content | Henry and James .portraits span.img-circle - img(src="/img/about/henry_oswald.jpg") + img(src=imgPath+"about/henry_oswald.jpg") |   span.img-circle - img(src="/img/about/james_allen.jpg") + img(src=imgPath+"about/james_allen.jpg") p a.btn.btn-primary(href="/project") < #{translate("back_to_your_projects")} diff --git a/services/web/app/views/translations/translation_message.jade b/services/web/app/views/translations/translation_message.jade index 333139139f..cf3ba0ce17 100644 --- a/services/web/app/views/translations/translation_message.jade +++ b/services/web/app/views/translations/translation_message.jade @@ -2,7 +2,7 @@ span(ng-controller="TranslationsPopupController", ng-cloak) .translations-message(ng-hide="hidei18nNotification") a(href=recomendSubdomain.url+currentUrl) !{translate("click_here_to_view_sl_in_lng", {lngName:"" + translate(recomendSubdomain.lngCode) + ""})} - img(src="/img/flags/24/#{recomendSubdomain.lngCode}.png") + img(src=imgPath+"flags/24/#{recomendSubdomain.lngCode}.png") button(ng-click="dismiss()").close.pull-right span(aria-hidden="true") × span.sr-only #{translate("close")} \ No newline at end of file diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index e98970fa60..85b12cec56 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -114,6 +114,10 @@ module.exports = settings = showSocialButtons: false showComments: false + # cdn: + # web: + # host:"https://www.somewhere.com" + # Where your instance of ShareLaTeX can be found publically. Used in emails # that are sent out, generated links, etc. siteUrl : siteUrl = 'http://localhost:3000'