90 lines
2.5 KiB
Swift
90 lines
2.5 KiB
Swift
import Foundation
|
|
|
|
final class TemplateFactory {
|
|
|
|
let templateFolder: URL
|
|
|
|
// MARK: Site Elements
|
|
|
|
let backNavigation: BackNavigationTemplate
|
|
|
|
let pageHead: PageHeadTemplate
|
|
|
|
let topBar: TopBarTemplate
|
|
|
|
let overviewSection: OverviewSectionTemplate
|
|
|
|
let overviewSectionClean: OverviewSectionCleanTemplate
|
|
|
|
let pageLink: PageLinkTemplate
|
|
|
|
let box: BoxTemplate
|
|
|
|
// MARK: Thumbnails
|
|
|
|
let largeThumbnail: LargeThumbnailTemplate
|
|
|
|
let squareThumbnail: SquareThumbnailTemplate
|
|
|
|
let smallThumbnail: SmallThumbnailTemplate
|
|
|
|
func thumbnail(style: ThumbnailStyle) -> ThumbnailTemplate {
|
|
switch style {
|
|
case .large:
|
|
return largeThumbnail
|
|
case .square:
|
|
return squareThumbnail
|
|
case .small:
|
|
return smallThumbnail
|
|
}
|
|
}
|
|
|
|
// MARK: Headers
|
|
|
|
let leftHeader: LeftHeaderTemplate
|
|
|
|
let centeredHeader: CenteredHeaderTemplate
|
|
|
|
// MARK: Pages
|
|
|
|
let page: PageTemplate
|
|
|
|
let image: PageImageTemplate
|
|
|
|
let video: PageVideoTemplate
|
|
|
|
// MARK: HTML
|
|
|
|
let html: HTMLElementsGenerator
|
|
|
|
// MARK: Init
|
|
|
|
init(templateFolder: URL, results: GenerationResultsHandler) throws {
|
|
self.templateFolder = 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()
|
|
}
|
|
|
|
// MARK: Convenience methods
|
|
|
|
func makePlaceholder(title: String, text: String) -> String {
|
|
box.generate([
|
|
.title: title,
|
|
.text: text])
|
|
}
|
|
}
|