Henry Oswald 10 лет назад
Родитель
Сommit
c21549220c

+ 11 - 0
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)-> 

+ 2 - 2
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

+ 1 - 1
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

+ 2 - 2
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

+ 2 - 2
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")}
 

+ 1 - 1
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:"<strong>" + translate(recomendSubdomain.lngCode) + "</strong>"})} 
-				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") &times;
 				span.sr-only #{translate("close")}

+ 4 - 0
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'