layout-base.pug 3.9 KB

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