layout-base.pug 4.3 KB

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