V2 #1

Merged
danieljsummers merged 102 commits from v2 into main 2022-06-23 00:35:12 +00:00
5 changed files with 31 additions and 25 deletions
Showing only changes of commit ac3a4fd3f4 - Show all commits

View File

@ -380,17 +380,20 @@ module Page =
|> tryFirst |> tryFirst
/// Find the current permalink for a page by a prior permalink /// Find the current permalink for a page by a prior permalink
let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) = let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) conn = backgroundTask {
rethink<Permalink list> { let! result =
withTable Table.Page (rethink<Page list> {
getAll (objList permalinks) "priorPermalinks" withTable Table.Page
filter "webLogId" webLogId getAll (objList permalinks) "priorPermalinks"
pluck [ "permalink" ] filter "webLogId" webLogId
limit 1 without [ "revisions"; "text" ]
result; withRetryDefault limit 1
} result; withRetryDefault
|> tryFirst }
|> tryFirst) conn
return result |> Option.map (fun pg -> pg.permalink)
}
/// Find all pages in the page list for the given web log /// Find all pages in the page list for the given web log
let findListed (webLogId : WebLogId) = let findListed (webLogId : WebLogId) =
rethink<Page list> { rethink<Page list> {
@ -506,16 +509,19 @@ module Post =
|> verifyWebLog webLogId (fun p -> p.webLogId) |> verifyWebLog webLogId (fun p -> p.webLogId)
/// Find the current permalink for a post by a prior permalink /// Find the current permalink for a post by a prior permalink
let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) = let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) conn = backgroundTask {
rethink<Permalink list> { let! result =
withTable Table.Post (rethink<Post list> {
getAll (objList permalinks) "priorPermalinks" withTable Table.Post
filter "webLogId" webLogId getAll (objList permalinks) "priorPermalinks"
pluck [ "permalink" ] filter "webLogId" webLogId
limit 1 without [ "revisions"; "text" ]
result; withRetryDefault limit 1
} result; withRetryDefault
|> tryFirst }
|> tryFirst) conn
return result |> Option.map (fun post -> post.permalink)
}
/// Find posts to be displayed on a category list page /// Find posts to be displayed on a category list page
let findPageOfCategorizedPosts (webLogId : WebLogId) (catIds : CategoryId list) (pageNbr : int64) postsPerPage = let findPageOfCategorizedPosts (webLogId : WebLogId) (catIds : CategoryId list) (pageNbr : int64) postsPerPage =

View File

@ -302,7 +302,7 @@ let private deriveAction ctx : HttpHandler seq =
match Data.Post.findCurrentPermalink [ permalink; altLink ] webLog.id conn |> await with match Data.Post.findCurrentPermalink [ permalink; altLink ] webLog.id conn |> await with
| Some link -> yield redirectTo true $"/{Permalink.toString link}" | Some link -> yield redirectTo true $"/{Permalink.toString link}"
| None -> () | None -> ()
// Prior permalink // Prior page
match Data.Page.findCurrentPermalink [ permalink; altLink ] webLog.id conn |> await with match Data.Page.findCurrentPermalink [ permalink; altLink ] webLog.id conn |> await with
| Some link -> yield redirectTo true $"/{Permalink.toString link}" | Some link -> yield redirectTo true $"/{Permalink.toString link}"
| None -> () | None -> ()

View File

@ -3,5 +3,5 @@
"hostname": "data02.bitbadger.solutions", "hostname": "data02.bitbadger.solutions",
"database": "myWebLog_dev" "database": "myWebLog_dev"
}, },
"Generator": "myWebLog 2.0-alpha06" "Generator": "myWebLog 2.0-alpha08"
} }

View File

@ -16,7 +16,7 @@
value="{{ model.permalink }}"> value="{{ model.permalink }}">
<label for="permalink">Permalink</label> <label for="permalink">Permalink</label>
{%- if model.page_id != "new" %} {%- if model.page_id != "new" %}
<span class="form-text"><a href="/page/{{ model.page_id }}/permalinks">Manage Permalinks</a></span> <span class="form-text"><a href="/admin/page/{{ model.page_id }}/permalinks">Manage Permalinks</a></span>
{% endif -%} {% endif -%}
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@
value="{{ model.permalink }}"> value="{{ model.permalink }}">
<label for="permalink">Permalink</label> <label for="permalink">Permalink</label>
{%- if model.page_id != "new" %} {%- if model.page_id != "new" %}
<span class="form-text"><a href="/post/{{ model.post_id }}/permalinks">Manage Permalinks</a></span> <span class="form-text"><a href="/admin/post/{{ model.post_id }}/permalinks">Manage Permalinks</a></span>
{% endif -%} {% endif -%}
</div> </div>
<div class="mb-2"> <div class="mb-2">