First cut at cache management (#23)

This commit is contained in:
2022-07-24 23:55:00 -04:00
parent e103738d39
commit ff9c08842b
4 changed files with 195 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<fieldset class="container pb-3">
<fieldset class="container mb-3">
<legend>Themes</legend>
<div class="row">
<div class="col">
@@ -22,10 +22,90 @@
</div>
</fieldset>
<fieldset class="container">
{%- assign cache_base_url = "admin/cache/" -%}
<legend>Caches</legend>
<div class="row">
<div class="row pb-3">
<div class="col">
TODO
<p>
myWebLog uses a few caches to ensure that it serves pages as fast as possible. Normal actions taken within the
admin area will keep these up to date; however, if changes occur outside of the system (creating a new web log
via CLI, loading an updated theme via CLI, direct data updates, etc.), these options allow for the caches to
be refreshed without requiring you to restart the application.
</p>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-6 pb-3">
<div class="card">
<header class="card-header text-white bg-secondary">Web Logs</header>
<div class="card-body">
<h6 class="card-subtitle text-muted pb-3">
These caches include the page list and categories for each web log
</h6>
{%- assign web_log_base_url = cache_base_url | append: "web-log/" -%}
<form method="post" class="container pb-3" hx-boost="false" hx-target="body" hx-swap="innerHTML show:window:top">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<button type="submit" class="btn btn-sm btn-primary pb-2"
hx-post="{{ web_log_base_url | append: "all/refresh" | relative_link }}">
Refresh All
</button>
<div class="row mwl-table-heading">
<div class="col">Name</div>
<div class="col">URL Base</div>
</div>
{%- for web_log in web_logs %}
<div class="row mwl-table-detail">
<div class="col">
{{ web_log[1] }}<br>
<small>
{%- assign refresh_url = web_log_base_url | append: web_log[0] | append: "/refresh" | relative_link -%}
<a href="{{ refresh_url }}" hx-post="{{ refresh_url }}">Refresh</a>
</small>
</div>
<div class="col">{{ web_log[2] }}</div>
</div>
{%- endfor %}
</form>
</div>
</div>
</div>
<div class="col-12 col-lg-6 pb-3">
<div class="card">
<header class="card-header text-white bg-secondary">Themes</header>
<div class="card-body">
<h6 class="card-subtitle text-muted pb-3">
The themes template cache is loaded on demand; refresh a cache with 0 templates will still refresh the
theme asset cache
</h6>
{%- assign theme_base_url = cache_base_url | append: "theme/" -%}
<form method="post" class="container pb-3" hx-boost="false" hx-target="body" hx-swap="innerHTML show:window:top">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<button type="submit" class="btn btn-sm btn-primary pb-2"
hx-post="{{ theme_base_url | append: "all/refresh" | relative_link }}">
Refresh All
</button>
<div class="row mwl-table-heading">
<div class="col-8">Name</div>
<div class="col-4">Cached Templates</div>
</div>
{%- for theme in cached_themes %}
{% unless theme[0] == "admin" %}
<div class="row mwl-table-detail">
<div class="col-8">
{{ theme[1] }}<br>
<small>
<span class="text-muted">{{ theme[0] }} &bull; </span>
{%- assign refresh_url = theme_base_url | append: theme[0] | append: "/refresh" | relative_link -%}
<a href="{{ refresh_url }}" hx-post="{{ refresh_url }}">Refresh</a>
</small>
</div>
<div class="col-4">{{ theme[2] }}</div>
</div>
{% endunless %}
{%- endfor %}
</form>
</div>
</div>
</div>
</div>
</fieldset>