Skip to content

Commit 58e92d5

Browse files
committed
Move custom text in README.md, bug fixes
1 parent 6b3a182 commit 58e92d5

5 files changed

Lines changed: 108 additions & 74 deletions

File tree

README.md

Lines changed: 85 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -60,70 +60,7 @@ commtrackr.init({ // Initialize CommTracker with configurations
6060
},
6161
stylesheets: [], // Additional stylesheets to include
6262
scripts: [], // Additional scripts to include
63-
customText: { // Custom text overrides for the tenant
64-
userWelcomeBefore: 'Welcome, ',
65-
userWelcomeAfter: '!',
66-
activationTitle: 'Activation',
67-
sessionTitle: 'Session',
68-
tenantTitle: 'Configuration',
69-
authTitle: 'Authenticate',
70-
adminTitle: 'Admin View',
71-
adminDescription: 'Manage commissions created on your platform.',
72-
devTitle: 'Developer View',
73-
devDescription: 'Manage commissions assigned to you.',
74-
userTitle: 'Commissions',
75-
userDescription: 'View and manage your past commissions.',
76-
newCommissionTitle: 'New Commission',
77-
newTaskLabel: 'New Task',
78-
notFoundTitle: 'Not Found',
79-
forbiddenTitle: 'Forbidden',
80-
errorTitle: 'Error',
81-
labelStatus: 'Status',
82-
labelOwner: 'Owner',
83-
labelAmount: 'Amount',
84-
labelDate: 'Date',
85-
labelAssignedTo: 'Assigned To',
86-
labelCurrency: 'Currency',
87-
labelLocked: 'Locked',
88-
labelTasks: 'Tasks',
89-
labelSendEmail: 'Send Email',
90-
labelRequired: 'Required',
91-
labelOptional: 'Optional',
92-
youLabel: '(you)',
93-
noneLabel: 'None',
94-
backLabel: 'Back',
95-
nextLabel: 'Next',
96-
startLabel: 'Start',
97-
createLabel: 'Create',
98-
returnLabel: 'Return',
99-
restartLabel: 'Restart',
100-
saveLabel: 'Save',
101-
syncLabel: 'Sync',
102-
backToLabel: 'Back to ',
103-
changesSaved: 'Changes saved',
104-
changesRestored: 'Changes restored',
105-
clearChanges: 'Clear changes',
106-
brandName: 'CommTrackr',
107-
createEstimatedTime: 'Estimated time to complete: 2 minutes',
108-
commissionNotFound: 'The requested commission was not found.',
109-
commissionLocked: 'This commission is locked from user editing.',
110-
forbiddenMessage: 'You do not have permission to edit this commission.',
111-
resourceNotFound: 'The requested resource was not found.',
112-
offTitle: 'CommTrackr Disabled',
113-
offDescription: 'Enable CommTrackr for your app using <code>commtrackr.on();</code>',
114-
tenantMisconfiguredTitle: 'Tenant Misconfigured',
115-
tenantMisconfiguredDescription: 'Configure your CommTrackr tenant using <code>commtrackr.init({ tenant: { ... } });</code>',
116-
serviceOffline: 'Service is currently offline.',
117-
noSession: 'No session found. Please enable cookies and try again.',
118-
userNotAuthenticated: 'User not authenticated. Please log in and try again.',
119-
serviceNotConfigured: 'Service is not properly configured. Please contact the administrator.',
120-
noFieldsConfigured: 'No fields configured for commission creation. Please contact the administrator.',
121-
createSuccess: 'Your commission was created successfully.',
122-
syncSuccess: 'Your commissions were synchronized successfully.',
123-
updateSuccess: 'Your commission was updated successfully.',
124-
commissionNotFoundJson: 'The requested commission was not found.',
125-
forbiddenJson: 'You do not have permission to edit this commission.'
126-
},
63+
customText: {} // Custom text overrides for the tenant; see "Custom Text" section below
12764
},
12865
vars: {
12966
userId: 'username', // req.session object variable for unique user identification
@@ -342,3 +279,87 @@ Default:
342279
Type: `Array`
343280

344281
Default: `'users'`
282+
283+
## Custom Text
284+
285+
The tenant `customText` configuration allows you to override default text strings used throughout the CommTrackr interface. This is useful for localization or customizing the user experience. The available text strings are as follows:
286+
287+
```json
288+
{
289+
userWelcomeBefore: 'Welcome, ',
290+
userWelcomeAfter: '!',
291+
activationTitle: 'Activation',
292+
sessionTitle: 'Session',
293+
tenantTitle: 'Configuration',
294+
authTitle: 'Authentication Required',
295+
authDescriptionBefore: 'You\'ll need to log into your ',
296+
authDescriptionAfter: ' account before managing your commissions.',
297+
authContinueLabel: 'Continue',
298+
adminTitle: 'Commission Management',
299+
adminDescription: 'Manage commissions created on your platform.',
300+
devTitle: 'Commission Management',
301+
devDescription: 'Manage commissions assigned to you.',
302+
userTitle: 'Commissions',
303+
userDescription: 'View and manage your past commissions.',
304+
newCommissionTitle: 'New Commission',
305+
newTaskLabel: 'New Task',
306+
notFoundTitle: 'Not Found',
307+
forbiddenTitle: 'Forbidden',
308+
errorTitle: 'Error',
309+
errorMessage: 'An unexpected error occurred. Please try again later.',
310+
labelStatus: 'Status',
311+
labelStatusDescription: 'Required: Commission status.',
312+
labelOwner: 'Owner',
313+
labelOwnerDescription: 'Required: Commission owner.',
314+
labelAmount: 'Amount',
315+
labelAmountDescription: 'Optional: Commission amount.',
316+
labelDate: 'Date',
317+
labelDateDescription: 'Optional: Commission creation date.',
318+
labelAssignedTo: 'Assigned To',
319+
labelAssignedToDescription: 'Optional: The developer to assign this commission to.',
320+
labelCurrency: 'Currency',
321+
labelCurrencyDescription: 'Optional: Commission currency.',
322+
labelLocked: 'Locked',
323+
labelLockedDescription: 'Optional: Whether or not the commission is locked from user editing.',
324+
labelTasks: 'Tasks',
325+
labelSendEmail: 'Send Email',
326+
labelSendEmailDescription: 'Optional: Send an email to the user regarding this update.',
327+
labelRequired: 'Required',
328+
labelOptional: 'Optional',
329+
youLabel: '(you)',
330+
noneLabel: 'None',
331+
backLabel: 'Back',
332+
backLabelWithArrow: '← Back',
333+
nextLabel: 'Next',
334+
startLabel: 'Start',
335+
createLabel: 'Create',
336+
returnLabel: 'Return',
337+
restartLabel: 'Restart',
338+
saveLabel: 'Save',
339+
syncLabel: 'Sync',
340+
backToLabel: 'Back to ',
341+
changesSaved: 'Changes saved',
342+
changesRestored: 'Changes restored',
343+
clearChanges: 'Clear changes',
344+
brandName: 'CommTrackr',
345+
createEstimatedTime: 'Estimated time to complete: 2 minutes',
346+
commissionNotFound: 'The requested commission was not found.',
347+
commissionLocked: 'This commission is locked from user editing.',
348+
forbiddenMessage: 'You do not have permission to edit this commission.',
349+
resourceNotFound: 'The requested resource was not found.',
350+
offTitle: 'CommTrackr Disabled',
351+
offDescription: 'Enable CommTrackr for your app using <code>commtrackr.on();</code>',
352+
tenantMisconfiguredTitle: 'Tenant Misconfigured',
353+
tenantMisconfiguredDescription: 'Configure your CommTrackr tenant using <code>commtrackr.init({ tenant: { ... } });</code>',
354+
serviceOffline: 'Service is currently offline.',
355+
noSession: 'No session found. Please enable cookies and try again.',
356+
userNotAuthenticated: 'User not authenticated. Please log in and try again.',
357+
serviceNotConfigured: 'Service is not properly configured. Please contact the administrator.',
358+
noFieldsConfigured: 'No fields configured for commission creation. Please contact the administrator.',
359+
createSuccess: 'Your commission was created successfully.',
360+
syncSuccess: 'Your commissions were synchronized successfully.',
361+
updateSuccess: 'Your commission was updated successfully.',
362+
commissionNotFoundJson: 'The requested commission was not found.',
363+
forbiddenMessage: 'You do not have permission to edit this commission.'
364+
}
365+
```

frontend/pages/auth.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
33
<h1><%= tenant.customText?.authTitle %></h1>
4-
<p><%= tenant.customText?.authDescription %></p>
4+
<p><%= tenant.customText?.authDescriptionBefore + (tenant.auth.provider || tenant.name) + tenant.customText?.authDescriptionAfter %></p>
55
<% if (tenant.auth.url) { %>
66
<div class="buttons">
77
<div href="<%= tenant.auth.url %>" class="button"><%= tenant.customText?.authContinueLabel %></div>

frontend/pages/foot.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<p class="fixed">© <%= new Date().getFullYear() %> <%= tenant.customText?.brandName %></p>
44
<p class="fixed2"><%= tenant.customText?.changesSaved %></p>
55
<p class="fixed3"><%= tenant.customText?.changesRestored %></p>
6-
<p class="fixed4"><%= tenant.customText?.backArrow %></p>
6+
<p class="fixed4"><%= tenant.customText?.backLabelWithArrow %></p>
77
<p class="fixed5"><%= tenant.customText?.clearChanges %></p>
88
<% } else { %>
99
<p class="fixed">Internal error</p>

frontend/pages/user.ejs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
33
<h1>
44
<% if (tenant.auth && tenant.auth.enabled) { %>
5-
<%= (tenant.customText && tenant.customText.userWelcomeBefore ? tenant.customText.userWelcomeBefore : 'Welcome, ') %><%= session[vars.userName] || session[vars.userId] %><%= (tenant.customText && tenant.customText.userWelcomeAfter ? tenant.customText.userWelcomeAfter : '!') %>
5+
<%= tenant.customText?.userWelcomeBefore %><%= session[vars.userName] || session[vars.userId] %><%= tenant.customText?.userWelcomeAfter %>
66
<% } else { %>
7-
<%= tenant.name %> <%= tenant.customText && tenant.customText.userTitle ? tenant.customText.userTitle : 'Commissions' %>
7+
<%= tenant.name %> <%= tenant.customText?.userTitle %>
88
<% } %>
99
</h1>
10-
<p><%= tenant.customText && tenant.customText.userDescription ? tenant.customText.userDescription : 'View and manage your past commissions.' %></p>
10+
<p><%= tenant.customText?.userDescription %></p>
1111
<div class="buttons">
12-
<a class="button" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText && tenant.customText.newCommissionTitle ? tenant.customText.newCommissionTitle : 'New Commission' %></a>
12+
<a class="button" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText?.newCommissionTitle %></a>
1313
<div id="sync" class="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23" fill="none">
1414
<path d="M18.5949 5.16663C16.8618 3.32009 14.3989 2.16663 11.6666 2.16663C6.41992 2.16663 2.16663 6.41992 2.16663 11.6666C2.16663 16.9133 6.41992 21.1666 11.6666 21.1666C14.3989 21.1666 16.8618 20.0132 18.5949 18.1666M17.3236 7.98035L20.9804 7.98035L20.9804 4.3235" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" />
15-
</svg> <%= tenant.customText && tenant.customText.syncLabel ? tenant.customText.syncLabel : 'Sync' %></div>
16-
<a class="button" href="<%= tenant.domain %>"><%= (tenant.customText && tenant.customText.backToLabel ? tenant.customText.backToLabel : 'Back to ') + tenant.name %></a>
15+
</svg> <%= tenant.customText?.syncLabel %></div>
16+
<a class="button" href="<%= tenant.domain %>"><%= tenant.customText?.backToLabel + tenant.name %></a>
1717
</div>
1818
<div class="commissions">
1919
<% session[vars.commissions].forEach(commission => { %>

index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const customText = {
3636
sessionTitle: 'Session',
3737
tenantTitle: 'Configuration',
3838
authTitle: 'Authentication Required',
39+
authDescriptionBefore: 'You\'ll need to log into your ',
40+
authDescriptionAfter: ' account before managing your commissions.',
41+
authContinueLabel: 'Continue',
3942
adminTitle: 'Commission Management',
4043
adminDescription: 'Manage commissions created on your platform.',
4144
devTitle: 'Commission Management',
@@ -47,20 +50,30 @@ const customText = {
4750
notFoundTitle: 'Not Found',
4851
forbiddenTitle: 'Forbidden',
4952
errorTitle: 'Error',
53+
errorMessage: 'An unexpected error occurred. Please try again later.',
5054
labelStatus: 'Status',
55+
labelStatusDescription: 'Required: Commission status.',
5156
labelOwner: 'Owner',
57+
labelOwnerDescription: 'Required: Commission owner.',
5258
labelAmount: 'Amount',
59+
labelAmountDescription: 'Optional: Commission amount.',
5360
labelDate: 'Date',
61+
labelDateDescription: 'Optional: Commission creation date.',
5462
labelAssignedTo: 'Assigned To',
63+
labelAssignedToDescription: 'Optional: The developer to assign this commission to.',
5564
labelCurrency: 'Currency',
65+
labelCurrencyDescription: 'Optional: Commission currency.',
5666
labelLocked: 'Locked',
67+
labelLockedDescription: 'Optional: Whether or not the commission is locked from user editing.',
5768
labelTasks: 'Tasks',
5869
labelSendEmail: 'Send Email',
70+
labelSendEmailDescription: 'Optional: Send an email to the user regarding this update.',
5971
labelRequired: 'Required',
6072
labelOptional: 'Optional',
6173
youLabel: '(you)',
6274
noneLabel: 'None',
6375
backLabel: 'Back',
76+
backLabelWithArrow: '← Back',
6477
nextLabel: 'Next',
6578
startLabel: 'Start',
6679
createLabel: 'Create',
@@ -91,7 +104,7 @@ const customText = {
91104
syncSuccess: 'Your commissions were synchronized successfully.',
92105
updateSuccess: 'Your commission was updated successfully.',
93106
commissionNotFoundJson: 'The requested commission was not found.',
94-
forbiddenJson: 'You do not have permission to edit this commission.'
107+
forbiddenMessage: 'You do not have permission to edit this commission.'
95108
};
96109

97110

@@ -365,7 +378,7 @@ app.post('/:id/edit', async (req, res) => {
365378
const commissionIndex = (req.session[vars.commissions] || []).findIndex(commission => String(commission.id) === String(req.params.id));
366379
if (commissionIndex === -1) return res.status(404).json({ status: 'error', message: getCustomText('commissionNotFoundJson') });
367380
const commission = req.session[vars.commissions][commissionIndex];
368-
if (commission.locked && (getUserRole(req.session) === 'user')) return res.status(403).json({ status: 'error', message: getCustomText('forbiddenJson') });
381+
if (commission.locked && (getUserRole(req.session) === 'user')) return res.status(403).json({ status: 'error', message: getCustomText('forbiddenMessage') });
369382
const data = {};
370383
fields.forEach(field => {
371384
if (field.id) data[field.id] = req.body[field.id] || null;

0 commit comments

Comments
 (0)