summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Templates/TemplateFulfiller.cs
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-04 23:30:39 +0100
committerivar <i@oiee.no>2025-12-04 23:30:39 +0100
commit8c355b82df02bc650c5ba101d838121f485e8581 (patch)
tree00ff527de5968d7899f7f653355073b8a416328b /api/WhatApi/Templates/TemplateFulfiller.cs
parentdeade767eace22a8c5281dcd5360c300395e2b5e (diff)
downloadwhat-master.tar.xz
what-master.zip
Improve login experienceHEADmaster
Diffstat (limited to 'api/WhatApi/Templates/TemplateFulfiller.cs')
-rw-r--r--api/WhatApi/Templates/TemplateFulfiller.cs28
1 files changed, 20 insertions, 8 deletions
diff --git a/api/WhatApi/Templates/TemplateFulfiller.cs b/api/WhatApi/Templates/TemplateFulfiller.cs
index 3433701..e24e77d 100644
--- a/api/WhatApi/Templates/TemplateFulfiller.cs
+++ b/api/WhatApi/Templates/TemplateFulfiller.cs
@@ -5,25 +5,37 @@ namespace WhatApi.Templates;
public class TemplateFulfiller
{
private static readonly FluidParser Parser = new();
+ private static readonly TemplateContext EmptyContext = new();
private static readonly string TemplateDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Templates");
private static string WebMapTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_map.liquid"));
private static string WebUploadTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_upload.liquid"));
private static string WebLoginTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_login.liquid"));
+ private static string WebTermsTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_terms.liquid"));
- public static string WebMapPage(object? data = null) {
+
+ public static string WebMapPage() {
Parser.TryParse(WebMapTemplate, out var template);
- var context = data is null ? new TemplateContext() : new TemplateContext(data);
- return template.Render(context);
+ return template.Render(EmptyContext);
}
- public static string WebUploadPage(object? data = null) {
+ public static string WebUploadPage() {
Parser.TryParse(WebUploadTemplate, out var template);
- var context = data is null ? new TemplateContext() : new TemplateContext(data);
- return template.Render(context);
+ return template.Render(EmptyContext);
+ }
+
+ public class WebLoginModel
+ {
+ public string Error { get; set; } = string.Empty;
}
- public static string WebLoginPage(object? data = null) {
+
+ public static string WebLoginPage(WebLoginModel model) {
Parser.TryParse(WebLoginTemplate, out var template);
- var context = data is null ? new TemplateContext() : new TemplateContext(data);
+ var context = new TemplateContext(model);
return template.Render(context);
}
+
+ public static string WebTermsPage() {
+ Parser.TryParse(WebTermsTemplate, out var template);
+ return template.Render(EmptyContext);
+ }
} \ No newline at end of file