diff --git a/src/MyWebLog.Data/RethinkDbData.fs b/src/MyWebLog.Data/RethinkDbData.fs index 7c318a9..ccf4ef2 100644 --- a/src/MyWebLog.Data/RethinkDbData.fs +++ b/src/MyWebLog.Data/RethinkDbData.fs @@ -226,7 +226,7 @@ type RethinkDbData (conn : Net.IConnection, config : DataConfig, log : ILogger obj ] write; withRetryOnce; ignoreResult conn } diff --git a/src/MyWebLog/Handlers/Admin.fs b/src/MyWebLog/Handlers/Admin.fs index 30ebac4..1808676 100644 --- a/src/MyWebLog/Handlers/Admin.fs +++ b/src/MyWebLog/Handlers/Admin.fs @@ -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 diff --git a/src/MyWebLog/Handlers/Routes.fs b/src/MyWebLog/Handlers/Routes.fs index e664a9d..0c82308 100644 --- a/src/MyWebLog/Handlers/Routes.fs +++ b/src/MyWebLog/Handlers/Routes.fs @@ -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 diff --git a/src/MyWebLog/appsettings.json b/src/MyWebLog/appsettings.json index e89af6d..5956ea7 100644 --- a/src/MyWebLog/appsettings.json +++ b/src/MyWebLog/appsettings.json @@ -1,5 +1,6 @@ { "Generator": "myWebLog 2.0", + "Generator": "myWebLog 2.1", "Logging": { "LogLevel": { "MyWebLog.Handlers": "Information" diff --git a/src/admin-theme/redirect-list.liquid b/src/admin-theme/redirect-list.liquid new file mode 100644 index 0000000..88ff325 --- /dev/null +++ b/src/admin-theme/redirect-list.liquid @@ -0,0 +1,58 @@ +

Redirect Rules

+
+ « Back to Settings +
+
+
+ {%- assign redir_count = redirections | size -%} + {% if redir_count > 0 -%} +
+
+
From
+
To
+
RegEx?
+
+
+
+ +
+ {% for redir in redirections -%} + {%- assign map_id = mapping_ids | value: map.tag -%} +
+
+ {{ redir.from }}
+ + {%- assign redir_url = "admin/settings/redirect-rules/" | append: forloop.index0 -%} + + Edit + + {% unless forloop.first %} + + {%- assign move_up = redir_url | append: "/up" | relative_link -%} + Move Up + {% endunless %} + {% unless forloop.last %} + + {%- assign move_down = redir_url | append: "/down" | relative_link -%} + Move Down + {% endunless %} + + {%- assign del_url = redir_url | append: "/delete" | relative_link -%} + Delete + +
+
{{ redir.to }}
+
{% if redir.is_regex %}Yes{% else %}No{% endif %}
+
+ {%- endfor %} +
+ {%- else -%} +
+

This web log has no redirect rules defined

+
+ {%- endif %} +
+
+
+
diff --git a/src/admin-theme/settings.liquid b/src/admin-theme/settings.liquid index ab956f8..92c5649 100644 --- a/src/admin-theme/settings.liquid +++ b/src/admin-theme/settings.liquid @@ -2,7 +2,8 @@

Go to: UsersRSS Settings • - Tag Mappings + Tag Mappings • + Redirect Rules

Web Log Settings diff --git a/src/admin-theme/version.txt b/src/admin-theme/version.txt index 821af72..eb1fc5a 100644 --- a/src/admin-theme/version.txt +++ b/src/admin-theme/version.txt @@ -1,2 +1,2 @@ myWebLog Admin -2.0.0 \ No newline at end of file +2.1.0 \ No newline at end of file