Files
compiler-explorer/views/_layout.pug
T
Austin Morton a2f9261c87 Use pug template inheritance
Additionally move the javascript code blocks to
the end of the html body, instead of the header.

This is generally good practice, but it also fixes
an issue with the cookie consent overlay due to
a html element not existing on the page at the time
of script execution.
2019-09-06 19:39:31 -04:00

38 lines
1.3 KiB
Plaintext

doctype html
html(lang="en")
head
base(href=httpRoot)
block meta
include meta.pug
block styles
link(href=require("main.css") rel="stylesheet")
style#theme
body(class=extraBodyClass)
block content
#root
block footer
include templates.pug
block scripts
script(src=`${httpRootDir}client-options.js?hash=${optionsHash}`)
//-
The atob/base64 stuff below is to prevent any XSS attacks: now we have user content in the options (from
short links), it's possible to do XSS attacks, by leaving <script> tags in the source etc, which can be
interpreted by the browser.
script
| var extraOptions = JSON.parse(decodeURIComponent("!{encodeURIComponent(compilerExplorerOptions)}"));
| for (k in extraOptions) { window.compilerExplorerOptions[k] = extraOptions[k]; }
|
| window.httpRoot = '#{httpRoot}'; window.httpRootDir = '#{httpRootDir}';
|
| if (window.navigator.userAgent.indexOf("Trident/") > 0) {
| var s = document.createElement("script");
| s.src = "#{httpRootDir}dist/es6-shim.min.js";
| document.head.appendChild(s);
| }
script(src=require("main.js"))