WIP on RSS settings page

This commit is contained in:
2022-05-28 23:22:14 -04:00
parent fbacacfb5b
commit 92cc50254c
3 changed files with 106 additions and 4 deletions

View File

@@ -11,6 +11,8 @@ open Microsoft.AspNetCore.Http
open MyWebLog
open MyWebLog.ViewModels
// ~~ FEED GENERATION ~~
/// The type of feed to generate
type FeedType =
| StandardFeed
@@ -211,12 +213,11 @@ let private addPodcast webLog (rssFeed : SyndicationFeed) (feed : CustomFeed) =
rssFeed.ElementExtensions.Add ("category", "itunes", categoryXml)
rssFeed.ElementExtensions.Add ("explicit", "itunes", ExplicitRating.toString podcast.explicit)
rssFeed.ElementExtensions.Add ("subscribe", "rawvoice", feedUrl)
// GET {any-prescribed-feed}
let generate (feedType : FeedType) postCount : HttpHandler = fun next ctx -> backgroundTask {
/// Create a feed with a known non-zero-length list of posts
let createFeed (feedType : FeedType) posts : HttpHandler = fun next ctx -> backgroundTask {
let webLog = ctx.WebLog
let conn = ctx.Conn
let! posts = getFeedPosts webLog feedType postCount conn
let! authors = Post.getAuthors webLog posts conn
let! tagMaps = Post.getTagMappings webLog posts conn
let cats = CategoryCache.get ctx
@@ -255,3 +256,24 @@ let generate (feedType : FeedType) postCount : HttpHandler = fun next ctx -> bac
return! (setHttpHeader "Content-Type" "text/xml" >=> setStatusCode 200 >=> setBodyFromString output) next ctx
}
// GET {any-prescribed-feed}
let generate (feedType : FeedType) postCount : HttpHandler = fun next ctx -> backgroundTask {
match! getFeedPosts ctx.WebLog feedType postCount ctx.Conn with
| posts when List.length posts > 0 -> return! createFeed feedType posts next ctx
| _ -> return! Error.notFound next ctx
}
// ~~ FEED ADMINISTRATION ~~
open DotLiquid
// GET: /admin/rss/settings
let editSettings : HttpHandler = fun next ctx -> task {
// TODO: stopped here
return!
Hash.FromAnonymousObject
{| csrf = csrfToken ctx
|}
|> viewForTheme "admin" "rss-settings" next ctx
}

View File

@@ -93,6 +93,9 @@ 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