--- /dev/null
+module.exports = async (_require, _pathname, _root, _jst_server) => {
+ return async env => {
+ let _out = [];
+ _out.push('<!DOCTYPE html>');
+ {
+ _out.push("<html>");
+ {
+ _out.push("<head>");
+ _out.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"olly.css\">");
+ {
+ _out.push("<title>");
+ _out.push("Blog: 31/03/2020");
+ _out.push("</title>");
+ }
+ _out.push("</head>");
+ }
+ {
+ _out.push("<body class=\"olly\">");
+ {
+ _out.push("<h1>");
+ _out.push("Olly's Blog: 31/03/2020");
+ _out.push("</h1>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("Today we got Linux running on my new Asus Zenbook UM433DA. My dad was hassling me for ages about Linux versus Windows. And I decided to give Linux a try. My dad was working from home, but he said no worries, I can just help you each time you get stuck.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("So first we went into the BIOS, we tried various ways to get into the BIOS like Del, Shift-F11 and so on. It turns out you have to press F2 on this laptop. So then we went into the boot options and chose the USB with Linux Mint 19.3 on it.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("This is where we ran into the first of many problems! Booting from the USB just gave us a boot menu and then a black screen when we tried to proceed. Choosing \"compatibility mode\" helped us to get past this to a desktop.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("Now we discovered the keyboard and mouse did not work! Fun, fun, fun. My dad thought about this for a while and pulled the USB keyboard and mouse off our TV media PC. This let us get going again.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("Except there were not enough USB ports because the Linux Mint 19.3 USB needed to be in and so we could only have the keyboard or the mouse, not both. With a lot of swapping between them we could navigate the installer.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("We chose to overwrite Windows 10 with Linux Mint's default partitioning scheme, and chose a name and a computer name. The installer completed, so then we rebooted into what should have been the live (installed) system.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("Unfortunately, it was back to the black screen and this time there was no option for compatibility mode. If you pressed shift at the right time in bootup you could force it to a boot menu but it only had normal and recovery mode and neither of these worked.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("We tried turning off the splash screen (by editing kernel commands in the boot menu and then pressing F10 to boot). It seemed to be crashing and saying something about apic, so we booted with the noapic option and this worked.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("The next thing to do once we had booted into the installed system was an ");
+ {
+ _out.push("<pre>");
+ _out.push("apt update");
+ _out.push("</pre>");
+ }
+ _out.push(" and an ");
+ {
+ _out.push("<pre>");
+ _out.push("apt upgrade");
+ _out.push("</pre>");
+ }
+ _out.push(". We were hoping it would install a later kernel but it didn't so we had to do this ourselves.");
+ _out.push("</p>");
+ }
+ {
+ _out.push("<p>");
+ _out.push("To see the available kernels we tried ");
+ {
+ _out.push("<pre>");
+ _out.push("apt-cache search linux-image");
+ _out.push("</pre>");
+ }
+ _out.push(" and then narrowed down the search to ");
+ {
+ _out.push("<pre>");
+ _out.push("apt-cache search linux-image-5.3.0-.*-generic");
+ _out.push("</pre>");
+ }
+ _out.push(", the final command to upgrade the kernel was: ");
+ {
+ _out.push("<pre>");
+ _out.push("apt install linux-image-5.3.0-45-generic linux-headers-5.3.0-45-generic");
+ _out.push("</pre>");
+ }
+ _out.push(".");
+ _out.push("</p>");
+ }
+ _out.push("</body>");
+ }
+ _out.push("</html>");
+ }
+ env.site.serve(env, 200, Buffer.from(_out.join('')), 'circle.html.jst');
+ };
+};
--- /dev/null
+let querystring = require('querystring')
+let stream_buffers = require('stream-buffers')
+
+return async env => {
+ _out = []
+ _out.push('<!DOCTYPE html>')
+ html {
+ head {
+ link(rel="stylesheet" type="text/css" href="olly.css") {}
+ title {
+ 'Pythagoras Calculator'
+ }
+ }
+ if (env.request.method == 'POST') {
+ let write_stream = new stream_buffers.WritableStreamBuffer()
+ let data = new Promise(
+ (resolve, reject) => {
+ write_stream.
+ on('finish', () => {resolve(write_stream.getContents())}).
+ on('error', () => {reject()})
+ }
+ )
+ env.request.pipe(write_stream)
+ let query = querystring.parse((await data).toString())
+
+ let radius_and_units = query.radius.split(' ')
+ let radius = parseFloat(radius_and_units[0])
+ let units = radius_and_units[1] || 'units'
+ let c = sqrt(a * a + b * b)
+
+ if (isNaN(a) || a < 0) {
+ _out.push(
+ `<h1>Error - Unable to Calculate Missing or Negative Radius</h1>
+`
+ )
+ }
+ else {
+ _out.push(
+ `<h1>A is: ${a} ${units}</h1>
+<h1>The hypotenuse (c) is: ${c} ${units}²</h1>
+
+`
+ )
+ }
+ _out.push(
+ `</body>
+</html>
+`
+ )
+ }
+ else {
+ _out.push(
+ `<h1>Please go <a href="/circle.html">here</a>.</h1>
+`
+ )
+ _out.push(
+ `</body>
+</html>
+`
+ )
+ }
+ env.site.serve(
+ env,
+ 200,
+ Buffer.from(_out.join('')),
+ 'calculatebutton.html.jst'
+ )
+}
+
--- /dev/null
+return async env => {
+ let _out = []
+ _out.push('<!DOCTYPE html>')
+ html {
+ head {
+ link(rel="stylesheet" type="text/css" href="olly.css") {}
+ title {
+ 'Triangle Calculator'
+ }
+ }
+ body.olly {
+ h1 {
+ 'Triangle Calculator'
+ }
+ ul{
+ li{
+ a(href="/pythagoras.html") {
+ 'Finding the Hypotonuse'
+ }
+ }
+ li{
+ a(href="/sohcahtoa.html") {
+ 'Finding an Unknown Side Length'
+ }
+ }
+ li{
+ a(href="/inverse_trig.html") {
+ 'Finding a Missing Angle'
+ }
+ }
+ }
+ }
+ }
+ env.site.serve(env, 200, Buffer.from(_out.join('')), 'index.html.jst')
+}
--- /dev/null
+return async env => {
+ let _out = []
+ _out.push('<!DOCTYPE html>')
+ html {
+ head {
+ link(rel="stylesheet" type="text/css" href="olly.css") {}
+ title {
+ 'Circle Calculator'
+ }
+ style {
+ form div + div {
+ margin-top: 1em
+ }
+ label {
+ display: inline-block;
+ width: 90px;
+ text-align: right
+ }
+ input,
+ textarea {
+ font: 1em sans-serif;
+ width: 300px;
+ box-sizing: border-box;
+ border: 1px solid #999
+ }
+ input:focus,
+ textarea:focus {
+ border-color: #000
+ }
+ textarea {
+ vertical-align: top;
+ height: 5em
+ }
+ .button {
+ padding-left: 90px
+ }
+ button {
+ margin-left: .5em
+ }
+ }
+ }
+ body.olly {
+ h1 {
+ 'Circle Calculator'
+ }
+ img(src="circle.svg") {}
+ br {}
+ 'Please type the number, optionally followed by the unit (there must be a space between the number and the unit).'
+ br {}
+ _out.push(' ')
+ form(action="/calculatebutton.html" method="post") {
+ div {
+ label(for="radius") {
+ 'Radius:'
+ }
+ ' '
+ input#radius(type="text" name="radius") {}
+ }
+ div.button {
+ button(type="submit") {
+ 'Calculate'
+ }
+ }
+ }
+ }
+ }
+ env.site.serve(env, 200, Buffer.from(_out.join('')), 'circle.html.jst')
+}
--- /dev/null
+return async env => {
+ let _out = []
+ _out.push('<!DOCTYPE html>')
+ html {
+ head {
+ link(rel="stylesheet" type="text/css" href="olly.css") {}
+ title {
+ 'Pythagoras Theorum'
+ }
+ style {
+ form div + div {
+ margin-top: 1em
+ }
+ label {
+ display: inline-block;
+ width: 90px;
+ text-align: right
+ }
+ input,
+ textarea {
+ font: 1em sans-serif;
+ width: 300px;
+ box-sizing: border-box;
+ border: 1px solid #999
+ }
+ input:focus,
+ textarea:focus {
+ border-color: #000
+ }
+ textarea {
+ vertical-align: top;
+ height: 5em
+ }
+ .button {
+ padding-left: 90px
+ }
+ button {
+ margin-left: .5em
+ }
+ }
+ }
+ body.olly {
+ h1 {
+ 'Finding the Hypotenuse'
+ }
+ //img(src="circle.svg") {}
+ br {}
+ 'Please type variables a and b, optionally followed by a unit (with a space between the number and the unit).'
+ br {}
+ _out.push(' ')
+ form(action="/calculatebutton.html" method="post") {
+ div {
+ label(for="radius") {
+ 'Radius:'
+ }
+ ' '
+ input#radius(type="text" name="radius") {}
+ }
+ div.button {
+ button(type="submit") {
+ 'Calculate'
+ }
+ }
+ }
+ }
+ }
+ env.site.serve(env, 200, Buffer.from(_out.join('')), 'circle.html.jst')
+}
--- /dev/null
+return async env => {
+ let _out = []
+ _out.push('<!DOCTYPE html>')
+ html {
+ head {
+ link(rel="stylesheet" type="text/css" href="olly.css") {}
+ title {
+ 'Circle Calculator'
+ }
+ style {
+ form div + div {
+ margin-top: 1em
+ }
+ label {
+ display: inline-block;
+ width: 90px;
+ text-align: right
+ }
+ input,
+ textarea {
+ font: 1em sans-serif;
+ width: 300px;
+ box-sizing: border-box;
+ border: 1px solid #999
+ }
+ input:focus,
+ textarea:focus {
+ border-color: #000
+ }
+ textarea {
+ vertical-align: top;
+ height: 5em
+ }
+ .button {
+ padding-left: 90px
+ }
+ button {
+ margin-left: .5em
+ }
+ }
+ }
+ body.olly {
+ h1 {
+ 'Circle Calculator'
+ }
+ img(src="circle.svg") {}
+ br {}
+ 'Please type the number, optionally followed by the unit (there must be a space between the number and the unit).'
+ br {}
+ _out.push(' ')
+ form(action="/calculatebutton.html" method="post") {
+ div {
+ label(for="radius") {
+ 'Radius:'
+ }
+ ' '
+ input#radius(type="text" name="radius") {}
+ }
+ div.button {
+ button(type="submit") {
+ 'Calculate'
+ }
+ }
+ }
+ }
+ }
+ env.site.serve(env, 200, Buffer.from(_out.join('')), 'circle.html.jst')
+}