Version 2.1 #41

Merged
danieljsummers merged 123 commits from version-2.1 into main 2024-03-27 00:13:28 +00:00
3 changed files with 20 additions and 10 deletions
Showing only changes of commit d8024ac6f4 - Show all commits

View File

@ -163,17 +163,24 @@ let private addEpisode (webLog: WebLog) (podcast: PodcastOptions) (episode: Epis
episode.Subtitle |> Option.iter (fun it -> item.ElementExtensions.Add("subtitle", Namespace.iTunes, it)) episode.Subtitle |> Option.iter (fun it -> item.ElementExtensions.Add("subtitle", Namespace.iTunes, it))
episode.FormatDuration() |> Option.iter (fun it -> item.ElementExtensions.Add("duration", Namespace.iTunes, it)) episode.FormatDuration() |> Option.iter (fun it -> item.ElementExtensions.Add("duration", Namespace.iTunes, it))
match episode.ChapterFile with let chapterUrl, chapterMimeType =
| Some chapters -> match episode.Chapters, episode.ChapterFile with
let url = toAbsolute webLog chapters | Some _, _ ->
let typ = Some $"{webLog.AbsoluteUrl post.Permalink}?chapters", Some JSON_CHAPTERS
match episode.ChapterType with | None, Some chapters ->
| Some mime -> Some mime let typ =
| None when chapters.EndsWith ".json" -> Some "application/json+chapters" match episode.ChapterType with
| None -> None | Some mime -> Some mime
| None when chapters.EndsWith ".json" -> Some JSON_CHAPTERS
| None -> None
Some (toAbsolute webLog chapters), typ
| None, None -> None, None
match chapterUrl with
| Some url ->
let elt = xmlDoc.CreateElement("podcast", "chapters", Namespace.podcast) let elt = xmlDoc.CreateElement("podcast", "chapters", Namespace.podcast)
elt.SetAttribute("url", url) elt.SetAttribute("url", url)
typ |> Option.iter (fun it -> elt.SetAttribute("type", it)) chapterMimeType |> Option.iter (fun it -> elt.SetAttribute("type", it))
item.ElementExtensions.Add elt item.ElementExtensions.Add elt
| None -> () | None -> ()

View File

@ -268,6 +268,9 @@ let redirectToGet url : HttpHandler = fun _ ctx -> task {
return! redirectTo false (ctx.WebLog.RelativeUrl(Permalink url)) earlyReturn ctx return! redirectTo false (ctx.WebLog.RelativeUrl(Permalink url)) earlyReturn ctx
} }
/// The MIME type for podcast episode JSON chapters
let JSON_CHAPTERS = "application/json+chapters"
/// Handlers for error conditions /// Handlers for error conditions
module Error = module Error =

View File

@ -238,7 +238,7 @@ let chapters (post: Post) : HttpHandler = fun next ctx ->
jsonFile["fileName"] <- absoluteUrl ep.Media ctx jsonFile["fileName"] <- absoluteUrl ep.Media ctx
if defaultArg ep.ChapterWaypoints false then jsonFile["waypoints"] <- true if defaultArg ep.ChapterWaypoints false then jsonFile["waypoints"] <- true
jsonFile["chapters"] <- chapterData jsonFile["chapters"] <- chapterData
json jsonFile next ctx (setContentType JSON_CHAPTERS >=> json jsonFile) next ctx
| None -> | None ->
match ep.ChapterFile with match ep.ChapterFile with
| Some file -> redirectTo true file next ctx | Some file -> redirectTo true file next ctx