layout-base.pug 3.6 KB

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