Full page content, fixes, cleaner settings

This commit is contained in:
Christoph Hagen
2024-12-13 11:26:34 +01:00
parent efc9234917
commit b3b8c9a610
50 changed files with 1351 additions and 607 deletions

View File

@ -0,0 +1,14 @@
struct AdditionalPageHeaders {
let headers: RequiredHeaders
let assetPath: String
var content: String {
headers.map { header in
let module = header.asModule ? " type='module'" : ""
return "<script\(module) src='\(assetPath)/\(header.rawValue)'></script>"
}.sorted().joined()
}
}

View File

@ -0,0 +1,14 @@
struct ContentBox: HtmlProducer {
let title: String
let text: String
func populate(_ result: inout String) {
result += "<div class='box'>"
result += "<span class='title'>\(title)</span>"
result += "<p>\(text)</p>"
result += "</div>"
}
}

View File

@ -0,0 +1,11 @@
struct ModelViewer {
let file: String
let description: String
var content: String {
"<model-viewer alt='\(description)' src='\(file)' ar shadow-intensity='1' camera-controls touch-action='pan-y'></model-viewer>"
}
}

View File

@ -0,0 +1,39 @@
struct RelatedPageLink {
struct Image {
let url: String
let description: String
let size: Int
}
let title: String
let description: String
let url: String
let image: Image?
var content: String {
var result = ""
result += "<a href='\(url)' class='related-box-wrapper'>"
result += "<div class='related-box'>"
if let image {
result += WebsiteImage(
rawImagePath: image.url,
width: image.size,
height: image.size,
altText: image.description)
.content
}
result += "<div class='related-content'>"
result += "<h3>\(title)</h3>"
result += "<p>\(description)</p>"
result += "</div></div></a>" // Close related-box-wrapper, related-box
return result
}
}

View File

@ -0,0 +1,41 @@
struct PartialSvgImage: HtmlProducer {
let imagePath: String
let altText: String
let x: Int
let y: Int
let width: Int
let height: Int
private var aspectRatio: Double {
guard height > 1 else {
return 1
}
return Double(width) / Double(height)
}
func populate(_ result: inout String) {
result += "<span class='content-image svg-image'>"
result += "<img src='\(imagePath)#svgView(viewBox(\(x), \(y), \(width), \(height)))' loading='lazy' style='aspect-ratio:\(aspectRatio)' alt='\(altText)'/>"
result += "</span>"
}
}
struct SvgImage: HtmlProducer {
let imagePath: String
let altText: String
func populate(_ result: inout String) {
result += "<div class='content-image svg-image'>"
result += "<img src='\(imagePath)' loading='lazy' alt='\(altText)'/>"
result += "</div>"
}
}