Use FileSystemProject in RazorLight

This commit is contained in:
2023-04-16 02:18:11 +02:00
parent e7d4d35f4e
commit 84cc5f0778
5 changed files with 7 additions and 9 deletions

View File

@ -14,8 +14,8 @@
window.addEventListener("afterprint", () => { location.reload(); }); window.addEventListener("afterprint", () => { location.reload(); });
} }
</script> </script>
<script src="C:\ProgramData\Elwig\resources\paged.polyfill.js"></script> <script src="@Raw(Model.DataPath)\resources\paged.polyfill.js"></script>
<link rel="stylesheet" href="C:\ProgramData\Elwig\resources\style.css"/> <link rel="stylesheet" href="@Raw(Model.DataPath)\resources\style.css" />
</head> </head>
<body> <body>
<div class="m1"></div> <div class="m1"></div>

View File

@ -9,6 +9,7 @@ namespace Elwig.Documents {
private TempFile? PdfFile = null; private TempFile? PdfFile = null;
public Document(string title) { public Document(string title) {
DataPath = App.DataPath;
Title = title; Title = title;
Header = "<h1>Winzergenossenschaft Matzen</h1>"; Header = "<h1>Winzergenossenschaft Matzen</h1>";
Footer = "Winzergenossenschaft für Matzen und Umgebung reg. Gen.m.b.H."; Footer = "Winzergenossenschaft für Matzen und Umgebung reg. Gen.m.b.H.";
@ -24,6 +25,8 @@ namespace Elwig.Documents {
PdfFile = null; PdfFile = null;
} }
public string DataPath { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Header { get; set; } public string Header { get; set; }

View File

@ -10,7 +10,7 @@ namespace Elwig.Documents {
public static async Task Init(Action evtHandler) { public static async Task Init(Action evtHandler) {
var e = new RazorLightEngineBuilder() var e = new RazorLightEngineBuilder()
.UseEmbeddedResourcesProject(typeof(App).Assembly, "Elwig.Documents") .UseFileSystemProject(App.DataPath + "resources")
.UseMemoryCachingProvider() .UseMemoryCachingProvider()
.Build(); .Build();

View File

@ -27,12 +27,6 @@
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Documents/Document.cshtml" />
<EmbeddedResource Include="Documents/BusinessDocument.cshtml" />
<EmbeddedResource Include="Documents/BusinessLetter.cshtml" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call fetch-resources.bat" /> <Exec Command="call fetch-resources.bat" />
</Target> </Target>

View File

@ -1,3 +1,4 @@
mkdir "C:\ProgramData\Elwig\resources"" mkdir "C:\ProgramData\Elwig\resources""
curl -s -L "https://unpkg.com/pagedjs/dist/paged.polyfill.js" -o "C:\ProgramData\Elwig\resources\paged.polyfill.js" 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" copy /y "Documents\style.css" "C:\ProgramData\Elwig\resources\style.css"
copy /y Documents\*.cshtml "C:\ProgramData\Elwig\resources"