public void CanOrderOrderedDocuments() { var path = Path.GetFullPath(@"data\ordered-documents\"); var command = new LoadDocumentsCommand(); command.Author = new Author(); command.DocumentsPath = path; command.OutputRootPath = Path.GetFullPath("output"); command.RenderedExtensions = new[] { "md" }; command.RootUrl = "http://www.example.com/"; command.ApplicationUrl = "/foo"; command.ExecuteAsync().Wait(); var order = new OrderCommand(); order.Documents = command.Documents; order.Execute(); Assert.Equal(1, order.Books.Count()); var doc = command.Documents.Skip(3).Take(1).Single(); var data = order.Books.First().GetAsDynamic(doc); }
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); }
public void CanOrderUnorderedDocuments() { var path = Path.GetFullPath(@"data\dated-documents\"); var command = new LoadDocumentsCommand(); command.Author = new Author(); command.DocumentsPath = path; command.OutputRootPath = Path.GetFullPath("output"); command.RenderedExtensions = new[] { "md" }; command.RootUrl = "http://www.example.com/"; command.ApplicationUrl = "/foo"; command.ExecuteAsync().Wait(); var order = new OrderCommand(); order.Documents = command.Documents; order.Execute(); Assert.Equal(0, order.Books.Count()); }
public void CanSpecifyOutputPath() { var path = Path.GetFullPath(@"data\test-documents\explicit-output"); var outputPath = Path.GetFullPath("output"); var expectedOutput = Path.Combine(outputPath, @"put-that\over\here.txt"); var expectedUrl = "http://www.example.com/app/sub/put-that/over/here.txt"; var command = new LoadDocumentsCommand(); command.Author = new Author(); command.DocumentsPath = path; command.OutputRootPath = outputPath; command.RenderedExtensions = new[] { "md" }; command.RootUrl = "http://www.example.com/"; command.ApplicationUrl = "/app/sub"; command.ExecuteAsync().Wait(); var document = command.Documents.Single(); Assert.Equal(expectedOutput, document.OutputPath); Assert.Equal(expectedUrl, document.Url); }
public void CanLoadOrderedDocuments() { var path = Path.GetFullPath(@"data\ordered-documents\"); var command = new LoadDocumentsCommand(); command.Author = new Author(); command.DocumentsPath = path; command.OutputRootPath = Path.GetFullPath("output"); command.RenderedExtensions = new[] { "md" }; command.RootUrl = "http://www.example.com/"; command.ApplicationUrl = "/foo"; command.ExecuteAsync().Wait(); var documents = command.Documents.OrderBy(d => d.Order).ToList(); Assert.Equal(1, documents[0].Order); Assert.Equal("First Ordered Document", documents[0].Metadata.Get <string>("title")); Assert.Equal("first-ordered-document.txt", documents[0].OutputRelativePath); Assert.Equal(1, documents[1].Order); Assert.Equal("Sub-Second Document", documents[1].Metadata.Get <string>("title")); Assert.Equal("second-document\\sub-second-document.txt", documents[1].OutputRelativePath); Assert.Equal(2, documents[2].Order); Assert.Equal("Second Document", documents[2].Metadata.Get <string>("title")); Assert.Equal("second-document.txt", documents[2].OutputRelativePath); Assert.Equal(2, documents[3].Order); Assert.Equal("Another Sub-Second Document", documents[3].Metadata.Get <string>("title")); Assert.Equal("second-document\\another-sub-second-document.txt", documents[3].OutputRelativePath); Assert.Equal(3, documents[4].Order); Assert.Equal("Third Document From Metadata", documents[4].Metadata.Get <string>("title")); Assert.Equal("third-document-from-metadata.txt", documents[4].OutputRelativePath); }