layout-marketing.pug 4.5 KB

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