-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathextensions.js
More file actions
50 lines (34 loc) · 1.1 KB
/
extensions.js
File metadata and controls
50 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Important: Do not remove this file
// This script loads 3rd-party extensions into each FlowStream
exports.install = function(instance) {
REPO.extensions = [];
// It loads all HTML files in the extensions directory
let path = Total.path.root('extensions');
Total.Fs.readdir(path, async function(err, response) {
if (err)
return;
for (let file of response) {
if (!file.endsWith('.html'))
continue;
let body = await Total.readfile(PATH.join(path, file), 'utf8');
let index = body.indexOf('<script total>');
let total = null;
if (index !== -1) {
total = body.substring(index, body.indexOf('</script>', index + 14) + 9);
body = body.replace(total, '').trim();
total = total.substring(14, total.length - 9).trim();
}
let name = file.replace(/\.html$/i, '');
if (total)
(new Function('exports', total))({ id: name, name: name, flow: instance });
if (body)
REPO.extensions.push({ id: name, html: body });
}
});
// A global action that returns UI customization
NEWACTION('Extensions', {
action: function($) {
$.callback(REPO.extensions);
}
});
};