layout-base.pug 3.5 KB

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