layout-base.pug 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. include ./_mixins/foot_scripts
  2. doctype html
  3. html(
  4. lang=(currentLngCode || 'en')
  5. class=(fixedSizeDocument ? 'fixed-size-document' : undefined)
  6. )
  7. - metadata = metadata || {}
  8. - let bootstrap5PageStatus = 'disabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
  9. - let bootstrap5PageSplitTest = ''
  10. - let isWebsiteRedesign = false
  11. block entrypointVar
  12. block vars
  13. head
  14. include ./_metadata.pug
  15. - const bootstrapVersion = bootstrap5PageStatus !== 'disabled' && (bootstrap5Override || (bootstrap5PageStatus === 'enabled' && splitTestVariants[bootstrap5PageSplitTest] === 'enabled')) ? 5 : 3
  16. - const ieeeStylesheetEnabled = splitTestVariants?.['ieee-stylesheet'] !== 'disabled'
  17. //- Stylesheet
  18. link(rel='stylesheet', href=buildCssPath(getCssThemeModifier(userSettings, brandVariation, ieeeStylesheetEnabled), bootstrapVersion), id="main-stylesheet")
  19. block css
  20. each file in entrypointStyles(entrypoint)
  21. link(rel='stylesheet', href=file)
  22. block _headLinks
  23. if (typeof suppressRelAlternateLinks == "undefined")
  24. if settings.i18n.subdomainLang
  25. each subdomainDetails in settings.i18n.subdomainLang
  26. if !subdomainDetails.hide
  27. link(rel="alternate", href=subdomainDetails.url + currentUrl, hreflang=subdomainDetails.lngCode)
  28. if (entrypoint !== 'marketing')
  29. link(rel="preload", href=buildJsPath(currentLngCode + "-json.js"), as="script", nonce=scriptNonce)
  30. //- Scripts
  31. if (typeof suppressGoogleAnalytics == "undefined")
  32. include _google_analytics
  33. block meta
  34. meta(name="ol-csrfToken" content=csrfToken)
  35. //- Configure dynamically loaded assets (via webpack) to be downloaded from CDN
  36. //- See: https://webpack.js.org/guides/public-path/#on-the-fly
  37. meta(name="ol-baseAssetPath" content=buildBaseAssetPath())
  38. meta(name="ol-mathJaxPath" content=mathJaxPath)
  39. meta(name="ol-usersEmail" content=getUserEmail())
  40. meta(name="ol-ab" data-type="json" content={})
  41. meta(name="ol-user_id" content=getLoggedInUserId())
  42. //- Internationalisation settings
  43. meta(name="ol-i18n" data-type="json" content={
  44. currentLangCode: currentLngCode
  45. })
  46. //- Expose some settings globally to the frontend
  47. meta(name="ol-ExposedSettings" data-type="json" content=ExposedSettings)
  48. meta(name="ol-splitTestVariants" data-type="json" content=splitTestVariants || {})
  49. meta(name="ol-splitTestInfo" data-type="json" content=splitTestInfo || {})
  50. if (typeof settings.algolia != "undefined")
  51. meta(name="ol-algolia" data-type="json" content={
  52. appId: settings.algolia.app_id,
  53. apiKey: settings.algolia.read_only_api_key,
  54. indexes: settings.algolia.indexes
  55. })
  56. meta(name="ol-isManagedAccount" data-type="boolean" content=isManagedAccount)
  57. each restriction in userRestrictions || []
  58. meta(name='ol-cannot-' + restriction data-type="boolean" content=true)
  59. meta(name="ol-bootstrapVersion" data-type="json" content=bootstrapVersion)
  60. block head-scripts
  61. body(class={
  62. 'thin-footer': showThinFooter,
  63. 'website-redesign': isWebsiteRedesign === true
  64. }, data-theme="default")
  65. if(settings.recaptcha && settings.recaptcha.siteKeyV3)
  66. script(type="text/javascript", nonce=scriptNonce, src="https://www.recaptcha.net/recaptcha/api.js?render=" + settings.recaptcha.siteKeyV3, defer=deferScripts)
  67. if (typeof suppressSkipToContent == "undefined")
  68. a(class="skip-to-content" href="#main-content") #{translate('skip_to_content')}
  69. block body
  70. if (settings.devToolbar.enabled)
  71. div#dev-toolbar
  72. block foot-scripts
  73. +foot-scripts
  74. script(type="text/javascript", nonce=scriptNonce).
  75. window.addEventListener('DOMContentLoaded', function() {
  76. //- Look for bundle
  77. var cdnBlocked = typeof Frontend === 'undefined'
  78. //- Prevent loops
  79. var noCdnAlreadyInUrl = window.location.href.indexOf("nocdn=true") != -1
  80. if (cdnBlocked && !noCdnAlreadyInUrl && navigator.userAgent.indexOf("Googlebot") == -1) {
  81. //- Set query param, server will not set CDN url
  82. window.location.search += "&nocdn=true";
  83. }
  84. })