made RenderMode configurable

This commit is contained in:
Shaun Walker
2021-05-30 15:37:23 -04:00
parent afcc5e2170
commit 276817c89d
8 changed files with 67 additions and 18 deletions

View File

@ -20,10 +20,23 @@ namespace Oqtane.Infrastructure
return _config.GetSection(key);
}
public string GetSetting(string sectionKey, string settingKey, string defaultValue)
public T GetSetting<T>(string sectionKey, T defaultValue)
{
var value = _config.GetSection(sectionKey).GetValue(settingKey, defaultValue);
if (string.IsNullOrEmpty(value)) value = defaultValue;
return GetSetting(sectionKey, "", defaultValue);
}
public T GetSetting<T>(string sectionKey, string settingKey, T defaultValue)
{
T value;
if (!string.IsNullOrEmpty(settingKey))
{
value = _config.GetSection(sectionKey).GetValue(settingKey, defaultValue);
}
else
{
value = _config.GetValue(sectionKey, defaultValue);
}
if (value == null) value = defaultValue;
return value;
}

View File

@ -55,7 +55,7 @@ namespace Oqtane.Infrastructure
{
File.Delete(destinationFile);
}
if (Path.GetExtension(destinationFile) == ".nupkg.bak")
if (destinationFile.ToLower().EndsWith(".nupkg.bak"))
{
// leave a copy in the current folder as it is distributed with the core framework
File.Copy(file, destinationFile);

View File

@ -5,7 +5,8 @@ namespace Oqtane.Infrastructure
public interface IConfigManager
{
public IConfigurationSection GetSection(string sectionKey);
public string GetSetting(string sectionKey, string settingKey, string defaultValue);
public T GetSetting<T>(string settingKey, T defaultValue);
public T GetSetting<T>(string sectionKey, string settingKey, T defaultValue);
void AddOrUpdateSetting<T>(string key, T value, bool reload);
void AddOrUpdateSetting<T>(string file, string key, T value, bool reload);
void RemoveSetting(string key, bool reload);

View File

@ -41,6 +41,9 @@ namespace Oqtane.Infrastructure
case "2.0.2":
Upgrade_2_0_2(tenant, scope);
break;
case "2.1.0":
Upgrade_2_1_0(tenant, scope);
break;
}
}
}
@ -113,6 +116,18 @@ namespace Oqtane.Infrastructure
}
}
private void Upgrade_2_1_0(Tenant tenant, IServiceScope scope)
{
if (tenant.Name == TenantNames.Master)
{
_configManager.RemoveSetting("Localization:SupportedCultures", true);
if (_configManager.GetSetting("RenderMode", "") == "")
{
_configManager.AddOrUpdateSetting("RenderMode", "ServerPrerendered", true);
}
}
}
private void CreateSitePages(IServiceScope scope, List<PageTemplate> pageTemplates)
{
if (pageTemplates.Count != 0)