From 794e6e146df6503800e26194e649ad647abbc399 Mon Sep 17 00:00:00 2001 From: Paulo Jorge Reis Date: Thu, 22 Nov 2018 15:17:10 +0000 Subject: [PATCH] Merge pull request #1180 from sharelatex/pr-ieee-basic-styling-fixed IEEE basic styling fixed GitOrigin-RevId: 2f3fb3850435b52cea5228ac4a0dd2c1a874e36c --- .../infrastructure/ExpressLocals.coffee | 43 +++++++++++------- services/web/app/views/general/500.pug | 2 +- services/web/app/views/layout.pug | 2 +- .../app/views/project/editor/left-menu.pug | 2 +- .../stylesheets/core/ol-ieee-variables.less | 44 +++++++++++++++++++ .../web/public/stylesheets/ol-ieee-style.less | 10 ++--- 6 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 services/web/public/stylesheets/core/ol-ieee-variables.less diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index ee4618687d..9539ce61d1 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -45,6 +45,7 @@ pathList = [ "/stylesheets/style.css" "/stylesheets/ol-style.css" "/stylesheets/ol-light-style.css" + "/stylesheets/ol-ieee-style.css" ].concat(Modules.moduleAssetFiles(jsPath)) if !Settings.useMinifiedJs @@ -126,7 +127,6 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)-> res.locals.lib = PackageVersions.lib - res.locals.buildJsPath = (jsFile, opts = {})-> path = Path.join(jsPath, jsFile) @@ -157,21 +157,33 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)-> else return res.locals.buildJsPath(jsFile, opts) - res.locals.buildCssPath = (cssFile, opts)-> - path = Path.join("/stylesheets/", cssFile) - if opts?.hashedPath && hashedFiles[path]? + + IEEE_BRAND_ID = 15 + res.locals.isIEEE = (brandVariation) -> + brandVariation?.brand_id == IEEE_BRAND_ID + + _buildCssFileName = (themeModifier) -> + return "/" + Settings.brandPrefix + (if themeModifier then themeModifier else "") + "style.css" + + res.locals.getCssThemeModifier = (userSettings, brandVariation) -> + # Themes only exist in OL v2 + if Settings.overleaf? + # The IEEE theme takes precedence over the user personal setting, i.e. a user with + # a theme setting of "light" will still get the IEE theme in IEEE branded projects. + if res.locals.isIEEE(brandVariation) + themeModifier = "ieee-" + else if userSettings?.overallTheme? + themeModifier = userSettings.overallTheme + return themeModifier + + res.locals.buildCssPath = (themeModifier, buildOpts) -> + cssFileName = _buildCssFileName themeModifier + path = Path.join("/stylesheets/", cssFileName) + if buildOpts?.hashedPath && hashedFiles[path]? hashedPath = hashedFiles[path] return Url.resolve(staticFilesBase, hashedPath) return Url.resolve(staticFilesBase, path) - res.locals.buildCssFileNameForUser = (userSettings) -> - if userSettings?.overallTheme? and Settings.overleaf? - themeModifier = userSettings.overallTheme - return res.locals.buildCssFileName(themeModifier) - - res.locals.buildCssFileName = (themeModifier) -> - return "/" + Settings.brandPrefix + (if themeModifier then themeModifier else "") + "style.css" - res.locals.buildImgPath = (imgFile)-> path = Path.join("/img/", imgFile) return Url.resolve(staticFilesBase, path) @@ -183,8 +195,6 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)-> next() - - webRouter.use (req, res, next)-> res.locals.settings = Settings next() @@ -344,10 +354,11 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)-> next() webRouter.use (req, res, next) -> + #TODO if Settings.overleaf? res.locals.overallThemes = [ - { name: "Default", val: "", path: res.locals.buildCssPath(res.locals.buildCssFileName(), {hashedPath:true}) } - { name: "Light", val: "light-", path: res.locals.buildCssPath(res.locals.buildCssFileName("light-"), {hashedPath:true}) } + { name: "Default", val: "", path: res.locals.buildCssPath(null, { hashedPath: true }) } + { name: "Light", val: "light-", path: res.locals.buildCssPath("light-", { hashedPath: true }) } ] next() diff --git a/services/web/app/views/general/500.pug b/services/web/app/views/general/500.pug index f1dc479a1d..db04c72eb3 100644 --- a/services/web/app/views/general/500.pug +++ b/services/web/app/views/general/500.pug @@ -4,7 +4,7 @@ html.full-height(itemscope, itemtype='http://schema.org/Product') title Something went wrong link(rel="icon", href="/" + settings.brandPrefix + "favicon.ico") if buildCssPath - link(rel="stylesheet", href=buildCssPath("/" + settings.brandPrefix + "style.css")) + link(rel="stylesheet", href=buildCssPath(null, { hashedPath: true })) link(href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css",rel="stylesheet") body.full-height .content.content-alt.full-height diff --git a/services/web/app/views/layout.pug b/services/web/app/views/layout.pug index d82d95df39..e89d770a69 100644 --- a/services/web/app/views/layout.pug +++ b/services/web/app/views/layout.pug @@ -25,7 +25,7 @@ html( link(rel="mask-icon", href="/" + settings.brandPrefix + "mask-favicon.svg", color=settings.brandPrefix === 'ol-' ? "#4f9c45" : "#a93529") //- Stylesheet - link(rel='stylesheet', href=buildCssPath(buildCssFileNameForUser(userSettings), {hashedPath:true}), id="main-stylesheet") + link(rel='stylesheet', href=buildCssPath(getCssThemeModifier(userSettings, brandVariation), { hashedPath: true }), id="main-stylesheet") block _headLinks diff --git a/services/web/app/views/project/editor/left-menu.pug b/services/web/app/views/project/editor/left-menu.pug index de64b7c54a..1482644af3 100644 --- a/services/web/app/views/project/editor/left-menu.pug +++ b/services/web/app/views/project/editor/left-menu.pug @@ -139,7 +139,7 @@ aside#left-menu.full-size( each editorTheme in editorThemes option(value=editorTheme) #{editorTheme.replace(/_/g, ' ')} - - if (settings.overleaf != null) + - if (settings.overleaf != null && !isIEEE(brandVariation)) .form-controls label(for="overallTheme") #{translate("overall_theme")} select( diff --git a/services/web/public/stylesheets/core/ol-ieee-variables.less b/services/web/public/stylesheets/core/ol-ieee-variables.less new file mode 100644 index 0000000000..143d948aff --- /dev/null +++ b/services/web/public/stylesheets/core/ol-ieee-variables.less @@ -0,0 +1,44 @@ +@ieee-blue : #00629B; +@ieee-dark-blue : #002855; +@ieee-cyan : #00B5E2; +@ieee-dark-cyan : #009CA6; +@ieee-red : #BA0C2F; +@ieee-orange : #FFA300; +@ieee-yellow : #FFD100; +@ieee-light-green : #78BE20; +@ieee-dark-green : #00843D; +@ieee-purple : #981D97; + +@ol-blue-gray-0 : #F4F5F8; +@ol-blue-gray-1 : #D8E0E6; +@ol-blue-gray-2 : #8195A1; +@ol-blue-gray-3 : #425E6E; +@ol-blue-gray-4 : #26425F; +@ol-blue-gray-5 : #1E3048; +@ol-blue-gray-6 : #112437; + +@ol-green : @ieee-dark-green; +@ol-dark-green : darken(@ieee-dark-green, 15%); +@ol-blue : @ieee-blue; +@ol-dark-blue : @ieee-dark-blue; +@ol-red : @ieee-red; +@ol-dark-red : darken(@ieee-red, 15%); + +@brand-primary : @ieee-blue; +@brand-secondary : @ieee-dark-blue; +@brand-success : @ol-blue; +@brand-info : @ieee-dark-cyan; +@brand-warning : @ieee-orange; +@brand-danger : @ol-red; + +@btn-primary-bg : @ieee-blue; +@link-color : @ieee-blue; +@link-hover-color : @ieee-dark-blue; + +@toolbar-btn-active-bg-color : @ieee-blue; +@file-tree-item-selected-bg : @ieee-blue; +@file-tree-multiselect-bg : @ieee-cyan; + +@editor-toggler-hover-bg-color: @ieee-blue; + +@toggle-switch-highlight-color: @ieee-blue; diff --git a/services/web/public/stylesheets/ol-ieee-style.less b/services/web/public/stylesheets/ol-ieee-style.less index 7484073d2c..1235633f5b 100644 --- a/services/web/public/stylesheets/ol-ieee-style.less +++ b/services/web/public/stylesheets/ol-ieee-style.less @@ -1,6 +1,6 @@ -@import "ol-style.less"; -@import "core/ol-light-variables.less"; +@import 'ol-style.less'; +@import 'core/ol-ieee-variables.less'; -@is-overleaf : true; -@is-overleaf-light : false; -@show-rich-text : true; \ No newline at end of file +@is-overleaf : true; +@is-overleaf-light: false; +@show-rich-text : true;