layout-base.pug 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-dictionariesRoot" content=dictionariesRoot)
  40. meta(name="ol-usersEmail" content=getUserEmail())
  41. meta(name="ol-ab" data-type="json" content={})
  42. meta(name="ol-user_id" content=getLoggedInUserId())
  43. //- Internationalisation settings
  44. meta(name="ol-i18n" data-type="json" content={
  45. currentLangCode: currentLngCode
  46. })
  47. //- Expose some settings globally to the frontend
  48. meta(name="ol-ExposedSettings" data-type="json" content=ExposedSettings)
  49. meta(name="ol-splitTestVariants" data-type="json" content=splitTestVariants || {})
  50. meta(name="ol-splitTestInfo" data-type="json" content=splitTestInfo || {})
  51. if (typeof settings.algolia != "undefined")
  52. meta(name="ol-algolia" data-type="json" content={
  53. appId: settings.algolia.app_id,
  54. apiKey: settings.algolia.read_only_api_key,
  55. indexes: settings.algolia.indexes
  56. })
  57. meta(name="ol-isManagedAccount" data-type="boolean" content=isManagedAccount)
  58. each restriction in userRestrictions || []
  59. meta(name='ol-cannot-' + restriction data-type="boolean" content=true)
  60. meta(name="ol-bootstrapVersion" data-type="json" content=bootstrapVersion)
  61. block head-scripts
  62. body(class={
  63. 'thin-footer': showThinFooter,
  64. 'website-redesign': isWebsiteRedesign === true
  65. }, data-theme="default")
  66. if(settings.recaptcha && settings.recaptcha.siteKeyV3)
  67. script(type="text/javascript", nonce=scriptNonce, src="https://www.recaptcha.net/recaptcha/api.js?render=" + settings.recaptcha.siteKeyV3, defer=deferScripts)
  68. if (typeof suppressSkipToContent == "undefined")
  69. a(class="skip-to-content" href="#main-content") #{translate('skip_to_content')}
  70. block body
  71. if (settings.devToolbar.enabled)
  72. div#dev-toolbar
  73. block foot-scripts
  74. +foot-scripts
  75. script(type="text/javascript", nonce=scriptNonce).
  76. window.addEventListener('DOMContentLoaded', function() {
  77. //- Look for bundle
  78. var cdnBlocked = typeof Frontend === 'undefined'
  79. //- Prevent loops
  80. var noCdnAlreadyInUrl = window.location.href.indexOf("nocdn=true") != -1
  81. if (cdnBlocked && !noCdnAlreadyInUrl && navigator.userAgent.indexOf("Googlebot") == -1) {
  82. //- Set query param, server will not set CDN url
  83. window.location.search += "&nocdn=true";
  84. }
  85. })