Rework content commands, add audio player

This commit is contained in:
Christoph Hagen
2024-12-14 16:31:40 +01:00
parent b3b8c9a610
commit be2aab2ea8
52 changed files with 1758 additions and 767 deletions

View File

@ -0,0 +1,28 @@
import Foundation
extension Content {
private static let disallowedCharactersInIds = CharacterSet.alphanumerics.union(CharacterSet(charactersIn: "-")).inverted
private static let disallowedCharactersInFileIds = CharacterSet.alphanumerics.union(CharacterSet(charactersIn: "-.")).inverted
func isNewIdForTag(_ id: String) -> Bool {
!tags.contains { $0.id == id }
}
func isNewIdForPage(_ id: String) -> Bool {
!pages.contains { $0.id == id }
}
func isNewIdForPost(_ id: String) -> Bool {
!posts.contains { $0.id == id }
}
func isValidIdForTagOrTagOrPost(_ id: String) -> Bool {
id.rangeOfCharacter(from: Content.disallowedCharactersInIds) == nil
}
func isValidIdForFile(_ id: String) -> Bool {
id.rangeOfCharacter(from: Content.disallowedCharactersInFileIds) == nil
}
}