Support directory installations

- Add web log to HttpContext on first retrieval per req
- Add several DotLiquid filters
- Use int for page numbers
- Update all themes to use rel/abs link and other filters
This commit is contained in:
2022-05-21 22:55:13 -04:00
parent 63425ad806
commit cbf87f5b49
41 changed files with 658 additions and 485 deletions

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="/admin/category/save" method="post">
<form action="{{ "admin/category/save" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<input type="hidden" name="categoryId" value="{{ model.category_id }}">
<div class="container">

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article class="container">
<a href="/admin/category/new/edit" class="btn btn-primary btn-sm mb-3">Add a New Category</a>
<a href="{{ "admin/category/new/edit" | relative_link }}" class="btn btn-primary btn-sm mb-3">Add a New Category</a>
<table class="table table-sm table-hover">
<thead>
<tr>
@@ -17,16 +17,19 @@
{%- endif %}
{{ cat.name }}<br>
<small>
{%- if cat.post_count > 0 %}
<a href="{{ cat | category_link }}" target="_blank">
View {{ cat.post_count }} Post{% unless cat.post_count == 1 %}s{% endunless -%}
</a>
{%- if cat.post_count > 0 %}
<a href="{{ cat | category_link }}" target="_blank">
View {{ cat.post_count }} Post{% unless cat.post_count == 1 %}s{% endunless -%}
</a>
<span class="text-muted"> &bull; </span>
{%- endif %}
{%- capture cat_edit %}admin/category/{{ cat.id }}/edit{% endcapture -%}
<a href="{{ cat_edit | relative_link }}">Edit</a>
<span class="text-muted"> &bull; </span>
{%- endif %}
<a href="/admin/category/{{ cat.id }}/edit">Edit</a>
<span class="text-muted"> &bull; </span>
<a href="/admin/category/{{ cat.id }}/delete" class="text-danger"
onclick="return Admin.deleteCategory('{{ cat.id }}', '{{ cat.name }}')">
{%- capture cat_del %}admin/category/{{ cat.id }}/delete{% endcapture -%}
{%- capture cat_del_link %}{{ cat_del | relative_link }}{% endcapture -%}
<a href="{{ cat_del_link }}" class="text-danger"
onclick="return Admin.deleteCategory('{{ cat.name }}', '{{ cat_del_link }}')">
Delete
</a>
</small>

View File

@@ -9,8 +9,8 @@
Published <span class="badge rounded-pill bg-secondary">{{ model.posts }}</span>
&nbsp; Drafts <span class="badge rounded-pill bg-secondary">{{ model.drafts }}</span>
</h6>
<a href="/admin/posts" class="btn btn-secondary me-2">View All</a>
<a href="/admin/post/new/edit" class="btn btn-primary">Write a New Post</a>
<a href="{{ "admin/posts" | relative_permalink }}" 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>
</div>
</div>
</section>
@@ -22,8 +22,8 @@
All <span class="badge rounded-pill bg-secondary">{{ model.pages }}</span>
&nbsp; Shown in Page List <span class="badge rounded-pill bg-secondary">{{ model.listed_pages }}</span>
</h6>
<a href="/admin/pages" class="btn btn-secondary me-2">View All</a>
<a href="/admin/page/new/edit" class="btn btn-primary">Create a New Page</a>
<a href="{{ "admin/pages" | relative_link }}" class="btn btn-secondary me-2">View All</a>
<a href="{{ "admin/page/new/edit" | relative_link }}" class="btn btn-primary">Create a New Page</a>
</div>
</div>
</section>
@@ -37,15 +37,15 @@
All <span class="badge rounded-pill bg-secondary">{{ model.categories }}</span>
&nbsp; Top Level <span class="badge rounded-pill bg-secondary">{{ model.top_level_categories }}</span>
</h6>
<a href="/admin/categories" class="btn btn-secondary me-2">View All</a>
<a href="/admin/category/new/edit" class="btn btn-secondary">Add a New Category</a>
<a href="{{ "admin/categories" | relative_link }}" class="btn btn-secondary me-2">View All</a>
<a href="{{ "admin/category/new/edit" | relative_link }}" class="btn btn-secondary">Add a New Category</a>
</div>
</div>
</section>
</div>
<div class="row pb-3">
<div class="col text-end">
<a href="/admin/settings" class="btn btn-secondary">Modify Settings</a>
<a href="{{ "admin/settings" | relative_link }}" class="btn btn-secondary">Modify Settings</a>
</div>
</div>
</article>

View File

@@ -12,7 +12,7 @@
<header>
<nav class="navbar navbar-dark bg-dark navbar-expand-md justify-content-start px-2 position-fixed top-0 w-100">
<div class="container-fluid">
<a class="navbar-brand" href="/">{{ web_log.name }}</a>
<a class="navbar-brand" href="{{ "" | relative_link }}">{{ web_log.name }}</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText"
aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>

View File

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

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="/admin/page/save" method="post">
<form action="{{ "admin/page/save" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<input type="hidden" name="pageId" value="{{ model.page_id }}">
<div class="container">
@@ -16,7 +16,8 @@
value="{{ model.permalink }}">
<label for="permalink">Permalink</label>
{%- if model.page_id != "new" %}
<span class="form-text"><a href="/admin/page/{{ model.page_id }}/permalinks">Manage Permalinks</a></span>
{%- capture perm_edit %}admin/page/{{ model.page_id }}/permalinks{% endcapture -%}
<span class="form-text"><a href="{{ perm_edit | relative_link }}">Manage Permalinks</a></span>
{% endif -%}
</div>
</div>

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article class="container">
<a href="/admin/page/new/edit" 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>
<table class="table table-sm table-hover">
<thead>
<tr>
@@ -17,12 +17,15 @@
{%- if pg.is_default %} &nbsp; <span class="badge bg-success">HOME PAGE</span>{% endif -%}
{%- if pg.show_in_page_list %} &nbsp; <span class="badge bg-primary">IN PAGE LIST</span> {% endif -%}<br>
<small>
<a href="/{% unless pg.is_default %}{{ pg.permalink }}{% endunless %}" target="_blank">View Page</a>
{%- capture pg_link %}{% unless pg.is_default %}{{ pg.permalink }}{% endunless %}{% endcapture -%}
<a href="{{ pg_link | relative_link }}" target="_blank">View Page</a>
<span class="text-muted"> &bull; </span>
<a href="{{ pg.id | edit_page_link }}">Edit</a>
<a href="{{ pg | edit_page_link }}">Edit</a>
<span class="text-muted"> &bull; </span>
<a href="/admin/page/{{ pg.id }}/delete" class="text-danger"
onclick="return Admin.deletePage('{{ pg.id }}', '{{ pg.title }}')">
{%- capture pg_del %}admin/page/{{ pg.id }}/delete{% endcapture -%}
{%- capture pg_del_link %}{{ pg_del | relative_link }}{% endcapture -%}
<a href="{{ pg_del_link }}" class="text-danger"
onclick="return Admin.deletePage('{{ pg.title }}', '{{ pg_del_link }}')">
Delete
</a>
</small>

View File

@@ -1,6 +1,7 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="/admin/{{ model.entity }}/permalinks" method="post">
{%- capture form_action %}admin/{{ model.entity }}/permalinks{% endcapture -%}
<form action="{{ form_action | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<input type="hidden" name="id" value="{{ model.id }}">
<div class="container">
@@ -10,7 +11,8 @@
<strong>{{ model.current_title }}</strong><br>
<small class="text-muted">
<span class="fst-italic">{{ model.current_permalink }}</span><br>
<a href="/admin/{{ model.entity }}/{{ model.id }}/edit">&laquo; Back to Edit {{ model.entity | capitalize }}</a>
{%- capture back_link %}admin/{{ model.entity }}/{{ model.id }}/edit{% endcapture -%}
<a href="{{ back_link | relative_link }}">&laquo; Back to Edit {{ model.entity | capitalize }}</a>
</small>
</p>
</div>

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="/admin/post/save" method="post">
<form action="{{ "/admin/post/save" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<input type="hidden" name="postId" value="{{ model.post_id }}">
<div class="container">
@@ -16,7 +16,8 @@
value="{{ model.permalink }}">
<label for="permalink">Permalink</label>
{%- if model.page_id != "new" %}
<span class="form-text"><a href="/admin/post/{{ model.post_id }}/permalinks">Manage Permalinks</a></span>
{%- capture perm_edit %}admin/post/{{ model.post_id }}/permalinks{% endcapture -%}
<span class="form-text"><a href="{{ perm_edit | relative_link }}">Manage Permalinks</a></span>
{% endif -%}
</div>
<div class="mb-2">

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article class="container">
<a href="/admin/post/new/edit" class="btn btn-primary btn-sm mb-3">Write a New Post</a>
<a href="{{ "/admin/post/new/edit" | relative_link }}" class="btn btn-primary btn-sm mb-3">Write a New Post</a>
<table class="table table-sm table-hover">
<thead>
<tr>
@@ -23,12 +23,14 @@
<td>
{{ post.title }}<br>
<small>
<a href="/{{ post.permalink }}" target="_blank">View Post</a>
<a href="{{ post | relative_link }}" target="_blank">View Post</a>
<span class="text-muted"> &bull; </span>
<a href="{{ post.id | edit_post_link }}">Edit</a>
<a href="{{ post | edit_post_link }}">Edit</a>
<span class="text-muted"> &bull; </span>
<a href="/admin/post/{{ pg.id }}/delete" class="text-danger"
onclick="return Admin.deletePost('{{ post.id }}', '{{ post.title }}')">
{%- capture post_del %}admin/post/{{ pg.id }}/delete{% endcapture -%}
{%- capture post_del_link %}{{ post_del | relative_link }}{% endcapture -%}
<a href="{{ post_del_link }}" class="text-danger"
onclick="return Admin.deletePost('{{ post.title }}', '{{ post_del_link }}')">
Delete
</a>
</small>
@@ -44,12 +46,12 @@
<div class="d-flex justify-content-evenly">
<div>
{% if model.newer_link %}
<p><a class="btn btn-default" href="/{{ model.newer_link.value }}">&laquo; Newer Posts</a></p>
<p><a class="btn btn-default" href="{{ model.newer_link.value }}">&laquo; Newer Posts</a></p>
{% endif %}
</div>
<div class="text-right">
{% if model.older_link %}
<p><a class="btn btn-default" href="/{{ model.older_link.value }}">Older Posts &raquo;</a></p>
<p><a class="btn btn-default" href="{{ model.older_link.value }}">Older Posts &raquo;</a></p>
{% endif %}
</div>
</div>

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ web_log.name }} Settings</h2>
<article>
<form action="/admin/settings" method="post">
<form action="{{ "admin/settings" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<div class="container">
<div class="row">

View File

@@ -1,12 +1,12 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="/admin/tag-mapping/save" method="post">
<form action="{{ "admin/tag-mapping/save" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<input type="hidden" name="id" value="{{ model.id }}">
<div class="container">
<div class="row mb-3">
<div class="col">
<a href="/admin/tag-mappings">&laquo; Back to Tag Mappings</a>
<a href="{{ "admin/tag-mappings" | relative_link }}">&laquo; Back to Tag Mappings</a>
</div>
</div>
<div class="row mb-3">

View File

@@ -1,6 +1,8 @@
<h2 class="my-3">{{ page_title }}</h2>
<article class="container">
<a href="/admin/tag-mapping/new/edit" class="btn btn-primary btn-sm mb-3">Add a New Tag Mapping</a>
<a href="{{ "admin/tag-mapping/new/edit" | relative_link }}" class="btn btn-primary btn-sm mb-3">
Add a New Tag Mapping
</a>
<table class="table table-sm table-hover">
<thead>
<tr>
@@ -15,8 +17,13 @@
<td class="no-wrap">
{{ map.tag }}<br>
<small>
<a href="/admin/tag-mapping/{{ map_id }}/delete" class="text-danger"
onclick="return Admin.deleteTagMapping('{{ map_id }}', '{{ map.tag }}')">
{%- capture map_edit %}admin/tag-mapping/{{ map_id }}/edit{% endcapture -%}
<a href="{{ map_edit | relative_link }}">Edit</a>
<span class="text-muted"> &bull; </span>
{%- capture map_del %}admin/tag-mapping/{{ map_id }}/delete{% endcapture -%}
{%- capture map_del_link %}{{ map_del | relative_link }}{% endcapture -%}
<a href="{{ map_del_link }}" class="text-danger"
onclick="return Admin.deleteTagMapping('{{ map.tag }}', '{{ map_del_link }}')">
Delete
</a>
</small>

View File

@@ -1,6 +1,6 @@
<h2 class="my-3">{{ page_title }}</h2>
<article>
<form action="/admin/user/save" method="post">
<form action="{{ "admin/user/save" | relative_link }}" method="post">
<input type="hidden" name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<div class="container">
<div class="row mb-3">