Merge pull request #56 from oqtane/master

sync
This commit is contained in:
Shaun Walker 2020-10-04 10:57:24 -04:00 committed by GitHub
commit ece8f3a57e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 27 deletions

View File

@ -79,16 +79,24 @@ namespace Oqtane.Controllers
// Get the satellite assemblies // Get the satellite assemblies
foreach (var culture in _localizationManager.GetSupportedCultures()) foreach (var culture in _localizationManager.GetSupportedCultures())
{ {
var assembliesFolderPath = Path.Combine(binFolder, culture);
if (culture == Constants.DefaultCulture) if (culture == Constants.DefaultCulture)
{ {
continue; continue;
} }
foreach (var resourceFile in Directory.EnumerateFiles(Path.Combine(binFolder, culture))) if(Directory.Exists(assembliesFolderPath))
{
foreach (var resourceFile in Directory.EnumerateFiles(assembliesFolderPath))
{ {
list.Add(Path.Combine(culture, Path.GetFileNameWithoutExtension(resourceFile))); list.Add(Path.Combine(culture, Path.GetFileNameWithoutExtension(resourceFile)));
} }
} }
else
{
Console.WriteLine($"The satellite assemblies folder named '{culture}' is not found.");
}
}
// get module and theme dependencies // get module and theme dependencies
foreach (var assembly in assemblies) foreach (var assembly in assemblies)

View File

@ -15,10 +15,10 @@ namespace Microsoft.Extensions.DependencyInjection
{ {
public static class OqtaneServiceCollectionExtensions public static class OqtaneServiceCollectionExtensions
{ {
public static IServiceCollection AddOqtane(this IServiceCollection services, Runtime runtime) public static IServiceCollection AddOqtane(this IServiceCollection services, Runtime runtime, string[] supportedCultures)
{ {
LoadAssemblies(); LoadAssemblies();
LoadSatelliteAssemblies(); LoadSatelliteAssemblies(supportedCultures);
services.AddOqtaneServices(runtime); services.AddOqtaneServices(runtime);
return services; return services;
@ -122,7 +122,7 @@ namespace Microsoft.Extensions.DependencyInjection
} }
} }
private static void LoadSatelliteAssemblies() private static void LoadSatelliteAssemblies(string[] supportedCultures)
{ {
var assemblies = AppDomain.CurrentDomain.GetAssemblies(); var assemblies = AppDomain.CurrentDomain.GetAssemblies();
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
@ -133,10 +133,7 @@ namespace Microsoft.Extensions.DependencyInjection
AssemblyLoadContext.Default.Resolving += ResolveDependencies; AssemblyLoadContext.Default.Resolving += ResolveDependencies;
using (var serviceScope = ServiceActivator.GetScope()) foreach (var culture in supportedCultures)
{
var localizationManager = serviceScope.ServiceProvider.GetService<ILocalizationManager>();
foreach (var culture in localizationManager.GetSupportedCultures())
{ {
if (culture == Constants.DefaultCulture) if (culture == Constants.DefaultCulture)
{ {
@ -144,6 +141,8 @@ namespace Microsoft.Extensions.DependencyInjection
} }
var assembliesFolder = new DirectoryInfo(Path.Combine(assemblyPath, culture)); var assembliesFolder = new DirectoryInfo(Path.Combine(assemblyPath, culture));
if (assembliesFolder.Exists)
{
foreach (var assemblyFile in assembliesFolder.EnumerateFiles(Constants.StalliteAssemblyExtension)) foreach (var assemblyFile in assembliesFolder.EnumerateFiles(Constants.StalliteAssemblyExtension))
{ {
AssemblyName assemblyName; AssemblyName assemblyName;
@ -168,6 +167,10 @@ namespace Microsoft.Extensions.DependencyInjection
} }
} }
} }
else
{
Console.WriteLine($"The satellite assemblies folder named '{culture}' is not found.");
}
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
@ -26,11 +27,14 @@ namespace Oqtane
{ {
public class Startup public class Startup
{ {
public IConfigurationRoot Configuration { get; } private static readonly string[] DefaultSupportedCultures = new[] { Constants.DefaultCulture };
private string _webRoot; private string _webRoot;
private Runtime _runtime; private Runtime _runtime;
private bool _useSwagger; private bool _useSwagger;
public IConfigurationRoot Configuration { get; }
public Startup(IWebHostEnvironment env) public Startup(IWebHostEnvironment env)
{ {
var builder = new ConfigurationBuilder() var builder = new ConfigurationBuilder()
@ -128,7 +132,10 @@ namespace Oqtane
.AddSignInManager() .AddSignInManager()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
services.Configure<LocalizationOptions>(Configuration.GetSection("Localization")); var localizationSection = Configuration.GetSection("Localization");
var localizationOptions = localizationSection.Get<LocalizationOptions>();
services.Configure<LocalizationOptions>(localizationSection);
services.Configure<IdentityOptions>(options => services.Configure<IdentityOptions>(options =>
{ {
@ -202,11 +209,11 @@ namespace Oqtane
services.AddTransient<ISqlRepository, SqlRepository>(); services.AddTransient<ISqlRepository, SqlRepository>();
services.AddTransient<IUpgradeManager, UpgradeManager>(); services.AddTransient<IUpgradeManager, UpgradeManager>();
// TODO: Check if there's a better way instead of building service provider
ServiceActivator.Configure(services.BuildServiceProvider());
// load the external assemblies into the app domain, install services // load the external assemblies into the app domain, install services
services.AddOqtane(_runtime); services.AddOqtane(_runtime,
localizationOptions.SupportedCultures.IsNullOrEmpty()
? DefaultSupportedCultures
: localizationOptions.SupportedCultures);
services.AddMvc() services.AddMvc()
.AddNewtonsoftJson() .AddNewtonsoftJson()

View File

@ -38,15 +38,10 @@ Please note that this project is owned by the .NET Foundation and is governed by
# Roadmap # Roadmap
This project is a work in progress and the schedule for implementing enhancements is dependent upon the availability of community members who are willing/able to assist. This project is a work in progress and the schedule for implementing enhancements is dependent upon the availability of community members who are willing/able to assist.
V.Next ( still in the process of being prioritized ) V.2.0.0 ( estimated release date Nov 10, 2020 )
- [ ] Admin UI markup optimization - [ ] Migrate to .NET 5
- [ ] DB Migrations for framework installation/upgrade
- [ ] Support for SQLite
- [ ] Static Localization ( ie. labels, help text, etc.. ) - [ ] Static Localization ( ie. labels, help text, etc.. )
- [ ] Migrate to Code-Behind Pattern ( *.razor.cs ) - [ ] Admin UI markup optimization
- [ ] Generic Repository Pattern
- [ ] JwT token authentication ( possibly using IdentityServer )
- [ ] Optional Encryption for Settings Values
V1.0.0 (MVP) - Released in conjunction with .NET Core 3.2 ( May 2020 ) V1.0.0 (MVP) - Released in conjunction with .NET Core 3.2 ( May 2020 )
- [x] Multi-Tenant ( Shared Database & Isolated Database ) - [x] Multi-Tenant ( Shared Database & Isolated Database )
@ -66,6 +61,13 @@ V1.0.0 (MVP) - Released in conjunction with .NET Core 3.2 ( May 2020 )
- [x] Auto-Upgrade Framework - [x] Auto-Upgrade Framework
- [x] Progressive Web Application Support - [x] Progressive Web Application Support
Future Consideration
- [ ] DB Migrations for framework installation/upgrade
- [ ] Support for SQLite
- [ ] Generic Repository Pattern
- [ ] JwT token authentication ( possibly using IdentityServer )
- [ ] Optional Encryption for Settings Values
# Background # Background
Oqtane was created by [Shaun Walker](https://www.linkedin.com/in/shaunbrucewalker/) and is inspired by the DotNetNuke web application framework. Initially created as a proof of concept, Oqtane is a native Blazor application written from the ground up using modern .NET Core technology. It is a modular application framework offering a fully dynamic page compositing model, multi-site support, designer friendly templates (skins), and extensibility via third party modules. Oqtane was created by [Shaun Walker](https://www.linkedin.com/in/shaunbrucewalker/) and is inspired by the DotNetNuke web application framework. Initially created as a proof of concept, Oqtane is a native Blazor application written from the ground up using modern .NET Core technology. It is a modular application framework offering a fully dynamic page compositing model, multi-site support, designer friendly templates (skins), and extensibility via third party modules.