diff --git a/README.md b/README.md index 492e57b..50ca81a 100644 --- a/README.md +++ b/README.md @@ -572,6 +572,10 @@ Options: --config Read defaults from a JSON config file. Any CLI flag passed alongside it overrides the file's value. See "Configuration file" below. + --minimal-ui Slim HTML status page: keep stream links, listener + counts and previews; hide input/port/rate/version + rows, external-player URLs, recorder cards and + Now Playing. API endpoints are unchanged. --keep-alive Keep HTTP outputs available after stdin reaches EOF. If stdin is a FIFO (mkfifo), the reader also re-opens it on EOF so a new producer can attach; diff --git a/Sources/LiveAudioServer/LiveAudioServerApp.swift b/Sources/LiveAudioServer/LiveAudioServerApp.swift index 9367d0d..c1fbfb4 100644 --- a/Sources/LiveAudioServer/LiveAudioServerApp.swift +++ b/Sources/LiveAudioServer/LiveAudioServerApp.swift @@ -86,6 +86,10 @@ func printUsage() { --config Read defaults from a JSON config file. Any CLI flag passed alongside it overrides the file's value. See the README for the full schema. + --minimal-ui Slim HTML status page: keep stream links, listener + counts and previews; hide input/port/rate/version + rows, external-player URLs, recorder cards and + Now Playing. API endpoints are unchanged. --keep-alive Keep HTTP outputs available after stdin reaches EOF. If stdin is a FIFO (created with mkfifo), the reader also re-opens it on EOF so a new diff --git a/Sources/LiveAudioServerCore/CLIParse.swift b/Sources/LiveAudioServerCore/CLIParse.swift index 7670406..78a81f6 100644 --- a/Sources/LiveAudioServerCore/CLIParse.swift +++ b/Sources/LiveAudioServerCore/CLIParse.swift @@ -226,6 +226,8 @@ public func parseCLI(_ args: [String]) -> CLIParseResult { config.httpAuthRealm = r case "--keep-alive": config.keepAliveOnInputEnd = true + case "--minimal-ui": + config.minimalUI = true case "--exit-with-parent": config.exitWithParent = true case "--no-fifo-reopen": diff --git a/Sources/LiveAudioServerCore/Config.swift b/Sources/LiveAudioServerCore/Config.swift index 47053a0..72071e4 100644 --- a/Sources/LiveAudioServerCore/Config.swift +++ b/Sources/LiveAudioServerCore/Config.swift @@ -68,6 +68,12 @@ public struct ServerConfig { /// `LiveAudioServerApp`. public var exitWithParent: Bool = false public var keepAliveOnInputEnd: Bool = false + /// Slim down the HTML status page for host apps that embed it: keeps the + /// stream links, listener counts and audio previews, and drops the + /// input/port/rate/version rows, the external-player URL card, the + /// recorder cards and the Now Playing card. The JSON/API endpoints are + /// unaffected. CLI: `--minimal-ui`. + public var minimalUI: Bool = false /// When the input stream is a FIFO/named pipe and `keepAliveOnInputEnd` is /// on, re-`open()` the same path on EOF so a new producer can attach. /// Plain pipes (e.g. shell `|`) cannot be reopened — this only takes diff --git a/Sources/LiveAudioServerCore/HTTPServer.swift b/Sources/LiveAudioServerCore/HTTPServer.swift index 7d2c6ae..648765e 100644 --- a/Sources/LiveAudioServerCore/HTTPServer.swift +++ b/Sources/LiveAudioServerCore/HTTPServer.swift @@ -220,8 +220,8 @@ func statusPage(config: ServerConfig, } var recorderCards = "" - if config.enableMP3 { recorderCards += recorderCard("mp3", label: "MP3") } - if config.enableAAC { recorderCards += recorderCard("aac", label: "AAC") } + if !config.minimalUI && config.enableMP3 { recorderCards += recorderCard("mp3", label: "MP3") } + if !config.minimalUI && config.enableAAC { recorderCards += recorderCard("aac", label: "AAC") } var urlRows = "" if config.enableMP3 { @@ -257,6 +257,44 @@ func statusPage(config: ServerConfig, df.locale = Locale(identifier: "en_US_POSIX") let startedStr = df.string(from: startedAt) + let urlCard: String = config.minimalUI ? "" : """ +
+

Stream URLs for external players

+ \(urlRows) +
+ """ + let nowPlayingCard: String = config.minimalUI ? "" : """ + + """ + let detailRows: String = config.minimalUI ? "" : """ +
+ Input Source + \(config.inputSource.displayName) +
+
+ Port + \(config.port) +
+
+ Sample Rate + \(config.sampleRate) Hz +
+
+ Channels + \(config.channels == 1 ? "Mono" : "Stereo") +
+ \(row("Version", "\(liveAudioServerVersion) (\(liveAudioServerGitSHA))")) + \(row("Started", "\(startedStr) · up \(uptimeStr)")) + """ + + let html = """ @@ -336,24 +374,7 @@ func statusPage(config: ServerConfig,

🎙 LiveAudioServer

Live audio streaming — listener counts update every 5s

-
- Input Source - \(config.inputSource.displayName) -
-
- Port - \(config.port) -
-
- Sample Rate - \(config.sampleRate) Hz -
-
- Channels - \(config.channels == 1 ? "Mono" : "Stereo") -
- \(row("Version", "\(liveAudioServerVersion) (\(liveAudioServerGitSHA))")) - \(row("Started", "\(startedStr) · up \(uptimeStr)")) + \(detailRows) \(streamRows) @@ -361,21 +382,11 @@ func statusPage(config: ServerConfig, \(players) -
-

Stream URLs for external players

- \(urlRows) -
+ \(urlCard) \(recorderCards) - + \(nowPlayingCard)