From e266fbf289d5d7d7c488d809dd3c66395d24cbac Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 2 Sep 2025 11:51:01 +0200 Subject: [PATCH] core plugin, both signalR and service override works, theme added --- .../Infrastructure/PluginNopStartup.cs | 27 +++---- .../Areas/Admin/Views/_ViewImports.cshtml | 10 +++ .../Infrastructure/PluginNopStartup.cs | 60 +++++++++++++++ .../Infrastructure/RouteProvider.cs | 24 ++++++ .../Infrastructure/ViewLocationExpander.cs | 38 ++++++++++ Nop.Plugin.Misc.MangoCore/MangoCorePlugin.cs | 60 +++++++++++++++ .../Nop.Plugin.Misc.MangoCore.csproj | 70 ++++++++++++++++++ .../Views/_ViewImports.cshtml | 11 +++ Nop.Plugin.Misc.MangoCore/logo.jpg | Bin 0 -> 3118 bytes Nop.Plugin.Misc.MangoCore/plugin.json | 13 ++++ 10 files changed, 298 insertions(+), 15 deletions(-) create mode 100644 Nop.Plugin.Misc.MangoCore/Areas/Admin/Views/_ViewImports.cshtml create mode 100644 Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs create mode 100644 Nop.Plugin.Misc.MangoCore/Infrastructure/RouteProvider.cs create mode 100644 Nop.Plugin.Misc.MangoCore/Infrastructure/ViewLocationExpander.cs create mode 100644 Nop.Plugin.Misc.MangoCore/MangoCorePlugin.cs create mode 100644 Nop.Plugin.Misc.MangoCore/Nop.Plugin.Misc.MangoCore.csproj create mode 100644 Nop.Plugin.Misc.MangoCore/Views/_ViewImports.cshtml create mode 100644 Nop.Plugin.Misc.MangoCore/logo.jpg create mode 100644 Nop.Plugin.Misc.MangoCore/plugin.json diff --git a/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs index 13d60df..8867987 100644 --- a/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs +++ b/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs @@ -24,15 +24,15 @@ public class PluginNopStartup : INopStartup options.ViewLocationExpanders.Add(new ViewLocationExpander()); }); - services.AddCors(feature => - feature.AddPolicy( - "AllowBlazorClient", - apiPolicy => apiPolicy - .WithOrigins("https://localhost:7144") - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials() - )); + //services.AddCors(feature => + // feature.AddPolicy( + // "AllowBlazorClient", + // apiPolicy => apiPolicy + // .WithOrigins("https://localhost:7144") + // .AllowAnyHeader() + // .AllowAnyMethod() + // .AllowCredentials() + // )); services.AddSignalR(); @@ -55,23 +55,20 @@ public class PluginNopStartup : INopStartup public void Configure(IApplicationBuilder application) { - - application.UseWhen(context => context.Request.Path.StartsWithSegments("/fbhub"), app => { - app.UseCors("AllowBlazorClient"); - app.UseRouting(); + //app.UseCors("AllowBlazorClient"); + //app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapHub("/fbhub"); }); }); - } /// /// Gets order of this startup configuration implementation /// - public int Order => 100; + public int Order => 4000; } \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/Areas/Admin/Views/_ViewImports.cshtml b/Nop.Plugin.Misc.MangoCore/Areas/Admin/Views/_ViewImports.cshtml new file mode 100644 index 0000000..270744e --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/Areas/Admin/Views/_ViewImports.cshtml @@ -0,0 +1,10 @@ +@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Nop.Web.Framework + +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@using Nop.Web.Framework.UI +@using Nop.Web.Framework.Extensions +@using System.Text.Encodings.Web +@using Nop.Services.Events +@using Nop.Web.Framework.Events \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs new file mode 100644 index 0000000..2a431ac --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/Infrastructure/PluginNopStartup.cs @@ -0,0 +1,60 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Mvc.Razor; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Nop.Core.Infrastructure; + +namespace Nop.Plugin.Misc.MangoCore.Infrastructure; + +public class PluginNopStartup : INopStartup +{ + /// + /// Add and configure any of the middleware + /// + /// Collection of service descriptors + /// Configuration of the application + public void ConfigureServices(IServiceCollection services, IConfiguration configuration) + { + services.Configure(options => + { + options.ViewLocationExpanders.Add(new ViewLocationExpander()); + }); + + services.AddCors(feature => + feature.AddPolicy( + "AllowBlazorClient", + apiPolicy => apiPolicy + .WithOrigins("https://localhost:7144") + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials() + )); + + //register services and interfaces + //services.AddScoped(); + } + + /// + /// Configure the using of added middleware + /// + /// Builder for configuring an application's request pipeline + public void Configure(IApplicationBuilder application) + { + + application.UseWhen(context => context.Request.Path.StartsWithSegments("/fbhub"), app => + { + app.UseCors("AllowBlazorClient"); + app.UseRouting(); + //app.UseEndpoints(endpoints => + //{ + // endpoints.MapHub("/fbhub"); + //}); + }); + + } + + /// + /// Gets order of this startup configuration implementation + /// + public int Order => 100; +} \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/Infrastructure/RouteProvider.cs b/Nop.Plugin.Misc.MangoCore/Infrastructure/RouteProvider.cs new file mode 100644 index 0000000..4ed34bd --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/Infrastructure/RouteProvider.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Routing; +using Nop.Web.Framework.Mvc.Routing; + +namespace Nop.Plugin.Misc.MangoCore.Infrastructure; + +/// +/// Represents plugin route provider +/// +public class RouteProvider : IRouteProvider +{ + /// + /// Register routes + /// + /// Route builder + public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder) + { + + } + + /// + /// Gets a priority of route provider + /// + public int Priority => 0; +} \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/Infrastructure/ViewLocationExpander.cs b/Nop.Plugin.Misc.MangoCore/Infrastructure/ViewLocationExpander.cs new file mode 100644 index 0000000..f492d40 --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/Infrastructure/ViewLocationExpander.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Mvc.Razor; + +namespace Nop.Plugin.Misc.MangoCore.Infrastructure; + +public class ViewLocationExpander : IViewLocationExpander +{ + /// + /// Invoked by a to determine the values that would be consumed by this instance + /// of . The calculated values are used to determine if the view location + /// has changed since the last time it was located. + /// + /// The for the current view location + /// expansion operation. + public void PopulateValues(ViewLocationExpanderContext context) + { + } + + /// + /// Invoked by a to determine potential locations for a view. + /// + /// The for the current view location + /// expansion operation. + /// The sequence of view locations to expand. + /// A list of expanded view locations. + public IEnumerable ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable viewLocations) + { + if (context.AreaName == "Admin") + { + viewLocations = new[] { $"/Plugins/Nop.Plugin.Misc.MangoCore/Areas/Admin/Views/{context.ControllerName}/{context.ViewName}.cshtml" }.Concat(viewLocations); + } + else + { + viewLocations = new[] { $"/Plugins/Nop.Plugin.Misc.MangoCore/Views/{context.ControllerName}/{context.ViewName}.cshtml" }.Concat(viewLocations); + } + + return viewLocations; + } +} \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/MangoCorePlugin.cs b/Nop.Plugin.Misc.MangoCore/MangoCorePlugin.cs new file mode 100644 index 0000000..9a65489 --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/MangoCorePlugin.cs @@ -0,0 +1,60 @@ +using DocumentFormat.OpenXml.Packaging; +using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.Routing; +using Nop.Services.Cms; +using Nop.Services.Configuration; +using Nop.Services.Localization; +using Nop.Services.Plugins; +using Nop.Services.Security; +using Nop.Web.Framework.Infrastructure; +using Nop.Web.Framework.Menu; + +namespace Nop.Plugin.Misc.MangoCore; + +/// +/// Rename this file and change to the correct type +/// +public class MangoCorePlugin : BasePlugin +{ + protected readonly IActionContextAccessor _actionContextAccessor; + private readonly ISettingService _settingService; + //private readonly IWebHelper _webHelper; + protected readonly IPermissionService _permissionService; + protected readonly ILocalizationService _localizationService; + protected readonly IUrlHelperFactory _urlHelperFactory; + private readonly IAdminMenu _adminMenu; + + //handle AdminMenuCreatedEvent + + + public MangoCorePlugin(IActionContextAccessor actionContextAccessor, + ISettingService settingService, + //IWebHelper webHelper, + ILocalizationService localizationService, + IPermissionService permissionService, + IUrlHelperFactory urlHelperFactory, + IAdminMenu adminMenu) + { + _actionContextAccessor = actionContextAccessor; + _settingService = settingService; + //_webHelper = webHelper; + _localizationService = localizationService; + _urlHelperFactory = urlHelperFactory; + _adminMenu = adminMenu; + _permissionService = permissionService; + } + + // --- INSTALL --- + public override async Task InstallAsync() + { + + await base.InstallAsync(); + } + + // --- UNINSTALL --- + public override async Task UninstallAsync() + { + await base.UninstallAsync(); + } + +} \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/Nop.Plugin.Misc.MangoCore.csproj b/Nop.Plugin.Misc.MangoCore/Nop.Plugin.Misc.MangoCore.csproj new file mode 100644 index 0000000..ee8668d --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/Nop.Plugin.Misc.MangoCore.csproj @@ -0,0 +1,70 @@ + + + + net9.0 + $(SolutionDir)\Presentation\Nop.Web\Plugins\Nop.Plugin.Misc.MangoCore + $(OutputPath) + + false + enable + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Nop.Plugin.Misc.MangoCore/Views/_ViewImports.cshtml b/Nop.Plugin.Misc.MangoCore/Views/_ViewImports.cshtml new file mode 100644 index 0000000..253a8a0 --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/Views/_ViewImports.cshtml @@ -0,0 +1,11 @@ +@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Nop.Web.Framework + +@using Microsoft.AspNetCore.Mvc.ViewFeatures +@using Nop.Web.Framework.UI +@using Nop.Web.Framework.Extensions +@using System.Text.Encodings.Web +@using Nop.Services.Events +@using Nop.Web.Framework.Events +@using Nop.Web.Framework.Infrastructure \ No newline at end of file diff --git a/Nop.Plugin.Misc.MangoCore/logo.jpg b/Nop.Plugin.Misc.MangoCore/logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..cae3ce3f17ad9ee8604dab7af6726378985e81ae GIT binary patch literal 3118 zcma)$c|6qX+sD5%!;BeXMvXOPA5o4usL%;nXJ}#;WGk}ga2i`#>Nw#vQWRs~mtm~O zIfhOmhJ$EQjBP}=Aw;C?n#Z&Kp6Acs`+nW8*L8oc>vP>7!Kh#gK;kWNmH-G00A7a& z5PSkq=3zH(-T^>>5b&QOAXo*&O}&CWy#cSbLj@!l2jT$GzYqBTfc%U9v4cUN!|vhz zSL5F;1Z@CH1ds>xAs`e0Mu8wGkf0MN0|3b3>cg1-3rqx#5I$5uLXiJ2LxqH4A^;cy zLIQv=7$O9P3Q7F8UMei;VRdmhu z)in(9hhKxh!eF68VE<(Yfl&}4KuJ;jU?#jc)xr1A(VSTo#(k;8 z%1DxAbfnG1nI+010-!EhUI18!SnXwPCGg6`L59&Ge1dwe{EusQOnD-gZof+kxv*|9%8&g@AHLgD?TQ#(sjq+ zmQ~6}&W(Od@#-8S`XJe>A~HmERNDCm1JowA9STL#z=akyDCc|?2H_vxJoop=sPt_k zpAo`Xtcp3Lv`V||ehMcl&6fUJq@5oxDgef%R=2rCkc67|RYE#RLF77_pXwFThv2{F zGRji>CdX%`XQtJQf7i$S8h828{^Qd;q)6ujjf&y>N166S#KB^TVNqe_=~It>DLv@g z9)VXi*&96`YhtnOC1ty7D6QohCyCYh?@CH>Nv5tjVf@f7d|%`0xjx*oj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