Add single file audio player, introduce blocks

This commit is contained in:
Christoph Hagen
2025-01-06 01:17:06 +01:00
parent c78c359819
commit 245534e989
27 changed files with 521 additions and 88 deletions

View File

@ -46,7 +46,7 @@ struct AudioPlayerCommandProcessor: CommandProcessor {
var amplitude: [AmplitudeSong] = []
for song in songs {
guard let image = content.image(song.cover) else {
guard let image = content.file(song.cover) else {
results.missing(file: song.cover, containedIn: file)
continue
}
@ -63,7 +63,11 @@ struct AudioPlayerCommandProcessor: CommandProcessor {
results.warning("Song '\(song.file)' in file \(fileId) is not an audio file")
continue
}
let coverUrl = image.absoluteUrl
let coverSize = 2 * content.settings.audioPlayer.playlistCoverImageSize
let coverImage = image.imageVersion(width: coverSize, height: coverSize, type: image.type)
let coverUrl = coverImage.outputPath
results.require(image: coverImage)
let playlistItem = AudioPlayer.PlaylistItem(
index: playlist.count,

View File

@ -13,7 +13,6 @@ struct ButtonCommandProcessor: CommandProcessor {
}
/**
Format: `![buttons](<<fileId>,<text>,<download-filename?>;...)`
Format: `![buttons](type=<specification>;...)`
Types:
- Download: `download=<fileId>,<text>,<download-filename?>`

View File

@ -1,25 +0,0 @@
import Splash
struct PageCodeProcessor {
private let codeHighlightFooter = "<script>hljs.highlightAll();</script>"
private let swift = SyntaxHighlighter(format: HTMLOutputFormat())
let results: PageGenerationResults
init(results: PageGenerationResults) {
self.results = results
}
func process(_ html: String, markdown: Substring) -> String {
guard markdown.starts(with: "```swift") else {
results.require(header: .codeHightlighting)
results.require(footer: codeHighlightFooter)
return html // Just use normal code highlighting
}
// Highlight swift code using Splash
let code = markdown.between("```swift", and: "```").trimmed
return "<pre><code>" + swift.highlight(code) + "</pre></code>"
}
}