layout-base.pug 3.8 KB

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