74 lines
3.2 KiB
Swift
74 lines
3.2 KiB
Swift
import Foundation
|
|
|
|
struct ContentPage: HtmlProducer {
|
|
|
|
private let linkTitle: String
|
|
|
|
private let description: String
|
|
|
|
private let language: ContentLanguage
|
|
|
|
private let dateString: String
|
|
|
|
private let title: String
|
|
|
|
private let tags: [FeedEntryData.Tag]
|
|
|
|
private let navigationBarData: NavigationBarData
|
|
|
|
private let pageContent: String
|
|
|
|
init(language: ContentLanguage, dateString: String, title: String, tags: [FeedEntryData.Tag], linkTitle: String, description: String, navigationBarData: NavigationBarData, pageContent: String) {
|
|
self.language = language
|
|
self.dateString = dateString
|
|
self.title = title
|
|
self.tags = tags
|
|
self.linkTitle = linkTitle
|
|
self.description = description
|
|
self.navigationBarData = navigationBarData
|
|
self.pageContent = pageContent
|
|
}
|
|
|
|
func populate(_ result: inout String) {
|
|
// TODO: Add headers and footers from page content
|
|
result += "<!DOCTYPE html><html lang=\"\(language.rawValue)\">"
|
|
result += PageHead(title: title, description: description, additionalHeaders: "").content
|
|
result += "<body>"
|
|
result += NavigationBar(data: navigationBarData).content
|
|
|
|
result += "<main><article>"
|
|
result += "<div style=\"height: 70px;\"></div>"
|
|
result += "<h3>\(dateString)</h3>"
|
|
result += "<h1>\(title)</h1>"
|
|
result += TagList(tags: tags).content
|
|
result += symbols
|
|
result += pageContent
|
|
result += "</article></main>"
|
|
|
|
result += "" // TODO: Footer
|
|
result += "</body></html>" // Close content
|
|
}
|
|
|
|
private let symbols: String =
|
|
"""
|
|
<div style="display:none">
|
|
<svg id="icon-clock" width="16" height="16" viewBox="0 0 16 16">
|
|
<path fill="currentColor" d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .3.4l3.5 2a.5.5 0 0 0 .4-.8L8 8.7V3.5z"/>
|
|
<path fill="currentColor" d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z"/>
|
|
</svg>
|
|
<svg id="icon-arrow-up" width="16" height="16">
|
|
<path fill="currentColor" d="m14 2.5a.5.5 0 0 0 -.5-.5h-6a.5.5 0 0 0 0 1h4.8l-10.16 10.15a.5.5 0 0 0 .7.7l10.16-10.14v4.79a.5.5 0 0 0 1 0z"/>
|
|
</svg>
|
|
<svg id="icon-arrow-down" width="16" height="16">
|
|
<path fill="currentColor" fill-rule="evenodd" d="M14 13.5a.5.5 0 0 1-.5.5h-6a.5.5 0 0 1 0-1h4.8L2.14 2.85a.5.5 0 1 1 .7-.7L13 12.29V7.5a.5.5 0 0 1 1 0v6z"/>
|
|
</svg>
|
|
<svg id="icon-sign" width="16" height="16">
|
|
<path fill="currentColor" d="M7 1.4V4H2a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h5v6h2v-6h3.5a1 1 0 0 0 .8-.4l2-2.3a.5.5 0 0 0 0-.6l-2-2.3a1 1 0 0 0-.8-.4H9V1.4a1 1 0 0 0-2 0zM12.5 5l1.7 2-1.7 2H2V5h10.5z"/>
|
|
</svg>
|
|
<svg id="icon-flame" width="16" height="16">
|
|
<path fill="currentColor" d="M8 16c3.3 0 6-2 6-5.5 0-1.5-.5-4-2.5-6 .3 1.5-1.3 2-1.3 2C11 4 9 .5 6 0c.4 2 .5 4-2 6-1.3 1-2 2.7-2 4.5C2 14 4.7 16 8 16Zm0-1c-1.7 0-3-1-3-2.8 0-.7.3-2 1.3-3-.2.8.7 1.3.7 1.3-.4-1.3.5-3.3 2-3.5-.2 1-.3 2 1 3a3 3 0 0 1 1 2.3C11 14 9.7 15 8 15Z"/>
|
|
</svg>
|
|
</div>
|
|
"""
|
|
}
|