1/// The front page of a run that has no coverage (DESIGN.md D8): it says so, and why.
2public struct UnavailablePage: Sendable {
3 public static let sitePath = IndexPage.sitePath
4 public static let notice = "Coverage is not available for this commit."
5
6 private let title: String
7 private let reason: String
8 private let commit: String?
9 private let subject: String?
10
11 /// - Parameters:
12 /// - title: the project's name, shown as given.
13 /// - reason: why there is no coverage; escaped, since CI supplies it.
14 /// - commit: the commit the run was built from, shown as given.
15 /// - subject: the commit's first message line.
167 public init(title: String, reason: String, commit: String?, subject: String?) {
177 self.title = title
187 self.reason = reason
197 self.commit = commit
207 self.subject = subject
217 }
22
237 public var html: String {
247 """
257 <!doctype html>
267 <html lang="en">
277 <head>
287 <meta charset="utf-8">
297 <meta name="viewport" content="width=device-width, initial-scale=1">
307 <title>\(escapingHTML(title))</title>
317 <link rel="stylesheet" href="\(SiteStylesheet.fileName)">
327 </head>
337 <body class="unavailable-page">
347 <header class="page-header">
357 <h1 class="site-title">\(escapingHTML(title))</h1>
367 \(commitMarkup)
377 </header>
387 <main>
397 <p class="notice">\(Self.notice)</p>
407 <p class="reason">\(escapingHTML(reason))</p>
417 </main>
427 </body>
437 </html>
447
457 """
467 }
47
487 private var commitMarkup: String {
4914 let parts = [commit, subject].compactMap { $0 }.map(escapingHTML)
507 guard !parts.isEmpty else { return "" }
516 return #"<p class="totals">"# + parts.joined(separator: " · ") + "</p>"
527 }
53}