Version 2.1 #41
|
@ -226,7 +226,7 @@ type RethinkDbData (conn : Net.IConnection, config : DataConfig, log : ILogger<R
|
|||
Utils.logMigrationStep log "v2 to v2.1" "Adding empty redirect rule set to all weblogs"
|
||||
do! rethink {
|
||||
withTable Table.WebLog
|
||||
update [ nameof WebLog.empty.RedirectRules, [] ]
|
||||
update [ nameof WebLog.empty.RedirectRules, [] :> obj ]
|
||||
write; withRetryOnce; ignoreResult conn
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ open MyWebLog
|
|||
open MyWebLog.ViewModels
|
||||
open NodaTime
|
||||
|
||||
/// ~~ DASHBOARDS ~~
|
||||
/// ~~~ DASHBOARDS ~~~
|
||||
module Dashboard =
|
||||
|
||||
// GET /admin/dashboard
|
||||
|
@ -75,7 +75,7 @@ module Dashboard =
|
|||
let toAdminDashboard : HttpHandler = redirectToGet "admin/administration"
|
||||
|
||||
|
||||
/// ~~ CACHES ~~
|
||||
/// ~~~ CACHES ~~~
|
||||
module Cache =
|
||||
|
||||
// POST /admin/cache/web-log/{id}/refresh
|
||||
|
@ -126,7 +126,7 @@ module Cache =
|
|||
}
|
||||
|
||||
|
||||
/// ~~ CATEGORIES ~~
|
||||
/// ~~~ CATEGORIES ~~~
|
||||
module Category =
|
||||
|
||||
open MyWebLog.Data
|
||||
|
@ -214,7 +214,20 @@ module Category =
|
|||
}
|
||||
|
||||
|
||||
/// ~~ TAG MAPPINGS ~~
|
||||
/// ~~~ REDIRECT RULES ~~~
|
||||
module RedirectRules =
|
||||
|
||||
// GET /admin/redirect-rules
|
||||
let all : HttpHandler = requireAccess WebLogAdmin >=> fun next ctx -> task {
|
||||
return!
|
||||
hashForPage "Redirect Rules"
|
||||
|> withAntiCsrf ctx
|
||||
|> addToHash "redirections" ctx.WebLog.RedirectRules
|
||||
|> adminView "redirect-list" next ctx
|
||||
}
|
||||
|
||||
|
||||
/// ~~~ TAG MAPPINGS ~~~
|
||||
module TagMapping =
|
||||
|
||||
open Microsoft.AspNetCore.Http
|
||||
|
@ -278,7 +291,7 @@ module TagMapping =
|
|||
}
|
||||
|
||||
|
||||
/// ~~ THEMES ~~
|
||||
/// ~~~ THEMES ~~~
|
||||
module Theme =
|
||||
|
||||
open System
|
||||
|
@ -440,7 +453,7 @@ module Theme =
|
|||
}
|
||||
|
||||
|
||||
/// ~~ WEB LOG SETTINGS ~~
|
||||
/// ~~~ WEB LOG SETTINGS ~~~
|
||||
module WebLog =
|
||||
|
||||
open System.Collections.Generic
|
||||
|
|
|
@ -130,6 +130,9 @@ let router : HttpHandler = choose [
|
|||
routef "/%s/revision/%s/preview" Post.previewRevision
|
||||
routef "/%s/revisions" Post.editRevisions
|
||||
])
|
||||
subRoute "/redirect-rules" (choose [
|
||||
route "" >=> Admin.RedirectRules.all
|
||||
])
|
||||
subRoute "/settings" (choose [
|
||||
route "" >=> Admin.WebLog.settings
|
||||
routef "/rss/%s/edit" Feed.editCustomFeed
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"Generator": "myWebLog 2.0",
|
||||
"Generator": "myWebLog 2.1",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"MyWebLog.Handlers": "Information"
|
||||
|
|
58
src/admin-theme/redirect-list.liquid
Normal file
58
src/admin-theme/redirect-list.liquid
Normal file
|
@ -0,0 +1,58 @@
|
|||
<h2 class="my-3">Redirect Rules</h2>
|
||||
<article>
|
||||
<a href="{{ "admin/settings" | relative_link }}">« Back to Settings</a>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{%- assign redir_count = redirections | size -%}
|
||||
{% if redir_count > 0 -%}
|
||||
<div class="container">
|
||||
<div class="row mwl-table-heading">
|
||||
<div class="col">From</div>
|
||||
<div class="col">To</div>
|
||||
<div class="col">RegEx?</div>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" class="container">
|
||||
<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 %}
|
||||
<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>
|
||||
</div>
|
||||
{%- endfor %}
|
||||
</form>
|
||||
{%- else -%}
|
||||
<div id="tag_new">
|
||||
<p class="text-muted text-center fst-italic">This web log has no redirect rules defined</p>
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
|
@ -2,7 +2,8 @@
|
|||
<article>
|
||||
<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="#tag-mappings">Tag Mappings</a> •
|
||||
<a href="{{ "admin/redirect-rules" | relative_link }}">Redirect Rules</a>
|
||||
</p>
|
||||
<fieldset class="container mb-3">
|
||||
<legend>Web Log Settings</legend>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
myWebLog Admin
|
||||
2.0.0
|
||||
2.1.0
|
Loading…
Reference in New Issue
Block a user