V2 #1

Merged
danieljsummers merged 102 commits from v2 into main 2022-06-23 00:35:12 +00:00
3 changed files with 8 additions and 4 deletions
Showing only changes of commit 664704d3d5 - Show all commits

View File

@ -129,8 +129,9 @@ let listPages pageNbr : HttpHandler = fun next ctx -> task {
let! pages = Data.Page.findPageOfPages webLog.id pageNbr ctx.Conn
return!
Hash.FromAnonymousObject
{| pages = pages |> List.map (DisplayPage.fromPageMinimal webLog)
page_title = "Pages"
{| csrf = csrfToken ctx
pages = pages |> List.map (DisplayPage.fromPageMinimal webLog)
page_title = "Pages"
|}
|> viewForTheme "admin" "page-list" next ctx
}
@ -191,7 +192,9 @@ let savePagePermalinks : HttpHandler = fun next ctx -> task {
let deletePage pgId : HttpHandler = fun next ctx -> task {
let webLog = ctx.WebLog
match! Data.Page.delete (PageId pgId) webLog.id ctx.Conn with
| true -> do! addMessage ctx { UserMessage.success with message = "Page deleted successfully" }
| true ->
do! PageListCache.update ctx
do! addMessage ctx { UserMessage.success with message = "Page deleted successfully" }
| false -> do! addMessage ctx { UserMessage.error with message = "Page not found; nothing deleted" }
return! redirectToGet (WebLog.relativeUrl webLog (Permalink "admin/pages")) next ctx
}

View File

@ -339,6 +339,7 @@ let all pageNbr : HttpHandler = fun next ctx -> task {
let! posts = Data.Post.findPageOfPosts webLog.id pageNbr 25 conn
let! hash = preparePostList webLog posts AdminList "" pageNbr 25 ctx conn
hash.Add ("page_title", "Posts")
hash.Add ("csrf", csrfToken ctx)
return! viewForTheme "admin" "post-list" next ctx hash
}

View File

@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="{{ "/admin/post/save" | relative_link }}" method="post">
<form action="{{ "admin/post/save" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<input type="hidden" name="postId" value="{{ model.post_id }}">
<div class="container">