layout.pug 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. if gaOptimize === true && typeof(gaOptimizeId) != "undefined"
  34. script(type='text/javascript').
  35. ga('require', '#{gaOptimizeId}')
  36. ga('send', 'event', 'pageview', document.title.substring(0, 499), window.location.href.substring(0, 499))
  37. if !experimentId
  38. //- Anti-flicker snippet
  39. //- Only run for tests controlled by Optimize editor
  40. style(type='text/css') .async-hide { opacity: 0 !important}
  41. script(type='text/javascript').
  42. (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
  43. h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
  44. (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
  45. })(window,document.documentElement,'async-hide','dataLayer',4000,
  46. {'#{gaOptimizeId}':true});
  47. - else
  48. script(type='text/javascript').
  49. window.ga = function() { console.log("would send to GA", arguments) };
  50. script(type="text/javascript").
  51. window.csrfToken = "#{csrfToken}";
  52. //- Configure dynamically loaded assets (via webpack) to be downloaded from CDN
  53. //- See: https://webpack.js.org/guides/public-path/#on-the-fly
  54. window.baseAssetPath = "#{buildBaseAssetPath()}"
  55. block head-scripts
  56. script.
  57. window.sharelatex = {
  58. siteUrl: '#{settings.siteUrl}',
  59. wsUrl: '#{wsUrl}',
  60. };
  61. window.ab = {};
  62. window.user_id = '#{getLoggedInUserId()}';
  63. window.ExposedSettings = JSON.parse('!{StringHelper.stringifyJsonForScript(ExposedSettings)}');
  64. - if (typeof(settings.algolia) != "undefined")
  65. script.
  66. window.sharelatex.algolia = {
  67. app_id:'#{settings.algolia.app_id}',
  68. api_key:'#{settings.algolia.read_only_api_key}',
  69. indexes:!{StringHelper.stringifyJsonForScript(settings.algolia.indexes)}
  70. }
  71. - if (typeof(settings.templates) != "undefined")
  72. script.
  73. window.sharelatex.templates = {
  74. user_id : '!{settings.templates.user_id}',
  75. cdnDomain : '!{settings.templates.cdnDomain}',
  76. indexName : '!{settings.templates.indexName}'
  77. }
  78. body
  79. if(settings.recaptcha && settings.recaptcha.siteKeyV3)
  80. script(src="https://www.google.com/recaptcha/api.js?render="+settings.recaptcha.siteKeyV3)
  81. - if(typeof(suppressNavbar) == "undefined")
  82. include layout/navbar
  83. block content
  84. - if(typeof(suppressFooter) == "undefined")
  85. include layout/footer
  86. != moduleIncludes("contactModal", locals)
  87. block foot-scripts
  88. script(src=buildJsPath('libraries.js'))
  89. script(src=buildJsPath('main.js'))
  90. script(type="text/javascript").
  91. //- Look for bundle
  92. var cdnBlocked = typeof Frontend === 'undefined'
  93. //- Prevent loops
  94. var noCdnAlreadyInUrl = window.location.href.indexOf("nocdn=true") != -1
  95. if (cdnBlocked && !noCdnAlreadyInUrl && navigator.userAgent.indexOf("Googlebot") == -1) {
  96. //- Set query param, server will not set CDN url
  97. window.location.search += "&nocdn=true";
  98. }