An error occurred (<%= code %>)
-Go home?
-From 3f91a121b33151cd466de930d0e68bdf87f4d19e Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Mon, 20 Dec 2021 14:48:04 +0000 Subject: Convert to typescript --- .eslintignore | 2 +- .gitignore | 1 + app/constants.mjs | 9 -- app/directory.mjs | 116 ---------------------- app/directory.ts | 210 ++++++++++++++++++++++++++++++++++++++++ app/index.mjs | 107 -------------------- app/index.ts | 113 +++++++++++++++++++++ app/static/css/globalstyles.css | 100 ------------------- app/static/scripts/purge.js | 15 --- app/static/scripts/rebuild.js | 14 --- app/views/error.ejs | 19 ---- app/views/index.ejs | 18 ---- app/views/page.ejs | 20 ---- app/views/partials/header.ejs | 12 --- app/views/partials/navbar.ejs | 3 - app/views/purge.ejs | 24 ----- app/views/rebuild.ejs | 23 ----- app/wikiparser.mjs | 7 +- package-lock.json | 193 ++++++++++++++++++++++++++++++++---- package.json | 5 +- pages/template/blog.wiki | 2 + pages/templates/blog.wiki | 2 - static/css/globalstyles.css | 100 +++++++++++++++++++ static/scripts/purge.js | 15 +++ static/scripts/rebuild.js | 14 +++ tsconfig.json | 11 +++ views/error.ejs | 19 ++++ views/index.ejs | 18 ++++ views/page.ejs | 20 ++++ views/partials/header.ejs | 12 +++ views/partials/navbar.ejs | 3 + views/purge.ejs | 24 +++++ views/rebuild.ejs | 23 +++++ 33 files changed, 768 insertions(+), 506 deletions(-) delete mode 100644 app/constants.mjs delete mode 100644 app/directory.mjs create mode 100644 app/directory.ts delete mode 100644 app/index.mjs create mode 100644 app/index.ts delete mode 100644 app/static/css/globalstyles.css delete mode 100644 app/static/scripts/purge.js delete mode 100644 app/static/scripts/rebuild.js delete mode 100644 app/views/error.ejs delete mode 100644 app/views/index.ejs delete mode 100644 app/views/page.ejs delete mode 100644 app/views/partials/header.ejs delete mode 100644 app/views/partials/navbar.ejs delete mode 100644 app/views/purge.ejs delete mode 100644 app/views/rebuild.ejs create mode 100644 pages/template/blog.wiki delete mode 100644 pages/templates/blog.wiki create mode 100644 static/css/globalstyles.css create mode 100644 static/scripts/purge.js create mode 100644 static/scripts/rebuild.js create mode 100644 tsconfig.json create mode 100644 views/error.ejs create mode 100644 views/index.ejs create mode 100644 views/page.ejs create mode 100644 views/partials/header.ejs create mode 100644 views/partials/navbar.ejs create mode 100644 views/purge.ejs create mode 100644 views/rebuild.ejs diff --git a/.eslintignore b/.eslintignore index 8ec4cb0..3eaeff0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,2 @@ -app/static/* +static/* node_modules/* diff --git a/.gitignore b/.gitignore index 713d500..17c578e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ +build/ .env diff --git a/app/constants.mjs b/app/constants.mjs deleted file mode 100644 index ace7e2f..0000000 --- a/app/constants.mjs +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -export const SERVER_PORT = 3000; -export const PARSER_MAX_RECURSION = 20; -export const PURGE_COOLDOWN_MIN = -1; -export const REBUILD_COOLDOWN_MIN = -1; -export const PAGES_DIR = 'pages'; -export const TEMPLATE_DIR = 'pages/tempates'; -export const IMAGES_DIR = 'pages/images'; diff --git a/app/directory.mjs b/app/directory.mjs deleted file mode 100644 index b470bc7..0000000 --- a/app/directory.mjs +++ /dev/null @@ -1,116 +0,0 @@ -'use strict'; - -import { PAGES_DIR, PURGE_COOLDOWN_MIN, REBUILD_COOLDOWN_MIN } from './constants.mjs'; -import { parse } from './wikiparser.mjs'; -import { readFileSync, readdirSync } from 'fs'; - -const pages = {}; -const metadata = {}; - -export function pageFor(path) { - path = path.replace(/[^a-z0-9]/gi, '_').toLowerCase(); - let page = pages[path]; - if (!page) { - return undefined; - } - - if (!page.html) { - buildPage(path); - return pages[path]; - } - - return page; -} - -function buildPage(path) { - let data; - try { - data = readFileSync(`${PAGES_DIR}/${path}.wiki`, 'utf-8'); - } catch { - return false; - } - let result = parse(data); - let title = result.metadata.displayTitle ?? 'Unnamed page'; - let content = `${result.metadata.notitle ? '' : `
Go home?
-- - -diff --git a/app/views/partials/navbar.ejs b/app/views/partials/navbar.ejs deleted file mode 100644 index ff0c84d..0000000 --- a/app/views/partials/navbar.ejs +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/app/views/purge.ejs b/app/views/purge.ejs deleted file mode 100644 index 04bae61..0000000 --- a/app/views/purge.ejs +++ /dev/null @@ -1,24 +0,0 @@ - - - -
Are you sure you wish to purge the page <%= page %>?
-The last build time for this page was <%= buildTime %> (<%= buildTimeRelative %> minutes ago).
- -Are you sure you wish to rebuild the page directory?
- -Go home?
++ + +diff --git a/views/partials/navbar.ejs b/views/partials/navbar.ejs new file mode 100644 index 0000000..ff0c84d --- /dev/null +++ b/views/partials/navbar.ejs @@ -0,0 +1,3 @@ + diff --git a/views/purge.ejs b/views/purge.ejs new file mode 100644 index 0000000..04bae61 --- /dev/null +++ b/views/purge.ejs @@ -0,0 +1,24 @@ + + + +
Are you sure you wish to purge the page <%= page %>?
+The last build time for this page was <%= buildTime %> (<%= buildTimeRelative %> minutes ago).
+ +Are you sure you wish to rebuild the page directory?
+ +