Skip to content

Commit 6e5341d

Browse files
committed
Update page title naming scheme, error page, reroute 404 page
1 parent 7c3d5cf commit 6e5341d

8 files changed

Lines changed: 28 additions & 19 deletions

File tree

frontend/pages/auth.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1>Authentication required.</h1>
3+
<h1>Authentication Required</h1>
44
<p>You'll need to log into your <%= tenant.auth.provider || tenant.name %> account before managing your commissions.</p>
55
<% if (tenant.auth.url) { %>
66
<div class="buttons">

frontend/pages/create.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1>New commission</h1>
3+
<h1>New Commission</h1>
44
<p>Estimated time to complete: 2 minutes</p>
55
<% var step = 1; fields.forEach(field => { %>
66
<div class="inputField <%= field.required ? 'required' : '' %>" id="<%= field.id %>" step="<%= step %>">

frontend/pages/error.ejs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%- include('head.ejs') %>
2+
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3+
<h1> <%= title || 'Error' %></h1>
4+
<p><%= message %></p>
5+
<%- include('foot.ejs') %>

frontend/pages/head.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<head>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title><%= title %><%= tenant.name %></title>
7+
<title><%= title %><%= title.length ? ' - ' : '' %><%= tenant.name %></title>
88
<meta name="description" content="<%= tenant.description %>">
99
<meta name="keywords" content="commission, commissions">
1010
<meta name="author" content="CommTrackr">
1111
<meta name="theme-color" content="<%= tenant.themeColor %>">
12-
<meta property="og:title" content="<%= title %><%= tenant.name %>">
12+
<meta property="og:title" content="<%= title %><%= title.length ? ' - ' : '' %><%= tenant.name %>">
1313
<meta property="og:description" content="<%= tenant.description %>">
1414
<meta property="og:image" content="<%= tenant.banner %>">
1515
<meta property="og:url" content="<%= tenant.domain %>">
1616
<meta property="og:type" content="website">
1717
<meta name="twitter:card" content="summary_large_image">
18-
<meta name="twitter:title" content="<%= title %><%= tenant.name %>">
18+
<meta name="twitter:title" content="<%= title %><%= title.length ? ' - ' : '' %><%= tenant.name %>">
1919
<meta name="twitter:description" content="<%= tenant.description %>">
2020
<meta name="twitter:image" content="<%= tenant.banner %>">
2121
<link rel="icon" href="<%= tenant.logo %>" type="image/png">

frontend/pages/off.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1>CommTrackr is disabled.</h1>
3+
<h1>CommTrackr Disabled</h1>
44
<p>Enable CommTrackr for your app using <code>commtrackr.on();</code></p>
55
<%- include('foot.ejs') %>

frontend/pages/tenant.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1>Tenant not configured.</h1>
3+
<h1>Tenant Misconfigured</h1>
44
<p>Configure your CommTrackr tenant using <code>commtrackr.init({ tenant: { ... } });</code></p>
55
<%- include('foot.ejs') %>

frontend/pages/user.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<% if (tenant.auth && tenant.auth.enabled) { %>
55
Welcome, <%= session[vars.name] || session[vars.userId] %>!
66
<% } else { %>
7-
<%= tenant.name %> commissions
7+
<%= tenant.name %> Commissions
88
<% } %>
99
</h1>
1010
<p>View and manage your past commissions.</p>

index.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ function getUserRole(session) {
109109
};
110110

111111
app.get('/', async (req, res) => {
112-
if (!on) return res.render('off', { tenant, title: 'Activation - ' });
113-
if (!req.session) return res.render('session', { tenant, title: 'Session - ' });
114-
if (!tenant.slug || !tenant.name || !tenant.domain) return res.render('tenant', { tenant, title: 'Configuration - ' });
115-
if (tenant.auth && tenant.auth.enabled && vars.userId && !req.session[vars.userId]) return res.render('auth', { tenant, title: 'Authenticate - ' });
112+
if (!on) return res.render('off', { tenant, title: 'Activation' });
113+
if (!req.session) return res.render('session', { tenant, title: 'Session' });
114+
if (!tenant.slug || !tenant.name || !tenant.domain) return res.render('tenant', { tenant, title: 'Configuration' });
115+
if (tenant.auth && tenant.auth.enabled && vars.userId && !req.session[vars.userId]) return res.render('auth', { tenant, title: 'Authenticate' });
116116
switch (getUserRole(req.session)) {
117117
case 'admin':
118-
res.render('admin', { tenant, title: 'Admin View - ', session: req.session, vars });
118+
res.render('admin', { tenant, title: 'Admin View', session: req.session, vars });
119119
break;
120120
case 'dev':
121-
res.render('dev', { tenant, title: 'Developer View - ', session: req.session, vars });
121+
res.render('dev', { tenant, title: 'Developer View', session: req.session, vars });
122122
break;
123123
default:
124124
res.render('user', { tenant, title: '', session: req.session, vars, fields });
@@ -127,11 +127,11 @@ app.get('/', async (req, res) => {
127127
});
128128

129129
app.get('/create', async (req, res) => {
130-
if (!on) return res.render('off', { tenant, title: 'Activation - ' });
131-
if (!req.session) return res.render('session', { tenant, title: 'Session - ' });
132-
if (!tenant.slug || !tenant.name || !tenant.domain) return res.render('tenant', { tenant, title: 'Configuration - ' });
133-
if (tenant.auth && tenant.auth.enabled && vars.userId && !req.session[vars.userId]) return res.render('auth', { tenant, title: 'Authenticate - ' });
134-
res.render('create', { tenant, title: 'New Commission - ', session: req.session, vars, fields });
130+
if (!on) return res.render('off', { tenant, title: 'Activation' });
131+
if (!req.session) return res.render('session', { tenant, title: 'Session' });
132+
if (!tenant.slug || !tenant.name || !tenant.domain) return res.render('tenant', { tenant, title: 'Configuration' });
133+
if (tenant.auth && tenant.auth.enabled && vars.userId && !req.session[vars.userId]) return res.render('auth', { tenant, title: 'Authenticate' });
134+
res.render('create', { tenant, title: 'New Commission', session: req.session, vars, fields });
135135
});
136136

137137
app.post('/create', async (req, res) => {
@@ -161,6 +161,10 @@ app.post('/create', async (req, res) => {
161161
res.status(200).json({ status: 'success', message: 'Your commission was created successfully.' });
162162
});
163163

164+
app.use((req, res) => {
165+
res.status(404).render('error', { tenant, title: 'Not Found', message: 'The requested resource was not found.' });
166+
});
167+
164168
module.exports = {
165169
routes: app,
166170
init,

0 commit comments

Comments
 (0)