Rule add/edit/move/delete works (#39)
- Begin moving auth to route definition where practical - Fix typo on post list page
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
<span class="text-muted"> • </span>
|
||||
{%- assign post_del_link = "admin/post/" | append: post.id | append: "/delete" | relative_link -%}
|
||||
<a href="{{ post_del_link }}" hx-post="{{ post_del_link }}" class="text-danger"
|
||||
hx-confirm="Are you sure you want to delete the page “{{ post.title | strip_html | escape }}”? This action cannot be undone.">
|
||||
hx-confirm="Are you sure you want to delete the post “{{ post.title | strip_html | escape }}”? This action cannot be undone.">
|
||||
Delete
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
48
src/admin-theme/redirect-edit.liquid
Normal file
48
src/admin-theme/redirect-edit.liquid
Normal file
@@ -0,0 +1,48 @@
|
||||
<h3>{% if model.rule_id < 0 %}Add{% else %}Edit{% endif %} Redirect Rule</h3>
|
||||
{%- assign post_url = "admin/settings/redirect-rules/" | append: model.rule_id | relative_link -%}
|
||||
<form action="{{ post_url }}" hx-post="{{ post_url }}" hx-target="body" method="POST" class="container">
|
||||
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
|
||||
<input type="hidden" name="RuleId" value="{{ model.rule_id }}">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-5 mb-3">
|
||||
<div class="form-floating">
|
||||
<input type="text" name="From" id="from" class="form-control" placeholder="From local URL/pattern" autofocus
|
||||
required value="{{ model.from | escape }}">
|
||||
<label for="from">From</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-5 mb-3">
|
||||
<div class="form-floating">
|
||||
<input type="text" name="To" id="to" class="form-control" placeholder="To URL/pattern" required
|
||||
value="{{ model.to | escape }}">
|
||||
<label for="from">To</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-2 mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" name="IsRegex" id="isRegex" class="form-check-input" value="true"
|
||||
{%- if model.is_regex %} checked="checked"{% endif %}>
|
||||
<label for="isRegex">Use RegEx</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if model.rule_id < 0 %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-12 text-center">
|
||||
<label>Add Rule</label>
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="New rule placement button group">
|
||||
<input type="radio" name="InsertAtTop" id="insert_top" class="btn-check" value="true">
|
||||
<label class="btn btn-sm btn-outline-secondary" for="insert_top">Top</label>
|
||||
<input type="radio" name="InsertAtTop" id="insert_bottom" class="btn-check" value="false" checked="checked">
|
||||
<label class="btn btn-sm btn-outline-secondary" for="insert_bottom">Bottom</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row mb-3">
|
||||
<div class="col text-center">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Save Changes</button>
|
||||
<a href="{{ "admin/settings/redirect-rules" | relative_link }}" class="btn btn-sm btn-secondary ms-3">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1,7 +1,17 @@
|
||||
<h2 class="my-3">Redirect Rules</h2>
|
||||
<h2 class="my-3">{{ page_title }}</h2>
|
||||
<article>
|
||||
<a href="{{ "admin/settings" | relative_link }}">« Back to Settings</a>
|
||||
<p class="mb-3">
|
||||
<a href="{{ "admin/settings" | relative_link }}">« Back to Settings</a>
|
||||
</p>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<a href="{{ "admin/settings/redirect-rules/-1" | relative_link }}" class="btn btn-primary btn-sm mb-3"
|
||||
hx-target="#redir_new">
|
||||
Add Redirect Rule
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{%- assign redir_count = redirections | size -%}
|
||||
@@ -13,42 +23,45 @@
|
||||
<div class="col">RegEx?</div>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" class="container">
|
||||
<div class="row mwl-table-detail" id="redir_new"></div>
|
||||
<form method="post" class="container" hx-target="body">
|
||||
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
|
||||
<div class="row mwl-table-detail" id="redir_new"></div>
|
||||
{% for redir in redirections -%}
|
||||
{%- assign map_id = mapping_ids | value: map.tag -%}
|
||||
<div class="row mwl-table-detail" id="redir_{{ forloop.index0 }}">
|
||||
<div class="col no-wrap">
|
||||
{{ redir.from }}<br>
|
||||
<small>
|
||||
{%- assign redir_url = "admin/settings/redirect-rules/" | append: forloop.index0 -%}
|
||||
<a href="{{ redir_url | relative_link }}" hx-target="#tag_{{ forloop.index0 }}"
|
||||
hx-swap="innerHTML show:#redir_{{ forloop.index0 }}:top">
|
||||
Edit
|
||||
</a>
|
||||
{% unless forloop.first %}
|
||||
<span class="text-muted"> • </span>
|
||||
{%- assign move_up = redir_url | append: "/up" | relative_link -%}
|
||||
<a href="{{ move_up }}" hx-post="{{ move_up }}">Move Up</a>
|
||||
{% endunless %}
|
||||
{% unless forloop.last %}
|
||||
<span class="text-muted"> • </span>
|
||||
{%- assign move_down = redir_url | append: "/down" | relative_link -%}
|
||||
<a href="{{ move_down }}" hx-post="{{ move_down }}">Move Down</a>
|
||||
{% endunless %}
|
||||
{% for redir in redirections -%}
|
||||
{%- assign redir_id = "redir_" | append: forloop.index0 -%}
|
||||
<div class="row mwl-table-detail" id="{{ redir_id }}">
|
||||
<div class="col no-wrap">
|
||||
{{ redir.from }}<br>
|
||||
<small>
|
||||
{%- assign redir_url = "admin/settings/redirect-rules/" | append: forloop.index0 -%}
|
||||
<a href="{{ redir_url | relative_link }}" hx-target="#{{ redir_id }}"
|
||||
hx-swap="innerHTML show:#{{ redir_id }}:top">
|
||||
Edit
|
||||
</a>
|
||||
{% unless forloop.first %}
|
||||
<span class="text-muted"> • </span>
|
||||
{%- assign del_url = redir_url | append: "/delete" | relative_link -%}
|
||||
<a href="{{ del_url }}" hx-post="{{ del_url }}" class="text-danger">Delete</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="col">{{ redir.to }}</div>
|
||||
<div class="col">{% if redir.is_regex %}Yes{% else %}No{% endif %}</div>
|
||||
{%- assign move_up = redir_url | append: "/up" | relative_link -%}
|
||||
<a href="{{ move_up }}" hx-post="{{ move_up }}">Move Up</a>
|
||||
{% endunless %}
|
||||
{% unless forloop.last %}
|
||||
<span class="text-muted"> • </span>
|
||||
{%- assign move_down = redir_url | append: "/down" | relative_link -%}
|
||||
<a href="{{ move_down }}" hx-post="{{ move_down }}">Move Down</a>
|
||||
{% endunless %}
|
||||
<span class="text-muted"> • </span>
|
||||
{%- assign del_url = redir_url | append: "/delete" | relative_link -%}
|
||||
<a href="{{ del_url }}" hx-post="{{ del_url }}" class="text-danger"
|
||||
hx-confirm="Are you sure you want to delete this redirect rule?">
|
||||
Delete
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
{%- endfor %}
|
||||
<div class="col">{{ redir.to }}</div>
|
||||
<div class="col">{% if redir.is_regex %}Yes{% else %}No{% endif %}</div>
|
||||
</div>
|
||||
{%- endfor %}
|
||||
</form>
|
||||
{%- else -%}
|
||||
<div id="tag_new">
|
||||
<div id="redir_new">
|
||||
<p class="text-muted text-center fst-italic">This web log has no redirect rules defined</p>
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<p class="text-muted">
|
||||
Go to: <a href="#users">Users</a> • <a href="#rss-settings">RSS Settings</a> •
|
||||
<a href="#tag-mappings">Tag Mappings</a> •
|
||||
<a href="{{ "admin/redirect-rules" | relative_link }}">Redirect Rules</a>
|
||||
<a href="{{ "admin/settings/redirect-rules" | relative_link }}">Redirect Rules</a>
|
||||
</p>
|
||||
<fieldset class="container mb-3">
|
||||
<legend>Web Log Settings</legend>
|
||||
|
||||
Reference in New Issue
Block a user