Converted to IOptions over IOptionsSnapshot due to the latter only working in scoped services.

Further amends to return to booting application.
This commit is contained in:
Andy Butland
2020-08-23 23:36:48 +02:00
parent 2f22313ceb
commit 2cd91a5a54
108 changed files with 230 additions and 146 deletions

View File

@@ -11,9 +11,9 @@ namespace Umbraco.Core.Configuration.Models
private const string DefaultPreviewBadge =
@"<div id=""umbracoPreviewBadge"" class=""umbraco-preview-badge""><span class=""umbraco-preview-badge__header"">Preview mode</span><a href=""{0}/preview/end?redir={1}"" class=""umbraco-preview-badge__end""><svg viewBox=""0 0 100 100"" xmlns=""http://www.w3.org/2000/svg""><title>Click to end</title><path d=""M5273.1 2400.1v-2c0-2.8-5-4-9.7-4s-9.7 1.3-9.7 4v2a7 7 0 002 4.9l5 4.9c.3.3.4.6.4 1v6.4c0 .4.2.7.6.8l2.9.9c.5.1 1-.2 1-.8v-7.2c0-.4.2-.7.4-1l5.1-5a7 7 0 002-4.9zm-9.7-.1c-4.8 0-7.4-1.3-7.5-1.8.1-.5 2.7-1.8 7.5-1.8s7.3 1.3 7.5 1.8c-.2.5-2.7 1.8-7.5 1.8z""/><path d=""M5268.4 2410.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1h-4.3zM5272.7 2413.7h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1s-.4-1-1-1zM5272.7 2417h-4.3c-.6 0-1 .4-1 1s.4 1 1 1h4.3c.6 0 1-.4 1-1 0-.5-.4-1-1-1z""/><path d=""M78.2 13l-8.7 11.7a32.5 32.5 0 11-51.9 25.8c0-10.3 4.7-19.7 12.9-25.8L21.8 13a47 47 0 1056.4 0z""/><path d=""M42.7 2.5h14.6v49.4H42.7z""/></svg></a></div><style type=""text/css"">.umbraco-preview-badge {{position: absolute;top: 1em;right: 1em;display: inline-flex;background: #1b264f;color: #fff;padding: 1em;font-size: 12px;z-index: 99999999;justify-content: center;align-items: center;box-shadow: 0 10px 50px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .16);line-height: 1;}}.umbraco-preview-badge__header {{font-weight: bold;}}.umbraco-preview-badge__end {{width: 3em;padding: 1em;margin: -1em -1em -1em 2em;display: flex;flex-shrink: 0;align-items: center;align-self: stretch;}}.umbraco-preview-badge__end:hover,.umbraco-preview-badge__end:focus {{background: #f5c1bc;}}.umbraco-preview-badge__end svg {{fill: #fff;width:1em;}}</style>";
public ContentNotificationSettings Notifications { get; set; }
public ContentNotificationSettings Notifications { get; set; } = new ContentNotificationSettings();
public ContentImagingSettings Imaging { get; set; }
public ContentImagingSettings Imaging { get; set; } = new ContentImagingSettings();
public bool ResolveUrlsFromTextString { get; set; } = false;

View File

@@ -2,8 +2,8 @@
{
public class ImagingSettings
{
public ImagingCacheSettings Cache { get; set; }
public ImagingCacheSettings Cache { get; set; } = new ImagingCacheSettings();
public ImagingResizeSettings Resize { get; set; }
public ImagingResizeSettings Resize { get; set; } = new ImagingResizeSettings();
}
}

View File

@@ -0,0 +1,74 @@
using System.Collections.Generic;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core.Configuration.Models
{
public class RequestHandlerSettings
{
private const string Prefix = Constants.Configuration.ConfigPrefix + "RequestHandler:";
private static readonly CharItem[] DefaultCharCollection =
{
new CharItem { Char = " ", Replacement = "-" },
new CharItem { Char = "\"", Replacement = "" },
new CharItem { Char = "'", Replacement = "" },
new CharItem { Char = "%", Replacement = "" },
new CharItem { Char = ".", Replacement = "" },
new CharItem { Char = ";", Replacement = "" },
new CharItem { Char = "/", Replacement = "" },
new CharItem { Char = "\\", Replacement = "" },
new CharItem { Char = ":", Replacement = "" },
new CharItem { Char = "#", Replacement = "" },
new CharItem { Char = "+", Replacement = "plus" },
new CharItem { Char = "*", Replacement = "star" },
new CharItem { Char = "&", Replacement = "" },
new CharItem { Char = "?", Replacement = "" },
new CharItem { Char = "æ", Replacement = "ae" },
new CharItem { Char = "ä", Replacement = "ae" },
new CharItem { Char = "ø", Replacement = "oe" },
new CharItem { Char = "ö", Replacement = "oe" },
new CharItem { Char = "å", Replacement = "aa" },
new CharItem { Char = "ü", Replacement = "ue" },
new CharItem { Char = "ß", Replacement = "ss" },
new CharItem { Char = "|", Replacement = "-" },
new CharItem { Char = "<", Replacement = "" },
new CharItem { Char = ">", Replacement = "" }
};
public bool AddTrailingSlash { get; set; } = true;
public bool ConvertUrlsToAscii { get; set; } = true;
public bool TryConvertUrlsToAscii { get; set; } = false;
//We need to special handle ":", as this character is special in keys
public IEnumerable<IChar> CharCollection
{
get
{
// TODO: implement from configuration
//var collection = _configuration.GetSection(Prefix + "CharCollection").GetChildren()
// .Select(x => new CharItem()
// {
// Char = x.GetValue<string>("Char"),
// Replacement = x.GetValue<string>("Replacement"),
// }).ToArray();
//if (collection.Any() || _configuration.GetSection("Prefix").GetChildren().Any(x =>
// x.Key.Equals("CharCollection", StringComparison.OrdinalIgnoreCase)))
//{
// return collection;
//}
return DefaultCharCollection;
}
}
public class CharItem : IChar
{
public string Char { get; set; }
public string Replacement { get; set; }
}
}
}