Prefetch paged.js

This commit is contained in:
2023-04-16 01:56:18 +02:00
parent e62126a83e
commit e1d0baf5fe
8 changed files with 13 additions and 28 deletions

View File

@ -1,9 +1,4 @@
using System; using Elwig.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Elwig.Models;
namespace Elwig.Documents { namespace Elwig.Documents {
public abstract class BusinessDocument : Document { public abstract class BusinessDocument : Document {

View File

@ -1,9 +1,4 @@
using System; using Elwig.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Elwig.Models;
namespace Elwig.Documents { namespace Elwig.Documents {
public class BusinessLetter : BusinessDocument { public class BusinessLetter : BusinessDocument {

View File

@ -14,8 +14,8 @@
window.addEventListener("afterprint", () => { location.reload(); }); window.addEventListener("afterprint", () => { location.reload(); });
} }
</script> </script>
<!-- TODO store paged.js locally to avoid using the internet --> <script src="C:\ProgramData\Elwig\resources\paged.polyfill.js"></script>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script> <!--link rel="stylesheet" href="C:\ProgramData\Elwig\resources\style.css"/-->
@{ await IncludeAsync("Style.css"); } @{ await IncludeAsync("Style.css"); }
</head> </head>
<body> <body>

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.IO; using System.IO;
using System.Windows;
using Elwig.Helpers; using Elwig.Helpers;
namespace Elwig.Documents { namespace Elwig.Documents {

View File

@ -1,17 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Shapes;
using PdfSharp.Pdf.IO; using PdfSharp.Pdf.IO;
using PuppeteerSharp; using PuppeteerSharp;
using PuppeteerSharp.Media;
using RazorLight;
using Elwig.Helpers; using Elwig.Helpers;
using Elwig.Windows; using Elwig.Windows;
@ -26,6 +17,8 @@ namespace Elwig.Documents {
Browser = await Puppeteer.LaunchAsync(new LaunchOptions { Browser = await Puppeteer.LaunchAsync(new LaunchOptions {
Headless = true, Headless = true,
ExecutablePath = Chromium, ExecutablePath = Chromium,
// paged.js uses XHRs to load styles, so this is needed
Args = new[] { "--allow-file-access-from-files" },
}); });
evtHandler(); evtHandler();
} }

View File

@ -1,5 +1,4 @@
@using RazorLight @using RazorLight
@inherits TemplatePage<Elwig.Documents.Document>
<style> <style>
:root { :root {

View File

@ -34,4 +34,8 @@
<EmbeddedResource Include="Documents/BusinessLetter.cshtml" /> <EmbeddedResource Include="Documents/BusinessLetter.cshtml" />
</ItemGroup> </ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call fetch-resources.bat" />
</Target>
</Project> </Project>

View File

@ -0,0 +1,3 @@
mkdir "C:\ProgramData\Elwig\resources""
curl -s -L "https://unpkg.com/pagedjs/dist/paged.polyfill.js" -o "C:\ProgramData\Elwig\resources\paged.polyfill.js"
::copy /y "Documents\style.css" "C:\ProgramData\Elwig\resources\style.css"