From 534a2912e167a6c9e2d4600352e9069ba1f73a1b Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Sun, 21 Aug 2022 20:38:14 +0200 Subject: [PATCH] Create dynamic manifest for pos apps (#4064) Co-authored-by: Dennis Reimann --- .../PointOfSale/Public/_LayoutPos.cshtml | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Views/Shared/PointOfSale/Public/_LayoutPos.cshtml b/BTCPayServer/Views/Shared/PointOfSale/Public/_LayoutPos.cshtml index 87f2fc82a..69a8ca7ee 100644 --- a/BTCPayServer/Views/Shared/PointOfSale/Public/_LayoutPos.cshtml +++ b/BTCPayServer/Views/Shared/PointOfSale/Public/_LayoutPos.cshtml @@ -1,12 +1,33 @@ @inject BTCPayServer.Services.ThemeSettings Theme - +@inject IWebHostEnvironment WebHostEnvironment @using BTCPayServer.Services.Apps @using BTCPayServer.Abstractions.Extensions +@using BTCPayServer.Abstractions.TagHelpers +@using BundlerMinifier.TagHelpers +@using Microsoft.AspNetCore.Hosting +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using Newtonsoft.Json +@using Newtonsoft.Json.Linq +@using System.IO @model BTCPayServer.Plugins.PointOfSale.Models.ViewPointOfSaleViewModel @{ ViewData["Title"] = Model.Title; Layout = null; + + async Task GetDynamicManifest(string title) + { + var manifest = WebHostEnvironment.WebRootFileProvider.GetFileInfo("manifest.json"); + if (!manifest.Exists) + { + return null; + } + using var reader = new StreamReader(manifest.CreateReadStream()); + var jObject = JObject.Parse(await reader.ReadToEndAsync()); + jObject["short_name"] = title; + jObject["name"] = $"BTCPay Server: {title}"; + return $"data:application/manifest+json, {jObject.ToString(Formatting.None)}"; + } } @@ -18,7 +39,7 @@ - + @if (Model.CustomCSSLink != null)