Fix /page/x/ URLs

- Make log on push URL to history
- Fix dashboard post links
This commit is contained in:
Daniel J. Summers 2022-06-02 07:37:11 -04:00
parent c2b6d7c82c
commit dd3bba8310
5 changed files with 9 additions and 4 deletions

View File

@ -111,6 +111,10 @@ let pageOfPosts pageNbr : HttpHandler = fun next ctx -> task {
return! themedView "index" next ctx hash return! themedView "index" next ctx hash
} }
// GET /page/{pageNbr}/
let redirectToPageOfPosts (pageNbr : int) : HttpHandler = fun next ctx ->
redirectTo true (WebLog.relativeUrl ctx.WebLog (Permalink $"page/{pageNbr}")) next ctx
// GET /category/{slug}/ // GET /category/{slug}/
// GET /category/{slug}/page/{pageNbr} // GET /category/{slug}/page/{pageNbr}
let pageOfCategorizedPosts slugAndPage : HttpHandler = fun next ctx -> task { let pageOfCategorizedPosts slugAndPage : HttpHandler = fun next ctx -> task {

View File

@ -160,6 +160,7 @@ let router : HttpHandler = choose [
]) ])
GET >=> routexp "/category/(.*)" Post.pageOfCategorizedPosts GET >=> routexp "/category/(.*)" Post.pageOfCategorizedPosts
GET >=> routef "/page/%i" Post.pageOfPosts GET >=> routef "/page/%i" Post.pageOfPosts
GET >=> routef "/page/%i/" Post.redirectToPageOfPosts
GET >=> routexp "/tag/(.*)" Post.pageOfTaggedPosts GET >=> routexp "/tag/(.*)" Post.pageOfTaggedPosts
subRoute "/user" (choose [ subRoute "/user" (choose [
GET >=> choose [ GET >=> choose [

View File

@ -3,7 +3,7 @@
"hostname": "data02.bitbadger.solutions", "hostname": "data02.bitbadger.solutions",
"database": "myWebLog_dev" "database": "myWebLog_dev"
}, },
"Generator": "myWebLog 2.0-alpha26", "Generator": "myWebLog 2.0-alpha27",
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"MyWebLog.Handlers": "Debug" "MyWebLog.Handlers": "Debug"

View File

@ -9,8 +9,8 @@
Published <span class="badge rounded-pill bg-secondary">{{ model.posts }}</span> Published <span class="badge rounded-pill bg-secondary">{{ model.posts }}</span>
&nbsp; Drafts <span class="badge rounded-pill bg-secondary">{{ model.drafts }}</span> &nbsp; Drafts <span class="badge rounded-pill bg-secondary">{{ model.drafts }}</span>
</h6> </h6>
<a href="{{ "admin/posts" | relative_permalink }}" class="btn btn-secondary me-2">View All</a> <a href="{{ "admin/posts" | relative_link }}" class="btn btn-secondary me-2">View All</a>
<a href="{{ "admin/post/new/edit" | relative_permalink }}" class="btn btn-primary">Write a New Post</a> <a href="{{ "admin/post/new/edit" | relative_link }}" class="btn btn-primary">Write a New Post</a>
</div> </div>
</div> </div>
</section> </section>

View File

@ -1,6 +1,6 @@
<h2 class="my-3">Log On to {{ web_log.name }}</h2> <h2 class="my-3">Log On to {{ web_log.name }}</h2>
<article class="py-3"> <article class="py-3">
<form action="{{ "user/log-on" | relative_link }}" method="post"> <form action="{{ "user/log-on" | relative_link }}" method="post" hx-push-url="true">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}"> <input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
{% if model.return_to %} {% if model.return_to %}
<input type="hidden" name="returnTo" value="{{ model.return_to.value }}"> <input type="hidden" name="returnTo" value="{{ model.return_to.value }}">