Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DLRType"/> class.
 /// </summary>
 /// <param name="file">The path to the file.</param>
 /// <param name="scope">The script scope.</param>
 /// <param name="handler">The handler plugin.</param>
 public DLRType(string file, ScriptScope scope, ScriptingPlugin handler)
 {
     File    = file;
     Scope   = scope;
     Handler = handler;
     Name    = Path.GetFileName(file).Replace(".Plugin.py", string.Empty);
     Type    = Scope.GetVariable <Type>(Name);
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DLRType"/> class.
 /// </summary>
 /// <param name="file">The path to the file.</param>
 /// <param name="scope">The script scope.</param>
 /// <param name="handler">The handler plugin.</param>
 public DLRType(string file, ScriptScope scope, ScriptingPlugin handler)
 {
     File    = file;
     Scope   = scope;
     Handler = handler;
     Name    = Path.GetFileName(file).Replace(".Plugin.py", string.Empty);
     Type    = Scope.GetVariable<Type>(Name);
 }
Пример #3
0
        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);
        }
Пример #4
0
 public CommandEvalStart(IPlugin plugin)
 {
     _scriptPlugin = (ScriptingPlugin)plugin;
 }
Пример #5
0
 public CommandSReload(IPlugin plugin)
 {
     _scriptingPlugin = (ScriptingPlugin)plugin;
 }
Пример #6
0
        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);
        }