From 50179ffab966f4e7baf262365f7e4059c46d0b06 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sun, 29 May 2022 12:12:57 -0400 Subject: [PATCH] WIP on RSS settings page - Move tag mappings to /settings URLs - Remove container wrap for table pages - Add notes for empty tables --- src/MyWebLog.Domain/SupportTypes.fs | 4 + src/MyWebLog/Handlers/Feed.fs | 10 +- src/MyWebLog/Handlers/Routes.fs | 24 ++-- src/MyWebLog/Program.fs | 8 +- .../themes/admin/category-list.liquid | 65 ++++++----- src/MyWebLog/themes/admin/layout.liquid | 2 +- src/MyWebLog/themes/admin/page-list.liquid | 53 +++++---- src/MyWebLog/themes/admin/post-list.liquid | 61 +++++----- src/MyWebLog/themes/admin/rss-settings.liquid | 105 +++++++++++------- src/MyWebLog/themes/admin/settings.liquid | 4 + .../themes/admin/tag-mapping-edit.liquid | 4 +- .../themes/admin/tag-mapping-list.liquid | 6 +- 12 files changed, 199 insertions(+), 147 deletions(-) diff --git a/src/MyWebLog.Domain/SupportTypes.fs b/src/MyWebLog.Domain/SupportTypes.fs index f0e226b..3922b8e 100644 --- a/src/MyWebLog.Domain/SupportTypes.fs +++ b/src/MyWebLog.Domain/SupportTypes.fs @@ -302,6 +302,9 @@ type RssOptions = /// Whether feeds are enabled for all tags tagEnabled : bool + /// A copyright string to be placed in all feeds + copyright : string option + /// Custom feeds for this web log customFeeds: CustomFeed list } @@ -316,6 +319,7 @@ module RssOptions = itemsInFeed = None categoryEnabled = true tagEnabled = true + copyright = None customFeeds = [] } diff --git a/src/MyWebLog/Handlers/Feed.fs b/src/MyWebLog/Handlers/Feed.fs index f5ee7a9..c9f6d3b 100644 --- a/src/MyWebLog/Handlers/Feed.fs +++ b/src/MyWebLog/Handlers/Feed.fs @@ -199,7 +199,6 @@ let private addPodcast webLog (rssFeed : SyndicationFeed) (feed : CustomFeed) = "link", feedUrl ] |> List.fold (fun doc (name, value) -> addChild doc name "" value) (XmlDocument ())) - // TODO: is copyright required? rssFeed.ElementExtensions.Add ("summary", "itunes", podcast.summary) rssFeed.ElementExtensions.Add ("author", "itunes", podcast.displayedAuthor) podcast.subtitle |> Option.iter (fun sub -> rssFeed.ElementExtensions.Add ("subtitle", "itunes", sub)) @@ -238,10 +237,11 @@ let createFeed (feedType : FeedType) posts : HttpHandler = fun next ctx -> backg feed.Items <- posts |> Seq.ofList |> Seq.map toItem feed.Language <- "en" feed.Id <- webLog.urlBase + webLog.rss.copyright |> Option.iter (fun copy -> feed.Copyright <- TextSyndicationContent copy) + // TODO: adjust this link for non-root feeds feed.Links.Add (SyndicationLink (Uri $"{webLog.urlBase}/feed.xml", "self", "", "application/rss+xml", 0L)) - feed.AttributeExtensions.Add - (XmlQualifiedName ("content", "http://www.w3.org/2000/xmlns/"), "http://purl.org/rss/1.0/modules/content/") + addNamespace feed "content" "http://purl.org/rss/1.0/modules/content/" feed.ElementExtensions.Add ("link", "", webLog.urlBase) podcast |> Option.iter (addPodcast webLog feed) @@ -273,7 +273,9 @@ let editSettings : HttpHandler = fun next ctx -> task { // TODO: stopped here return! Hash.FromAnonymousObject - {| csrf = csrfToken ctx + {| csrf = csrfToken ctx + model = ctx.WebLog.rss + page_title = "RSS Settings" |} |> viewForTheme "admin" "rss-settings" next ctx } diff --git a/src/MyWebLog/Handlers/Routes.fs b/src/MyWebLog/Handlers/Routes.fs index e629997..38aafcd 100644 --- a/src/MyWebLog/Handlers/Routes.fs +++ b/src/MyWebLog/Handlers/Routes.fs @@ -93,13 +93,13 @@ let router : HttpHandler = choose [ routef "/%s/edit" Post.edit routef "/%s/permalinks" Post.editPermalinks ]) - subRoute "/rss" (choose [ - route "/settings" >=> Feed.editSettings - ]) - route "/settings" >=> Admin.settings - subRoute "/tag-mapping" (choose [ - route "s" >=> Admin.tagMappings - routef "/%s/edit" Admin.editMapping + subRoute "/settings" (choose [ + route "" >=> Admin.settings + route "/rss" >=> Feed.editSettings + subRoute "/tag-mapping" (choose [ + route "s" >=> Admin.tagMappings + routef "/%s/edit" Admin.editMapping + ]) ]) route "/user/edit" >=> User.edit ] @@ -118,10 +118,12 @@ let router : HttpHandler = choose [ route "/permalinks" >=> Post.savePermalinks routef "/%s/delete" Post.delete ]) - route "/settings" >=> Admin.saveSettings - subRoute "/tag-mapping" (choose [ - route "/save" >=> Admin.saveMapping - routef "/%s/delete" Admin.deleteMapping + subRoute "/settings" (choose [ + route "" >=> Admin.saveSettings + subRoute "/tag-mapping" (choose [ + route "/save" >=> Admin.saveMapping + routef "/%s/delete" Admin.deleteMapping + ]) ]) route "/user/save" >=> User.save ] diff --git a/src/MyWebLog/Program.fs b/src/MyWebLog/Program.fs index e58ff1c..2ae829a 100644 --- a/src/MyWebLog/Program.fs +++ b/src/MyWebLog/Program.fs @@ -202,7 +202,7 @@ let main args = opts.TableName <- "Session" opts.Connection <- conn) let _ = builder.Services.AddSession(fun opts -> - opts.IdleTimeout <- TimeSpan.FromMinutes 30 + opts.IdleTimeout <- TimeSpan.FromMinutes 60 opts.Cookie.HttpOnly <- true opts.Cookie.IsEssential <- true) @@ -218,15 +218,15 @@ let main args = Template.RegisterTag "user_links" [ // Domain types - typeof; typeof; typeof; typeof + typeof; typeof; typeof; typeof; typeof; typeof // View models typeof; typeof; typeof; typeof typeof; typeof; typeof; typeof typeof; typeof; typeof; typeof typeof; typeof // Framework types - typeof; typeof; typeof; typeof - typeof; typeof + typeof; typeof; typeof; typeof + typeof; typeof; typeof ] |> List.iter (fun it -> Template.RegisterSafeType (it, [| "*" |])) diff --git a/src/MyWebLog/themes/admin/category-list.liquid b/src/MyWebLog/themes/admin/category-list.liquid index e98e9f0..71d2c9f 100644 --- a/src/MyWebLog/themes/admin/category-list.liquid +++ b/src/MyWebLog/themes/admin/category-list.liquid @@ -1,5 +1,5 @@ 

{{ page_title }}

-
+
Add a New Category @@ -9,36 +9,43 @@ - {% for cat in categories -%} - - + - + {{ cat.name }}
+ + {%- if cat.post_count > 0 %} + + View {{ cat.post_count }} Post{% unless cat.post_count == 1 %}s{% endunless -%} + + + {%- endif %} + {%- capture cat_edit %}admin/category/{{ cat.id }}/edit{% endcapture -%} + Edit + + {%- capture cat_del %}admin/category/{{ cat.id }}/delete{% endcapture -%} + {%- capture cat_del_link %}{{ cat_del | relative_link }}{% endcapture -%} + + Delete + + + + + + {%- endfor %} + {%- else -%} + + - {%- endfor %} + {%- endif %}
- {%- if cat.parent_names %} - {% for name in cat.parent_names %}{{ name }} ⟩ {% endfor %} - {%- endif %} - {{ cat.name }}
- - {%- if cat.post_count > 0 %} - - View {{ cat.post_count }} Post{% unless cat.post_count == 1 %}s{% endunless -%} - - + {%- assign cat_count = categories | size -%} + {% if cat_count > 0 %} + {% for cat in categories -%} +
+ {%- if cat.parent_names %} + {% for name in cat.parent_names %}{{ name }} ⟩ {% endfor %} {%- endif %} - {%- capture cat_edit %}admin/category/{{ cat.id }}/edit{% endcapture -%} - Edit - - {%- capture cat_del %}admin/category/{{ cat.id }}/delete{% endcapture -%} - {%- capture cat_del_link %}{{ cat_del | relative_link }}{% endcapture -%} - - Delete - - - - {%- if cat.description %}{{ cat.description.value }}{% else %}none{% endif %} - + {%- if cat.description %}{{ cat.description.value }}{% else %}none{% endif %} +
This web log has no categores defined
diff --git a/src/MyWebLog/themes/admin/layout.liquid b/src/MyWebLog/themes/admin/layout.liquid index f03e8f0..55efeba 100644 --- a/src/MyWebLog/themes/admin/layout.liquid +++ b/src/MyWebLog/themes/admin/layout.liquid @@ -24,7 +24,7 @@ {{ "admin/pages" | nav_link: "Pages" }} {{ "admin/posts" | nav_link: "Posts" }} {{ "admin/categories" | nav_link: "Categories" }} - {{ "admin/tag-mappings" | nav_link: "Tag Mappings" }} + {{ "admin/settings" | nav_link: "Settings" }} {%- endif %}