Add stylesheet to index and circle calculator (need to do trapezium as well)
authorNick Downing <nick@ndcode.org>
Sat, 19 Jan 2019 01:41:47 +0000 (12:41 +1100)
committerNick Downing <nick@ndcode.org>
Sat, 19 Jan 2019 01:41:47 +0000 (12:41 +1100)
_config/globals.json
_config/server.jst
_config/site.jst
calculatebutton.html.jst
circle.html
index.html
olly.css [new file with mode: 0644]

index 2a17d44..3e9106a 100644 (file)
@@ -1,9 +1,24 @@
 {
-  "site_title": "Olly's website",
+  "site_title": "NDCODE",
   "navigation": [
-    "/index.html"
+    "/index.html",
+    "/team.html",
+    "/case_studies.html",
+    "/free_reports.html",
+    "/online_courses.html",
+    "/forum.html",
+    "/contact.html"
   ],
   "page_to_title": {
-    "/index.html": "Home"
+    "/index.html": "Home",
+    "/team.html": "Team",
+    "/case_studies.html": "Case studies",
+    "/free_reports.html": "Free reports",
+    "/online_courses.html": "Online courses",
+    "/forum.html": "Forum",
+    "/contact.html": "Contact",
+    "/signup.html": "Sign up",
+    "/login.html": "Log in",
+    "/recover_account.html": "Recover account"
   }
 }
index 1439059..e6ebffc 100644 (file)
@@ -1,25 +1,16 @@
-let jst_server = require('@ndcode/jst_server')
-
-return {
-  "enable_caching": false,
-  "listen": [
-    {"port": 8080},
-    {"port": 8443, "protocol": "https:"}
-  ],
-  "mime_types": {
-    ".css": "text/css; charset=utf-8",
-    ".html": "text/html; charset=utf-8",
-    ".ico": "image/x-icon",
-    ".jpg": "image/jpeg",
-    ".jpeg": "image/jpeg",
-    ".js": "application/javascript; charset=utf-8",
-    ".json": "application/json; charset=utf-8",
-    ".png": "image/png",
-    ".svg": "image/svg+xml",
-    ".xml": "text/xml; charset=utf-8"
+return async (resources, prev_server) => new _jst_server.Server(
+  resources,
+  {
+    hosts: {
+      'localhost': {
+        type: 'site',
+        root: '.'
+      },
+      'localhost.localdomain': {
+        type: 'redirect',
+        host: 'localhost'
+      }
+    }
   },
-  sites: {
-    'localhost': new jst_server.SiteDefault(_server, '.'),
-    'localhost.localdomain': new jst_server.SiteRedirect(_server, 'localhost')
-  }
-}
+  prev_server
+)
index 7a250a5..19894b7 100644 (file)
@@ -1,23 +1,77 @@
-let jst_server = require('@ndcode/jst_server')
+//let EmailJSCache = require('@ndcode/emailjs_cache')
+//let ZettairCache = require('@ndcode/zettair_cache')
+let assert = require('assert')
 
-let CustomSite = function(server, root) {
+let CustomSite = function(resources, root, options, prev_site) {
   if (!this instanceof CustomSite)
     throw Error('CustomSite is a constructor')
-  jst_server.SiteRoot.call(this, server, root)
+  _jst_server.Site.call(this, resources, root, options, prev_site)
+
+  this.emailjs_cache = undefined
+  this.zettair_cache = undefined
 }
 
-CustomSite.prototype = Object.create(jst_server.SiteRoot.prototype)
+CustomSite.prototype = Object.create(_jst_server.Site.prototype)
+
+//CustomSite.prototype.start = async function() {
+//  await _jst_server.Site.prototype.start.call(this)
+//
+//  assert(this.emailjs_cache === undefined)
+//  this.emailjs_cache = await this.resources.ref(
+//    'emailjs_cache',
+//    async () => new EmailJSCache(true)
+//  )
+//
+//  assert(this.zettair_cache === undefined)
+//  this.zettair_cache = await this.resources.ref(
+//    'zettair_cache',
+//    async () => new ZettairCache(true)
+//  )
+//}
+//
+//CustomSite.prototype.stop = async function() {
+//  await _jst_server.Site.prototype.stop.call(this)
+//
+//  assert(this.emailjs_cache !== undefined)
+//  await this.resources.unref('emailjs_cache')
+//
+//  assert(this.zettair_cache !== undefined)
+//  await this.resources.unref('zettair_cache')
+//}
+//
+//CustomSite.prototype.kick = async function() {
+//  await _jst_server.Site.prototype.kick.call(this)
+//
+//  assert(this.emailjs_cache !== undefined)
+//  this.emailjs_cache.kick()
+//
+//  assert(this.zettair_cache !== undefined)
+//  this.zettair_cache.kick()
+//}
+//
+//CustomSite.prototype.get_emailjs = function(pathname) {
+//  return /*await*/ this.emailjs_cache.get(this.root + pathname)
+//}
+//
+//CustomSite.prototype.get_zettair = function(pathname) {
+//  return /*await*/ this.zettair_cache.get(this.root + pathname)
+//}
 
 CustomSite.prototype.respond = async function(env) {
   if (
-    env.pathname === '/node_modules' ||
-    env.pathname.slice(0, 14) === '/node_modules/' ||
-    env.pathname === '/package.json'
+    env.parsed_url.pathname === '/node_modules' ||
+    env.parsed_url.pathname.slice(0, 14) === '/node_modules/' ||
+    env.parsed_url.pathname === '/package.json'
   ) {
-    this.die(env, `banned file ${env.pathname}`)
+    this.die(env, `banned file ${env.parsed_url.pathname}`)
     return
   }
-  return /*await*/ jst_server.SiteRoot.prototype.respond.call(this, env)
+  return /*await*/ _jst_server.Site.prototype.respond.call(this, env)
 }
 
-return new CustomSite(_server, _root)
+return async (resources, root, prev_site) => new CustomSite(
+  resources,
+  root,
+  {},
+  prev_site
+)
index 79a3582..0ef18cd 100644 (file)
@@ -27,9 +27,10 @@ return async env => {
         `<!DOCTYPE html>
 <html>
 <head>
+<link rel="stylesheet" type="text/css" href="olly.css">
 <title>Calculation</title>
 </head>
-<body>
+<body class="olly">
 <h1>Error - Unable to Calculate Negative Radius</h1>
 </body>
 </html>
@@ -44,9 +45,10 @@ return async env => {
       `<!DOCTYPE html>
 <html>
 <head>
+<link rel="stylesheet" type="text/css" href="olly.css">
 <title>Calculation</title>
 </head>
-<body>
+<body class="olly">
 <h1>The radius is: ${radius} ${units}</h1>
 <h1>The area is: ${area} ${units}²</h1>
 <h1>The circumference is: ${circumference} ${units}</h1>
@@ -65,9 +67,10 @@ return async env => {
       `<!DOCTYPE html>
 <html>
 <head>
+<link rel="stylesheet" type="text/css" href="olly.css">
 <title>Calculation</title>
 </head>
-<body>
+<body class="olly">
 <h1>Error - Unable to Calculate</h1>
 </body>
 </html>
index c6b89de..5418e84 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE html>
 <html>
 <head>
+<link rel="stylesheet" type="text/css" href="olly.css">
 <title>Circle Calculator</title>
 <style>
 form div + div {
@@ -52,7 +53,7 @@ button {
 }
 </style>
 </head>
-<body>
+<body class="olly">
 <h1>Circle Calculator</h1>
 <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).
index 5ba6ebd..f4cfa7a 100644 (file)
@@ -1,9 +1,10 @@
 <!DOCTYPE html>
 <html>
 <head>
+<link rel="stylesheet" type="text/css" href="olly.css">
 <title>Olly's Website</title>
 </head>
-<body>
+<body class="olly">
 <h1>Olly's Website</h1>
 <a href="/circle.html">Go to Circle Calculator</a>
 <br><a href="/trapezium.html">Go to Trapezium Area Calculator</a>
diff --git a/olly.css b/olly.css
new file mode 100644 (file)
index 0000000..6713d0c
--- /dev/null
+++ b/olly.css
@@ -0,0 +1,3 @@
+.olly {
+  font-family: sans-serif;
+}