feat: Begins vapor application, begins view controller.

This commit is contained in:
2025-12-30 10:12:45 -05:00
parent 6eedb7396d
commit 4e1be161b1
15 changed files with 586 additions and 9 deletions

View File

@@ -0,0 +1,43 @@
import Dependencies
import DependenciesMacros
import Elementary
import Logging
import ManualDCore
extension DependencyValues {
public var viewController: ViewController {
get { self[ViewController.self] }
set { self[ViewController.self] = newValue }
}
}
public typealias AnySendableHTML = (any HTML & Sendable)
@DependencyClient
public struct ViewController: Sendable {
public var view: @Sendable (Request) async throws -> AnySendableHTML
}
extension ViewController {
public struct Request: Sendable {
public let route: SiteRoute.View
public let isHtmxRequest: Bool
public let logger: Logger
public init(
route: SiteRoute.View,
isHtmxRequest: Bool,
logger: Logger
) {
self.route = route
self.isHtmxRequest = isHtmxRequest
self.logger = logger
}
}
}
extension ViewController: TestDependencyKey {
public static let testValue = Self()
}

View File

@@ -0,0 +1,25 @@
import Elementary
public struct MainPage<Inner: HTML>: SendableHTMLDocument where Inner: Sendable {
public var title: String { "Manual-D" }
public var lang: String { "en" }
let inner: Inner
init(_ inner: () -> Inner) {
self.inner = inner()
}
public var head: some HTML {
meta(.charset(.utf8))
script(.src("https://unpkg.com/htmx.org@2.0.8")) {}
script(.src("/js/main.js")) {}
link(.rel(.stylesheet), .href("/css/main.css"))
link(.rel(.icon), .href("/images/favicon.ico"), .custom(name: "type", value: "image/x-icon"))
}
public var body: some HTML {
inner
}
}
public protocol SendableHTMLDocument: HTMLDocument, Sendable {}