From 68ffad06a6cfd2cd2015ab03fb82bf69629dd7ec Mon Sep 17 00:00:00 2001 From: ivar Date: Tue, 2 Dec 2025 22:38:23 +0100 Subject: Move off razor pages --- api/WhatApi/Templates/TemplateFulfiller.cs | 23 ++++++++ api/WhatApi/Templates/web_map.liquid | 85 ++++++++++++++++++++++++++++++ api/WhatApi/Templates/web_upload.liquid | 75 ++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 api/WhatApi/Templates/TemplateFulfiller.cs create mode 100644 api/WhatApi/Templates/web_map.liquid create mode 100644 api/WhatApi/Templates/web_upload.liquid (limited to 'api/WhatApi/Templates') diff --git a/api/WhatApi/Templates/TemplateFulfiller.cs b/api/WhatApi/Templates/TemplateFulfiller.cs new file mode 100644 index 0000000..19d3bde --- /dev/null +++ b/api/WhatApi/Templates/TemplateFulfiller.cs @@ -0,0 +1,23 @@ +using Fluid; + +namespace WhatApi.Templates; + +public class TemplateFulfiller +{ + private static readonly FluidParser Parser = 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")); + + public static string WebMapPage(object? data = null) { + Parser.TryParse(WebMapTemplate, out var template); + var context = data is null ? new TemplateContext() : new TemplateContext(data); + return template.Render(context); + } + + public static string WebUploadPage(object? data = null) { + Parser.TryParse(WebUploadTemplate, out var template); + var context = data is null ? new TemplateContext() : new TemplateContext(data); + return template.Render(context); + } +} \ No newline at end of file diff --git a/api/WhatApi/Templates/web_map.liquid b/api/WhatApi/Templates/web_map.liquid new file mode 100644 index 0000000..d0a70e7 --- /dev/null +++ b/api/WhatApi/Templates/web_map.liquid @@ -0,0 +1,85 @@ + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/api/WhatApi/Templates/web_upload.liquid b/api/WhatApi/Templates/web_upload.liquid new file mode 100644 index 0000000..5688a01 --- /dev/null +++ b/api/WhatApi/Templates/web_upload.liquid @@ -0,0 +1,75 @@ + + + + + + + + + +
+
+ + + +
+
+
+

+
+
+
+
\ No newline at end of file
-- 
cgit v1.3