Reorganize headers, page templates
This commit is contained in:
parent
02a3dd4007
commit
c8a70a3d42
@ -36,13 +36,13 @@
|
|||||||
E22E87B2289F296700E51191 /* ThumbnailInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E87B1289F296700E51191 /* ThumbnailInfo.swift */; };
|
E22E87B2289F296700E51191 /* ThumbnailInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E87B1289F296700E51191 /* ThumbnailInfo.swift */; };
|
||||||
E22E87B6289FF67B00E51191 /* Metadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E87B5289FF67B00E51191 /* Metadata.swift */; };
|
E22E87B6289FF67B00E51191 /* Metadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E87B5289FF67B00E51191 /* Metadata.swift */; };
|
||||||
E26555E428A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26555E328A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift */; };
|
E26555E428A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26555E328A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift */; };
|
||||||
E2C5A5D528A0223C00102A25 /* OverviewPageTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5D428A0223C00102A25 /* OverviewPageTemplate.swift */; };
|
E2C5A5D528A0223C00102A25 /* HeaderTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5D428A0223C00102A25 /* HeaderTemplate.swift */; };
|
||||||
E2C5A5D728A022C500102A25 /* TemplateFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5D628A022C500102A25 /* TemplateFactory.swift */; };
|
E2C5A5D728A022C500102A25 /* TemplateFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5D628A022C500102A25 /* TemplateFactory.swift */; };
|
||||||
E2C5A5D928A023FA00102A25 /* PageHeadTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5D828A023FA00102A25 /* PageHeadTemplate.swift */; };
|
E2C5A5D928A023FA00102A25 /* PageHeadTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5D828A023FA00102A25 /* PageHeadTemplate.swift */; };
|
||||||
E2C5A5DB28A02F9000102A25 /* TopBarTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5DA28A02F9000102A25 /* TopBarTemplate.swift */; };
|
E2C5A5DB28A02F9000102A25 /* TopBarTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5DA28A02F9000102A25 /* TopBarTemplate.swift */; };
|
||||||
E2C5A5DD28A036BE00102A25 /* OverviewSectionTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5DC28A036BE00102A25 /* OverviewSectionTemplate.swift */; };
|
E2C5A5DD28A036BE00102A25 /* OverviewSectionTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5DC28A036BE00102A25 /* OverviewSectionTemplate.swift */; };
|
||||||
E2C5A5E128A0373300102A25 /* ThumbnailTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E028A0373300102A25 /* ThumbnailTemplate.swift */; };
|
E2C5A5E128A0373300102A25 /* ThumbnailTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E028A0373300102A25 /* ThumbnailTemplate.swift */; };
|
||||||
E2C5A5E328A037F900102A25 /* ContentPageTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E228A037F900102A25 /* ContentPageTemplate.swift */; };
|
E2C5A5E328A037F900102A25 /* PageTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E228A037F900102A25 /* PageTemplate.swift */; };
|
||||||
E2C5A5E528A03A6500102A25 /* BackNavigationTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E428A03A6500102A25 /* BackNavigationTemplate.swift */; };
|
E2C5A5E528A03A6500102A25 /* BackNavigationTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E428A03A6500102A25 /* BackNavigationTemplate.swift */; };
|
||||||
E2C5A5E928A0451C00102A25 /* LocalizedSiteTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E828A0451C00102A25 /* LocalizedSiteTemplate.swift */; };
|
E2C5A5E928A0451C00102A25 /* LocalizedSiteTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5E828A0451C00102A25 /* LocalizedSiteTemplate.swift */; };
|
||||||
E2C5A5EC28A055E900102A25 /* SiteElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5EB28A055E900102A25 /* SiteElement.swift */; };
|
E2C5A5EC28A055E900102A25 /* SiteElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C5A5EB28A055E900102A25 /* SiteElement.swift */; };
|
||||||
@ -95,13 +95,13 @@
|
|||||||
E22E87B1289F296700E51191 /* ThumbnailInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailInfo.swift; sourceTree = "<group>"; };
|
E22E87B1289F296700E51191 /* ThumbnailInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailInfo.swift; sourceTree = "<group>"; };
|
||||||
E22E87B5289FF67B00E51191 /* Metadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Metadata.swift; sourceTree = "<group>"; };
|
E22E87B5289FF67B00E51191 /* Metadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Metadata.swift; sourceTree = "<group>"; };
|
||||||
E26555E328A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkPreviewMetadataProvider.swift; sourceTree = "<group>"; };
|
E26555E328A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkPreviewMetadataProvider.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5D428A0223C00102A25 /* OverviewPageTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverviewPageTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5D428A0223C00102A25 /* HeaderTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5D628A022C500102A25 /* TemplateFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateFactory.swift; sourceTree = "<group>"; };
|
E2C5A5D628A022C500102A25 /* TemplateFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateFactory.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5D828A023FA00102A25 /* PageHeadTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageHeadTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5D828A023FA00102A25 /* PageHeadTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageHeadTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5DA28A02F9000102A25 /* TopBarTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopBarTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5DA28A02F9000102A25 /* TopBarTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopBarTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5DC28A036BE00102A25 /* OverviewSectionTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverviewSectionTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5DC28A036BE00102A25 /* OverviewSectionTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverviewSectionTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5E028A0373300102A25 /* ThumbnailTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5E028A0373300102A25 /* ThumbnailTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5E228A037F900102A25 /* ContentPageTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentPageTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5E228A037F900102A25 /* PageTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5E428A03A6500102A25 /* BackNavigationTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackNavigationTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5E428A03A6500102A25 /* BackNavigationTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackNavigationTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5E828A0451C00102A25 /* LocalizedSiteTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedSiteTemplate.swift; sourceTree = "<group>"; };
|
E2C5A5E828A0451C00102A25 /* LocalizedSiteTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedSiteTemplate.swift; sourceTree = "<group>"; };
|
||||||
E2C5A5EB28A055E900102A25 /* SiteElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteElement.swift; sourceTree = "<group>"; };
|
E2C5A5EB28A055E900102A25 /* SiteElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteElement.swift; sourceTree = "<group>"; };
|
||||||
@ -231,8 +231,8 @@
|
|||||||
E2C5A5E728A03E4000102A25 /* Pages */ = {
|
E2C5A5E728A03E4000102A25 /* Pages */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E2C5A5D428A0223C00102A25 /* OverviewPageTemplate.swift */,
|
E2C5A5D428A0223C00102A25 /* HeaderTemplate.swift */,
|
||||||
E2C5A5E228A037F900102A25 /* ContentPageTemplate.swift */,
|
E2C5A5E228A037F900102A25 /* PageTemplate.swift */,
|
||||||
);
|
);
|
||||||
path = Pages;
|
path = Pages;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -313,7 +313,7 @@
|
|||||||
E2C5A5D728A022C500102A25 /* TemplateFactory.swift in Sources */,
|
E2C5A5D728A022C500102A25 /* TemplateFactory.swift in Sources */,
|
||||||
E22E8772289D8C2700E51191 /* IndexPageGenerator.swift in Sources */,
|
E22E8772289D8C2700E51191 /* IndexPageGenerator.swift in Sources */,
|
||||||
E22E876E289D868100E51191 /* Site+LocalizedMetadata.swift in Sources */,
|
E22E876E289D868100E51191 /* Site+LocalizedMetadata.swift in Sources */,
|
||||||
E2C5A5D528A0223C00102A25 /* OverviewPageTemplate.swift in Sources */,
|
E2C5A5D528A0223C00102A25 /* HeaderTemplate.swift in Sources */,
|
||||||
E22E876C289D855D00E51191 /* ThumbnailStyle.swift in Sources */,
|
E22E876C289D855D00E51191 /* ThumbnailStyle.swift in Sources */,
|
||||||
E22E8798289EA42C00E51191 /* FileProcessor.swift in Sources */,
|
E22E8798289EA42C00E51191 /* FileProcessor.swift in Sources */,
|
||||||
E26555E428A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift in Sources */,
|
E26555E428A2C4FA00BAF496 /* LinkPreviewMetadataProvider.swift in Sources */,
|
||||||
@ -337,7 +337,7 @@
|
|||||||
E2C5A5EC28A055E900102A25 /* SiteElement.swift in Sources */,
|
E2C5A5EC28A055E900102A25 /* SiteElement.swift in Sources */,
|
||||||
E22E87B0289F221A00E51191 /* PrefilledTopBarTemplate.swift in Sources */,
|
E22E87B0289F221A00E51191 /* PrefilledTopBarTemplate.swift in Sources */,
|
||||||
E22E87A8289F0E7B00E51191 /* PageGenerator.swift in Sources */,
|
E22E87A8289F0E7B00E51191 /* PageGenerator.swift in Sources */,
|
||||||
E2C5A5E328A037F900102A25 /* ContentPageTemplate.swift in Sources */,
|
E2C5A5E328A037F900102A25 /* PageTemplate.swift in Sources */,
|
||||||
E2C5A5DD28A036BE00102A25 /* OverviewSectionTemplate.swift in Sources */,
|
E2C5A5DD28A036BE00102A25 /* OverviewSectionTemplate.swift in Sources */,
|
||||||
E2C5A5E528A03A6500102A25 /* BackNavigationTemplate.swift in Sources */,
|
E2C5A5E528A03A6500102A25 /* BackNavigationTemplate.swift in Sources */,
|
||||||
E2C5A5DB28A02F9000102A25 /* TopBarTemplate.swift in Sources */,
|
E2C5A5DB28A02F9000102A25 /* TopBarTemplate.swift in Sources */,
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "ink",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/johnsundell/ink.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "77c3d8953374a9cf5418ef0bd7108524999de85a",
|
||||||
|
"version" : "0.5.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 2
|
||||||
|
}
|
@ -32,20 +32,19 @@ struct IndexPageGenerator {
|
|||||||
to url: URL) throws {
|
to url: URL) throws {
|
||||||
let localized = site.localized(for: language)
|
let localized = site.localized(for: language)
|
||||||
|
|
||||||
var content = [OverviewPageTemplate.Key : String]()
|
var content = [PageTemplate.Key : String]()
|
||||||
content[.head] = try makeHead(site: site, language: language)
|
content[.head] = try makeHead(site: site, language: language)
|
||||||
content[.topBar] = factory.topBar.generate(section: nil, languageButton: languageButton)
|
content[.topBar] = factory.topBar.generate(section: nil, languageButton: languageButton)
|
||||||
content[.title] = localized.title
|
content[.contentClass] = "overview"
|
||||||
content[.subtitle] = localized.subtitle
|
content[.header] = makeHeader(localized: localized)
|
||||||
content[.titleText] = localized.description
|
|
||||||
let sections = site.elements.compactMap { $0 as? Section }
|
let sections = site.elements.compactMap { $0 as? Section }
|
||||||
content[.sections] = try factory.overviewSection.generate(
|
content[.content] = try factory.overviewSection.generate(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
in: site,
|
in: site,
|
||||||
language: language,
|
language: language,
|
||||||
sectionItemCount: sectionItemCount)
|
sectionItemCount: sectionItemCount)
|
||||||
content[.footer] = SiteGenerator.pageFooter
|
content[.footer] = SiteGenerator.pageFooter
|
||||||
try factory.overviewPage.generate(content, to: url)
|
try factory.page.generate(content, to: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeHead(site: Site, language: String) throws -> String {
|
private func makeHead(site: Site, language: String) throws -> String {
|
||||||
@ -57,4 +56,12 @@ struct IndexPageGenerator {
|
|||||||
linkPreviewImage: site.linkPreviewImage(for: language),
|
linkPreviewImage: site.linkPreviewImage(for: language),
|
||||||
customHeadContent: try site.customHeadContent()))
|
customHeadContent: try site.customHeadContent()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func makeHeader(localized: Site.LocalizedMetadata) -> String {
|
||||||
|
var content = [HeaderKey : String]()
|
||||||
|
content[.title] = localized.title
|
||||||
|
content[.subtitle] = localized.subtitle
|
||||||
|
content[.titleText] = localized.description
|
||||||
|
return factory.factory.centeredHeader.generate(content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,17 @@ struct OverviewPageGenerator {
|
|||||||
|
|
||||||
let metadata = section.localized(for: language)
|
let metadata = section.localized(for: language)
|
||||||
|
|
||||||
var content = [OverviewPageTemplate.Key : String]()
|
var content = [PageTemplate.Key : String]()
|
||||||
content[.head] = try makeHead(section: section, language: language)
|
content[.head] = try makeHead(section: section, language: language)
|
||||||
let languageButton = section.nextLanguage(for: language)
|
let languageButton = section.nextLanguage(for: language)
|
||||||
content[.topBar] = factory.topBar.generate(
|
content[.topBar] = factory.topBar.generate(
|
||||||
section: section.sectionId,
|
section: section.sectionId,
|
||||||
languageButton: languageButton)
|
languageButton: languageButton)
|
||||||
content[.sections] = try makeContent(section: section, language: language)
|
content[.contentClass] = "overview"
|
||||||
content[.title] = metadata.title
|
content[.header] = makeHeader(metadata: metadata, language: language, backText: backText)
|
||||||
content[.subtitle] = metadata.subtitle
|
content[.content] = try makeContent(section: section, language: language)
|
||||||
content[.titleText] = metadata.description
|
|
||||||
content[.footer] = SiteGenerator.pageFooter
|
content[.footer] = SiteGenerator.pageFooter
|
||||||
content[.backLink] = backText.unwrapped { factory.makeBackLink(text: $0, language: language) }
|
try factory.page.generate(content, to: url)
|
||||||
try factory.overviewPage.generate(content, to: url)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeContent(section: Section, language: String) throws -> String {
|
private func makeContent(section: Section, language: String) throws -> String {
|
||||||
@ -59,4 +57,15 @@ struct OverviewPageGenerator {
|
|||||||
customHeadContent: try section.customHeadContent())
|
customHeadContent: try section.customHeadContent())
|
||||||
return try factory.pageHead.generate(page: info)
|
return try factory.pageHead.generate(page: info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func makeHeader(metadata: Section.LocalizedMetadata,
|
||||||
|
language: String,
|
||||||
|
backText: String?) -> String {
|
||||||
|
var content = [HeaderKey : String]()
|
||||||
|
content[.title] = metadata.title
|
||||||
|
content[.subtitle] = metadata.subtitle
|
||||||
|
content[.titleText] = metadata.description
|
||||||
|
content[.backLink] = backText.unwrapped { factory.makeBackLink(text: $0, language: language) }
|
||||||
|
return factory.factory.centeredHeader.generate(content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,11 @@ struct PageGenerator {
|
|||||||
#warning("Make prev and next navigation relative")
|
#warning("Make prev and next navigation relative")
|
||||||
let metadata = page.localized(for: language)
|
let metadata = page.localized(for: language)
|
||||||
let nextLanguage = page.nextLanguage(for: language)
|
let nextLanguage = page.nextLanguage(for: language)
|
||||||
var content = [ContentPageTemplate.Key : String]()
|
var content = [PageTemplate.Key : String]()
|
||||||
content[.head] = try makeHead(page: page, language: language)
|
content[.head] = try makeHead(page: page, language: language)
|
||||||
content[.topBar] = factory.topBar.generate(section: page.sectionId, languageButton: nextLanguage)
|
content[.topBar] = factory.topBar.generate(section: page.sectionId, languageButton: nextLanguage)
|
||||||
content[.backLink] = factory.makeBackLink(text: backText, language: language)
|
content[.contentClass] = "content"
|
||||||
content[.title] = metadata.title
|
content[.header] = makeHeader(page: page.metadata, metadata: metadata, language: language, backText: backText)
|
||||||
content[.subtitle] = metadata.subtitle
|
|
||||||
content[.date] = factory.makeDateString(start: page.metadata.date, end: page.metadata.endDate)
|
|
||||||
content[.content] = try makeContent(page: page, language: language, url: inputContentUrl)
|
content[.content] = try makeContent(page: page, language: language, url: inputContentUrl)
|
||||||
content[.previousPageLinkText] = previousPage.unwrapped { factory.makePrevText($0.text) }
|
content[.previousPageLinkText] = previousPage.unwrapped { factory.makePrevText($0.text) }
|
||||||
content[.previousPageUrl] = previousPage?.link
|
content[.previousPageUrl] = previousPage?.link
|
||||||
@ -45,8 +43,8 @@ struct PageGenerator {
|
|||||||
content[.nextPageUrl] = nextPage?.link
|
content[.nextPageUrl] = nextPage?.link
|
||||||
content[.footer] = try page.customFooterContent()
|
content[.footer] = try page.customFooterContent()
|
||||||
|
|
||||||
try factory.contentPage.generate(content, to: url)
|
|
||||||
let url = files.outputFolder.appendingPathComponent(path)
|
let url = files.outputFolder.appendingPathComponent(path)
|
||||||
|
try factory.page.generate(content, to: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeContent(page: Page, language: String, url: URL) throws -> String {
|
private func makeContent(page: Page, language: String, url: URL) throws -> String {
|
||||||
@ -68,4 +66,13 @@ struct PageGenerator {
|
|||||||
customHeadContent: try page.customHeadContent())
|
customHeadContent: try page.customHeadContent())
|
||||||
return try factory.pageHead.generate(page: info)
|
return try factory.pageHead.generate(page: info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func makeHeader(page: Page.Metadata, metadata: Page.LocalizedMetadata, language: String, backText: String) -> String {
|
||||||
|
var content = [HeaderKey : String]()
|
||||||
|
content[.backLink] = factory.makeBackLink(text: backText, language: language)
|
||||||
|
content[.title] = metadata.title
|
||||||
|
content[.subtitle] = metadata.subtitle
|
||||||
|
content[.date] = factory.makeDateString(start: page.date, end: page.endDate)
|
||||||
|
return factory.factory.leftHeader.generate(content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,8 @@ struct LocalizedSiteTemplate {
|
|||||||
|
|
||||||
// MARK: Pages
|
// MARK: Pages
|
||||||
|
|
||||||
var overviewPage: OverviewPageTemplate {
|
var page: PageTemplate {
|
||||||
factory.overviewPage
|
factory.page
|
||||||
}
|
|
||||||
|
|
||||||
var contentPage: ContentPageTemplate {
|
|
||||||
factory.contentPage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(factory: TemplateFactory, language: String, site: Site, files: FileProcessor) throws {
|
init(factory: TemplateFactory, language: String, site: Site, files: FileProcessor) throws {
|
||||||
|
32
WebsiteGenerator/Templates/Pages/HeaderTemplate.swift
Normal file
32
WebsiteGenerator/Templates/Pages/HeaderTemplate.swift
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol HeaderTemplate {
|
||||||
|
|
||||||
|
func generate(_ content: [ThumbnailKey : String], shouldIndent: Bool) throws -> String
|
||||||
|
}
|
||||||
|
|
||||||
|
enum HeaderKey: String, CaseIterable {
|
||||||
|
case backLink = "BACK_LINK"
|
||||||
|
case title = "TITLE"
|
||||||
|
case subtitle = "SUBTITLE"
|
||||||
|
case titleText = "TITLE_TEXT"
|
||||||
|
case date = "DATE"
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CenteredHeaderTemplate: Template {
|
||||||
|
|
||||||
|
typealias Key = HeaderKey
|
||||||
|
|
||||||
|
let raw: String
|
||||||
|
|
||||||
|
static let templateName = "header-center.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LeftHeaderTemplate: Template {
|
||||||
|
|
||||||
|
typealias Key = HeaderKey
|
||||||
|
|
||||||
|
let raw: String
|
||||||
|
|
||||||
|
static let templateName = "header-left.html"
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
import Foundation
|
|
||||||
|
|
||||||
struct OverviewPageTemplate: Template {
|
|
||||||
|
|
||||||
enum Key: String, CaseIterable {
|
|
||||||
case head = "HEAD"
|
|
||||||
case topBar = "TOP_BAR"
|
|
||||||
case backLink = "BACK_LINK"
|
|
||||||
case title = "TITLE"
|
|
||||||
case subtitle = "SUBTITLE"
|
|
||||||
case titleText = "TITLE_TEXT"
|
|
||||||
case sections = "SECTIONS"
|
|
||||||
case footer = "FOOTER"
|
|
||||||
}
|
|
||||||
|
|
||||||
let raw: String
|
|
||||||
|
|
||||||
static let templateName = "overview-page.html"
|
|
||||||
}
|
|
@ -1,14 +1,12 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct ContentPageTemplate: Template {
|
struct PageTemplate: Template {
|
||||||
|
|
||||||
enum Key: String, CaseIterable {
|
enum Key: String, CaseIterable {
|
||||||
case head = "HEAD"
|
case head = "HEAD"
|
||||||
case topBar = "TOP_BAR"
|
case topBar = "TOP_BAR"
|
||||||
case backLink = "BACK_LINK"
|
case contentClass = "CONTENT_CLASS"
|
||||||
case title = "TITLE"
|
case header = "HEADER"
|
||||||
case subtitle = "SUBTITLE"
|
|
||||||
case date = "DATE"
|
|
||||||
case content = "CONTENT"
|
case content = "CONTENT"
|
||||||
case previousPageLinkText = "PREV_TEXT"
|
case previousPageLinkText = "PREV_TEXT"
|
||||||
case previousPageUrl = "PREV_LINK"
|
case previousPageUrl = "PREV_LINK"
|
@ -37,11 +37,15 @@ final class TemplateFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Headers
|
||||||
|
|
||||||
|
let leftHeader: LeftHeaderTemplate
|
||||||
|
|
||||||
|
let centeredHeader: CenteredHeaderTemplate
|
||||||
|
|
||||||
// MARK: Pages
|
// MARK: Pages
|
||||||
|
|
||||||
let overviewPage: OverviewPageTemplate
|
let page: PageTemplate
|
||||||
|
|
||||||
let contentPage: ContentPageTemplate
|
|
||||||
|
|
||||||
// MARK: Init
|
// MARK: Init
|
||||||
|
|
||||||
@ -56,7 +60,8 @@ final class TemplateFactory {
|
|||||||
self.largeThumbnail = try .init(in: templateFolder)
|
self.largeThumbnail = try .init(in: templateFolder)
|
||||||
self.squareThumbnail = try .init(in: templateFolder)
|
self.squareThumbnail = try .init(in: templateFolder)
|
||||||
self.smallThumbnail = try .init(in: templateFolder)
|
self.smallThumbnail = try .init(in: templateFolder)
|
||||||
self.overviewPage = try .init(in: templateFolder)
|
self.leftHeader = try .init(in: templateFolder)
|
||||||
self.contentPage = try .init(in: templateFolder)
|
self.centeredHeader = try .init(in: templateFolder)
|
||||||
|
self.page = try .init(in: templateFolder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user