Add pagination to page admin

- Update blog link in bit-badger theme
This commit is contained in:
Daniel J. Summers 2022-05-31 08:45:45 -04:00
parent 042e1fdec7
commit ba6403dfef
4 changed files with 25 additions and 3 deletions

View File

@ -132,6 +132,9 @@ let listPages pageNbr : HttpHandler = fun next ctx -> task {
{| csrf = csrfToken ctx {| csrf = csrfToken ctx
pages = pages |> List.map (DisplayPage.fromPageMinimal webLog) pages = pages |> List.map (DisplayPage.fromPageMinimal webLog)
page_title = "Pages" page_title = "Pages"
page_nbr = pageNbr
prev_page = if pageNbr = 2 then "" else $"/page/{pageNbr - 1}"
next_page = $"/page/{pageNbr + 1}"
|} |}
|> viewForTheme "admin" "page-list" next ctx |> viewForTheme "admin" "page-list" next ctx
} }

View File

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

View File

@ -1,6 +1,7 @@
<h2 class="my-3">{{ page_title }}</h2> <h2 class="my-3">{{ page_title }}</h2>
<article> <article>
<a href="{{ "admin/page/new/edit" | relative_link }}" class="btn btn-primary btn-sm mb-3">Create a New Page</a> <a href="{{ "admin/page/new/edit" | relative_link }}" class="btn btn-primary btn-sm mb-3">Create a New Page</a>
{%- assign page_count = pages | size -%}
<table class="table table-sm table-hover"> <table class="table table-sm table-hover">
<thead> <thead>
<tr> <tr>
@ -10,7 +11,6 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{%- assign page_count = pages | size -%}
{% if page_count > 0 %} {% if page_count > 0 %}
{% for pg in pages -%} {% for pg in pages -%}
<tr> <tr>
@ -43,6 +43,22 @@
{% endif %} {% endif %}
</tbody> </tbody>
</table> </table>
{% if page_nbr > 1 or page_count == 25 %}
<div class="d-flex justify-content-evenly">
<div>
{% if page_nbr > 1 %}
{%- capture prev_link %}admin/pages{{ prev_page }}{% endcapture -%}
<p><a class="btn btn-default" href="{{ prev_link | relative_link }}">&laquo; Previous</a></p>
{% endif %}
</div>
<div class="text-right">
{% if page_count == 25 %}
{%- capture next_link %}admin/pages{{ next_page }}{% endcapture -%}
<p><a class="btn btn-default" href="{{ next_link | relative_link }}">Next &raquo;</a></p>
{% endif %}
</div>
</div>
{% endif %}
<form method="post" id="deleteForm"> <form method="post" id="deleteForm">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}"> <input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
</form> </form>

View File

@ -91,14 +91,17 @@
</p> </p>
<p class="app-sidebar-description">Biloxi, Mississippi</p> <p class="app-sidebar-description">Biloxi, Mississippi</p>
</div> </div>
</div>
<div>
<div> <div>
<div class="app-sidebar-head">myWebLog</div>
<p class="app-sidebar-name"> <p class="app-sidebar-name">
<strong>The Bit Badger Blog</strong><br> <strong>The Bit Badger Blog</strong><br>
<a href="{{ "solutions/tech-blog" | relative_link }}" <a href="{{ "solutions/tech-blog" | relative_link }}"
title="About The Bit Badger Blog &bull; Bit Badger Solutions"> title="About The Bit Badger Blog &bull; Bit Badger Solutions">
About About
</a> • </a> •
<a href="https://blog.bitbadger.solutions" title="The Bit Badger Blog" target="_blank" rel="noopener"> <a href="https://bitbadger.solutions/blog" title="The Bit Badger Blog" target="_blank" rel="noopener">
Visit Visit
</a> </a>
</p> </p>