Add tests for OpenGraph view model properties
This commit is contained in:
@@ -442,6 +442,7 @@ type EditCommonModel() =
|
||||
/// <param name="og">The existing OpenGraph property set</param>
|
||||
member private this.PopulateOpenGraph(og: OpenGraphProperties) =
|
||||
this.AssignOpenGraph <- true
|
||||
this.OpenGraphType <- string og.Type
|
||||
this.OpenGraphImageUrl <- og.Image.Url
|
||||
this.OpenGraphImageType <- defaultArg og.Image.Type ""
|
||||
this.OpenGraphImageWidth <- defaultArg (og.Image.Width |> Option.map string) ""
|
||||
@@ -748,9 +749,10 @@ type EditPageModel() =
|
||||
|
||||
/// <summary>Update a page with values from this model</summary>
|
||||
/// <param name="page">The page to be updated</param>
|
||||
/// <param name="webLog">The web log to which this page belongs</param>
|
||||
/// <param name="now">The <c>Instant</c> to use for this particular update</param>
|
||||
/// <returns>The page, updated with the values from this model</returns>
|
||||
member this.UpdatePage (page: Page) now =
|
||||
member this.UpdatePage (page: Page) webLog now =
|
||||
let revision = { AsOf = now; Text = MarkupText.Parse $"{this.Source}: {this.Text}" }
|
||||
// Detect a permalink change, and add the prior one to the prior list
|
||||
match string page.Permalink with
|
||||
@@ -766,6 +768,7 @@ type EditPageModel() =
|
||||
IsInPageList = this.IsShownInPageList
|
||||
Template = match this.Template with "" -> None | tmpl -> Some tmpl
|
||||
Text = revision.Text.AsHtml()
|
||||
OpenGraph = this.ToOpenGraph webLog
|
||||
Metadata = Seq.zip this.MetaNames this.MetaValues
|
||||
|> Seq.filter (fun it -> fst it > "")
|
||||
|> Seq.map (fun it -> { Name = fst it; Value = snd it })
|
||||
@@ -905,9 +908,10 @@ type EditPostModel() =
|
||||
|
||||
/// <summary>Update a post with values from the submitted form</summary>
|
||||
/// <param name="post">The post which should be updated</param>
|
||||
/// <param name="webLog">The web log to which this post belongs</param>
|
||||
/// <param name="now">The <c>Instant</c> to use for this particular update</param>
|
||||
/// <returns>The post, updated with the values from this model</returns>
|
||||
member this.UpdatePost (post: Post) now =
|
||||
member this.UpdatePost (post: Post) (webLog: WebLog) now =
|
||||
let revision = { AsOf = now; Text = MarkupText.Parse $"{this.Source}: {this.Text}" }
|
||||
// Detect a permalink change, and add the prior one to the prior list
|
||||
match string post.Permalink with
|
||||
@@ -931,6 +935,7 @@ type EditPostModel() =
|
||||
Template = match this.Template.Trim() with "" -> None | tmpl -> Some tmpl
|
||||
CategoryIds = this.CategoryIds |> Array.map CategoryId |> List.ofArray
|
||||
Status = if this.DoPublish then Published else post.Status
|
||||
OpenGraph = this.ToOpenGraph webLog
|
||||
Metadata = Seq.zip this.MetaNames this.MetaValues
|
||||
|> Seq.filter (fun it -> fst it > "")
|
||||
|> Seq.map (fun it -> { Name = fst it; Value = snd it })
|
||||
|
||||
Reference in New Issue
Block a user