diff --git a/src/MyWebLog.Domain/ViewModels.fs b/src/MyWebLog.Domain/ViewModels.fs index a495625..38d554c 100644 --- a/src/MyWebLog.Domain/ViewModels.fs +++ b/src/MyWebLog.Domain/ViewModels.fs @@ -610,7 +610,7 @@ type PostListItem = tags : string list /// Metadata for the post - meta : MetaItem list + metadata : MetaItem list } /// Create a post list item from a post @@ -627,7 +627,7 @@ type PostListItem = text = if extra = "" then post.text else post.text.Replace ("href=\"/", $"href=\"{extra}/") categoryIds = post.categoryIds |> List.map CategoryId.toString tags = post.tags - meta = post.metadata + metadata = post.metadata } diff --git a/src/MyWebLog/Handlers/Feed.fs b/src/MyWebLog/Handlers/Feed.fs index 4e03d96..0313105 100644 --- a/src/MyWebLog/Handlers/Feed.fs +++ b/src/MyWebLog/Handlers/Feed.fs @@ -122,21 +122,21 @@ let private addEpisode webLog (feed : CustomFeed) (post : Post) (item : Syndicat let meta name = post.metadata |> List.tryFind (fun it -> it.name = name) let value (item : MetaItem) = item.value let epMediaUrl = - match (meta >> Option.get >> value) "media" with + match (meta >> Option.get >> value) "episode_media_file" with | link when link.StartsWith "http" -> link | link -> WebLog.absoluteUrl webLog (Permalink link) let epMediaType = - match meta "mediaType", podcast.defaultMediaType with + match meta "episode_media_type", podcast.defaultMediaType with | Some epType, _ -> Some epType.value | None, Some defType -> Some defType | _ -> None let epImageUrl = - match defaultArg ((meta >> Option.map value) "image") (Permalink.toString podcast.imageUrl) with + match defaultArg ((meta >> Option.map value) "episode_image") (Permalink.toString podcast.imageUrl) with | link when link.StartsWith "http" -> link | link -> WebLog.absoluteUrl webLog (Permalink link) let epExplicit = try - (meta >> Option.map (value >> ExplicitRating.parse)) "explicit" + (meta >> Option.map (value >> ExplicitRating.parse)) "episode_explicit" |> Option.defaultValue podcast.explicit |> ExplicitRating.toString with :? ArgumentException -> ExplicitRating.toString podcast.explicit @@ -144,8 +144,8 @@ let private addEpisode webLog (feed : CustomFeed) (post : Post) (item : Syndicat let xmlDoc = XmlDocument () let enclosure = xmlDoc.CreateElement "enclosure" enclosure.SetAttribute ("url", epMediaUrl) - meta "length" |> Option.iter (fun it -> enclosure.SetAttribute ("length", it.value)) - epMediaType |> Option.iter (fun typ -> enclosure.SetAttribute ("type", typ)) + meta "episode_media_length" |> Option.iter (fun it -> enclosure.SetAttribute ("length", it.value)) + epMediaType |> Option.iter (fun typ -> enclosure.SetAttribute ("type", typ)) item.ElementExtensions.Add enclosure item.ElementExtensions.Add ("creator", Namespace.dc, podcast.displayedAuthor) @@ -153,8 +153,10 @@ let private addEpisode webLog (feed : CustomFeed) (post : Post) (item : Syndicat item.ElementExtensions.Add ("summary", Namespace.iTunes, stripHtml post.text) item.ElementExtensions.Add ("image", Namespace.iTunes, epImageUrl) item.ElementExtensions.Add ("explicit", Namespace.iTunes, epExplicit) - meta "subtitle" |> Option.iter (fun it -> item.ElementExtensions.Add ("subtitle", Namespace.iTunes, it.value)) - meta "duration" |> Option.iter (fun it -> item.ElementExtensions.Add ("duration", Namespace.iTunes, it.value)) + meta "episode_subtitle" + |> Option.iter (fun it -> item.ElementExtensions.Add ("subtitle", Namespace.iTunes, it.value)) + meta "episode_duration" + |> Option.iter (fun it -> item.ElementExtensions.Add ("duration", Namespace.iTunes, it.value)) if post.metadata |> List.exists (fun it -> it.name = "chapter") then try diff --git a/src/MyWebLog/Handlers/Post.fs b/src/MyWebLog/Handlers/Post.fs index faa7aff..99e19c6 100644 --- a/src/MyWebLog/Handlers/Post.fs +++ b/src/MyWebLog/Handlers/Post.fs @@ -231,11 +231,14 @@ let edit postId : HttpHandler = fun next ctx -> task { } match result with | Some (title, post) -> - let! cats = Data.Category.findAllForView webLog.id conn + let! cats = Data.Category.findAllForView webLog.id conn + let model = EditPostModel.fromPost webLog post return! Hash.FromAnonymousObject {| csrf = csrfToken ctx - model = EditPostModel.fromPost webLog post + model = model + metadata = Array.zip model.metaNames model.metaValues + |> Array.mapi (fun idx (name, value) -> [| string idx; name; value |]) page_title = title categories = cats |} diff --git a/src/MyWebLog/themes/admin/post-edit.liquid b/src/MyWebLog/themes/admin/post-edit.liquid index 38a6787..ce61b78 100644 --- a/src/MyWebLog/themes/admin/post-edit.liquid +++ b/src/MyWebLog/themes/admin/post-edit.liquid @@ -55,8 +55,14 @@
+ {%- assign has_media = model.metaNames | where: "episode_media_file" | size -%} + {%- unless has_media == 0 %} + + {%- endunless %}
- {%- for meta in model.metadata %} + {%- for meta in metadata %}
diff --git a/src/MyWebLog/themes/awftw/index.liquid b/src/MyWebLog/themes/awftw/index.liquid index b239803..21e3118 100644 --- a/src/MyWebLog/themes/awftw/index.liquid +++ b/src/MyWebLog/themes/awftw/index.liquid @@ -33,8 +33,8 @@ #[i.fa.fa-clock-o(title='Clock' aria-hidden='true')] #[= readingTime(post.content, 'minutes', 175)] {% endcomment %}

- {%- assign media = post.meta | value: "media" -%} - {%- unless media == "-- media not found --" %} + {%- assign media = post.metadata | value: "episode_media_file" -%} + {%- unless media == "-- episode_media_file not found --" %}