Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace ForneverMind | ||
|
||
open System | ||
open System.Text | ||
|
||
open WilderMinds.RssSyndication | ||
open Freya.Core | ||
open Freya.Machines.Http | ||
open Freya.Types.Http | ||
|
||
open ForneverMind.Models | ||
|
||
type RssModule(config : ConfigurationModule, posts : PostsModule) = | ||
|
||
let sindicationItem (post : PostMetadata) : Item = | ||
let url = config.BaseUrl + post.Url | ||
Item(Title = post.Title, | ||
Body = post.Description, | ||
Link = Uri url, | ||
Permalink = url, // TODO[F]: isPermaLink="true" | ||
PublishDate = post.Date) // TODO[F]: Check date format used here | ||
|
||
let feedContent = | ||
let items = Seq.map sindicationItem posts.AllPosts | ||
let feed = | ||
Feed ( | ||
Title = "Engineer, programmer, gentleman", | ||
Description = "Friedrich von Never: Engineer, Programmer, Gentleman.", | ||
Link = Uri config.BaseUrl | ||
) | ||
Seq.iter feed.Items.Add items | ||
let text = feed.Serialize() | ||
Encoding.UTF8.GetBytes text | ||
|
||
let lastModificationDate = | ||
defaultArg (posts.AllPosts | ||
|> Seq.tryHead | ||
|> Option.map (fun p -> p.Date)) DateTime.UtcNow | ||
|
||
let handleFeed _ = | ||
freya { | ||
return | ||
{ | ||
Description = | ||
{ | ||
Charset = Some Charset.Utf8 | ||
Encodings = None | ||
MediaType = Some Common.rss | ||
Languages = None | ||
} | ||
Data = feedContent | ||
} | ||
} | ||
|
||
member __.Feed = | ||
freyaMachine { | ||
including Common.machine | ||
methodsSupported Common.methods | ||
lastModified (Common.initLastModified lastModificationDate) | ||
handleOk handleFeed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:5000" | ||
} |