layout-base.pug 3.8 KB

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