layout.pug 4.0 KB

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