@jrpool/kilotest 24.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +9 -0
- package/DEVELOPMENT.md +5860 -0
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/SERVICE.md +268 -0
- package/aceconfig.js +28 -0
- package/ai0BalanceForm/index.html +30 -0
- package/ai0BalanceForm/index.js +79 -0
- package/alerts.js +73 -0
- package/diagnoses/index.html +46 -0
- package/diagnoses/index.js +140 -0
- package/env.example +21 -0
- package/env.testaro +17 -0
- package/error.html +18 -0
- package/eslint.config.mjs +53 -0
- package/favicon.ico +0 -0
- package/index.html +39 -0
- package/index.js +639 -0
- package/issues/index.html +20 -0
- package/issues/index.js +173 -0
- package/job.json +100 -0
- package/manage/index.html +32 -0
- package/manage/index.js +22 -0
- package/package.json +38 -0
- package/pm2.config.js +15 -0
- package/reannotate/index.html +19 -0
- package/reannotate/index.js +39 -0
- package/reannotateForm/index.html +29 -0
- package/reannotateForm/index.js +114 -0
- package/recActionForm/index.html +33 -0
- package/recActionForm/index.js +49 -0
- package/reportHideForm/index.html +29 -0
- package/reportHideForm/index.js +89 -0
- package/reportIssue/index.html +38 -0
- package/reportIssue/index.js +181 -0
- package/reportIssues/index.html +47 -0
- package/reportIssues/index.js +259 -0
- package/reportUnhideForm/index.html +29 -0
- package/reportUnhideForm/index.js +89 -0
- package/reportsExpungeForm/index.html +29 -0
- package/reportsExpungeForm/index.js +105 -0
- package/reportsPruneForm/index.html +29 -0
- package/reportsPruneForm/index.js +105 -0
- package/reportsRewindForm/index.html +29 -0
- package/reportsRewindForm/index.js +105 -0
- package/retestRec/index.html +23 -0
- package/retestRec/index.js +19 -0
- package/retestRecForm/index.html +27 -0
- package/retestRecForm/index.js +36 -0
- package/rules/index.html +28 -0
- package/rules/index.js +71 -0
- package/style.css +196 -0
- package/targets/index.html +37 -0
- package/targets/index.js +170 -0
- package/testOrder/index.html +23 -0
- package/testOrder/index.js +62 -0
- package/testRec/index.html +23 -0
- package/testRec/index.js +25 -0
- package/testRecForm/index.html +34 -0
- package/testRecForm/index.js +22 -0
- package/tutorial/images/newsletter-form.png +0 -0
- package/tutorial/index.html +796 -0
- package/tutorial/index.js +53 -0
- package/util.js +686 -0
- package/wcagMap.json +102 -0
- package/wcagRenew/index.html +19 -0
- package/wcagRenew/index.js +70 -0
- package/wcagRenewForm/index.html +25 -0
- package/wcagRenewForm/index.js +22 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
index.js
|
|
3
|
+
Answers the tutorial request and saves tutorial comments.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// IMPORTS
|
|
7
|
+
|
|
8
|
+
const {getJSON} = require('../util');
|
|
9
|
+
const fs = require('fs/promises');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
// CONSTANTS
|
|
13
|
+
|
|
14
|
+
const commentsPath = path.join(__dirname, 'comments.json');
|
|
15
|
+
|
|
16
|
+
// FUNCTIONS
|
|
17
|
+
|
|
18
|
+
// Strips HTML tags and control characters, trims, and limits to 500 characters.
|
|
19
|
+
const sanitize = str => str
|
|
20
|
+
.replace(/<[^>]*>/g, '')
|
|
21
|
+
.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '')
|
|
22
|
+
.trim()
|
|
23
|
+
.slice(0, 500);
|
|
24
|
+
|
|
25
|
+
// Returns the tutorial page.
|
|
26
|
+
exports.answer = async () => {
|
|
27
|
+
let answerPage = await fs.readFile(path.join(__dirname, 'index.html'), 'utf8');
|
|
28
|
+
return {
|
|
29
|
+
status: 'ok',
|
|
30
|
+
answerPage
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
// Sanitizes and saves a tutorial comment to comments.json.
|
|
34
|
+
exports.saveComment = async content => {
|
|
35
|
+
if (!content || typeof content !== 'string') {
|
|
36
|
+
return {status: 'error', error: 'No content provided'};
|
|
37
|
+
}
|
|
38
|
+
const sanitized = sanitize(content);
|
|
39
|
+
if (!sanitized) {
|
|
40
|
+
return {status: 'error', error: 'Comment is empty after sanitization'};
|
|
41
|
+
}
|
|
42
|
+
let comments = [];
|
|
43
|
+
try {
|
|
44
|
+
const existing = await fs.readFile(commentsPath, 'utf8');
|
|
45
|
+
comments = JSON.parse(existing);
|
|
46
|
+
}
|
|
47
|
+
catch (_) {
|
|
48
|
+
// File absent or unparseable; start a fresh array.
|
|
49
|
+
}
|
|
50
|
+
comments.push({timeStamp: new Date().toISOString(), content: sanitized});
|
|
51
|
+
await fs.writeFile(commentsPath, getJSON(comments));
|
|
52
|
+
return {status: 'ok'};
|
|
53
|
+
};
|