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 0000000..cae3ce3 Binary files /dev/null and b/Nop.Plugin.Misc.MangoCore/logo.jpg differ diff --git a/Nop.Plugin.Misc.MangoCore/plugin.json b/Nop.Plugin.Misc.MangoCore/plugin.json new file mode 100644 index 0000000..0da3bb3 --- /dev/null +++ b/Nop.Plugin.Misc.MangoCore/plugin.json @@ -0,0 +1,13 @@ +{ + "Group": "Misc", + "FriendlyName": "MangoCorePlugin", + "SystemName": "Misc.MangoCorePlugin", + "Version": "1.00", + "SupportedVersions": [ + "4.80" + ], + "Author": "Adam Gelencser", + "DisplayOrder": 1, + "FileName": "Nop.Plugin.Misc.MangoCore.dll", + "Description": "" +} \ No newline at end of file