layout-base.pug 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 settings.i18n.subdomainLang
  18. each subdomainDetails in settings.i18n.subdomainLang
  19. if !subdomainDetails.hide
  20. link(rel="alternate", href=subdomainDetails.url+currentUrl, hreflang=subdomainDetails.lngCode)
  21. //- Scripts
  22. include _google_analytics
  23. block meta
  24. meta(name="ol-csrfToken" content=csrfToken)
  25. //- Configure dynamically loaded assets (via webpack) to be downloaded from CDN
  26. //- See: https://webpack.js.org/guides/public-path/#on-the-fly
  27. meta(name="ol-baseAssetPath" content=buildBaseAssetPath())
  28. meta(name="ol-usersEmail" content=getUserEmail())
  29. meta(name="ol-sharelatex" data-type="json" content={
  30. siteUrl: settings.siteUrl,
  31. wsUrl,
  32. })
  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. if (typeof(settings.templates) != "undefined")
  50. meta(name="ol-sharelatex.templates" data-type="json" content={
  51. user_id : settings.templates.user_id,
  52. cdnDomain : settings.templates.cdnDomain,
  53. indexName : settings.templates.indexName
  54. })
  55. each restriction in userRestrictions || []
  56. meta(name='ol-cannot-' + restriction data-type="boolean" content=true)
  57. block head-scripts
  58. body(ng-csp=(cspEnabled ? "no-unsafe-eval" : false) class=(showThinFooter ? 'thin-footer' : undefined))
  59. if(settings.recaptcha && settings.recaptcha.siteKeyV3)
  60. script(type="text/javascript", nonce=scriptNonce, src="https://www.recaptcha.net/recaptcha/api.js?render="+settings.recaptcha.siteKeyV3)
  61. if (typeof(suppressSkipToContent) == "undefined")
  62. a(class="skip-to-content" href="#main-content") #{translate('skip_to_content')}
  63. block body
  64. block foot-scripts
  65. each file in entrypointScripts(entrypoint)
  66. script(type="text/javascript", nonce=scriptNonce, src=file)
  67. script(type="text/javascript", nonce=scriptNonce).
  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. }