90 lines
2.2 KiB
Swift
90 lines
2.2 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) 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.html = .init()
|
|
}
|
|
|
|
// MARK: Convenience methods
|
|
|
|
func makePlaceholder(title: String, text: String) -> String {
|
|
box.generate([
|
|
.title: title,
|
|
.text: text])
|
|
}
|
|
}
|