implement UserTemplates for overriding templates. Call your templates with wtvshared.getTemplate(service_name,'path_to_template.ext');

This commit is contained in:
zefie
2022-10-15 18:57:02 -04:00
parent f1b931f31f
commit 47e87a4ebc
118 changed files with 1047 additions and 181 deletions

View File

@@ -771,7 +771,23 @@ class WTVShared {
return this.zlib.deflateSync(data, { 'level': 9 }).toString('base64');
}
getTemplate(service_name, path, path_only = true) {
var self = this;
var outdata = null;
var found = false
this.minisrv_config.config.ServiceTemplates.forEach(function (template_vault_dir) {
if (found) return;
var search = self.getAbsolutePath(template_vault_dir + self.path.sep + service_name + self.path.sep + path);
if (self.fs.existsSync(search)) {
if (path_only) outdata = search;
else outdata = fs.readFileSync(search).toString('ascii');
if (!self.minisrv_config.config.debug_flags.quiet) console.log(" * Found " + search + " to handle template");
found = true;
return false;
}
});
return outdata;
}
}
class clientShowAlert {