From f869c06aeea02faa5230e6b0d8d5dc5e892fb3b5 Mon Sep 17 00:00:00 2001 From: lepipele Date: Fri, 13 Apr 2018 15:42:34 -0500 Subject: [PATCH 01/12] Adding Bootstrap theme uri field to settings --- BTCPayServer/Services/PoliciesSettings.cs | 3 +++ BTCPayServer/Views/Server/Policies.cshtml | 9 +++++++++ BTCPayServer/Views/Shared/_Layout.cshtml | 2 ++ 3 files changed, 14 insertions(+) diff --git a/BTCPayServer/Services/PoliciesSettings.cs b/BTCPayServer/Services/PoliciesSettings.cs index 431e902eb..4a6b5a5ea 100644 --- a/BTCPayServer/Services/PoliciesSettings.cs +++ b/BTCPayServer/Services/PoliciesSettings.cs @@ -15,5 +15,8 @@ namespace BTCPayServer.Services [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public bool LockSubscription { get; set; } + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] + public string CustomBootstrapThemeCssUri { get; set; } } } diff --git a/BTCPayServer/Views/Server/Policies.cshtml b/BTCPayServer/Views/Server/Policies.cshtml index f8c99b5d5..b2d3413db 100644 --- a/BTCPayServer/Views/Server/Policies.cshtml +++ b/BTCPayServer/Views/Server/Policies.cshtml @@ -15,6 +15,15 @@
+
diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index fef623c19..eae6d48cc 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -19,6 +19,8 @@ @* CSS *@ + + @* JS *@ From 81afe397be998d9ce96698b28cdbdb3fcccf5836 Mon Sep 17 00:00:00 2001 From: lepipele Date: Fri, 13 Apr 2018 16:15:03 -0500 Subject: [PATCH 02/12] CssThemeManager that injects Bootstrap css uri from settings --- BTCPayServer/Controllers/ServerController.cs | 10 ++++- .../HostedServices/CssThemeManager.cs | 44 +++++++++++++++++++ BTCPayServer/Hosting/BTCPayServerServices.cs | 1 + BTCPayServer/Views/Shared/_Layout.cshtml | 42 +++++++++--------- BTCPayServer/bundleconfig.json | 1 - 5 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 BTCPayServer/HostedServices/CssThemeManager.cs diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index 649e8fd2c..ab7860078 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -1,4 +1,5 @@ -using BTCPayServer.Models; +using BTCPayServer.HostedServices; +using BTCPayServer.Models; using BTCPayServer.Models.ServerViewModels; using BTCPayServer.Services; using BTCPayServer.Services.Mails; @@ -21,11 +22,13 @@ namespace BTCPayServer.Controllers { private UserManager _UserManager; SettingsRepository _SettingsRepository; + private CssThemeManager _CssThemeManager; - public ServerController(UserManager userManager, SettingsRepository settingsRepository) + public ServerController(UserManager userManager, SettingsRepository settingsRepository, CssThemeManager cssThemeManager) { _UserManager = userManager; _SettingsRepository = settingsRepository; + _CssThemeManager = cssThemeManager; } [Route("server/users")] @@ -138,6 +141,9 @@ namespace BTCPayServer.Controllers public async Task Policies(PoliciesSettings settings) { await _SettingsRepository.UpdateSetting(settings); + // TODO: remove controller/class-level property and have only reference to + // CssThemeManager here in this method + _CssThemeManager.Update(settings.CustomBootstrapThemeCssUri); TempData["StatusMessage"] = "Policies upadated successfully"; return View(settings); } diff --git a/BTCPayServer/HostedServices/CssThemeManager.cs b/BTCPayServer/HostedServices/CssThemeManager.cs new file mode 100644 index 000000000..570d5aea3 --- /dev/null +++ b/BTCPayServer/HostedServices/CssThemeManager.cs @@ -0,0 +1,44 @@ +using System; +using Microsoft.Extensions.Logging; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using BTCPayServer.Logging; +using Microsoft.Extensions.Hosting; +using NBXplorer; +using NBXplorer.Models; +using System.Collections.Concurrent; +using BTCPayServer.Events; +using BTCPayServer.Services; + +namespace BTCPayServer.HostedServices +{ + public class CssThemeManager + { + public CssThemeManager(SettingsRepository settingsRepository) + { + Update(settingsRepository); + } + + private string _bootstrapThemeUri; + public string BootstrapThemeUri + { + get { return _bootstrapThemeUri; } + } + + private async void Update(SettingsRepository settingsRepository) + { + var data = (await settingsRepository.GetSettingAsync()) ?? new PoliciesSettings(); + Update(data.CustomBootstrapThemeCssUri); + } + + public void Update(string newUri) + { + if (String.IsNullOrWhiteSpace(newUri)) + _bootstrapThemeUri = "/vendor/bootstrap4/css/bootstrap.css"; + else + _bootstrapThemeUri = newUri; + } + } +} diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index 8441f9562..633a2935e 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -136,6 +136,7 @@ namespace BTCPayServer.Hosting services.TryAddSingleton(); services.TryAddSingleton(); + services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index eae6d48cc..8e3daba74 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -3,6 +3,7 @@ @inject RoleManager RoleManager @inject BTCPayServer.Services.BTCPayServerEnvironment env @inject BTCPayServer.HostedServices.NBXplorerDashboard dashboard +@inject BTCPayServer.HostedServices.CssThemeManager themeManager @addTagHelper *, Meziantou.AspNetCore.BundleTagHelpers @@ -17,10 +18,9 @@ BTCPay Server @* CSS *@ + - - @* JS *@ @@ -50,25 +50,25 @@ diff --git a/BTCPayServer/bundleconfig.json b/BTCPayServer/bundleconfig.json index ed1df25a9..8e45601a3 100644 --- a/BTCPayServer/bundleconfig.json +++ b/BTCPayServer/bundleconfig.json @@ -2,7 +2,6 @@ { "outputFileName": "wwwroot/bundles/main-bundle.min.css", "inputFiles": [ - "wwwroot/vendor/bootstrap4/css/bootstrap.css", "wwwroot/vendor/magnific-popup/magnific-popup.css", "wwwroot/vendor/font-awesome/css/font-awesome.css", "wwwroot/main/**/*.css", From b099f93c78a6b57820929e862c393a1666014d97 Mon Sep 17 00:00:00 2001 From: lepipele Date: Fri, 13 Apr 2018 16:15:21 -0500 Subject: [PATCH 03/12] Adjusting Policies form to look better on different screen sizes --- BTCPayServer/Views/Server/Policies.cshtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Views/Server/Policies.cshtml b/BTCPayServer/Views/Server/Policies.cshtml index b2d3413db..516435718 100644 --- a/BTCPayServer/Views/Server/Policies.cshtml +++ b/BTCPayServer/Views/Server/Policies.cshtml @@ -8,12 +8,12 @@

@ViewData["Title"]

@Html.Partial("_StatusMessage", TempData["StatusMessage"])
-
+
-
+
From 2f515e1cc0506384930f715644cd5a4a9195ed2a Mon Sep 17 00:00:00 2001 From: lepipele Date: Tue, 17 Apr 2018 15:20:27 -0500 Subject: [PATCH 04/12] Removing unused classes --- BTCPayServer/wwwroot/main/css/site.css | 32 +------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/BTCPayServer/wwwroot/main/css/site.css b/BTCPayServer/wwwroot/main/css/site.css index 8663af490..4f4b3e3a1 100644 --- a/BTCPayServer/wwwroot/main/css/site.css +++ b/BTCPayServer/wwwroot/main/css/site.css @@ -1,38 +1,8 @@ -/* Wrapping element */ -/* Set some basic padding to keep content from hitting the edges */ -.body-content { - padding-left: 15px; - padding-right: 15px; -} - -/* Carousel */ -.carousel-caption p { - font-size: 20px; - line-height: 1.4; -} - -/* Make .svg files in the carousel display properly in older browsers */ -.carousel-inner .item img[src$=".svg"] { - width: 100%; -} - -/* Hide/rearrange for smaller screens */ -@media screen and (max-width: 767px) { - /* Hide captions */ - .carousel-caption { - display: none; - } -} - -html { +html { position: relative; min-height: 100%; } -body { - margin: 0 0 18px !important; -} - footer { position: absolute; left: 0; From fd087bbeb812f631a35a6d9f5f538ce18c02fa45 Mon Sep 17 00:00:00 2001 From: lepipele Date: Tue, 17 Apr 2018 15:33:29 -0500 Subject: [PATCH 05/12] Streamlining style for footer --- BTCPayServer/Views/Shared/_Layout.cshtml | 4 ++-- BTCPayServer/wwwroot/main/css/site.css | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index 8e3daba74..7616f1ab5 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -77,8 +77,8 @@ @RenderBody() -