diff --git a/Sources/Generator/Templates/Elements/BackNavigationTemplate.swift b/Sources/Generator/Templates/Elements/BackNavigationTemplate.swift index cbf9643..1e7a96c 100644 --- a/Sources/Generator/Templates/Elements/BackNavigationTemplate.swift +++ b/Sources/Generator/Templates/Elements/BackNavigationTemplate.swift @@ -10,4 +10,6 @@ struct BackNavigationTemplate: Template { static let templateName = "back.html" let raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Elements/BoxTemplate.swift b/Sources/Generator/Templates/Elements/BoxTemplate.swift index c2de89e..98d334e 100644 --- a/Sources/Generator/Templates/Elements/BoxTemplate.swift +++ b/Sources/Generator/Templates/Elements/BoxTemplate.swift @@ -10,4 +10,6 @@ struct BoxTemplate: Template { static let templateName = "box.html" var raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Elements/OverviewSectionCleanTemplate.swift b/Sources/Generator/Templates/Elements/OverviewSectionCleanTemplate.swift index 0627dd3..5bac1ae 100644 --- a/Sources/Generator/Templates/Elements/OverviewSectionCleanTemplate.swift +++ b/Sources/Generator/Templates/Elements/OverviewSectionCleanTemplate.swift @@ -9,4 +9,6 @@ struct OverviewSectionCleanTemplate: Template { static let templateName = "overview-section-clean.html" let raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Elements/OverviewSectionTemplate.swift b/Sources/Generator/Templates/Elements/OverviewSectionTemplate.swift index bf8fec3..33a8aee 100644 --- a/Sources/Generator/Templates/Elements/OverviewSectionTemplate.swift +++ b/Sources/Generator/Templates/Elements/OverviewSectionTemplate.swift @@ -12,4 +12,6 @@ struct OverviewSectionTemplate: Template { static let templateName = "overview-section.html" let raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Elements/PageHeadTemplate.swift b/Sources/Generator/Templates/Elements/PageHeadTemplate.swift index 3206515..90cca87 100644 --- a/Sources/Generator/Templates/Elements/PageHeadTemplate.swift +++ b/Sources/Generator/Templates/Elements/PageHeadTemplate.swift @@ -12,5 +12,7 @@ struct PageHeadTemplate: Template { let raw: String + let results: GenerationResultsHandler + static let templateName = "head.html" } diff --git a/Sources/Generator/Templates/Elements/PageImageTemplate.swift b/Sources/Generator/Templates/Elements/PageImageTemplate.swift index 9d3d46e..6f2c606 100644 --- a/Sources/Generator/Templates/Elements/PageImageTemplate.swift +++ b/Sources/Generator/Templates/Elements/PageImageTemplate.swift @@ -15,4 +15,6 @@ struct PageImageTemplate: Template { let raw: String + let results: GenerationResultsHandler + } diff --git a/Sources/Generator/Templates/Elements/PageLinkTemplate.swift b/Sources/Generator/Templates/Elements/PageLinkTemplate.swift index 4654d56..96f013b 100644 --- a/Sources/Generator/Templates/Elements/PageLinkTemplate.swift +++ b/Sources/Generator/Templates/Elements/PageLinkTemplate.swift @@ -15,6 +15,8 @@ struct PageLinkTemplate: Template { let raw: String + let results: GenerationResultsHandler + func makePath(components: [String]) -> String { components.joined(separator: " » ") //  » ") } diff --git a/Sources/Generator/Templates/Elements/PageVideoTemplate.swift b/Sources/Generator/Templates/Elements/PageVideoTemplate.swift index 6678eed..b8392ad 100644 --- a/Sources/Generator/Templates/Elements/PageVideoTemplate.swift +++ b/Sources/Generator/Templates/Elements/PageVideoTemplate.swift @@ -23,6 +23,8 @@ struct PageVideoTemplate: Template { let raw: String + let results: GenerationResultsHandler + func generate(sources: [VideoSource], options: T) -> String where T: Sequence, T.Element == VideoOption { let sourcesCode = sources.map(makeSource).joined(separator: "\n") let optionCode = options.map { $0.rawValue }.joined(separator: " ") diff --git a/Sources/Generator/Templates/Elements/ThumbnailTemplate.swift b/Sources/Generator/Templates/Elements/ThumbnailTemplate.swift index a0ce8dc..c90e4bc 100644 --- a/Sources/Generator/Templates/Elements/ThumbnailTemplate.swift +++ b/Sources/Generator/Templates/Elements/ThumbnailTemplate.swift @@ -20,6 +20,8 @@ struct LargeThumbnailTemplate: Template, ThumbnailTemplate { let raw: String + let results: GenerationResultsHandler + func makeCorner(text: String) -> String { "\(text)" } @@ -36,6 +38,8 @@ struct SquareThumbnailTemplate: Template, ThumbnailTemplate { static let templateName = "thumbnail-square.html" let raw: String + + let results: GenerationResultsHandler } struct SmallThumbnailTemplate: Template, ThumbnailTemplate { @@ -45,5 +49,7 @@ struct SmallThumbnailTemplate: Template, ThumbnailTemplate { static let templateName = "thumbnail-small.html" let raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Elements/TopBarTemplate.swift b/Sources/Generator/Templates/Elements/TopBarTemplate.swift index 6c2234b..665d566 100644 --- a/Sources/Generator/Templates/Elements/TopBarTemplate.swift +++ b/Sources/Generator/Templates/Elements/TopBarTemplate.swift @@ -12,4 +12,6 @@ struct TopBarTemplate: Template { static let templateName = "bar.html" var raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Filled/LocalizedSiteTemplate.swift b/Sources/Generator/Templates/Filled/LocalizedSiteTemplate.swift index 4c90a82..e34f88e 100644 --- a/Sources/Generator/Templates/Filled/LocalizedSiteTemplate.swift +++ b/Sources/Generator/Templates/Filled/LocalizedSiteTemplate.swift @@ -35,7 +35,7 @@ struct LocalizedSiteTemplate { factory.page } - init(factory: TemplateFactory, language: String, site: Element) { + init(factory: TemplateFactory, language: String, site: Element, log: GenerationResultsHandler) { self.author = site.author self.factory = factory @@ -67,9 +67,11 @@ struct LocalizedSiteTemplate { sections: sections, topBarWebsiteTitle: site.topBarTitle) self.pageHead = PageHeadGenerator( - factory: factory) + factory: factory, + log: log) self.overviewSection = OverviewSectionGenerator( - factory: factory) + factory: factory, + log: log) } // MARK: Content diff --git a/Sources/Generator/Templates/Pages/HeaderTemplate.swift b/Sources/Generator/Templates/Pages/HeaderTemplate.swift index 1c16248..fc77484 100644 --- a/Sources/Generator/Templates/Pages/HeaderTemplate.swift +++ b/Sources/Generator/Templates/Pages/HeaderTemplate.swift @@ -19,6 +19,8 @@ struct CenteredHeaderTemplate: Template { let raw: String + let results: GenerationResultsHandler + static let templateName = "header-center.html" } @@ -28,5 +30,7 @@ struct LeftHeaderTemplate: Template { let raw: String + let results: GenerationResultsHandler + static let templateName = "header-left.html" } diff --git a/Sources/Generator/Templates/Pages/PageTemplate.swift b/Sources/Generator/Templates/Pages/PageTemplate.swift index 434eb3e..77a03fa 100644 --- a/Sources/Generator/Templates/Pages/PageTemplate.swift +++ b/Sources/Generator/Templates/Pages/PageTemplate.swift @@ -18,4 +18,6 @@ struct PageTemplate: Template { static let templateName = "page.html" let raw: String + + let results: GenerationResultsHandler } diff --git a/Sources/Generator/Templates/Template.swift b/Sources/Generator/Templates/Template.swift index ae13724..fbdc740 100644 --- a/Sources/Generator/Templates/Template.swift +++ b/Sources/Generator/Templates/Template.swift @@ -8,25 +8,28 @@ protocol Template { var raw: String { get } - init(raw: String) + var results: GenerationResultsHandler { get } + + init(raw: String, results: GenerationResultsHandler) } extension Template { - init(in folder: URL) throws { + init(in folder: URL, results: GenerationResultsHandler) throws { let url = folder.appendingPathComponent(Self.templateName) - try self.init(from: url) + try self.init(from: url, results: results) } - init(from url: URL) throws { + init(from url: URL, results: GenerationResultsHandler) throws { let raw = try String(contentsOf: url) - self.init(raw: raw) + self.init(raw: raw, results: results) } func generate(_ content: [Key : String], to url: URL) -> Bool { let content = generate(content) - return files.write(content, to: url) + #warning("log.write(content, to: url, file: )") + return true } func generate(_ content: [Key : String], shouldIndent: Bool = false) -> String { diff --git a/Sources/Generator/Templates/TemplateFactory.swift b/Sources/Generator/Templates/TemplateFactory.swift index a6729dc..d9f2753 100644 --- a/Sources/Generator/Templates/TemplateFactory.swift +++ b/Sources/Generator/Templates/TemplateFactory.swift @@ -59,23 +59,23 @@ final class TemplateFactory { // MARK: Init - init(templateFolder: URL) throws { + init(templateFolder: URL, results: GenerationResultsHandler) throws { self.templateFolder = templateFolder - self.backNavigation = try .init(in: templateFolder) - self.pageHead = try .init(in: templateFolder) - self.topBar = try .init(in: templateFolder) - self.overviewSection = try .init(in: templateFolder) - self.overviewSectionClean = try .init(in: templateFolder) - self.box = try .init(in: templateFolder) - self.pageLink = try .init(in: templateFolder) - self.largeThumbnail = try .init(in: templateFolder) - self.squareThumbnail = try .init(in: templateFolder) - self.smallThumbnail = try .init(in: templateFolder) - self.leftHeader = try .init(in: templateFolder) - self.centeredHeader = try .init(in: templateFolder) - self.page = try .init(in: templateFolder) - self.image = try .init(in: templateFolder) - self.video = try .init(in: templateFolder) + self.backNavigation = try .init(in: templateFolder, results: results) + self.pageHead = try .init(in: templateFolder, results: results) + self.topBar = try .init(in: templateFolder, results: results) + self.overviewSection = try .init(in: templateFolder, results: results) + self.overviewSectionClean = try .init(in: templateFolder, results: results) + self.box = try .init(in: templateFolder, results: results) + self.pageLink = try .init(in: templateFolder, results: results) + self.largeThumbnail = try .init(in: templateFolder, results: results) + self.squareThumbnail = try .init(in: templateFolder, results: results) + self.smallThumbnail = try .init(in: templateFolder, results: results) + self.leftHeader = try .init(in: templateFolder, results: results) + self.centeredHeader = try .init(in: templateFolder, results: results) + self.page = try .init(in: templateFolder, results: results) + self.image = try .init(in: templateFolder, results: results) + self.video = try .init(in: templateFolder, results: results) self.html = .init() }