An error occurred (<%= code %>)
-Go home?
+An error occurred (<%= code %>)
+Go home?
+From a84425a42e9246243dffd23dba33b4d4a5b626ac Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Mon, 22 Nov 2021 14:17:44 +0000 Subject: Update styles & add page rebuilding --- app/constants.mjs | 1 + app/directory.mjs | 8 ++++++-- app/index.mjs | 2 +- app/static/css/globalstyles.css | 9 +++++++-- app/static/scripts/rebuild.js | 14 ++++++++++++++ app/views/error.ejs | 9 ++++++--- app/views/index.ejs | 7 +++++-- app/views/page.ejs | 11 +++++++---- app/views/partials/header.ejs | 5 +---- app/views/partials/navbar.ejs | 3 +++ app/views/purge.ejs | 15 +++++++++------ app/views/rebuild.ejs | 14 ++++++++++---- 12 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 app/static/scripts/rebuild.js create mode 100644 app/views/partials/navbar.ejs diff --git a/app/constants.mjs b/app/constants.mjs index e9b4730..ace7e2f 100644 --- a/app/constants.mjs +++ b/app/constants.mjs @@ -3,6 +3,7 @@ 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 index 38b05ca..b470bc7 100644 --- a/app/directory.mjs +++ b/app/directory.mjs @@ -1,6 +1,6 @@ 'use strict'; -import { PAGES_DIR, PURGE_COOLDOWN_MIN } from './constants.mjs'; +import { PAGES_DIR, PURGE_COOLDOWN_MIN, REBUILD_COOLDOWN_MIN } from './constants.mjs'; import { parse } from './wikiparser.mjs'; import { readFileSync, readdirSync } from 'fs'; @@ -22,7 +22,7 @@ export function pageFor(path) { return page; } -export function buildPage(path) { +function buildPage(path) { let data; try { data = readFileSync(`${PAGES_DIR}/${path}.wiki`, 'utf-8'); @@ -47,6 +47,9 @@ export function buildPage(path) { } export function rebuild() { + if (metadata.fileTreeBuildTime + REBUILD_COOLDOWN_MIN * 60 * 1000 > Date.now()) { + return false; + } for (var page in pages) { delete pages[page]; } @@ -70,6 +73,7 @@ export function rebuild() { }); metadata.navbar = primaryPages; metadata.fileTreeBuildTime = new Date(); + return true; } export function exists(path) { diff --git a/app/index.mjs b/app/index.mjs index cf47100..0f14ccf 100644 --- a/app/index.mjs +++ b/app/index.mjs @@ -88,7 +88,7 @@ app.get('/special/rebuild', (req, res) => { }); app.get('/special/rebuild/confirm', (req, res) => { - if (directory.rebuild()[0]) { + if (directory.rebuild()) { res.status(200).send(); } else { res.status(429).send(); diff --git a/app/static/css/globalstyles.css b/app/static/css/globalstyles.css index bdecaa6..599c836 100644 --- a/app/static/css/globalstyles.css +++ b/app/static/css/globalstyles.css @@ -5,12 +5,13 @@ font-weight: 700; line-height: 1.2; color: #ddd; + text-shadow: 0px 1px 10px #9876aa; } html, body { border: 0; margin: 0; - background-color: #000; + background-color: #111; color: #ddd; font-family: 'Cousine', monospace, sans-serif; line-height: 1.3; @@ -65,6 +66,10 @@ h1, h2, h3, h4, h5, h6 { margin: 0 auto; } +#content-container { + box-shadow: 0px 0px 15px 10px rgba(152,118,170,0.05); +} + #content { padding: 20px; max-width: 1200px; @@ -73,7 +78,7 @@ h1, h2, h3, h4, h5, h6 { } a { - color: #ffc66d; + color: #9876aa; text-decoration: underline; } diff --git a/app/static/scripts/rebuild.js b/app/static/scripts/rebuild.js new file mode 100644 index 0000000..8fd0e2e --- /dev/null +++ b/app/static/scripts/rebuild.js @@ -0,0 +1,14 @@ +$(() => { + $('#confirm').click(() => { + $.ajax({ + type: 'GET', + url: `/special/rebuild/confirm`, + success: () => { + $('#response').html('
Go home?
+Go home?
+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 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?
- +Are you sure you wish to rebuild the page directory?
+ +