This commit is contained in:
2020-09-14 20:59:48 +00:00
parent 498d556692
commit d7220f5d1f
2 changed files with 87 additions and 4 deletions

View File

@@ -377,14 +377,21 @@ namespace AyaNova.Biz
log.LogDebug($"Preparing page: adding base reporting scripts to page"); log.LogDebug($"Preparing page: adding base reporting scripts to page");
//Add Handlebars JS for compiling and presenting //Add Handlebars JS for compiling and presenting
//https://handlebarsjs.com/
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb.js") }); await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb.js") });
//add Marked for markdown processing //add Marked for markdown processing
//https://github.com/markedjs/marked
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") }); await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") });
//add DOM Purify for markdown template sanitization processing //add DOM Purify for markdown template sanitization processing
//https://github.com/cure53/DOMPurify
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-pf.js") }); await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-pf.js") });
//add Bar code library
//https://github.com/metafloor/bwip-js
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-bc.js") });
//add stock helpers //add stock helpers
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") }); await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
@@ -395,13 +402,15 @@ namespace AyaNova.Biz
//add report pre-render, helpers and style //add report pre-render, helpers and style
//TODO: Add code to vet / evaluate these scripts and see if they are safe and contain valid methods expected //TODO: Add code to vet / evaluate these scripts and see if they are safe and contain valid methods expected
if(string.IsNullOrWhiteSpace(report.JsPrerender)){ if (string.IsNullOrWhiteSpace(report.JsPrerender))
{
report.JsPrerender = "async function ayPrepareData(reportData){return reportData;}"; report.JsPrerender = "async function ayPrepareData(reportData){return reportData;}";
} }
await page.AddScriptTagAsync(new AddTagOptions() { Content = report.JsPrerender }); await page.AddScriptTagAsync(new AddTagOptions() { Content = report.JsPrerender });
if (!string.IsNullOrWhiteSpace(report.JsHelpers)) if (!string.IsNullOrWhiteSpace(report.JsHelpers))
await page.AddScriptTagAsync(new AddTagOptions() { Content = report.JsHelpers }); await page.AddScriptTagAsync(new AddTagOptions() { Content = report.JsHelpers });
if (!string.IsNullOrWhiteSpace(report.Style)) if (!string.IsNullOrWhiteSpace(report.Style))
await page.AddStyleTagAsync(new AddTagOptions() { Content = report.Style }); await page.AddStyleTagAsync(new AddTagOptions() { Content = report.Style });

File diff suppressed because one or more lines are too long