Example #1
0
        private async Task <Site> Load(string sitePath, string outputPath, IEnumerable <string> renderedExtensions)
        {
            Site site;

            SiteConfig config;

            using (var capture = Statistics.Current.Start(StatisticTiming.LoadedConfiguration))
            {
                var command = new LoadSiteConfigCommand();
                command.ConfigPath = Path.Combine(sitePath, "site.config");
                command.OutputPath = outputPath;
                config             = await command.ExecuteAsync();
            }

            using (var capture = Statistics.Current.Start(StatisticTiming.LoadedSite))
            {
                // Load documents.
                IEnumerable <DocumentFile> documents;
                {
                    var load = new LoadDocumentsCommand();
                    load.Author             = config.Author;
                    load.OutputRootPath     = config.OutputPath;
                    load.RenderedExtensions = renderedExtensions;
                    load.DocumentsPath      = config.DocumentsPath;
                    load.RootUrl            = config.RootUrl;
                    load.ApplicationUrl     = config.Url;
                    documents = await load.ExecuteAsync();
                }

                // Load files.
                IEnumerable <StaticFile> files;
                {
                    var load = new LoadFilesCommand();
                    load.OutputPath = config.OutputPath;
                    load.FilesPath  = config.FilesPath;
                    load.RootUrl    = config.RootUrl;
                    load.Url        = config.Url;
                    files           = load.Execute();
                }

                // Load layouts.
                IEnumerable <LayoutFile> layouts;
                {
                    var load = new LoadLayoutsCommand();
                    load.LayoutsPath = config.LayoutsPath;
                    layouts          = await load.ExecuteAsync();
                }

                site = new Site(config, documents, files, layouts);
            }

            Statistics.Current.SiteFiles = site.Documents.Count + site.Files.Count + site.Layouts.Count;

            return(site);
        }
Example #2
0
        public void CanLoadLayouts()
        {
            var path = Path.GetFullPath(@"data\layouts\");

            var command = new LoadLayoutsCommand();

            command.LayoutsPath = path;
            var layouts = command.ExecuteAsync().Result;

            Assert.NotEmpty(command.Layouts);
            Assert.NotEmpty(layouts);
        }