From 65ba1b16e39d0a79fb5b2345030ef5f41bb8f2c8 Mon Sep 17 00:00:00 2001 From: William Mantly Date: Tue, 4 Aug 2026 13:26:48 -0400 Subject: [PATCH] feat: error page + navbar active styling (v1.18.0) - Add SSO-style error page (views/error.ejs) and render it for browser navigation in the error handler (API still returns JSON). - Navbar: username not underlined; only the active nav link is bold+underlined. Co-Authored-By: Claude --- CHANGELOG.md | 4 ++++ nodejs/app.js | 12 +++++++++++- nodejs/public/css/styles.css | 6 ++++++ nodejs/views/error.ejs | 25 +++++++++++++++++++++++++ nodejs/views/top.ejs | 2 +- 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 nodejs/views/error.ejs diff --git a/CHANGELOG.md b/CHANGELOG.md index 240dfca..dcd14bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.18.0 +- feat: Add SSO-style error page (404/500) for browser navigation instead of a bare text response +- feat: navbar — username no longer underlined; only the active link is bold + underlined + ## v1.16.1 - fix: remove missing DEPLOYMENT.md from Docker build context diff --git a/nodejs/app.js b/nodejs/app.js index eb7d128..fe081f8 100644 --- a/nodejs/app.js +++ b/nodejs/app.js @@ -4,6 +4,8 @@ const express = require('express'); const compression = require('compression'); require('./models'); // wire model-redis + register models +const conf = require('@simpleworkjs/conf'); +const buildInfo = require('./utils/build_info'); const app = express(); @@ -41,7 +43,15 @@ app.use((err, req, res, next) => { if(req.path.startsWith('/api/')){ return res.status(status).json({name: err.name || 'Error', message: err.message || 'Error'}); } - res.status(status).send(err.message || 'Error'); + // Browser navigation gets the HTML error page (shared with SSO). + res.status(status).render('error', { + title: conf.environment !== 'production' ? 'dev' : '', + titleIcon: conf.environment !== 'production' ? '' : '', + name: conf.name, + logo: conf.logo, + ...buildInfo, + error: err, + }); }); module.exports = app; diff --git a/nodejs/public/css/styles.css b/nodejs/public/css/styles.css index 7065eae..fd0dde2 100755 --- a/nodejs/public/css/styles.css +++ b/nodejs/public/css/styles.css @@ -3,6 +3,12 @@ nav.navbar{ padding-right: 1em; } +/* Only the active top-nav link is bold + underlined; the username is plain. */ +.top-nav a.active{ + font-weight: bold; + text-decoration: underline; +} + body { display: flex; flex-direction: column; diff --git a/nodejs/views/error.ejs b/nodejs/views/error.ejs new file mode 100644 index 0000000..03fdca4 --- /dev/null +++ b/nodejs/views/error.ejs @@ -0,0 +1,25 @@ +<%- include('top') %> + +
+
+
+
+ +
+

<%= error.status || 500 %>

+

<%= error.message || 'Something went wrong' %>

+

+ <% if (error.status === 404) { %> + The page you are looking for doesn't exist or has been moved. + <% } else { %> + An unexpected error occurred. Please try again later. + <% } %> +

+ + Return to Home + +
+
+
+ +<%- include('bottom') %> diff --git a/nodejs/views/top.ejs b/nodejs/views/top.ejs index 0ea839c..aaeb960 100644 --- a/nodejs/views/top.ejs +++ b/nodejs/views/top.ejs @@ -49,7 +49,7 @@
<% if(ui.profileUrl){ %> - <% } else { %>