layout.pug 4.7 KB

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