layout.pug 4.6 KB

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