public SiteObject(ILoggerFactory loggerFactory = null) { var sharedFolder = Path.Combine(Path.GetDirectoryName(typeof(SiteObject).GetTypeInfo().Assembly.Location), SharedFolderName); _contentFileSystems = new List <IFileSystem>(); var sharedPhysicalFileSystem = new PhysicalFileSystem(); // Make sure that SharedFileSystem is a read-only filesystem SharedFileSystem = new ReadOnlyFileSystem(new SubFileSystem(sharedPhysicalFileSystem, sharedPhysicalFileSystem.ConvertPathFromInternal(sharedFolder))); SharedMetaFileSystem = SharedFileSystem.GetOrCreateSubFileSystem(LunetFolder); _fileSystem = new AggregateFileSystem(SharedFileSystem); MetaFileSystem = new SubFileSystem(_fileSystem, LunetFolder); ConfigFile = new FileEntry(_fileSystem, UPath.Root / DefaultConfigFileName); StaticFiles = new PageCollection(); Pages = new PageCollection(); DynamicPages = new PageCollection(); // Create the logger LoggerFactory = loggerFactory ?? Microsoft.Extensions.Logging.LoggerFactory.Create(builder => { builder.AddProvider(new LoggerProviderIntercept(this)) .AddFilter(LogFilter) .AddConsole(); }); Log = LoggerFactory.CreateLogger("lunet"); ContentTypes = new ContentTypeManager(); DefaultPageExtension = DefaultPageExtensionValue; Html = new HtmlObject(this); SetValue(SiteVariables.Html, Html, true); CommandLine = new LunetCommandLine(this); Statistics = new SiteStatistics(); Scripts = new ScriptingPlugin(this); Content = new ContentPlugin(this); Plugins = new OrderedList <ISitePlugin>(); _pluginBuilders = new ContainerBuilder(); _pluginBuilders.RegisterInstance(LoggerFactory).As <ILoggerFactory>(); _pluginBuilders.RegisterInstance(this); }
public SiteObject(ILoggerFactory loggerFactory = null) { ReadmeAsIndex = true; ErrorRedirect = "/404.html"; var sharedFolder = Path.Combine(AppContext.BaseDirectory, SharedFolderName); _contentFileSystems = new List <IFileSystem>(); var sharedPhysicalFileSystem = new PhysicalFileSystem(); // Make sure that SharedFileSystem is a read-only filesystem SharedFileSystem = new ReadOnlyFileSystem(new SubFileSystem(sharedPhysicalFileSystem, sharedPhysicalFileSystem.ConvertPathFromInternal(sharedFolder))); SharedMetaFileSystem = SharedFileSystem.GetOrCreateSubFileSystem(LunetFolder); _fileSystem = new AggregateFileSystem(SharedFileSystem); // MetaFileSystem provides an aggregate view of the shared meta file system + the user meta file system _metaFileSystem = new AggregateFileSystem(SharedMetaFileSystem); MetaFileSystem = _metaFileSystem; ConfigFile = new FileEntry(_fileSystem, UPath.Root / DefaultConfigFileName); StaticFiles = new PageCollection(); Pages = new PageCollection(); DynamicPages = new PageCollection(); // Create the logger LoggerFactory = loggerFactory ?? Microsoft.Extensions.Logging.LoggerFactory.Create(builder => { // Similar to builder.AddSimpleConsole // But we are using our own console that stays on the same line if the message doesn't have new lines builder.AddConfiguration(); builder.AddProvider(new LoggerProviderIntercept(this)) .AddFilter(LogFilter) .AddConsoleFormatter <SimpleConsoleFormatter, SimpleConsoleFormatterOptions>(configure => { configure.SingleLine = true; }); builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <ILoggerProvider, ConsoleLoggerProvider>()); LoggerProviderOptions.RegisterProviderOptions <ConsoleLoggerOptions, ConsoleLoggerProvider>(builder.Services); }); Log = LoggerFactory.CreateLogger("lunet"); ContentTypes = new ContentTypeManager(); DefaultPageExtension = DefaultPageExtensionValue; Html = new HtmlPage(this); CommandLine = new LunetCommandLine(this); Statistics = new SiteStatistics(); Scripts = new ScriptingPlugin(this); Content = new ContentPlugin(this); Plugins = new OrderedList <ISitePlugin>(); Builtins = new BuiltinsObject(this); ForceExcludes = new GlobCollection() { $"**/{LunetFolderName}/{BuildFolderName}/**", $"/{DefaultConfigFileName}", }; Excludes = new GlobCollection() { "**/~*/**", "**/.*/**", "**/_*/**", }; Includes = new GlobCollection() { $"**/{LunetFolderName}/**", }; SetValue(SiteVariables.ForceExcludes, ForceExcludes, true); SetValue(SiteVariables.Excludes, Excludes, true); SetValue(SiteVariables.Includes, Includes, true); SetValue(SiteVariables.Pages, Pages, true); _pluginBuilders = new ContainerBuilder(); _pluginBuilders.RegisterInstance(LoggerFactory).As <ILoggerFactory>(); _pluginBuilders.RegisterInstance(this); }