Improve 301 and 404 again slightly, reinstate the default 'Hello, world' site
authorNick Downing <downing.nick@gmail.com>
Sun, 21 Oct 2018 10:30:03 +0000 (21:30 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 21 Oct 2018 10:30:03 +0000 (21:30 +1100)
Server.js
config/sites.json
site/index.html.js [deleted file]
site/index.html.jst [new file with mode: 0644]

index cebcce5..336e60e 100644 (file)
--- a/Server.js
+++ b/Server.js
@@ -78,11 +78,16 @@ Server.prototype.die = function(response, pathname) {
     404,
     this.mime_type_html,
     Buffer.from(
-      `<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
-<TITLE>404 Not Found</TITLE></HEAD><BODY>
-<H1>404 Not Found</H1>
-The document ${pathname} was not found.
-</BODY></HTML>
+      `<html>
+  <head>
+    <meta http-equiv="content-type" content="text/html;charset=utf-8">
+    <title>404 Not Found</title>
+  </head>
+  <body style="font-family: sans-serif, serif, monospace; font-size: 16px;">
+    <h2>404 Not Found</h2>
+    <p>The document ${pathname} was not found.</p>
+  </body>
+</html>
 `
     )
   )
@@ -96,18 +101,22 @@ Server.prototype.redirect = function(response, location) {
     301,
     this.mime_type_html,
     Buffer.from(
-      `<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
-<TITLE>301 Moved</TITLE></HEAD><BODY>
-<H1>301 Moved</H1>
-The document has moved
-<A HREF="${location}">here</A>.
-</BODY></HTML>
+      `<html>
+  <head>
+    <meta http-equiv="content-type" content="text/html;charset=utf-8">
+    <title>301 Moved Permanetly</title>
+  </head>
+  <body style="font-family: sans-serif, serif, monospace; font-size: 16px;">
+    <h2>301 Moved Permanently</h2>
+    <p>The document has moved <a href="${location}">here</a>.</p>
+  </body>
+</html>
 `
     )
   )
 }
 
-let site_factory_default = async root => new Site(root)
+let site_factory_default = async (server, root) => new Site(server, root)
 
 Server.prototype.respond = async function(request, response, protocol) {
   try {
index 140e82a..2868a40 100644 (file)
@@ -1,4 +1,4 @@
 {
-  "localhost": {"type": "site", "root": "../businessdataflow.git"},
+  "localhost": {"type": "site", "root": "site"},
   "localhost.localdomain": {"type": "redirect", "domain": "localhost"}
 }
diff --git a/site/index.html.js b/site/index.html.js
deleted file mode 100644 (file)
index eec73bd..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-html(lang=_env.lang) {
-  head {
-    link(rel="stylesheet" type="text/css" href="css/styles.css") {}
-  }
-  body {
-    p {'Hello, world'}
-  }
-}
diff --git a/site/index.html.jst b/site/index.html.jst
new file mode 100644 (file)
index 0000000..d1f46e6
--- /dev/null
@@ -0,0 +1,10 @@
+return async (_env, _out) => {
+  html {
+    head {
+      link(rel="stylesheet" type="text/css" href="css/styles.css") {}
+    }
+    body {
+      p {'Hello, world'}
+    }
+  }
+}