diff --git a/WebsiteGenerator.xcodeproj/project.pbxproj b/WebsiteGenerator.xcodeproj/project.pbxproj index d6770de..981a24d 100644 --- a/WebsiteGenerator.xcodeproj/project.pbxproj +++ b/WebsiteGenerator.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ E22E8763289D84C300E51191 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E8762289D84C300E51191 /* main.swift */; }; E22E876C289D855D00E51191 /* ThumbnailStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E876B289D855D00E51191 /* ThumbnailStyle.swift */; }; - E22E8772289D8C2700E51191 /* IndexPageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E8771289D8C2700E51191 /* IndexPageGenerator.swift */; }; E22E877D289DBA0A00E51191 /* OverviewSectionGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E877C289DBA0A00E51191 /* OverviewSectionGenerator.swift */; }; E22E878C289E4A8900E51191 /* Ink in Frameworks */ = {isa = PBXBuildFile; productRef = E22E878B289E4A8900E51191 /* Ink */; }; E22E8795289E81D700E51191 /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22E8794289E81D700E51191 /* URL+Extensions.swift */; }; @@ -72,7 +71,6 @@ E22E875F289D84C300E51191 /* WebsiteGenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = WebsiteGenerator; sourceTree = BUILT_PRODUCTS_DIR; }; E22E8762289D84C300E51191 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; E22E876B289D855D00E51191 /* ThumbnailStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailStyle.swift; sourceTree = ""; }; - E22E8771289D8C2700E51191 /* IndexPageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndexPageGenerator.swift; sourceTree = ""; }; E22E877C289DBA0A00E51191 /* OverviewSectionGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverviewSectionGenerator.swift; sourceTree = ""; }; E22E8794289E81D700E51191 /* URL+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extensions.swift"; sourceTree = ""; }; E22E879A289EE02F00E51191 /* Optional+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Extensions.swift"; sourceTree = ""; }; @@ -180,7 +178,6 @@ E22E879F289F008200E51191 /* ThumbnailListGenerator.swift */, E22E877C289DBA0A00E51191 /* OverviewSectionGenerator.swift */, E22E87A3289F0C7000E51191 /* SiteGenerator.swift */, - E22E8771289D8C2700E51191 /* IndexPageGenerator.swift */, E22E87A7289F0E7B00E51191 /* PageGenerator.swift */, E22E879D289EFDFC00E51191 /* OverviewPageGenerator.swift */, E2F8FA1D28A539C500632026 /* MarkdownProcessor.swift */, @@ -329,7 +326,6 @@ buildActionMask = 2147483647; files = ( E2C5A5D728A022C500102A25 /* TemplateFactory.swift in Sources */, - E22E8772289D8C2700E51191 /* IndexPageGenerator.swift in Sources */, E2F8FA3A28AE313A00632026 /* ValidationLog.swift in Sources */, E253C88528BA32FB0076B6D0 /* HTMLElementsGenerator.swift in Sources */, E2C5A5D528A0223C00102A25 /* HeaderTemplate.swift in Sources */, diff --git a/WebsiteGenerator/Generators/IndexPageGenerator.swift b/WebsiteGenerator/Generators/IndexPageGenerator.swift deleted file mode 100644 index c663810..0000000 --- a/WebsiteGenerator/Generators/IndexPageGenerator.swift +++ /dev/null @@ -1,39 +0,0 @@ -import Foundation - -struct IndexPageGenerator { - - private let factory: LocalizedSiteTemplate - - init(factory: LocalizedSiteTemplate) { - self.factory = factory - } - - func generate(site: Element, language: String) { - let localized = site.localized(for: language) - let path = site.localizedPath(for: language) - let pageUrl = files.urlInOutputFolder(path) - let languageButton = site.nextLanguage(for: language) - let sectionItemCount = site.overviewItemCount - - var content = [PageTemplate.Key : String]() - content[.head] = factory.pageHead.generate(page: site, language: language) - content[.topBar] = factory.topBar.generate(sectionUrl: nil, languageButton: languageButton) - content[.contentClass] = "overview" - content[.header] = makeHeader(page: site, metadata: localized, language: language) - content[.content] = factory.overviewSection.generate( - sections: site.sortedItems, - in: site, - language: language, - sectionItemCount: sectionItemCount) - content[.footer] = site.customFooterContent() - guard factory.page.generate(content, to: pageUrl) else { - return - } - files.generated(page: path) - } - - private func makeHeader(page: Element, metadata: Element.LocalizedMetadata, language: String) -> String { - let content = factory.makeHeaderContent(page: page, metadata: metadata, language: language) - return factory.factory.centeredHeader.generate(content) - } -} diff --git a/WebsiteGenerator/Generators/SiteGenerator.swift b/WebsiteGenerator/Generators/SiteGenerator.swift index c542943..b833941 100644 --- a/WebsiteGenerator/Generators/SiteGenerator.swift +++ b/WebsiteGenerator/Generators/SiteGenerator.swift @@ -27,7 +27,8 @@ struct SiteGenerator { // Generate sections let overviewGenerator = OverviewPageGenerator(factory: template) let pageGenerator = PageGenerator(factory: template) - var elementsToProcess: [Element] = site.elements + + var elementsToProcess: [Element] = [site] while let element = elementsToProcess.popLast() { // Move recursively down to all pages elementsToProcess.append(contentsOf: element.elements) @@ -46,10 +47,5 @@ struct SiteGenerator { previousPage: nil) } } - - let generator = IndexPageGenerator(factory: template) - - // Generate front page - generator.generate(site: site, language: language) } }