layout.pug 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. doctype html
  2. html(
  3. lang=(currentLngCode || 'en')
  4. )
  5. - metadata = metadata || {}
  6. block vars
  7. head
  8. include ./_metadata.pug
  9. //- Stylesheet
  10. link(rel='stylesheet', href=buildCssPath(getCssThemeModifier(userSettings, brandVariation)), id="main-stylesheet")
  11. block css
  12. each file in entrypointStyles('main')
  13. link(rel='stylesheet', href=file)
  14. block _headLinks
  15. if settings.i18n.subdomainLang
  16. each subdomainDetails in settings.i18n.subdomainLang
  17. if !subdomainDetails.hide
  18. link(rel="alternate", href=subdomainDetails.url+currentUrl, hreflang=subdomainDetails.lngCode)
  19. //- Scripts
  20. //- Google Analytics
  21. if (typeof(gaToken) != "undefined")
  22. script(type="text/javascript", nonce=scriptNonce).
  23. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  24. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  25. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  26. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  27. script(type="text/javascript", nonce=scriptNonce).
  28. ga('create', '#{gaToken}', '#{settings.cookieDomain.replace(/^\./, "")}');
  29. ga('set', 'anonymizeIp', true);
  30. ga('send', 'pageview');
  31. try {
  32. ga.isBlocked = localStorage.getItem('gaBlocked') === 'true'
  33. if (!ga.isBlocked) {
  34. window.addEventListener('load', function () {
  35. setTimeout(function () {
  36. if (!ga.loaded) localStorage.setItem('gaBlocked', 'true')
  37. }, 4000)
  38. })
  39. }
  40. } catch (e) {}
  41. else
  42. script(type="text/javascript", nonce=scriptNonce).
  43. window.ga = function() { console.log("would send to GA", arguments) };
  44. if (typeof(gaTokenV4) != "undefined")
  45. script(async, nonce=scriptNonce, src='https://www.googletagmanager.com/gtag/js?id=' + gaTokenV4)
  46. script(type="text/javascript", nonce=scriptNonce).
  47. window.dataLayer = window.dataLayer || [];
  48. function gtag(){dataLayer.push(arguments);}
  49. gtag('js', new Date());
  50. gtag('config', '#{gaTokenV4}');
  51. block meta
  52. meta(name="ol-csrfToken" content=csrfToken)
  53. //- Configure dynamically loaded assets (via webpack) to be downloaded from CDN
  54. //- See: https://webpack.js.org/guides/public-path/#on-the-fly
  55. meta(name="ol-baseAssetPath" content=buildBaseAssetPath())
  56. meta(name="ol-usersEmail" content=getUserEmail())
  57. meta(name="ol-sharelatex" data-type="json" content={
  58. siteUrl: settings.siteUrl,
  59. wsUrl,
  60. })
  61. meta(name="ol-ab" data-type="json" content={})
  62. meta(name="ol-user_id" content=getLoggedInUserId())
  63. //- Internationalisation settings
  64. meta(name="ol-i18n" data-type="json" content={
  65. currentLangCode: currentLngCode
  66. })
  67. //- Expose some settings globally to the frontend
  68. meta(name="ol-ExposedSettings" data-type="json" content=ExposedSettings)
  69. meta(name="ol-splitTestVariants" data-type="json" content=splitTestVariants || {})
  70. if (typeof(settings.algolia) != "undefined")
  71. meta(name="ol-algolia" data-type="json" content={
  72. appId: settings.algolia.app_id,
  73. apiKey: settings.algolia.read_only_api_key,
  74. indexes: settings.algolia.indexes
  75. })
  76. if (typeof(settings.templates) != "undefined")
  77. meta(name="ol-sharelatex.templates" data-type="json" content={
  78. user_id : settings.templates.user_id,
  79. cdnDomain : settings.templates.cdnDomain,
  80. indexName : settings.templates.indexName
  81. })
  82. block head-scripts
  83. body(ng-csp=(cspEnabled ? "no-unsafe-eval" : false))
  84. if(settings.recaptcha && settings.recaptcha.siteKeyV3)
  85. script(type="text/javascript", nonce=scriptNonce, src="https://www.recaptcha.net/recaptcha/api.js?render="+settings.recaptcha.siteKeyV3)
  86. if (typeof(suppressSkipToContent) == "undefined")
  87. a(class="skip-to-content" href="#main-content") #{translate('skip_to_content')}
  88. if (typeof(suppressNavbar) == "undefined")
  89. include layout/navbar
  90. block content
  91. if (typeof(suppressFooter) == "undefined")
  92. include layout/footer
  93. != moduleIncludes("contactModal", locals)
  94. block foot-scripts
  95. each file in entrypointScripts("main")
  96. script(type="text/javascript", nonce=scriptNonce, src=file)
  97. script(type="text/javascript", nonce=scriptNonce).
  98. //- Look for bundle
  99. var cdnBlocked = typeof Frontend === 'undefined'
  100. //- Prevent loops
  101. var noCdnAlreadyInUrl = window.location.href.indexOf("nocdn=true") != -1
  102. if (cdnBlocked && !noCdnAlreadyInUrl && navigator.userAgent.indexOf("Googlebot") == -1) {
  103. //- Set query param, server will not set CDN url
  104. window.location.search += "&nocdn=true";
  105. }