From 44b7ed0e6e77e2db519601f991ca6de901e69caf Mon Sep 17 00:00:00 2001 From: d11n Date: Fri, 1 Dec 2023 16:13:44 +0100 Subject: [PATCH] Store Branding: Refactoring and logo as favicon (#5519) * Store Branding: Refactoring and logo as favicon - Encapsulates store branding properties into their own view model - Uses the logo as favicon on public pages * Refactorings * Updates --- .../Controllers/UIInvoiceController.UI.cs | 12 ++++------ .../Controllers/UIPaymentRequestController.cs | 20 +++++++++++----- .../UIPublicLightningNodeInfoController.cs | 11 +++------ .../Controllers/UIPullPaymentController.cs | 7 ++++-- .../Controllers/UIStoresController.cs | 14 +++++------ BTCPayServer/Forms/Models/FormViewModel.cs | 5 ++-- BTCPayServer/Forms/UIFormsController.cs | 5 ++-- .../InvoiceReceiptViewModel.cs | 4 +--- .../Models/InvoicingModels/PaymentModel.cs | 3 +-- .../ListPaymentRequestsViewModel.cs | 7 +----- BTCPayServer/Models/StoreBrandingViewModel.cs | 24 +++++++++++++++++++ BTCPayServer/Models/ViewPullPaymentModel.cs | 9 +------ .../PaymentRequest/PaymentRequestService.cs | 1 - .../Plugins/Crowdfund/CrowdfundPlugin.cs | 13 +++++----- .../Models/ViewCrowdfundViewModel.cs | 7 ++---- .../Controllers/UIPointOfSaleController.cs | 17 +++++++------ .../Models/ViewPointOfSaleViewModel.cs | 10 ++------ .../Crowdfund/Public/ViewCrowdfund.cshtml | 17 ++++--------- BTCPayServer/Views/Shared/LayoutHead.cshtml | 12 +++++++++- .../Shared/LayoutHeadStoreBranding.cshtml | 13 +++++++--- .../Shared/PointOfSale/Public/Light.cshtml | 2 +- .../Shared/PointOfSale/Public/Print.cshtml | 2 +- .../Shared/PointOfSale/Public/Static.cshtml | 2 +- .../Shared/PointOfSale/Public/_Layout.cshtml | 7 ++---- .../Views/Shared/_LayoutSignedOut.cshtml | 3 +-- BTCPayServer/Views/Shared/_StoreHeader.cshtml | 7 +++--- BTCPayServer/Views/UIForms/View.cshtml | 6 ++--- .../Views/UIInvoice/CheckoutV2.cshtml | 6 ++--- .../Views/UIInvoice/InvoiceReceipt.cshtml | 6 ++--- .../UIInvoice/InvoiceReceiptPrint.cshtml | 2 +- .../ViewPaymentRequest.cshtml | 8 +++---- .../ShowLightningNodeInfo.cshtml | 8 +++---- .../UIPullPayment/ViewPullPayment.cshtml | 8 +++---- 33 files changed, 138 insertions(+), 140 deletions(-) create mode 100644 BTCPayServer/Models/StoreBrandingViewModel.cs diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index 24e15cbad..05aa53d35 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -223,9 +223,7 @@ namespace BTCPayServer.Controllers Currency = i.Currency, Timestamp = i.InvoiceTime, StoreName = store.StoreName, - BrandColor = storeBlob.BrandColor, - LogoFileId = storeBlob.LogoFileId, - CssFileId = storeBlob.CssFileId, + StoreBranding = new StoreBrandingViewModel(storeBlob), ReceiptOptions = receipt }; @@ -858,11 +856,11 @@ namespace BTCPayServer.Controllers DefaultLang = lang ?? invoice.DefaultLanguage ?? storeBlob.DefaultLang ?? "en", ShowPayInWalletButton = storeBlob.ShowPayInWalletButton, ShowStoreHeader = storeBlob.ShowStoreHeader, - CustomCSSLink = storeBlob.CustomCSS, + StoreBranding = new StoreBrandingViewModel(storeBlob) + { + CustomCSSLink = storeBlob.CustomCSS + }, CustomLogoLink = storeBlob.CustomLogo, - LogoFileId = storeBlob.LogoFileId, - CssFileId = storeBlob.CssFileId, - BrandColor = storeBlob.BrandColor, CheckoutType = invoice.CheckoutType ?? storeBlob.CheckoutType, HtmlTitle = storeBlob.HtmlTitle ?? "BTCPay Invoice", CelebratePayment = storeBlob.CelebratePayment, diff --git a/BTCPayServer/Controllers/UIPaymentRequestController.cs b/BTCPayServer/Controllers/UIPaymentRequestController.cs index ae3a20ce8..f8e7f9a97 100644 --- a/BTCPayServer/Controllers/UIPaymentRequestController.cs +++ b/BTCPayServer/Controllers/UIPaymentRequestController.cs @@ -10,6 +10,7 @@ using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Forms; using BTCPayServer.Forms.Models; +using BTCPayServer.Models; using BTCPayServer.Models.PaymentRequestViewModels; using BTCPayServer.PaymentRequest; using BTCPayServer.Services; @@ -209,12 +210,14 @@ namespace BTCPayServer.Controllers } var storeBlob = store.GetStoreBlob(); + vm.HubPath = PaymentRequestHub.GetHubPath(Request); vm.StoreName = store.StoreName; vm.StoreWebsite = store.StoreWebsite; - vm.BrandColor = storeBlob.BrandColor; - vm.LogoFileId = storeBlob.LogoFileId; - vm.CssFileId = storeBlob.CssFileId; - vm.HubPath = PaymentRequestHub.GetHubPath(Request); + vm.StoreBranding = new StoreBrandingViewModel(storeBlob) + { + EmbeddedCSS = vm.EmbeddedCSS, + CustomCSSLink = vm.CustomCSSLink + }; return View(vm); } @@ -240,7 +243,6 @@ namespace BTCPayServer.Controllers var formData = await FormDataService.GetForm(prFormId); if (formData is null) { - return RedirectToAction("PayPaymentRequest", new { payReqId }); } @@ -266,8 +268,14 @@ namespace BTCPayServer.Controllers } viewModel.FormName = formData.Name; viewModel.Form = form; + + var storeBlob = result.StoreData.GetStoreBlob(); + viewModel.StoreBranding = new StoreBrandingViewModel(storeBlob) + { + EmbeddedCSS = prBlob.EmbeddedCSS, + CustomCSSLink = prBlob.CustomCSSLink + }; return View("Views/UIForms/View", viewModel); - } [HttpGet("{payReqId}/pay")] diff --git a/BTCPayServer/Controllers/UIPublicLightningNodeInfoController.cs b/BTCPayServer/Controllers/UIPublicLightningNodeInfoController.cs index 7315dbfa4..01aca617a 100644 --- a/BTCPayServer/Controllers/UIPublicLightningNodeInfoController.cs +++ b/BTCPayServer/Controllers/UIPublicLightningNodeInfoController.cs @@ -5,6 +5,7 @@ using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Lightning; using BTCPayServer.Logging; +using BTCPayServer.Models; using BTCPayServer.Payments; using BTCPayServer.Payments.Lightning; using BTCPayServer.Services.Stores; @@ -42,9 +43,7 @@ namespace BTCPayServer.Controllers { CryptoCode = cryptoCode, StoreName = store.StoreName, - BrandColor = storeBlob.BrandColor, - LogoFileId = storeBlob.LogoFileId, - CssFileId = storeBlob.CssFileId + StoreBranding = new StoreBrandingViewModel(storeBlob) }; try { @@ -74,7 +73,6 @@ namespace BTCPayServer.Controllers return existing; } - private string GetImage(PaymentMethodId paymentMethodId, BTCPayNetwork network) { var res = paymentMethodId.PaymentType == PaymentTypes.BTCLike @@ -84,7 +82,6 @@ namespace BTCPayServer.Controllers } } - public class ShowLightningNodeInfoViewModel { public class NodeData @@ -103,13 +100,11 @@ namespace BTCPayServer.Controllers return _connection; } } + public StoreBrandingViewModel StoreBranding { get; set; } public NodeData[] NodeInfo { get; set; } public bool Available { get; set; } public string CryptoCode { get; set; } public string CryptoImage { get; set; } public string StoreName { get; set; } - public string LogoFileId { get; set; } - public string CssFileId { get; set; } - public string BrandColor { get; set; } } } diff --git a/BTCPayServer/Controllers/UIPullPaymentController.cs b/BTCPayServer/Controllers/UIPullPaymentController.cs index a3b68da37..50ba820ae 100644 --- a/BTCPayServer/Controllers/UIPullPaymentController.cs +++ b/BTCPayServer/Controllers/UIPullPaymentController.cs @@ -83,8 +83,6 @@ namespace BTCPayServer.Controllers ViewPullPaymentModel vm = new(pp, DateTimeOffset.UtcNow) { - BrandColor = storeBlob.BrandColor, - CssFileId = storeBlob.CssFileId, AmountCollected = totalPaid, AmountDue = amountDue, ClaimedAmount = amountDue, @@ -105,6 +103,11 @@ namespace BTCPayServer.Controllers }).ToList() }; vm.IsPending &= vm.AmountDue > 0.0m; + vm.StoreBranding = new StoreBrandingViewModel(storeBlob) + { + EmbeddedCSS = blob.View.EmbeddedCSS, + CustomCSSLink = blob.View.CustomCSSLink + }; if (_pullPaymentHostedService.SupportsLNURL(blob)) { diff --git a/BTCPayServer/Controllers/UIStoresController.cs b/BTCPayServer/Controllers/UIStoresController.cs index 2e9775c60..2b99fecfe 100644 --- a/BTCPayServer/Controllers/UIStoresController.cs +++ b/BTCPayServer/Controllers/UIStoresController.cs @@ -139,9 +139,10 @@ namespace BTCPayServer.Controllers public async Task Index(string storeId) { var userId = _UserManager.GetUserId(User); - if(userId is null) + if (string.IsNullOrEmpty(userId)) return Forbid(); - var store = await _Repo.FindStore(storeId, _UserManager.GetUserId(User)); + + var store = await _Repo.FindStore(storeId, userId); if (store is null) { return Forbid(); @@ -158,12 +159,10 @@ namespace BTCPayServer.Controllers return View(); } - [HttpGet] - [Route("{storeId}/users")] + [HttpGet("{storeId}/users")] public async Task StoreUsers() { - StoreUsersViewModel vm = new StoreUsersViewModel(); - vm.Role = StoreRoleId.Guest.Role; + var vm = new StoreUsersViewModel { Role = StoreRoleId.Guest.Role }; await FillUsers(vm); return View(vm); } @@ -182,8 +181,7 @@ namespace BTCPayServer.Controllers public StoreData CurrentStore => HttpContext.GetStoreData(); - [HttpPost] - [Route("{storeId}/users")] + [HttpPost("{storeId}/users")] public async Task StoreUsers(string storeId, StoreUsersViewModel vm) { await FillUsers(vm); diff --git a/BTCPayServer/Forms/Models/FormViewModel.cs b/BTCPayServer/Forms/Models/FormViewModel.cs index 77c5efc64..c258f74d7 100644 --- a/BTCPayServer/Forms/Models/FormViewModel.cs +++ b/BTCPayServer/Forms/Models/FormViewModel.cs @@ -1,13 +1,11 @@ using System.Collections.Generic; using BTCPayServer.Abstractions.Form; +using BTCPayServer.Models; namespace BTCPayServer.Forms.Models; public class FormViewModel { - public string LogoFileId { get; set; } - public string CssFileId { get; set; } - public string BrandColor { get; set; } public string StoreName { get; set; } public string FormName { get; set; } public Form Form { get; set; } @@ -15,5 +13,6 @@ public class FormViewModel public string AspAction { get; set; } public Dictionary RouteParameters { get; set; } = new(); public MultiValueDictionary FormParameters { get; set; } = new(); + public StoreBrandingViewModel StoreBranding { get; set; } public string FormParameterPrefix { get; set; } } diff --git a/BTCPayServer/Forms/UIFormsController.cs b/BTCPayServer/Forms/UIFormsController.cs index 971e1c958..b83e189b6 100644 --- a/BTCPayServer/Forms/UIFormsController.cs +++ b/BTCPayServer/Forms/UIFormsController.cs @@ -13,6 +13,7 @@ using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Forms.Models; +using BTCPayServer.Models; using BTCPayServer.Services.Stores; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -164,9 +165,7 @@ public class UIFormsController : Controller FormName = formData.Name, Form = form, StoreName = store?.StoreName, - BrandColor = storeBlob?.BrandColor, - CssFileId = storeBlob?.CssFileId, - LogoFileId = storeBlob?.LogoFileId, + StoreBranding = new StoreBrandingViewModel(storeBlob) }); } diff --git a/BTCPayServer/Models/InvoicingModels/InvoiceReceiptViewModel.cs b/BTCPayServer/Models/InvoicingModels/InvoiceReceiptViewModel.cs index 40f8e1387..1065596d8 100644 --- a/BTCPayServer/Models/InvoicingModels/InvoiceReceiptViewModel.cs +++ b/BTCPayServer/Models/InvoicingModels/InvoiceReceiptViewModel.cs @@ -9,13 +9,11 @@ namespace BTCPayServer.Models.InvoicingModels public class InvoiceReceiptViewModel { public InvoiceStatus Status { get; set; } + public StoreBrandingViewModel StoreBranding { get; set; } public string InvoiceId { get; set; } public string OrderId { get; set; } public string Currency { get; set; } public string StoreName { get; set; } - public string BrandColor { get; set; } - public string LogoFileId { get; set; } - public string CssFileId { get; set; } public decimal Amount { get; set; } public DateTimeOffset Timestamp { get; set; } public Dictionary AdditionalData { get; set; } diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 3d5a918e9..5d6a53d20 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -23,10 +23,9 @@ namespace BTCPayServer.Models.InvoicingModels public string CryptoCode { get; set; } public bool Displayed { get; set; } } + public StoreBrandingViewModel StoreBranding { get; set; } public string CustomCSSLink { get; set; } public string CustomLogoLink { get; set; } - public string CssFileId { get; set; } - public string LogoFileId { get; set; } public string PaymentSoundUrl { get; set; } public string NfcReadSoundUrl { get; set; } public string ErrorSoundUrl { get; set; } diff --git a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs index 703c73427..ba7b895a4 100644 --- a/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs +++ b/BTCPayServer/Models/PaymentRequestViewModels/ListPaymentRequestsViewModel.cs @@ -118,8 +118,6 @@ namespace BTCPayServer.Models.PaymentRequestViewModels EmbeddedCSS = blob.EmbeddedCSS; CustomCSSLink = blob.CustomCSSLink; AllowCustomPaymentAmounts = blob.AllowCustomPaymentAmounts; - if (!string.IsNullOrEmpty(EmbeddedCSS)) - EmbeddedCSS = $""; switch (data.Status) { case Client.Models.PaymentRequestData.PaymentRequestStatus.Pending: @@ -139,7 +137,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels throw new ArgumentOutOfRangeException(); } } - + public StoreBrandingViewModel StoreBranding { get; set; } public bool AllowCustomPaymentAmounts { get; set; } public string Email { get; set; } public string Status { get; set; } @@ -154,9 +152,6 @@ namespace BTCPayServer.Models.PaymentRequestViewModels public DateTime? ExpiryDate { get; set; } public string Title { get; set; } public string Description { get; set; } - public string LogoFileId { get; set; } - public string CssFileId { get; set; } - public string BrandColor { get; set; } public string StoreName { get; set; } public string StoreWebsite { get; set; } public string EmbeddedCSS { get; set; } diff --git a/BTCPayServer/Models/StoreBrandingViewModel.cs b/BTCPayServer/Models/StoreBrandingViewModel.cs new file mode 100644 index 000000000..d8788a89d --- /dev/null +++ b/BTCPayServer/Models/StoreBrandingViewModel.cs @@ -0,0 +1,24 @@ +using BTCPayServer.Data; + +namespace BTCPayServer.Models; + +public class StoreBrandingViewModel +{ + public string BrandColor { get; set; } + public string LogoFileId { get; set; } + public string CssFileId { get; set; } + public string CustomCSSLink { get; set; } + public string EmbeddedCSS { get; set; } + + public StoreBrandingViewModel() + { + } + + public StoreBrandingViewModel(StoreBlob storeBlob) + { + if (storeBlob == null) return; + BrandColor = storeBlob.BrandColor; + LogoFileId = storeBlob.LogoFileId; + CssFileId = storeBlob.CssFileId; + } +} diff --git a/BTCPayServer/Models/ViewPullPaymentModel.cs b/BTCPayServer/Models/ViewPullPaymentModel.cs index 315b495f4..2730900b6 100644 --- a/BTCPayServer/Models/ViewPullPaymentModel.cs +++ b/BTCPayServer/Models/ViewPullPaymentModel.cs @@ -34,10 +34,6 @@ namespace BTCPayServer.Models ExpiryDate = data.EndDate is DateTimeOffset dt ? (DateTime?)dt.UtcDateTime : null; Email = blob.View.Email; MinimumClaim = blob.MinimumClaim; - EmbeddedCSS = blob.View.EmbeddedCSS; - CustomCSSLink = blob.View.CustomCSSLink; - if (!string.IsNullOrEmpty(EmbeddedCSS)) - EmbeddedCSS = $""; IsPending = !data.IsExpired(); var period = data.GetPeriod(now); if (data.Archived) @@ -91,15 +87,12 @@ namespace BTCPayServer.Models public DateTime? ExpiryDate { get; set; } public string Title { get; set; } public string Description { get; set; } - public string BrandColor { get; set; } - public string CssFileId { get; set; } - public string EmbeddedCSS { get; set; } - public string CustomCSSLink { get; set; } public List Payouts { get; set; } = new(); public DateTimeOffset StartDate { get; set; } public DateTime LastRefreshed { get; set; } public CurrencyData CurrencyData { get; set; } public Uri LnurlEndpoint { get; set; } + public StoreBrandingViewModel StoreBranding { get; set; } public bool Archived { get; set; } public bool AutoApprove { get; set; } diff --git a/BTCPayServer/PaymentRequest/PaymentRequestService.cs b/BTCPayServer/PaymentRequest/PaymentRequestService.cs index 61e610daa..20726b089 100644 --- a/BTCPayServer/PaymentRequest/PaymentRequestService.cs +++ b/BTCPayServer/PaymentRequest/PaymentRequestService.cs @@ -94,7 +94,6 @@ namespace BTCPayServer.PaymentRequest } var blob = pr.GetBlob(); - var invoices = await _paymentRequestRepository.GetInvoicesForPaymentRequest(id); var paymentStats = _invoiceRepository.GetContributionsByPaymentMethodId(blob.Currency, invoices, true); var amountDue = blob.Amount - paymentStats.TotalCurrency; diff --git a/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs b/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs index 8daff4031..ec8b57b24 100644 --- a/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs +++ b/BTCPayServer/Plugins/Crowdfund/CrowdfundPlugin.cs @@ -8,6 +8,7 @@ using BTCPayServer.Abstractions.Models; using BTCPayServer.Abstractions.Services; using BTCPayServer.Configuration; using BTCPayServer.Data; +using BTCPayServer.Models; using BTCPayServer.Plugins.Crowdfund.Controllers; using BTCPayServer.Plugins.Crowdfund.Models; using BTCPayServer.Plugins.PointOfSale; @@ -177,19 +178,19 @@ namespace BTCPayServer.Plugins.Crowdfund var store = appData.StoreData; var storeBlob = store.GetStoreBlob(); - + var storeBranding = new StoreBrandingViewModel(storeBlob) + { + CustomCSSLink = settings.CustomCSSLink, + EmbeddedCSS = settings.EmbeddedCSS + }; return new ViewCrowdfundViewModel { Title = settings.Title, Tagline = settings.Tagline, Description = settings.Description, - CustomCSSLink = settings.CustomCSSLink, MainImageUrl = settings.MainImageUrl, - EmbeddedCSS = settings.EmbeddedCSS, StoreName = store.StoreName, - CssFileId = storeBlob.CssFileId, - LogoFileId = storeBlob.LogoFileId, - BrandColor = storeBlob.BrandColor, + StoreBranding = storeBranding, StoreId = appData.StoreDataId, AppId = appData.Id, StartDate = settings.StartDate?.ToUniversalTime(), diff --git a/BTCPayServer/Plugins/Crowdfund/Models/ViewCrowdfundViewModel.cs b/BTCPayServer/Plugins/Crowdfund/Models/ViewCrowdfundViewModel.cs index 41f720233..58bf15b74 100644 --- a/BTCPayServer/Plugins/Crowdfund/Models/ViewCrowdfundViewModel.cs +++ b/BTCPayServer/Plugins/Crowdfund/Models/ViewCrowdfundViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using BTCPayServer.Models; using BTCPayServer.Plugins.PointOfSale.Models; using BTCPayServer.Services.Rates; @@ -14,12 +15,7 @@ namespace BTCPayServer.Plugins.Crowdfund.Models public string Title { get; set; } public string Description { get; set; } public string MainImageUrl { get; set; } - public string CssFileId { get; set; } - public string LogoFileId { get; set; } public string StoreName { get; set; } - public string BrandColor { get; set; } - public string EmbeddedCSS { get; set; } - public string CustomCSSLink { get; set; } public DateTime? StartDate { get; set; } public DateTime? EndDate { get; set; } @@ -29,6 +25,7 @@ namespace BTCPayServer.Plugins.Crowdfund.Models public CrowdfundInfo Info { get; set; } public string Tagline { get; set; } + public StoreBrandingViewModel StoreBranding { get; set; } public ViewPointOfSaleViewModel.Item[] Perks { get; set; } public bool SimpleDisplay { get; set; } public bool DisqusEnabled { get; set; } diff --git a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs index 9fee422c5..07af727b9 100644 --- a/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs +++ b/BTCPayServer/Plugins/PointOfSale/Controllers/UIPointOfSaleController.cs @@ -87,13 +87,17 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers var store = await _appService.GetStore(app); var storeBlob = store.GetStoreBlob(); + var storeBranding = new StoreBrandingViewModel(storeBlob) + { + EmbeddedCSS = settings.EmbeddedCSS, + CustomCSSLink = settings.CustomCSSLink + }; + return View($"PointOfSale/Public/{viewType}", new ViewPointOfSaleViewModel { Title = settings.Title, StoreName = store.StoreName, - BrandColor = storeBlob.BrandColor, - CssFileId = storeBlob.CssFileId, - LogoFileId = storeBlob.LogoFileId, + StoreBranding = storeBranding, Step = step.ToString(CultureInfo.InvariantCulture), ViewType = (PosViewType)viewType, ShowCustomAmount = settings.ShowCustomAmount, @@ -117,12 +121,9 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers CustomButtonText = settings.CustomButtonText, CustomTipText = settings.CustomTipText, CustomTipPercentages = settings.CustomTipPercentages, - CustomCSSLink = settings.CustomCSSLink, - CustomLogoLink = storeBlob.CustomLogo, AppId = appId, StoreId = store.Id, Description = settings.Description, - EmbeddedCSS = settings.EmbeddedCSS, RequiresRefundEmail = settings.RequiresRefundEmail }); } @@ -458,9 +459,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers var vm = new FormViewModel { StoreName = store.StoreName, - BrandColor = storeBlob.BrandColor, - CssFileId = storeBlob.CssFileId, - LogoFileId = storeBlob.LogoFileId, + StoreBranding = new StoreBrandingViewModel(storeBlob), FormName = formData.Name, Form = form, AspController = controller, diff --git a/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs b/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs index afa0c737c..57954cfb5 100644 --- a/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs +++ b/BTCPayServer/Plugins/PointOfSale/Models/ViewPointOfSaleViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using BTCPayServer.JsonConverters; +using BTCPayServer.Models; using BTCPayServer.Services.Apps; using Microsoft.AspNetCore.Mvc.Rendering; using Newtonsoft.Json; @@ -57,9 +58,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Models public bool SymbolSpace { get; set; } } - public string LogoFileId { get; set; } - public string CssFileId { get; set; } - public string BrandColor { get; set; } + public StoreBrandingViewModel StoreBranding { get; set; } public string StoreName { get; set; } public CurrencyInfoData CurrencyInfo { get; set; } public PosViewType ViewType { get; set; } @@ -106,14 +105,9 @@ namespace BTCPayServer.Plugins.PointOfSale.Models public string CustomButtonText { get; set; } public string CustomTipText { get; set; } public int[] CustomTipPercentages { get; set; } - - [Display(Name = "Custom CSS URL")] - public string CustomCSSLink { get; set; } - public string CustomLogoLink { get; set; } public string Description { get; set; } public SelectList AllCategories { get; set; } [Display(Name = "Custom CSS Code")] - public string EmbeddedCSS { get; set; } public RequiresRefundEmail RequiresRefundEmail { get; set; } = RequiresRefundEmail.InheritFromStore; public string StoreId { get; set; } } diff --git a/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml b/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml index e3740d633..2fa2eaf81 100644 --- a/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml +++ b/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml @@ -4,6 +4,7 @@ @inject BTCPayServer.Security.ContentSecurityPolicies Csp @{ ViewData["Title"] = Model.Title; + ViewData["StoreBranding"] = Model.StoreBranding; Layout = null; Csp.UnsafeEval(); if (!string.IsNullOrEmpty(Model.DisqusShortname)) @@ -16,18 +17,8 @@ - - - - - @if (!string.IsNullOrEmpty(Model.CustomCSSLink)) - { - - } - @if (!string.IsNullOrEmpty(Model.EmbeddedCSS)) - { - @Safe.Raw($"") - } + + - + @if (!Model.Enabled) diff --git a/BTCPayServer/Views/Shared/LayoutHead.cshtml b/BTCPayServer/Views/Shared/LayoutHead.cshtml index 2a7764d79..f30cdd04e 100644 --- a/BTCPayServer/Views/Shared/LayoutHead.cshtml +++ b/BTCPayServer/Views/Shared/LayoutHead.cshtml @@ -1,7 +1,6 @@ @inject BTCPayServer.Services.PoliciesSettings PoliciesSettings - @if (PoliciesSettings.DiscourageSearchEngines) { @@ -16,6 +15,17 @@ +@if (ViewData.TryGetValue("StoreBranding", out var storeBranding)) +{ + +} +else +{ + + + + +} @* Non-JS *@