From 70a7dc39876f2825962a96d85a6d4f3363435e43 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 29 Mar 2015 05:14:18 +0200 Subject: Documentation of rss patch --- lists/dirty-haskell/002 | 1 + lists/zz_all/002 | 1 + posts/blog-rss.md | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 120000 lists/dirty-haskell/002 create mode 120000 lists/zz_all/002 create mode 100644 posts/blog-rss.md diff --git a/lists/dirty-haskell/002 b/lists/dirty-haskell/002 new file mode 120000 index 0000000..ed24126 --- /dev/null +++ b/lists/dirty-haskell/002 @@ -0,0 +1 @@ +../../posts/blog-rss.md \ No newline at end of file diff --git a/lists/zz_all/002 b/lists/zz_all/002 new file mode 120000 index 0000000..ed24126 --- /dev/null +++ b/lists/zz_all/002 @@ -0,0 +1 @@ +../../posts/blog-rss.md \ No newline at end of file diff --git a/posts/blog-rss.md b/posts/blog-rss.md new file mode 100644 index 0000000..559a6c6 --- /dev/null +++ b/posts/blog-rss.md @@ -0,0 +1,25 @@ +% dirty-haskell.org´s rss feeds + +I extended the software suite inherited from [math.kleen.org](http://math.kleen.org) to include support for rss feeds. +The heart of the issue is a ~80 line haskell script I chose to call, in a bout of creativity, "generate-rss.hs". +The script uses the [feed](http://hackage.haskell.org/package/feed-0.3.9.2) package. + +generate-rss.hs gets passed a title and a list of paths below ./lists to incorporate as items. +It generates an empty feed structure, adds title and a (hardcoded) base url for RSS metadata, and iterates over the given paths — generating for each path an item to be included in the finished feed. +This procedure makes use of a state monad (StateT (Feed, Maybe ClockTime) IO ()) to sequentially add items to the feed and keep track of the modification/change time of the newest path examined. +Each item carries a title, an url, a date, and contents as follows: + +- The date used is the modification/change time of the path supplied as a command line argument at the beginning of the program (usually a symbolic link in ./lists) — as such it is the time the post was linked into the particular list we´re generating a RSS feed for (this was not a deliberate design choice but a side effect of the canonical implementation — it was later decided that this behaviour was in fact the one expected all along). +- The url is generated by following, recursively, the trail of symbolic links starting in ./lists, assuming the final target is indeed in ./posts, and forming the filename of that target into a (hopefully) functional url in a hardcoded fashion. +- The title is extracted from the markdown file using a function shamelessly copied from extract-title.hs (The author wrote that one too, after all). +- The contents are read into Pandoc and rendered into [AsciiDoc](http://en.wikipedia.org/wiki/AsciiDoc) format (it seemed convenient at the time). + +Along the way two helper functions were introduced — if an implementation of those already exists in Prelude or somewhere else common please mail in a comment: + + (<->) :: [(a -> b)] -> a -> [b] + [] <-> _ = [] + (f:fs) <-> x = (f x:fs <-> x) + + (<-->) :: [(a -> a)] -> a -> a + [] <--> x = x + (f:fs) <--> x = fs <--> (f x) -- cgit v1.2.3