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