Fix prior permalink lookup (a8)

- Fix permalink edit links (a7)
This commit is contained in:
Daniel J. Summers 2022-05-21 11:00:03 -04:00
parent 0a21240984
commit ac3a4fd3f4
5 changed files with 31 additions and 25 deletions

View File

@ -380,17 +380,20 @@ module Page =
|> tryFirst
/// Find the current permalink for a page by a prior permalink
let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) =
rethink<Permalink list> {
withTable Table.Page
getAll (objList permalinks) "priorPermalinks"
filter "webLogId" webLogId
pluck [ "permalink" ]
limit 1
result; withRetryDefault
}
|> tryFirst
let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) conn = backgroundTask {
let! result =
(rethink<Page list> {
withTable Table.Page
getAll (objList permalinks) "priorPermalinks"
filter "webLogId" webLogId
without [ "revisions"; "text" ]
limit 1
result; withRetryDefault
}
|> tryFirst) conn
return result |> Option.map (fun pg -> pg.permalink)
}
/// Find all pages in the page list for the given web log
let findListed (webLogId : WebLogId) =
rethink<Page list> {
@ -506,16 +509,19 @@ module Post =
|> verifyWebLog webLogId (fun p -> p.webLogId)
/// Find the current permalink for a post by a prior permalink
let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) =
rethink<Permalink list> {
withTable Table.Post
getAll (objList permalinks) "priorPermalinks"
filter "webLogId" webLogId
pluck [ "permalink" ]
limit 1
result; withRetryDefault
}
|> tryFirst
let findCurrentPermalink (permalinks : Permalink list) (webLogId : WebLogId) conn = backgroundTask {
let! result =
(rethink<Post list> {
withTable Table.Post
getAll (objList permalinks) "priorPermalinks"
filter "webLogId" webLogId
without [ "revisions"; "text" ]
limit 1
result; withRetryDefault
}
|> tryFirst) conn
return result |> Option.map (fun post -> post.permalink)
}
/// Find posts to be displayed on a category list page
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
| Some link -> yield redirectTo true $"/{Permalink.toString link}"
| None -> ()
// Prior permalink
// Prior page
match Data.Page.findCurrentPermalink [ permalink; altLink ] webLog.id conn |> await with
| Some link -> yield redirectTo true $"/{Permalink.toString link}"
| None -> ()

View File

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

View File

@ -16,7 +16,7 @@
value="{{ model.permalink }}">
<label for="permalink">Permalink</label>
{%- 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 -%}
</div>
</div>

View File

@ -16,7 +16,7 @@
value="{{ model.permalink }}">
<label for="permalink">Permalink</label>
{%- 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 -%}
</div>
<div class="mb-2">