diff --git a/Application/BuildScripts/DownloadTranslations.ps1 b/Application/BuildScripts/DownloadTranslations.ps1 new file mode 100644 index 000000000..0b67d2592 --- /dev/null +++ b/Application/BuildScripts/DownloadTranslations.ps1 @@ -0,0 +1,12 @@ +param ( + [string]$OutputDir = $(throw "-OutputDir is required.") +) + +$localizations = @("en-US", "ru-RU", "es-EC", "pt-BR", "de-DE") +foreach($localization in $localizations) +{ + $url = "http://api.raidmax.org:5000/localization/{0}" -f $localization + $filePath = "{0}Localization\IW4MAdmin.{1}.json" -f $OutputDir, $localization + $response = Invoke-WebRequest $url + Out-File -FilePath $filePath -InputObject $response.Content -Encoding utf8 +} \ No newline at end of file diff --git a/Application/BuildScripts/PreBuild.bat b/Application/BuildScripts/PreBuild.bat index 9c0d2d322..876350c23 100644 --- a/Application/BuildScripts/PreBuild.bat +++ b/Application/BuildScripts/PreBuild.bat @@ -1,3 +1,6 @@ set SolutionDir=%1 set ProjectDir=%2 -set TargetDir=%3 \ No newline at end of file +set TargetDir=%3 + +echo D | xcopy "%SolutionDir%Plugins\ScriptPlugins\*.js" "%TargetDir%Plugins" /y +powershell -File "%ProjectDir%BuildScripts\DownloadTranslations.ps1" %TargetDir% \ No newline at end of file diff --git a/Application/Main.cs b/Application/Main.cs index cce9f2f0e..bb91e45c9 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -233,7 +233,7 @@ namespace IW4MAdmin.Application serviceCollection.AddSingleton(_serviceProvider => serviceCollection) .AddSingleton(new BaseConfigurationHandler("IW4MAdminSettings") as IConfigurationHandler) .AddSingleton(new BaseConfigurationHandler("CommandConfiguration") as IConfigurationHandler) - .AddSingleton(_serviceProvider => _serviceProvider.GetRequiredService>().Configuration()) + .AddSingleton(_serviceProvider => _serviceProvider.GetRequiredService>().Configuration() ?? new ApplicationConfiguration()) .AddSingleton(_serviceProvider => _serviceProvider.GetRequiredService>().Configuration() ?? new CommandConfiguration()) .AddSingleton(_serviceProvider => defaultLogger) .AddSingleton() diff --git a/SharedLibraryCore/Database/DatabaseContext.cs b/SharedLibraryCore/Database/DatabaseContext.cs index 2a82d0f7a..948f5eb14 100644 --- a/SharedLibraryCore/Database/DatabaseContext.cs +++ b/SharedLibraryCore/Database/DatabaseContext.cs @@ -26,7 +26,6 @@ namespace SharedLibraryCore.Database static string _ConnectionString; static string _provider; - private static readonly string _migrationPluginDirectory = @"X:\IW4MAdmin\BUILD\Plugins"; private static readonly ILoggerFactory _loggerFactory = LoggerFactory.Create(builder => { builder.AddConsole() @@ -72,7 +71,7 @@ namespace SharedLibraryCore.Database protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { //optionsBuilder.UseLoggerFactory(_loggerFactory) - // .EnableSensitiveDataLogging(); + // .EnableSensitiveDataLogging(); if (string.IsNullOrEmpty(_ConnectionString)) { @@ -198,11 +197,14 @@ namespace SharedLibraryCore.Database // adapted from // https://aleemkhan.wordpress.com/2013/02/28/dynamically-adding-dbset-properties-in-dbcontext-for-entity-framework-code-first/ -#if DEBUG - string pluginDir = _migrationPluginDirectory; -#else + string pluginDir = Path.Join(Utilities.OperatingDirectory, "Plugins"); -#endif + + if (Utilities.IsDevelopment) + { + pluginDir = Path.Join(Utilities.OperatingDirectory, "..", "..", "..", "..", "BUILD", "Plugins"); + } + IEnumerable directoryFiles = Directory.GetFiles(pluginDir).Where(f => f.EndsWith(".dll")); foreach (string dllPath in directoryFiles) diff --git a/WebfrontCore/Controllers/DynamicFileController.cs b/WebfrontCore/Controllers/DynamicFileController.cs index 73aaaf717..9b5bbb00a 100644 --- a/WebfrontCore/Controllers/DynamicFileController.cs +++ b/WebfrontCore/Controllers/DynamicFileController.cs @@ -24,11 +24,14 @@ namespace WebfrontCore.Controllers { if (fileName.EndsWith(".css")) { -#if DEBUG - string cssData = await System.IO.File.ReadAllTextAsync($"X:\\IW4MAdmin\\WebfrontCore\\wwwroot\\css\\{fileName}"); - cssData = await Manager.MiddlewareActionHandler.Execute(cssData, "custom_css_accent"); - return Content(cssData, "text/css"); -#endif + if (Utilities.IsDevelopment) + { + var path = Path.Join(Utilities.OperatingDirectory, "..", "..", "..", "..", "WebfrontCore", "wwwroot", "css", fileName); + string cssData = await System.IO.File.ReadAllTextAsync(path); + cssData = await Manager.MiddlewareActionHandler.Execute(cssData, "custom_css_accent"); + return Content(cssData, "text/css"); + } + if (!_fileCache.ContainsKey(fileName)) {