V2 #1
|
@ -178,6 +178,9 @@ type Post =
|
||||||
/// The instant on which the post was last updated
|
/// The instant on which the post was last updated
|
||||||
updatedOn : DateTime
|
updatedOn : DateTime
|
||||||
|
|
||||||
|
/// The template to use in displaying the post
|
||||||
|
template : string option
|
||||||
|
|
||||||
/// The text of the post in HTML (ready to display) format
|
/// The text of the post in HTML (ready to display) format
|
||||||
text : string
|
text : string
|
||||||
|
|
||||||
|
@ -211,6 +214,7 @@ module Post =
|
||||||
publishedOn = None
|
publishedOn = None
|
||||||
updatedOn = DateTime.MinValue
|
updatedOn = DateTime.MinValue
|
||||||
text = ""
|
text = ""
|
||||||
|
template = None
|
||||||
categoryIds = []
|
categoryIds = []
|
||||||
tags = []
|
tags = []
|
||||||
metadata = []
|
metadata = []
|
||||||
|
|
|
@ -376,6 +376,9 @@ type EditPostModel =
|
||||||
/// The tags for the post
|
/// The tags for the post
|
||||||
tags : string
|
tags : string
|
||||||
|
|
||||||
|
/// The template used to display the post
|
||||||
|
template : string
|
||||||
|
|
||||||
/// The category IDs for the post
|
/// The category IDs for the post
|
||||||
categoryIds : string[]
|
categoryIds : string[]
|
||||||
|
|
||||||
|
@ -413,6 +416,7 @@ type EditPostModel =
|
||||||
source = MarkupText.sourceType latest.text
|
source = MarkupText.sourceType latest.text
|
||||||
text = MarkupText.text latest.text
|
text = MarkupText.text latest.text
|
||||||
tags = String.Join (", ", post.tags)
|
tags = String.Join (", ", post.tags)
|
||||||
|
template = defaultArg post.template ""
|
||||||
categoryIds = post.categoryIds |> List.map CategoryId.toString |> Array.ofList
|
categoryIds = post.categoryIds |> List.map CategoryId.toString |> Array.ofList
|
||||||
status = PostStatus.toString post.status
|
status = PostStatus.toString post.status
|
||||||
doPublish = false
|
doPublish = false
|
||||||
|
|
|
@ -232,6 +232,7 @@ let edit postId : HttpHandler = fun next ctx -> task {
|
||||||
match result with
|
match result with
|
||||||
| Some (title, post) ->
|
| Some (title, post) ->
|
||||||
let! cats = Data.Category.findAllForView webLog.id conn
|
let! cats = Data.Category.findAllForView webLog.id conn
|
||||||
|
let! templates = templatesForTheme ctx "post"
|
||||||
let model = EditPostModel.fromPost webLog post
|
let model = EditPostModel.fromPost webLog post
|
||||||
return!
|
return!
|
||||||
Hash.FromAnonymousObject {|
|
Hash.FromAnonymousObject {|
|
||||||
|
@ -240,6 +241,7 @@ let edit postId : HttpHandler = fun next ctx -> task {
|
||||||
metadata = Array.zip model.metaNames model.metaValues
|
metadata = Array.zip model.metaNames model.metaValues
|
||||||
|> Array.mapi (fun idx (name, value) -> [| string idx; name; value |])
|
|> Array.mapi (fun idx (name, value) -> [| string idx; name; value |])
|
||||||
page_title = title
|
page_title = title
|
||||||
|
templates = templates
|
||||||
categories = cats
|
categories = cats
|
||||||
|}
|
|}
|
||||||
|> viewForTheme "admin" "post-edit" next ctx
|
|> viewForTheme "admin" "post-edit" next ctx
|
||||||
|
@ -322,6 +324,7 @@ let save : HttpHandler = fun next ctx -> task {
|
||||||
|> Seq.filter (fun it -> it <> "")
|
|> Seq.filter (fun it -> it <> "")
|
||||||
|> Seq.sort
|
|> Seq.sort
|
||||||
|> List.ofSeq
|
|> List.ofSeq
|
||||||
|
template = match model.template.Trim () with "" -> None | tmpl -> Some tmpl
|
||||||
categoryIds = model.categoryIds |> Array.map CategoryId |> List.ofArray
|
categoryIds = model.categoryIds |> Array.map CategoryId |> List.ofArray
|
||||||
status = if model.doPublish then Published else post.status
|
status = if model.doPublish then Published else post.status
|
||||||
metadata = Seq.zip model.metaNames model.metaValues
|
metadata = Seq.zip model.metaNames model.metaValues
|
||||||
|
|
|
@ -32,7 +32,7 @@ module CatchAll =
|
||||||
debug (fun () -> $"Found post by permalink")
|
debug (fun () -> $"Found post by permalink")
|
||||||
let model = Post.preparePostList webLog [ post ] Post.ListType.SinglePost "" 1 1 ctx conn |> await
|
let model = Post.preparePostList webLog [ post ] Post.ListType.SinglePost "" 1 1 ctx conn |> await
|
||||||
model.Add ("page_title", post.title)
|
model.Add ("page_title", post.title)
|
||||||
yield fun next ctx -> themedView "single-post" next ctx model
|
yield fun next ctx -> themedView (defaultArg post.template "single-post") next ctx model
|
||||||
| None -> ()
|
| None -> ()
|
||||||
// Current page
|
// Current page
|
||||||
match Data.Page.findByPermalink permalink webLog.id conn |> await with
|
match Data.Page.findByPermalink permalink webLog.id conn |> await with
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"hostname": "data02.bitbadger.solutions",
|
"hostname": "data02.bitbadger.solutions",
|
||||||
"database": "myWebLog_dev"
|
"database": "myWebLog_dev"
|
||||||
},
|
},
|
||||||
"Generator": "myWebLog 2.0-alpha35",
|
"Generator": "myWebLog 2.0-alpha36",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"MyWebLog.Handlers": "Debug"
|
"MyWebLog.Handlers": "Debug"
|
||||||
|
|
|
@ -127,6 +127,16 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-lg-3">
|
<div class="col-12 col-lg-3">
|
||||||
|
<div class="form-floating pb-3">
|
||||||
|
<select name="template" id="template" class="form-control">
|
||||||
|
{% for tmpl in templates -%}
|
||||||
|
<option value="{{ tmpl[0] }}"{% if model.template == tmpl[0] %} selected="selected"{% endif %}>
|
||||||
|
{{ tmpl[1] }}
|
||||||
|
</option>
|
||||||
|
{%- endfor %}
|
||||||
|
</select>
|
||||||
|
<label for="template">Post Template</label>
|
||||||
|
</div>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Categories</legend>
|
<legend>Categories</legend>
|
||||||
{% for cat in categories %}
|
{% for cat in categories %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user