From 4dc56e5dfe5a1eed317a5b9d7358933cb5ea8804 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Wed, 31 Aug 2022 09:02:40 +0200 Subject: [PATCH] Print draft pages --- WebsiteGenerator/Files/FileSystem.swift | 23 +++++++++++++++++-- .../Generators/PageGenerator.swift | 4 +++- WebsiteGenerator/main.swift | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/WebsiteGenerator/Files/FileSystem.swift b/WebsiteGenerator/Files/FileSystem.swift index b6f83f1..2e8cb76 100644 --- a/WebsiteGenerator/Files/FileSystem.swift +++ b/WebsiteGenerator/Files/FileSystem.swift @@ -57,6 +57,11 @@ final class FileSystem { */ private var emptyPages: Set = [] + /** + All pages which have `status` set to ``PageState.draft`` + */ + private var draftPages: Set = [] + /** All paths to page element folders, indexed by their unique id. @@ -427,9 +432,23 @@ final class FileSystem { guard !emptyPages.isEmpty else { return } - log.add(info: "\(emptyPages.count) empty pages:", source: "Files") + print("\(emptyPages.count) empty pages:") for page in emptyPages.sorted() { - log.add(info: "\(page) has no content", source: "Files") + print(" " + page) + } + } + + func isDraft(path: String) { + draftPages.insert(path) + } + + func printDraftPages() { + guard !draftPages.isEmpty else { + return + } + print("\(draftPages.count) drafts:") + for page in draftPages.sorted() { + print(" " + page) } } diff --git a/WebsiteGenerator/Generators/PageGenerator.swift b/WebsiteGenerator/Generators/PageGenerator.swift index 8eb3686..33876da 100644 --- a/WebsiteGenerator/Generators/PageGenerator.swift +++ b/WebsiteGenerator/Generators/PageGenerator.swift @@ -49,7 +49,9 @@ struct PageGenerator { } let url = files.urlInOutputFolder(path) - if pageContent == nil { + if page.state == .draft { + files.isDraft(path: page.path) + } else if pageContent == nil, page.state != .hidden { files.isEmpty(page: path) } guard factory.page.generate(content, to: url) else { diff --git a/WebsiteGenerator/main.swift b/WebsiteGenerator/main.swift index 328eeeb..258ae07 100644 --- a/WebsiteGenerator/main.swift +++ b/WebsiteGenerator/main.swift @@ -22,9 +22,10 @@ do { private let siteGenerator = try SiteGenerator() try siteGenerator.generate(site: siteData) -print("Pages generated") +print("Pages generated\n") files.createImages() files.printEmptyPages() +files.printDraftPages() print("Images generated") files.copyRequiredFiles() print("Required files copied")